﻿function ToggleAnswer(srcId)
{
	var targetObj = document.getElementById(srcId+'_Answer');
	targetObj.style.display = targetObj.style.display == 'none' ? 'block' : 'none';
}

function PrintEmail(theName, theExtras, theLink, theDomain) 
{
	var theEmail = theName + "@" + theDomain;

    if (theName == "") {
        theName = "ERROR";
        theLink = "ERROR";
        myEmail = theName;
        myLink = theLink;
    } else {
        if ((theExtras == "") && (theLink =="")){
            myEmail = theEmail;
            myLink = theEmail;
        }
       
        if ((theLink == "") && (theExtras != "")){
            myLink = theEmail;
            myEmail = theEmail+theExtras;
        }
       
        if ((theLink != "") && (theExtras != "")){
            myLink = theLink;
            myEmail = theEmail+theExtras;
        }
       
        if ((theLink != "") && (theExtras == "")){
            myLink = theLink;
            myEmail = theEmail;
        }
    }
   
    document.write('<a href="mailto:' + myEmail + '">' + myLink + '</a>');
}

function AddProductToCart(productId)
{
	var startCheckoutUrl = "/checkout/step1.aspx";
	new Ajax.Request('/QuickAddToCard.ashx?ProductId='+productId, {
		method:'get',
		onSuccess: function(transport){
			var response = transport.responseText || "no response text";
			myLightbox.end();
			location.replace(startCheckoutUrl);
		},
		onFailure: function(){
			alert('Kon het product niet toevoegen aan je winkelwagen.\r\nProbeert het door op de \'Voeg toe\' knop op de pagina te klikken.') 
		}
	}); 
}

function ValidateSize(sender, args)
{
	args.IsValid = (args.Value.indexOf("maat")==-1);
}


function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function addInputSubmitEvent(input, button) {
    input.onkeydown = function(e) {
        e = e || window.event;
        window.status = e.keyCode;
        if (e.keyCode == 13) {
            button.click();
            return false;
        }
    };
}


function ToggleAddressBlock(checked) {
    alert(checked);
}
