//******************* this script is written by Jan Smeelen *******************

function setupForm() {

   if  (userProfile=="1") 

        { (document.myForm.i0.checked) = true; 

           where = "_blank"; }

   else

           where = "_top";

   for (var i=0; i<=(document.links.length-1); i++) {

        document.links[i].target = where; 

      }

}



function Set_Cookie(name,value,expires,path,domain,secure) {

    document.cookie = name + "=" +escape(value) +

        ( (expires) ? ";expires=" + expires.toGMTString() : "") +

        ( (path) ? ";path=" + path : "") + 

        ( (domain) ? ";domain=" + domain : "") +

        ( (secure) ? ";secure" : "");

}



function Get_Cookie(name) {

    var start = document.cookie.indexOf(name+"=");

    var len = start+name.length+1;

    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;

    if (start == -1) return null;

    var end = document.cookie.indexOf(";",len);

    if (end == -1) end = document.cookie.length;

    return unescape(document.cookie.substring(len,end));

}



function eigenklik() {

 where = "_self"; 

 for (var i=0; i<=(document.links.length-1); i++) {

        document.links[i].target = where; 

		}

}



function linkcheck() {

var today = new Date();

var expires = new Date(today.getTime() + (56 * 86400000));

for (i=0; i<1; i++) {

if (document.myForm.i0.checked) {

Set_Cookie("externlink",1,expires);

     where = "_blank"; 

}

else

{ 

Set_Cookie("externlink",0,expires);

 where = "_top";

 } 

    for (var i=0; i<=(document.links.length-1); i++) {

       document.links[i].target = where; 

}

}

}

var userProfile = Get_Cookie("externlink");

//******************************* EURO CALCULATOR ************************************

	function toEuro(i)
	{
		if (i == 1 && document.layers)
			return;
		var a = document.forms.euroform.gld;
		var b = document.forms.euroform.eur;
		var t = a.value;
		var c;
		if ((c = t.indexOf(",")) != -1)
			t = t.substring(0, c) + '.' + t.substring(c+1, 999);
		var cv = parseFloat(t);
		if (isNaN(cv)) cv = 0;
		cv = cv / 2.20371;
		cv = (Math.round(cv * 100)) / 100;
		b.value = cv;
		if (b.value.charAt(0) == '.')
			b.value = "0" + b.value;
		if (b.value.indexOf('.') == -1)
			b.value = b.value + ".00";
		while (b.value.charAt(b.value.length-3) != '.')
			b.value = b.value + '0'; 
	}
	
	function toGulden(i)
	{
		if (i == 1 && document.layers)
			return;
		var b = document.forms.euroform.gld;
		var a = document.forms.euroform.eur;
		var t = a.value;
		var c;
		if ((c = t.indexOf(",")) != -1)
			t = t.substring(0, c) + '.' + t.substring(c+1, 999);
		var cv = parseFloat(t);
		if (isNaN(cv)) cv = 0;
		cv = cv * 2.20371;
		cv = (Math.round(cv * 100)) / 100;
		b.value = cv;
		if (b.value.charAt(0) == '.')
			b.value = "0" + b.value;
		if (b.value.indexOf('.') == -1)
			b.value = b.value + ".00";
		while (b.value.charAt(b.value.length-3) != '.')
			b.value = b.value + '0'; 
	}

//****************************** Postcode muk **********************************

function postcodeZoeken1() {
	toonResultaat('', 0);
	document.adres.submit();
}

function adresZoeken() {
	toonResultaat('', 0);
	if (document.postcode.postcode.value.charAt(4) == " ") {
		var pc1 = document.postcode.postcode.value.substr(0,4);
		var pc2 = document.postcode.postcode.value.substr(5,2);
		document.postcode.postcode.value = pc1 + pc2;
	}
	document.postcode.submit();
}

function toonResultaat(url, scrollb) { 
   eval("zoekresultaat = window.open(url, 'zoekresultaat', 'top=20,left=20,toolbar=0,scrollbars=" + scrollb + ",location=0,statusbar=1,menubar=0,resizable=0,width=550,height=330');");
}

function postcodeZoeken() {
	toonResultaat('', 'auto');
	if (document.layers) 
		document.layers['zoeken'].document.adres.submit(); 
	else 
		document.adres.submit();
}

function SubmitAdresZoekForm()
{
  with (document.adres) {
    action = 'http://www.tpgpost.nl/cgi-bin/pzm-a.pl';
    method = 'get'; 
    submit();
  }
}

function SubmitPostcodeZoekForm()
{
  with (document.postcode) {
    action = 'http://www.tpgpost.nl/cgi-bin/pzm-p.pl';
    method = 'get'; 
    submit();
  }
}