$(document).ready(function(){ 
	//Sitespecific javascript here
	$("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');

	$("<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\"><h1>Tingsrydtandl&auml;karna</h1><p>Du bes&ouml;ker oss fr&aring;n en mobil enhet. <br />Vi rekommenderar att du anv&auml;nder v&aring;r mobilsajt f&ouml;r b&auml;sta upplevelse:</p><p><a href=\"#\" id=\"mob_resp\">V&aring;r vanliga webbplats</a><a href=\"/Mobil\" id=\"mob_mob\">Anv&auml;nd v&aring;r mobilsajt</a></p><p><label><input id=\"mob_remember\" type=\"checkbox\" value=\"remember\" /> Kom ih&aring;g mitt val</label> <em>Kommer ih&aring;g ditt val i 7 dagar</em></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;
			}

		}

	
});
