function toggleLib(obj, show) {
	if (show) {
		obj.next().show();
		obj.parent().css('background-image', 'url("http://klant2.exed.nl/gsk/panadol/images/bullet-pijl-down.gif")');
		setHeight();
	}
	else {
		obj.next().hide();
		obj.parent().css('background-image', 'url("http://klant2.exed.nl/gsk/panadol/images/bullet-pijl.gif")');
		setHeight();
	}
}

function setHeight() {
	var height = $(".contentData").height();
	if (height > 550) {
		$(".contentText").css("height", height + "px");
		
		/*if ($.browser.msie && $.browser.version < 7) {
		}
		else {
			$(".contentText").gradient({ from: 'ffffff', to: 'F9F3C0' });
		}*/
		
		// Als de content over de footer dreigt heen te vallen, schuif de footer op
		if (height > 700) {
			$(".contentSub").css("height", (height - 300) + "px");
		}
	}
}

$(document).ready(function() {
	// Hoogte attribute moet geset zijn om gradient te kunnen gebruiken
	var height = $(".contentData").height();
	
	// Minimale hoogte
	if (document.location.href.indexOf("welkom.aspx") <= 0 && height < 550) {
		height = 550;
	}
	
	$(".contentText").css("height", height + "px");
	if ($.browser.msie && $.browser.version < 7) {
	}
	else {
		$(".contentText").gradient({ from: 'ffffff', to: 'F9F3C0' });
	}
	
	// Als de content over de footer dreigt heen te vallen, schuif de footer op
	if (height > 700) {
		$(".contentSub").css("height", (height - 300) + "px");
	}
	
	// Schuif content veld naar beneden voor specifieke pagina's
	if (document.location.href.indexOf("welkom.aspx") > 0) {
		$(".mainContent").css("margin-top", "450px");
		$(".poppetje").css("display", "none");
	}
	else {
		$(".mainContent").css("margin-top", "25px");
	}
	
	// Set actieve menuitem
	if (document.location.href.indexOf("welkom.aspx") > 0) {
		$("#home a").css("color", "#FF0103");
	}
	else if (document.location.href.indexOf("/artrose") > 0) {
		$("#artrose a").css("color", "#FF0103");
	}
	else if (document.location.href.indexOf("/productpagina") > 0 || document.location.href.indexOf("/verkorte") > 0) {
		$("#panadol a").css("color", "#FF0103");
	}
	else if (document.location.href.indexOf("/actie") > 0) {
		$("#actie a").css("color", "#FF0103");
	}
	else if (document.location.href.indexOf("/pain_update_library") > 0) {
		$("#pain a").css("color", "#FF0103");
	}
	
	// Mouseover buttons
	$("a img").each(function() {
		var src = $(this).attr("src");
		var img = src.replace("01_", "02_");
		$(this).hover(
			function() {
				$(this).attr("src", img);
			},
			function() {
				$(this).attr("src", src);
			}
		);
	});
	
	// Pain Update Library - main items
	$(".painLibSub").each(function() {
		$(this).prev().toggle(
			function() {
				toggleLib($(this), true);
			},
			function() {
				toggleLib($(this), false);
			});
	});
	
	// Pain Update Library - sub items
	$(".painLibSubSub").each(function() {
		$(this).prev().toggle(
			function() {
				toggleLib($(this), true);
			},
			function() {
				toggleLib($(this), false);
			});
	});
	
	// Logo-button
	$(".logos").click(function() {
		window.location = "http://www.gsk.nl/consumer_healthcare.aspx";
	});
});