

$(document).ready(function(){
		Shadowbox.init({
			players:    ["img"],
			skipSetup: false,
			language: 'sv'
    	}); 
	//Sitespecific javascript here

$('#add_monitor').click(function(e){
	e.preventDefault;
		$("#search_car_advanced").attr("action","/CM.php?PageID=101848");
		$("#search_car_advanced").submit();
		return false;
});

	//Searchbox clear and fill
	function input_values()
	{
		 //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();
		$('#search input').blur(function(){
			if (searchBox.val() == "") {
				var theValue = "Fyll i sökord";
				searchBox.val(theValue);
			};

		});
		$('#content form input[name^="start"],#content form input[name^="from"]').focus(function(){
			if ($(this).val() != "") {
				var theValue = "";
				$(this).val('');
			};

		});
		$('#content form input[name^="start"],#content form input[name^="from"]').blur(function(){
			if ($(this).val() == "") {
				var theValue = "Från";
				$(this).val(theValue);
			};

		});
		$('#content form input[name^="end"],#content form input[name^="to"]').focus(function(){
			if ($(this).val() != "") {
				var theValue = "";
				$(this).val('');
			};

		});
		$('#content form input[name^="end"],#content form input[name^="to"]').blur(function(){
			if ($(this).val() == "") {
				var theValue = "Till";
				$(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, ul li:first').addClass('first');
		$('table tr td:last, ul li:last').addClass('last');


        
    /*List even odd and first and last*/
    $('ul li:even').addClass('even');
    $('ul li:odd').addClass('odd');
    $('ul li:first-child').addClass('first');
    $('ul li:last-child').addClass('last');


	/*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;
	});
	
	/*Top ten numbers*/
	$('#top_ten_models li a').each(function(index){
		index++;
		$(this).prepend(index+'. ');
	});
	
	//Legend to header
$('#main fieldset legend').each(function(){
	//$legendvalue = $(this).html();
	//$(this).parent().prepend('<h2>'+$legendvalue+'</h2>');
	$(this).hide();
});

	//Current menu injection
	$('#nav_ul li.current a').append(' &laquo;').prepend('&raquo; ');

//Avancerad sök
$('#topten_search_advanced').click(function(){
	
	$(this).toggleClass('show_advanced');
	if ($(this).hasClass('show_advanced')) {
		$('.advanced input[type=text]').val('');
		$('.advanced input:checkbox:checked').attr('checked', false);
		
		
		$('#content form input[name^="start"],#content form input[name^="from"]').val('Från');
		$('#content form input[name^="end"],#content form input[name^="to"]').val('Till');
		
		
	};
	$('.advanced').toggle();
	return false;
});


});
