
$(document).ready(function(){

		$("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')").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, ul li:first-child').addClass('first');
		$('table tr td:last, ul li:last-child').addClass('last');

	$("#subscriber_name").bind("click", function(){
		
		if($(this).val() == 'Namn / Företag')
	  	{
			$(this).val('')
		}
	});
	
	$("#subscriber_name").bind("blur", function(){
		
		if($(this).val() == '')
	  	{
			$(this).val('Namn / Företag')
		}
	});
	
	$("#subscriber_email").bind("click", function(){
		
		if($(this).val() == 'E-post')
	  	{
			$(this).val('')
		}
	});
	
	$("#subscriber_email").bind("blur", function(){
		
		if($(this).val() == '')
	  	{
			$(this).val('E-post')
		}
	});
	
	$("#newsletter_subscribe").mouseover( function() { 
		
		$(this).attr("src", "/System/Templates/Sites/162/images/button_newsletter_subscribe_over.gif");
	});

	
	$("#newsletter_subscribe").mouseout( function() { 
		
		$(this).attr("src", "/System/Templates/Sites/162/images/button_newsletter_subscribe.gif");
	});
	
	$("#login > a").bind("click", function(){
		
		window.open( 'http://login.hldesign.se/', '_blank', 'resizable=1,toolbar=1,menubar=1,location=1' );
		return false
	});
	
	$("#subnav ul li").mouseover(function() {
			$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");
		});
	$('#newsletter').click(function(){
		$('#newsletter_signup').toggle('slow');
		return false;
		});
	
		
		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();
	//$("<li id=\"nav_select\" />").prependTo("#nav ul");

//Create mobile selectbox of menu
$("<select id=\"nav_select\" />").appendTo("#nav");

// Create default option "Go to..."
	$("<option />", {
	   "selected": "selected",
	   "value"   : "",
	   "text"    : "Meny"
	}).appendTo("#nav_select");

	// Populate dropdown with menu items
	$("#nav ul > li > a").each(function() {
	 var el = $(this);
	 $("<option />", {
	     "value"   : el.attr("href"),
	     "text"    : el.text()
	 }).appendTo("#nav_select");
	});
	$("#nav_select").change(function() {
	  window.location = $(this).find("option:selected").val();
	});

	//create mobile splashscreen
	
	
	  var winWidth = $(window).width();
		var winHeight = $(window).height();
		
		if(winWidth < 600){
			var haveMobile = $.cookie('mobile_choice_made');
			switch(haveMobile){
				case 'responsive':
				//console.log(haveMobile);
				break;
				case 'mobile':
				//console.log(haveMobile);
				document.location.href='/Mobil';
				break;
				default:
					var mobile_greeting = "<div id=\"mobile_choice\"><img src=\"/System/Templates/Sites/162/v2/images/mobile_logo.png\" alt=\"HL DESIGN\" /><h1>Vi bygger mobila webbplatser</h1><p>Du besöker oss från en mobil enhet. Det finns två sorters mobilanpassningar:</p><p><a href=\"#\" id=\"mob_resp\">Responsiv design</a>Responsiv design ger dig tillgång till hela webbplatsen, där presentationen anpassats för mindre skärmar.<br /><a href=\"/Mobil\" id=\"mob_mob\">Mobilanpassade mallar</a>Mobilmallar ger dig en mini-webbplats med information endast tillgänglig för mobiler.</p><p>Båda valen har sina fördelar och vi ser alltid till vilken lösning som passar kunden bäst.</p><p><label><input id=\"mob_remember\" type=\"checkbox\" value=\"remember\" /> Kom ihåg mitt val</label></p></div>";

					$('#container').hide().after(mobile_greeting);
					$('#mob_resp').live('click',function(e){
						e.preventDefault();
						if ($('#mob_remember').is(':checked')) {
							$.cookie('mobile_choice_made', 'responsive', { expires: 7, path: '/' });
						}
						$('#mobile_choice').remove();
						$('#container').show();
						return false
					});
					$('#mob_mob').live('click',function(){
						if ($('#mob_remember').is(':checked')) {
							$.cookie('mobile_choice_made', 'mobile', { expires: 7, path: '/' });
						}
					});
				break;
			}

		}
			

	


});



