$(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, #search 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)").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').addClass('first');
		$('table tr td:last-child').addClass('last');
		
    //List even odd and first and last list
    $('ul li:nth-child(even)').addClass('even');
    $('ul li:nth-child(odd)').addClass('odd');
    $('ul li:first-child').addClass('first');
    $('ul li:last-child').addClass('last');
		
		//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"});
		};
		
		//Move nav
		//$('#header').append($('#nav'));

	//breadcrumb
	$('#breadcrumb li + li').prepend('&mt;&nbsp;');
	
	//navigation main
	$('#nav_main ul > li.current ul').hide();
	$('#nav_main ul > li').hover(function(){
		$(this).find('ul').show();
	},function(){
		$(this).find('ul').hide();
	});

	
	/*Accordion menu*/
	/*//Hide submenus
	$('#sub_nav li ul').hide();
	//If menu option is current, show sub menu
	if ($('#sub_nav li:first-child').hasClass('current'))
		{
			$('#sub_nav ul:first-child > li > ul').slideToggle('slow');
		};
	//When clicking the top level, show submenu, but not sub sub menus
	$('#sub_nav ul:first-child > li > a').click(function() {
		
			$(this).parent().toggleClass('current');
		
		$(this).next().slideToggle('slow');
		return false;
	});
	
	//Lightbox effect to gallery links
	//More information about this plug in http://www.gmarwaha.com/jquery/jcarousellite/#doc
	$('#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'

	}
	);
	
	//Initialize Carousell
	function myGallery() {
    $("#gallery").jCarouselLite({
        btnNext: "#gallery .next", //name of next button
        btnPrev: "#gallery .prev", //name of previous button
        visible: 9.5, 		//How many thumbs to be shown
        circular: "true", 	//Setting this to false will turn off the eternal scroll feature
        scroll: 5			//how many thumbs to scroll by clicking the next and previous buttons
    });
	}
	myGallery();
*/

/*tools*/
 //$('.col50:eq(1)').append('<ul id="tools>"<li class="print"><a href="#print">Skriv ut</a></li></ul>');
 $('a.print').click(function() {
  window.print();
  return false;
 });
 
 /*nyhetssidan*/
$('.col50 #news h3').before($('.col50 #news .wm_news_entry .wm_news_published'));

/*Calendar tricks*/
function calendarTricks(){
	//first hide the secondary calendars
	//$('.cal2,.cal3').hide();
	//Show all
	$('#cal_all').click(function(){
		$('.cal1,.cal2,.cal3').show();
		return false;
	});
	//Show first
	$('#cal1').click(function(){
		$('.cal1').show();
		$('.cal2,.cal3').hide();
		return false;
	});
	//Show second
	$('#cal2').click(function(){
		$('.cal2').show();
		$('.cal1,.cal3').hide();
		return false;
	});
	//Show third
	$('#cal3').click(function(){
		$('.cal3').show();
		$('.cal2,.cal1').hide();
		return false;
	});
}
calendarTricks();

/*food nav move - ain't I a stinker?*/
//$('#food h3').append($('.food_nav a.next_month').html('&raquo;').removeClass('next_month')).prepend($('.food_nav a.prev_month').html('&laquo;').removeClass('prev_month'));
$('#food h2').append($('.food_nav a.next_month').html('&raquo;')).prepend($('.food_nav a.prev_month').html('&laquo;'));


});
