$(document).ready(function() {
	/*$("input#search").focus(function() {
				if($(this).attr("value") == "Søg..."){
					$(this).attr("value", "");
				}
		});
	
	$("input#search").blur(function() {
			if($(this).attr("value") == ""){
				$(this).attr("value", "Søg...");
			}
		});*/
	
	//Navbar-selected-fix
	switch(pageName) {
		case "Forside":
			$('div#hjem').css('background-image', 'url("/gfx/menu/hjemHover.png")');
			break;
		case "Arbejdsområder":
			$('div#arbejdsomraader').css('background-image', 'url("/gfx/menu/arbejdsomraaderHover.png")');
			break;
		case "Referencer":
			$('div#referencer').css('background-image', 'url("/gfx/menu/referencerHover.png")');
			break;
		case "Priser":
			$('div#priser').css('background-image', 'url("/gfx/menu/priserHover.png")');
			break;
		case "Links":
			$('div#links').css('background-image', 'url("/gfx/menu/linksHover.png")');
			break;
		case "Om Talknuseren":
			$('div#omTalknuseren').css('background-image', 'url("/gfx/menu/omTalknuserenHover.png")');
			break;
		case "Kontakt":
			$('div#kontakt').css('background-image', 'url("/gfx/menu/kontaktHover.png")');
			break;
		default:
			$('div#hjem').css('background-image', 'url("/gfx/menu/hjemHover.png")');
			break;
	}
	
	
	$('div.contentBoxContent h1').first().css('margin-top', '0px');
	$('div.contentBoxContent h1').next('h2').css('margin-top', '0px');
	$('div.contentBoxContent p:last, div.contentBoxContent h1:last').css('margin-bottom', '0px');
	
	if($.browser.msie){
		if($.browser.version < 9.0){
			$('div#shortRecommendation').cycle({
				sync: 0,
				pause: 1,
				speed: 3000,
				timeout: 10000,
				fx: 'none',
				cleartypeNoBg: true
			});
		} else {
			$('div#shortRecommendation').cycle({
				sync: 0,
				pause: 1,
				speed: 3000,
				timeout: 10000
			});
		}
	} else {
		$('div#shortRecommendation').cycle({
			sync: 0,
			pause: 1,
			speed: 3000,
			timeout: 10000
		});
	}
	
	//tabBox
	var activeTab = 1;
	$('div#tab' + activeTab).attr('id', 'tab' + activeTab + 'Pressed');
	
	/*$('div.tabBoxEntry').hover(function() {
		var thisID = $(this).attr('id');
		if(thisID == 'tab1' || thisID == 'tab2' || thisID == 'tab3'){
			$('div#tab1Pressed').attr('id', 'tab1');
			$('div#tab2Pressed').attr('id', 'tab2');
			$('div#tab3Pressed').attr('id', 'tab3');
			
			$(this).attr('id', thisID + 'Pressed');
		}
	}, function() {
		var thisID = $(this).attr('id');
		if(thisID == 'tab1Pressed' || thisID == 'tab2Pressed' || thisID == 'tab3Pressed'){
			newID = thisID.substr(0, 4);
			$(this).attr('id', newID);
		}
		
		$('div#tab' + activeTab).attr('id', 'tab' + activeTab + 'Pressed');
	}); */
	
	$('div.tabContent').hide();
	$('div#tabContent' + activeTab).show();
	
	$('div.tabBoxEntry').click(function(){
		$('div.tabContent').hide();
		var thisID = $(this).attr('id');
		var activeTab = thisID.substr(3, 1);
		
		$('div#tab1Pressed').attr('id', 'tab1');
		$('div#tab2Pressed').attr('id', 'tab2');
		$('div#tab3Pressed').attr('id', 'tab3');
		
		$('div#tab' + activeTab).attr('id', 'tab' + activeTab + 'Pressed');
		$('div#tabContent' + activeTab).fadeIn(750);
	});
	
	//Referencer
	$('h3.referencer:first').css('margin-top', '0px');
	$('div.referenceExtend').hide();
	$('h3.referencer a').click(function(){
		var thisID = $(this).attr('id');
		if($(this).text() == '(Læs mere)'){
			$('div#re'+thisID.substr(1)).show();
			$(this).text('(Læs mindre)');
		} else {
			$('div#re'+thisID.substr(1)).hide();
			$(this).text('(Læs mere)');
		}
	});
});
