$(document).ready(function(){ 
	//Sitespecific javascript here
	//Greybox closebox
$(".greybox").click(function(){
			$("#GB_window").css("background-color","#aaaaaa").prepend('<span class="closeMe">St&auml;ng</span>');
			$(".closeMe").click(GB_hide);
			});
	//Searchbox clear and fill
	function input_values()
	{	
		var inputBox = $('#newsletter input, #header form input');
	
		
		inputBox.focus(function(){
			if ($(this).val() != "") {
				
				var theValue = $(this).val();
				$(this).attr('temp', theValue)
				$(this).val('');
			};
		
		});
		inputBox.blur(function(){
			if ($(this).val() == "") {
				var theValue = $(this).attr('temp');
				$(this).val(theValue);
			};
			
		});
	}
	input_values();
	
	//Even and odd rows in tables
	/* if Environment is NOT Editor */
		$("table tr").mouseover(function() {
			$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");
		});
		$("table tr:nth-child(even), table tr td:nth-child(even), ul li:nth-child(even)").addClass("even");
		$("table tr:nth-child(odd), table tr td:nth-child(odd), ul li:nth-child(odd)").addClass("odd");
		$("table tr:first-child").removeClass('even').addClass("th");
		$('table tr td:first-child, ul li:first-child').addClass('first');
		$('table tr td:last-child, ul li:last-child').addClass('last');
		
    //List even odd and first and last list

		
		//Show links with flowplayer as embedded media
		if ($('p > a').attr('title') == 'flowplayer') {
			$('a[title=flowplayer]').jmedia(
			{version:"6,0"},
			{width:"630", 
			height:"355", 
			autoplay: true,
			maintainaspect:"true"});
		};


	

	
	function createSkitterFront(){
		$('#slideshow table#slideshow_base').hide();
		var slideBase = $('#slideshow table#slideshow_base tbody tr');

		var	slideDest = '<div class="box_skitter box_skitter_large">';
				slideDest += '<ul>';
				slideDest += '</ul>';
				slideDest += '</div>';
				
					
		$('#slideshow').append(slideDest);
			
		slideBase.each(function(){
			var slideImg = $(this).find('td:eq(0)').html();
			var slideHeading = $(this).find('td:eq(1)').text();
			var slideText = $(this).find('td:eq(2)').text();
			var slideArtName = $(this).find('td:eq(3)').text();
			var slideLink = $(this).find('td:eq(4)').text();
			
			
			var eachSlide;
					eachSlide = '\n\t<li>';
					eachSlide += '<a href="'+slideLink+'" title="'+slideHeading+'">'+slideImg+'</a>';
					eachSlide += '<div class="label_text">';
					eachSlide += '<h2>'+slideHeading+'</h2><p>';
					eachSlide += '<span class="art_name">'+slideArtName+'</span>&nbsp;|&nbsp;';
					eachSlide += '<span class="art_cat">'+slideText+'</span>';
					eachSlide += '</p><iframe src="http://www.facebook.com/plugins/like.php?locale=sv_SE&amp;app_id=185918778131095&amp;href='+slideLink+'&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=segoe+ui&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe>';
					eachSlide += '</div>';
					eachSlide += '</li>';
			
			$('.box_skitter ul').append(eachSlide);
			
		});
		$('#slideshow table#slideshow_base').remove();
		skitterShow('fade',1,8000,'450px');
	}
	if ($('#slideshow table').attr('id') == 'slideshow_base') {
		createSkitterFront();
	}
	
	
	
	function skitter_gallery(){
		$('#main table.gallery').hide();
		var slideBase = $('#main table.gallery tbody tr');

		var	slideDest = '<div class="box_skitter box_skitter_small">';
				slideDest += '<ul>';
				slideDest += '</ul>';
				slideDest += '</div>';
				
					
		$('#main table.gallery').after(slideDest);
			
		slideBase.each(function(){
			var slideImg = $(this).find('td:eq(0)').html();
			var slideText = $(this).find('td:eq(1)').text();

			
			var eachSlide;
					eachSlide = '\n\t<li>';
					eachSlide += slideImg;
					eachSlide += '<div class="label_text">';
					eachSlide += '<p>'+slideText+'</p>';
					eachSlide += '</div>';
					eachSlide += '</li>';
			
			$('.box_skitter ul').append(eachSlide);
			
		});
		$('#main table.gallery').remove();
		skitterShow('fade',1,10000,'480px');
	}
	if ($('#main table').hasClass('gallery')) {
		skitter_gallery();
	}
	
	
	function skitterShow(animationType,speed, interval, labelWidth){
		$('.box_skitter').skitter({
			dots: true,
			animation: animationType,
			velocity: speed,
			interval: interval,
			numbers: false,
			width_label: labelWidth,
			animateNumberOut: {backgroundColor:'#cccccc', color:'#ccc'},
			animateNumberOver: {backgroundColor:'#ffffff', color:'#ccc'},
			animateNumberActive: {backgroundColor:'#ffffff', color:'#ccc'}
		});
	}

	if($(".snn_button").length >= 1){
		$(".snn_button").click(function(){
	    	//var page = $('#office').val();
	    	var action = "/shop/checkout_fast";
	    	$("#entry_form").attr("action", action); 
	    	$("#entry_form").submit();
		});
	}	

	if ($('#nav_sub *').length == 0) {
		$('#nav_sub').hide();
	}
	

	
	
});
