// JavaScript Document

function dropDown_show(menuItem){
	
	document.getElementById(menuItem).style.display = "block";
	
	}
		
function dropDown_hide(menuItem){
	
	document.getElementById(menuItem).style.display = "none";
	
	}
	


function enlarge(img, w, h)
	{
	window.open("popUps/img_enlarge.php?img="+img,"Large_image","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,fullscreen=no,width="+w+",height="+h+",top=0,left=0");	
	}
	
	function close_window()
		{
			window.close();
		}
		

function submitOnChange(){
	document.form.submit();
}


function deleteIt(url){
	if(confirm("Vill du verkligen radera")){
	window.location=url;
	}
	}
	
function mail_sent(){
	
	alert("Tack! \n Vi kontaktar dig snarast.");
	
	}
	
$(document).ready(function() {
	
	$("a.gallery_link").fancybox();
	
});

$(document).ready(function() {
	
	$("a.panorama").fancybox({
		 'width' : '75%',
		 'height' : '75%',
		 'autoScale' : false,
		 'transitionIn' : 'none',
		 'transitionOut' : 'none',
		 'type' : 'iframe'
	 });
	 
});

$(document).ready(function() {
	
	$("a.sms").hover(function(){
		$(this).stop().animate({
		 width: '120px',
		 height: '120px'
		}, 500);
		$(this).children('p').stop().animate({
			height: '25px',
			right: '7px',
			top: '24px'
		}, 400);
	 }, function() {
		 $(this).stop().animate({
		 width: '80px',
		 height: '80px'
		}, 500);
		$(this).children('p').stop().delay(100).animate({
			height: '4px',
			right: '0px',
			top: '27px'
		}, 400);
	 });
	 
});

$(document).ready(function() {
	
	$( "ul.menu li a" ).hover( function() {
		$( 'ul[id="' + $( this ).attr('open') + '"]:not(.active)').show();
	}, function() {
		$( 'ul[id="' + $( this ).attr('open') + '"]:not(.active)').hide();
	});
	
	$( 'ul.menu li ul' ).hover( function() {
		$( this ).show();
	}, function() {
		$( this ).hide();
	});
	
	$( "span.open" ).click( function() {
		$( this ).next().toggle().toggleClass( 'active' );
	});
	 
});


// Slider
$(window).load(function() {

	var sWidth = $('.slider div img').width();
	var sCount = $('.slider div').children().length;
	
	$('.slider div').width( sWidth * sCount);
	
	var ref = 0;
	var count = 0;
	
	function Slider() {
		count ++;
		
		if (count == sCount) {
			count = 0;
			ref = 0;
		} else if (count < 0) {
			count = sCount - 1;
			ref = -sCount + 1;
		} else {
			ref--;
		}
		
        $('.slider div').stop().animate({
			left: sWidth*ref
        }, 300);
    }
	
	var timer;
	
	var ie7 = (document.all && !window.opera && window.XMLHttpRequest) ? true : false;
	
	if ( ie7 == false ) {
		timer = setInterval(Slider, 4000);
	}
	
});
