function updateCart()
{
	if(document.getElementById("sendfriend"))
	{
	    advAJAX.assign(document.getElementById("sendfriend"), {
	      onSuccess : function(obj) {
	      	  /*
		      	  document.getElementById("log").innerHTML = obj.responseText;
		      	  alert(obj.responseText);
	      	  */
	      	  document.getElementById('SendaFriend').innerHTML = "Uw e-mail is verstuurd. <a href='javascript:;' onclick='sendFriendClose();'>Sluit melding</a>";
	      }
	    });
	}
}

function sendFriend()
{
	document.getElementById('SendaFriend').style.display = "block";
	document.getElementById('paginaUrl').value = document.location;
}

function sendFriendClose()
{
	document.getElementById('SendaFriend').style.display = "none";
}

function sendMail()
{
	if(document.getElementById('emailAdres').value.length > 0)
	{
		alert("Mail send");
		submit();
		return true;
	}
	else
	{
		alert("No mail address");
		return false;
	}
}

function filedownload()
{
    var axel = Math.random() + "";
    var num = axel * 1000000000000000000;
    var spotpix = new Image();
    
    spotpix.src = "http://ad.se.doubleclick.net/activity;1196609;type=zovir826;cat=linkt882;ord=" + num;
}

function filedownload2()
{
	var axel = Math.random() + "";
	var num = axel * 1000000000000000000;
	var spotpix = new Image();
	spotpix.src = "http://ad.se.doubleclick.net/activity;src=1196609;type=zovir826;cat=linkt882;ord=" + num;
	if(navigator.appName == "Netscape" || navigator.appName == "Opera")
	{
		spotpix.onload = passed();
	}
	else if(navigator.appName == "Microsoft Internet Explorer")
	{
		spotpix.onload = passed;
	}
	else
	{
		spotpix.onload = passed;
	}
}

function passedTest()
{
	window.location = "http://www.google.com";
}

function passed()
{
    top.location.href="http://www.zovirax.nl/downloads/files/" + "zovirax_babyfolder.zip";
}

/**
 *	Checklist volgende
 */
function checklistNext() {
	var display = $("#question_stress").css("display"); 
	// Stress
	if (display == "block" || display == "table") {
		$("#question_stress").css("display", "none");
		$("#question_weer").css("display", "block");
	}
	// Weer
	else if ($("#question_weer").css("display") == "block") {
		$("#question_weer").css("display", "none");
		$("#question_ziekte").css("display", "block");
	}
	// Ziekte
	else if ($("#question_ziekte").css("display") == "block") {
		$("#question_ziekte").css("display", "none");
		$("#question_lifestyle").css("display", "block");
	}	
	// Lifestyle
	else if ($("#question_lifestyle").css("display") == "block") {
		$("#question_lifestyle").css("display", "none");
		$("#question_vrouw").css("display", "block");
		$("#nextBtn").css("display", "none");
		$("#resultBtn").css("display", "block");
	}
}

/**
 *	Checklist resultaat
 */
function checklist() {
	// Stress
	var stress = false;
	for (var i=1; i<=5; i++) {
		var radio = $("#checklist :radio[name='stress" + i + "']:checked");
		if (radio.length > 0) {
			if (radio.val() > 1) {
				$("#result_stress").css("display", "block");
				stress = true;
			}
			else {
				radio.parents("tr").remove();
			}
		}
		else {
			$("#checklist :radio[name='stress" + i + "']").parents("tr").remove();
		}
	}
	
	if (stress == false) {
		$("td.subkop.stress").parents("tr").remove();
	} 
	else {
		$("#question_stress").css("display", "block");
	}
	
	// Weer
	var weer = false;
	for (var i=1; i<=3; i++) {
		var radio = $("#checklist :radio[name='weer" + i + "']:checked");
		if (radio.length > 0) {
			if (radio.val() > 1) {
				$("#result_weer").css("display", "block");
				weer = true;
			}
			else {
				radio.parents("tr").remove();
			}
		}
		else {
			$("#checklist :radio[name='weer" + i + "']").parents("tr").remove();
		}
	}
	
	if (weer == false) {
		$("td.subkop.weer").parents("tr").remove();
	}
	else {
		$("#question_weer").css("display", "block");
	}
	
	// Ziekte
	var ziekte = false;
	for (var i=1; i<=3; i++) {
		var radio = $("#checklist :radio[name='ziekte" + i + "']:checked");
		if (radio.length > 0) {
			if (radio.val() > 1) {
				$("#result_ziek").css("display", "block");
				ziekte = true;
			}
			else {
				radio.parents("tr").remove();
			}
		}
		else {
			$("#checklist :radio[name='ziekte" + i + "']").parents("tr").remove();
		}
	}
	
	if (ziekte == false) {
		$("td.subkop.ziekte").parents("tr").remove();
	}
	else {
		$("#question_ziekte").css("display", "block");
	}
	
	// Lifestyle
	var lifestyle = false;
	for (var i=1; i<=4; i++) {
		var radio = $("#checklist :radio[name='lifestyle" + i + "']:checked");
		if (radio.length > 0) {
			if (radio.val() > 1) {
				$("#result_lifestyle").css("display", "block");
				lifestyle = true;
			}
			else {
				radio.parents("tr").remove();
			}
		}
		else {
			$("#checklist :radio[name='lifestyle" + i + "']").parents("tr").remove();
		}
	}
	
	if (lifestyle == false) {
		$("td.subkop.lifestyle").parents("tr").remove();
	}
	else {
		$("#question_lifestyle").css("display", "block");
	}
	
	// Vrouw
	if ($(":radio[name='vrouw1']:checked").val() > 1 || $(":radio[name='zwanger']:checked").val() == "ja") {
		$("#question_vrouw").css("display", "block");
		$("#result_vrouw").css("display", "block");
	}
	else {
		$("td.subkop.vrouw").parents("tr").remove();
		$(":radio[name='vrouw1']").parents("tr").remove();
		$(":radio[name='zwanger']").parents("tr").remove();
	}
	
	$("span.kop").text("Jouw koortslip checklist - resultaat");
	$("#checklist .btn").css("display", "none");
	$("#checklist_result").css("display", "block");
}

function sendchecklist() {
	$("#email").css("display", "block");
}

function sendresult() {
	var email = $("#email :input[name='email']").val();
	var content = "<html><head><style>body { font: normal 12px Arial; } div { width: 450px; padding: 10px; border: 1px solid #4CA0BA; }</style></head>";
	content += "<body><i>Tips op basis van de door jou ingevulde koortslip checklist:</i><br /><br />";
	
	if ($("#result_stress").css("display") == "block") {
		content += "<div>";
		content += $("#result_stress").html();
		content += "</div>";
	}
	if ($("#result_weer").css("display") == "block") {
		content += "<div>";
		content += $("#result_weer").html();
		content += "</div>";
	}
	if ($("#result_ziek").css("display") == "block") {
		content += "<div>";
		content += $("#result_ziek").html();
		content += "</div>";
	}
	if ($("#result_lifestyle").css("display") == "block") {
		content += "<div>";
		content += $("#result_lifestyle").html();
		content += "</div>";
	}
	if ($("#result_vrouw").css("display") == "block") {
		content += "<div>";
		content += $("#result_vrouw").html();
		content += "</div>";
	}
	content += "<i>Met vriendelijke groet,<br /><br />Zovirax.nl</i><br /><br /><hr />Deze email is automatisch gegenereerd op <a href='http://www.zovirax.nl'>www.zovirax.nl</a>.";
	content += "</body></html>";
	
	$.post("/sendmail.aspx", { email: email, data: content }, function(data) {
		if (data == "error") {
			alert("Er is een fout opgetreden, de mail is helaas niet verstuurd. Probeer het later nog eens.");
		}
		else {
			$("#email_send").css("display", "block");
		}
	});
}

// Poll vote
function vote() {
	var vote = $(".poll_antwoorden :input[name='poll']:checked");
	if (vote.length == 0) {
		alert("Maak eerst een keuze.");
	}
	else {
		var answer = vote.val();
		$.getJSON("http://www.klant.exed.nl/gsk/zovirax_nl/poll.php?format=json&jsoncallback=?", { vote: answer }, function(data) {
			$("#poll_btn").remove();
			$(".poll_antwoorden").html("");
			$.each(data, function(i, item) {
				$(".poll_antwoorden").append("<div>" + item.answer + " (stemmen: <b>" + item.percentage + "%</b>)</div>");
			});
		});
	}
}

// Print checklist
function printChecklist() {
	var content = $(".subcontentlefttext").html();
	var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes,width=650, height=600, left=100, top=25";
	var docprint = window.open("", "printDialog", disp_setting); 
	docprint.document.open(); 
	docprint.document.write('<html><head><title>Zovirax.nl - Checklist</title>'); 
	docprint.document.write('<link rel="stylesheet" href="/style.css" type="text/css" />');
	docprint.document.write('<style>body { background-color: #FFF; background-image: none; }</style>');
	docprint.document.write('</head><body onload="window.print()">');          
	docprint.document.write(content);          
	docprint.document.write('</body></html>'); 
	docprint.document.close(); 
	docprint.focus();
} 