/**
* Styleswitch stylesheet switcher built on jQuery
* Under an Attribution, Share Alike License
* By Kelvin Luck ( http://www.kelvinluck.com/ )
**/

(function($)
{
	$(document).ready(function() {
		$('.styleswitch').click(function()
		{
			switchStylestyle(this.getAttribute("rel"));
			return false;
		});
		var c = readCookie('style');
		if (c) switchStylestyle(c);
	});

	function switchStylestyle(styleName)
	{
		$('link[@rel*=style][title]').each(function(i) 
		{
			this.disabled = true;
			if (this.getAttribute('title') == styleName) this.disabled = false;
		});
		createCookie('style', styleName, 365);
	}
})(jQuery);
// cookie functions http://www.quirksmode.org/js/cookies.html
function createCookie(name,value,days)
{
	if (days)
	{
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name)
{
	createCookie(name,"",-1);
}
// /cookie functions

// **************************
// ** background switcher **
// **************************
$('#nav-mainareas .viden:not(.active)').hover(function() {
     $(this).css({ 'background-position' : '0px 0px' });
   }, function() {
     $(this).css({ 'background-position' : '0px -50px' });
}); 

$('#nav-mainareas .forebyg:not(.active)').hover(function() {
     $(this).css({ 'background-position' : '0px -100px' });
   }, function() {
     $(this).css({ 'background-position' : '0px -150px' });
}); 

$('#nav-mainareas .stoet:not(.active)').hover(function() {
     $(this).css({ 'background-position' : '0px -200px' });
   }, function() {
     $(this).css({ 'background-position' : '0px -250px' });
}); 

// ** Frontpage **
$('.frontpage #nav-mainareas .viden').hover(function() {
     $(this).css({ 'background-position' : '-317px 0px' });
   }, function() {
     $(this).css({ 'background-position' : '0px 0px' });
}); 

$('.frontpage #nav-mainareas .forebyg').hover(function() {
     $(this).css({ 'background-position' : '-317px -167px' });
   }, function() {
     $(this).css({ 'background-position' : '0px -167px' });
}); 

$('.frontpage #nav-mainareas .stoet').hover(function() {
     $(this).css({ 'background-position' : '-318px -334px' });
   }, function() {
     $(this).css({ 'background-position' : '0px -334px' });
}); 

// **************************
// ** Form text remover ** //
// **************************

// $(document).ready(function() {
// $('input[type="text"]').addClass("idleField");
// $('input[type="text"]').focus(function() {
// $(this).removeClass("idleField").addClass("focusField");
// 	if (this.value == this.defaultValue){ 
// 		this.value = '';
// 	}
// 	if(this.value != this.defaultValue){
// 		this.select();
// 	}
// });
// $('input[type="text"]').blur(function() {
// 	$(this).removeClass("focusField").addClass("idleField");
// 		if ($.trim(this.value) == ''){
// 			this.value = (this.defaultValue ? this.defaultValue : '');
// 		}
// 	});
// });


// ********************************
// Styled tables
// ********************************

$(document).ready(function() {
    // IE round corners
    if($.browser.msie){
        $('<div class="tr"></div><div class="tl"></div><div class="br"></div><div class="bl"></div>').appendTo(".box");
    }
	$("#content-main table.oversigt").wrap('<div class="table-oversigt"></div>');
	$("#content-main table.grey").wrap('<div class="table-grey"></div>');
	$("#content-main table :nth-child(1)").addClass("first");
	$("#content-main table tr :nth-child(1)").addClass("first");
	
	$('<div class="PlayIcon"></div>').appendTo(".PlayIconWrap");
});
