$(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 search_input_values()
	{	
		var searchBox = $('#search input');
		$('#search input').focus(function(){
			if (searchBox.val() != "") {
				
				var theValue = searchBox.val();
				searchBox.attr('temp', theValue)
				searchBox.val('');
			};
		
		});
		$('#search input').blur(function(){
			if (searchBox.val() == "") {
				var theValue = searchBox.attr('temp');
				searchBox.val(theValue);
			};
			
		});
	}
	search_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)").addClass("even");
		$("table tr:nth-child(odd), table tr td: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');


		
		if ($('p > a').attr('title') == 'flowplayer') {
			$('a[title=flowplayer]').jmedia(
			{version:"6,0"},
			{width:"630", 
			height:"355", 
			autoplay: true,
			maintainaspect:"true"});
		};


	
	/*Accordion menu*/
	//Only on products, gallery, yeah, not normal content pages.
	//Hide submenus
	$('#sub_nav li ul').hide();
	//If menu option is current, show sub menu
	
			$('#sub_nav ul:first-child > li.current > ul').slideToggle('slow');
			
			
			
		
	//When clicking the top level, show submenu, but not sub sub menus
	//only do this IF there is a sub menu, otherwise treat as normal link
	$('#sub_nav ul:first-child > li > a:not(:only-child)').click(function() {

		//if ($('#container').hasClass('p_content')) {}
		//if link has no siblings, or submenus, return the link. 
		
			$(this).parent().toggleClass('current'); //set class of the parent to current for styling
			$(this).next().slideToggle('slow'); //slide down the next ul after the a tag
			return false; //commenting this out will stop links from working. We want this for content pages.
		
		
	});
	
	$('#gallery ul a').lightBox(
		{
		imageLoading: '/System/Templates/Sites/206/images/lightbox-ico-loading.gif',
		imageBtnClose:'/System/Templates/Sites/206/images/lightbox-btn-close.gif',
		imageBtnPrev: '/System/Templates/Sites/206/images/lightbox-btn-prev.gif',
		imageBtnNext: '/System/Templates/Sites/206/images/lightbox-btn-next.gif'
	}
	);
});
