// HOMEPAGE SLIDER

// set this variable for delay (1000 = 1 second)

// END OF HOMEPAGE SLIDER


// LIGHTBOX - FANCYBOX
/*
$(function(){

	$("a.fancybox").fancybox({
		'overlayShow'	: false,
		'zoomSpeedIn'	: 600,
		'zoomSpeedOut'	: 500,
		'easingIn'		: 'easeOutBack',
		'easingOut'		: 'easeInBack' 
	});
		
});
*/
// END OF FANCYBOX


// CONTACT FORM 

	jQuery(document).ready(function($) {
    	$('#contactform').ajaxForm({
    	   	target: '#error',
    	   	beforeSubmit: function() {
    		$('#error').append('<p class="loading">Sending your message...</p>');
    		},
    		success: function() {
    		$('#error p.loading').fadeOut();
    		$('#error').fadeIn('slow');
    		}
    	});
    	
    	
    	
    	var delayLength = 7000;

		$(function(){
		
			//$("#spotlight").append('<span class="pause png_bg">Stop</span>');
			
			var $slide1 = $("#item1");
		
			var panelWidth = $slide1.css("width");
			var panelPaddingLeft = $slide1.css("paddingLeft");
			var panelPaddingRight = $slide1.css("paddingRight");
		
			panelWidth = parseFloat(panelWidth, 10) + 100;
			panelPaddingLeft = parseFloat(panelPaddingLeft, 10);
			panelPaddingRight = parseFloat(panelPaddingRight, 10);
		
			panelWidth = panelWidth + panelPaddingLeft + panelPaddingRight;
		
			var numPanels = $(".spotlight-item").length;
			var tooFar = -(panelWidth * numPanels);
			
			function doMove(panelWidth, tooFar) {
				var leftValue = $("#mover").css("left");
			
				// Fix for IE
				if (leftValue == "auto") { leftValue = 0; };
			
				var movement = parseFloat(leftValue, 10) - panelWidth;
			
				if (movement == tooFar) {
					$(".spotlight-item img").animate({
						"top": -300
					}, function() {
						$("#mover").animate({
							"left": 0
						}, function() {
							$(".spotlight-item img").animate({
								"top": 0
							});
						});
					});
				}
				else {
					$(".spotlight-item img").animate({
						"top": -300
					}, function() {
						$("#mover").animate({
							"left": movement
						}, function() {
							$(".spotlight-item img").animate({
								"top": 0
							});
						});
					});
				}
			}
			
			sliderIntervalID = setInterval(function(){
				doMove(panelWidth, tooFar);
			}, delayLength);
			
			$(".pause").click(function(){
			if ($(this).text() == "Stop") {
				clearInterval(sliderIntervalID);
			 	$(this).text("Start");
			}
			else {
				sliderIntervalID = setInterval(function(){
					doMove(panelWidth, tooFar);
				}, delayLength);
			 	$(this).text("Stop");
			 }
			});
		
		});

    	
	});		
		
	
	function autoLogin(){
		if (document.frmLogin.Autologin.checked==true){
			//Use a secure connection
			if (document.location.protocol!="https:"){
				document.frmLogin.action=document.location.href.replace("http","https").replace(document.location.search,"");
				document.frmLogin.Userpassword.value="";
				document.frmLogin.Usermail.disabled="disabled";
				document.frmLogin.Userpassword.disabled="disabled";
				$("#submitButton").attr("disabled","disabled");
				$("#submitButton em").text("Laddar om...");
				document.frmLogin.submit();
			}
		}
	}






