$(function(){
	$.fn.supersized.options = {  
		startwidth: 1300,  
		startheight: 800,
		vertical_center: 1,
		slideshow: 1,
		navigation: 0,
		thumbnail_navigation: 0,
		transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
		pause_hover: 0,
		slide_counter: 0,
		slide_captions: 0,
		slide_interval: 6000,
		slides : [
			{image : 'images/home/bg01.jpg'},
			{image : 'images/home/bg02.jpg'},
			{image : 'images/home/bg03.jpg'},
			{image : 'images/home/bg04.jpg'}

		]
	};
	$('#supersized').supersized();

	/*
	* Fix Slider on each resize
	*/
	 function detectViewport(d){
		 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
		 var viewportwidth;
		var viewportheight;				 
		 
		 if (typeof window.innerWidth != 'undefined')
		 {
			  viewportwidth = window.innerWidth,
			  viewportheight = window.innerHeight
		 }
		 
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		
		 else if (typeof document.documentElement != 'undefined'
			 && typeof document.documentElement.clientWidth !=
			 'undefined' && document.documentElement.clientWidth != 0)
		 {
			   viewportwidth = document.documentElement.clientWidth,
			   viewportheight = document.documentElement.clientHeight
		 }
		 
		 // older versions of IE
		 
		 else
		 {
			   viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
			   viewportheight = document.getElementsByTagName('body')[0].clientHeight
		 }
		 
		 if(d == "w")
			return viewportwidth;
		 else
			return viewportheight;
	}
	
	window.onresize = function(){
		resizeSlider();
	}
	
	window.onload = function(){
		resizeSlider();
	}			
	/*
	* Function to resize the inner Slider Wrapper.
	*/
	function resizeSlider(){
		var outerWidth =  detectViewport("w");
		var buttonWitdth = $("#leftbtn").outerWidth();					
		var newSliderWidth = outerWidth - (buttonWitdth*2);
		$("#shortcuts-slider").css("width", newSliderWidth - 6);
					
		if($('#slide').css('right') != 0)
			$("#slide").animate({'right':'0px'}, "slow");
	}

	/*
	*Calculate new width of SLIDE
	
	var shortcutHeight = $(".shortcut").outerWidth();
	var countShortcut = $("#slide ul > li").size();
	$("#slide").css('width', shortcutHeight*countShortcut);
	*/
	
	//move
	$("#rightbtn").click(function(){
		var slideWidth =  $("#slide").outerWidth();
		var sliderWidth = $("#shortcuts-slider").outerWidth();							
		var target = slideWidth - sliderWidth;
		$("#slide").stop().animate({'right':target+'px'}, "normal");
	})
	
	$("#leftbtn").click(function(){
		$("#slide").stop().animate({'right':'0px'}, "normal");
	})
	
});
