// Load External File
function loadjscssfile(filename, filetype){
	 if (filetype=="js"){ //if filename is a external JavaScript file
	  var fileref=document.createElement('script')
	  fileref.setAttribute("type","text/javascript")
	  fileref.setAttribute("src", filename)
	 }
	 else if (filetype=="css"){ //if filename is an external CSS file
	  var fileref=document.createElement("link")
	  fileref.setAttribute("rel", "stylesheet")
	  fileref.setAttribute("type", "text/css")
	  fileref.setAttribute("href", filename)
	 }
	 if (typeof fileref!="undefined")
	 	document.getElementsByTagName("head")[0].appendChild(fileref)
}


// Show all sliders please
function showallsliders(){
	$('#slider01').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider02').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider03').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider04').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider05').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider06').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider07').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider08').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider09').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider10').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider11').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider12').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider13').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
	$('#slider14').nivoSlider({ effect:'fade', animSpeed:200, pauseTime:3000, keyboardNav:true, pauseOnHover:true, captionOpacity:0.8 });
}


// Display arrowkey please
function display_arrowkeys(){
	$('#slider01 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider01 .nivo-controlNav').html());
	$('#slider02 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider02 .nivo-controlNav').html());
	$('#slider03 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider04 .nivo-controlNav').html());
	$('#slider04 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider04 .nivo-controlNav').html());
	$('#slider05 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider05 .nivo-controlNav').html());
	$('#slider06 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider06 .nivo-controlNav').html());
	$('#slider07 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider07 .nivo-controlNav').html());
	$('#slider08 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider08 .nivo-controlNav').html());
	$('#slider09 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider09 .nivo-controlNav').html());
	$('#slider11 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider11 .nivo-controlNav').html());
	$('#slider12 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider12 .nivo-controlNav').html());
	$('#slider13 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider13 .nivo-controlNav').html());
	$('#slider14 .nivo-controlNav').html("<p class='arrowkeys'>Skip through images using arrow keys</p>" + $('#slider14 .nivo-controlNav').html());
}


// Don't display scrolling
function noscrolling(){
	$('.slides').css("width","950px");	
	$('.slides > div').css("position","relative");
	$('.sliderwrap').css("position","relative");
	$('.sliderwrap').css("left","0");	
	$('.containerslide').css("overflow-x","visible");	
	$('.containerslide').css("overflow-y","visible");
	$('.nivoSlider').css("margin-bottom","0");
	$('#nextbox').hide();
	$('p.arrowkeys').hide();
}


// Do display scrolling
function scrolling(){
	// Loop Slider Basics
	$("#nextbox").fadeIn(1200);
	showallsliders();	
	// $('#slider07').data('nivo:vars').stop = true;	
	// $('#slider08').data('nivo:vars').stop = true;	
    // $('#slider09').data('nivo:vars').stop = true;	
    // $('#slider10').data('nivo:vars').stop = true;	
    // $('#slider11').data('nivo:vars').stop = true;
    // $('#slider12').data('nivo:vars').stop = true;
    // $('#slider13').data('nivo:vars').stop = true;
    // $('#slider14').data('nivo:vars').stop = true;
	display_arrowkeys();
}



// Page Loads
$(window).load(function() { 
	// Looped slider
	if ($.browser.opera || ($.browser.msie && $.browser.version.substr(0,1) == 6) || ($.browser.msie && $.browser.version.substr(0,1) == 7)) { var pleasedo = "nothing"; } else {
		loadjscssfile("css/edit.css", "css");
		$.fn.loopedSlider.defaults.addPagination = false;
		$('#loopedSlider').loopedSlider();
	}
	left_point = $('#content').offset().right;
	$('#nextbox').css("left",left_point);
	if ($.browser.opera || ($.browser.msie && $.browser.version.substr(0,1) == 6) || ($.browser.msie && $.browser.version.substr(0,1) == 7)) {noscrolling(); } else { scrolling(); }
	$('img.me').hover(
	  function () {
		alert ('bla');
	    $(this).attr("src","../images/content/alsome.jpg");
	  }, 
	  function () {
	    $(this).attr("src","../images/content/me.jpg");
	  }
	);
});


     
$(document).ready(function(){
	if ($.browser.msie && $.browser.version.substr(0,1) == 6) { $(document).pngFix(); }
	// FadeIn Next/Previous Button 
	var the_window = $(window);
	the_window.resize(function () {
			    left_point = $('#content').offset().right;
		    	$('#nextbox').css("left",left_point);	        
	});

	// Project Navigation
	var isCtrl = false; 
	document.onkeyup=function(e){ 
		if (e.which == 17) isCtrl=false; 
	} 
	document.onkeydown=function(e) { 
		if(e.which == 17) isCtrl=true; 
		if(e.which == 78) { 
			$('.previous').click();
			return false; 
		} 
		if(e.which == 77) { 
			$('.next').click();
			return false; 
		} 
	}

});

