if (!Array.indexOf) {  Array.prototype.indexOf = function (obj, start) {    for (var i = (start || 0); i < this.length; i++) {      if (this[i] == obj) {        return i;      }    }    return -1;  }}//---------------------------------------------------------------------||// FUNCTION:    ValidateEmail                		                   ||// PARAMETERS:  FieldID                                                ||// RETURNS:     false when no valid email address                      ||// PURPOSE:     Check if the field contains data                       ||//---------------------------------------------------------------------||function ValidateEmail(field_id) {	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;	var field_value = document.getElementById(field_id).value;	if(reg.test(field_value) == false) {		return false;	}	var field_title = document.getElementById(field_id).title;	if (field_title!=null) {		if(field_title==field_value) {			return false;		}	}}//---------------------------------------------------------------------||// FUNCTION:    ValidateValueNotEmpty                                  ||// PARAMETERS:  FieldID                                                ||// RETURNS:     false when no value                                    ||// PURPOSE:     Check if the field contains data                       ||//---------------------------------------------------------------------||function ValidateValueNotEmpty(field_id) {	if (document.getElementById(field_id).type == "select-one") {		var field_value = document.getElementById(field_id).options[document.getElementById(field_id).selectedIndex].value;		if (field_value == '') {			field_value = document.getElementById(field_id).options[document.getElementById(field_id).selectedIndex].text;		}	}	else {		var field_value = document.getElementById(field_id).value;	}	if(field_value==null || field_value=="") {		return false;   	}	var field_title = document.getElementById(field_id).title;	if (field_title!=null) {		if(field_title==field_value) {			return false;		}	}}//---------------------------------------------------------------------||// FUNCTION:    formatMoney                                            ||// PARAMETERS:  (numbers behind separator, decimal separator, thousend ||// RETURNS:     formatted value                                        ||// PURPOSE:     For use with currency			                       ||//---------------------------------------------------------------------||Number.prototype.formatMoney = function(c, d, t){	var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "",	i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;	return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t)	+ (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");};//---------------------------------------------------------------------||// FUNCTION:    GetCity                                                ||// PARAMETERS:  zipcode_id, city_id                                    ||// RETURNS:     city                                                   ||// PURPOSE:     For use with currency			                       ||//---------------------------------------------------------------------||function GetCity(zipcode_id, city_id) {	var zipcode = document.getElementById(zipcode_id).value.replace(/ /g,'').toUpperCase();	if (zipcode.match(/^[1-9]\d{3}[A-Z]{2}$/)) {		zipcode = zipcode.substring(0, 4) + " " + zipcode.substring(4);	}	document.getElementById(zipcode_id).value = zipcode; 	if (window.XMLHttpRequest) {		xmlHttp=new XMLHttpRequest();	}	else {  // for older IE 5/6		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");	}	var url="/4daction/web_shop_page/" + webshop.administration_id + "/get_city";	xmlHttp.open("POST",url,false);	xmlHttp.send("wPC="+zipcode);	if (xmlHttp.responseText != "") {		document.getElementById(city_id).value = xmlHttp.responseText;	}}//---------------------------------------------------------------------||// FUNCTION:    getCookieVal                                           ||// PARAMETERS:  offset                                                 ||// RETURNS:     URL unescaped Cookie Value                             ||// PURPOSE:     Get a specific value from a cookie                     ||//---------------------------------------------------------------------||function getCookieVal (offset) {   var endstr = document.cookie.indexOf (";", offset);   if ( endstr == -1 )      endstr = document.cookie.length;   return(unescape(document.cookie.substring(offset, endstr)));}//---------------------------------------------------------------------||// FUNCTION:    FixCookieDate                                          ||// PARAMETERS:  date                                                   ||// RETURNS:     date                                                   ||// PURPOSE:     Fixes cookie date, stores back in date                 ||//---------------------------------------------------------------------||function FixCookieDate (date) {   var base = new Date(0);   var skew = base.getTime();   date.setTime (date.getTime() - skew);}//---------------------------------------------------------------------||// FUNCTION:    GetCookie                                              ||// PARAMETERS:  Name                                                   ||// RETURNS:     Value in Cookie                                        ||// PURPOSE:     Retrieves cookie from users browser                    ||//---------------------------------------------------------------------||function GetCookie (name) {   var arg = name + "=";   var alen = arg.length;   var clen = document.cookie.length;   var i = 0;   while ( i < clen ) {      var j = i + alen;      if ( document.cookie.substring(i, j) == arg ) return(getCookieVal (j));      i = document.cookie.indexOf(" ", i) + 1;      if ( i == 0 ) break;   }   return(null);}//---------------------------------------------------------------------||// FUNCTION:    GetCookieStr                                           ||// PARAMETERS:  Name                                                   ||// RETURNS:     Value in Cookie                                        ||// PURPOSE:     Retrieves cookie from users browser                    ||//---------------------------------------------------------------------||function GetCookieStr (name) {   var strValue = GetCookie (name);   if (strValue == null) { strValue = '';}   return(strValue);}//---------------------------------------------------------------------||// FUNCTION:    SetCookie                                              ||// PARAMETERS:  name, value, expiration date, path, domain, security   ||// RETURNS:     Null                                                   ||// PURPOSE:     Stores a cookie in the users browser                   ||//---------------------------------------------------------------------||function SetCookie (name,value,expires,path,domain,secure) {   document.cookie = name + "=" + escape (value) +                     ((expires) ? "; expires=" + expires.toGMTString() : "") +                     ((path) ? "; path=" + path : "") +                     ((domain) ? "; domain=" + domain : "") +                     ((secure) ? "; secure" : "");}//---------------------------------------------------------------------||// FUNCTION:    DeleteCookie                                           ||// PARAMETERS:  Cookie name, path, domain                              ||// RETURNS:     null                                                   ||// PURPOSE:     Removes a cookie from users browser.                   ||//---------------------------------------------------------------------||function DeleteCookie (name,path,domain) {   if ( GetCookie(name) ) {      document.cookie = name + "=" +                        ((path) ? "; path=" + path : "") +                        ((domain) ? "; domain=" + domain : "") +                        "; expires=Thu, 01-Jan-70 00:00:01 GMT";   }}//---------------------------------------------------------------------||// FUNCTION:    GetCurrentUserInfo                                     ||// PARAMETERS:  None					                               ||// RETURNS:     null                                                   ||// PURPOSE:     Set the current user in the correct field.             ||//---------------------------------------------------------------------||function GetCurrentUserInfo() {	var current_username = GetCookie('Username');	if(current_username==null || current_username=="") {		current_username = 'Niet aangemeld';		document.getElementById('login_form').style.display = '';		document.getElementById('logoff_form').style.display = 'none';	}	else {		document.getElementById('login_form').style.display = 'none';		document.getElementById('logoff_form').style.display = '';	}	document.getElementById('current_user').innerHTML = current_username;}//---------------------------------------------------------------------||// FUNCTION:    GetCurrentArticleInfo                                  ||// PARAMETERS:  ProductID, PriceRow, Run			                   ||// RETURNS:     xmlDoc                                                 ||// PURPOSE:     Set the current user in the correct field.             ||//---------------------------------------------------------------------||function GetCurrentArticleInfo(strID_NUM, PriceRow, Run) {	if (window.XMLHttpRequest) {		xmlHttp=new XMLHttpRequest();	}	else {  // for older IE 5/6		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");	}	var url="/4daction/web_shop_page/" + webshop.administration_id + "/price";	xmlHttp.open("POST",url,false);	xmlHttp.send("wUNIQUE="+strID_NUM+"&wPOSITION="+PriceRow+"&wRUN01="+Run);	return xmlHttp.responseXML;		}//---------------------------------------------------------------------||// FUNCTION:    GetCountryList                                         ||// PARAMETERS:  Current Country  		                               ||// RETURNS:     null                                                   ||// PURPOSE:     Gets the country list and fills the list.              ||//---------------------------------------------------------------------||function GetCountryList(Country) {	if (window.XMLHttpRequest) {		xmlHttp=new XMLHttpRequest();	}	else {  // for older IE 5/6		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");	}	var url="/4daction/web_shop_page/" + webshop.administration_id + "/country";	xmlHttp.open("POST",url,false);	xmlHttp.send("");	var xmlDoc = xmlHttp.responseXML;	var items = xmlDoc.getElementsByTagName("country");	for ( i = 0; i < items.length; i++ ) {		var item = items[i];		var name = item.getElementsByTagName("name")[0].firstChild.nodeValue;                document.getElementById('country').options[i] = new Option(name);                if (Country != '') {	        if (Country==name) {    	    	document.getElementById('country').selectedIndex = i;        	}        }        else {			if (item.getElementsByTagName("default")[0].firstChild.nodeValue == "1") {        		document.getElementById('country').selectedIndex = i;  			}  		}	}	return;		}//---------------------------------------------------------------------||// FUNCTION:    AddToCart		                                       ||// PARAMETERS:  ProductID, PriceRow, Run                               ||// RETURNS:     null                                                   ||// PURPOSE:     Add a product to the shopping cart.              	   ||//---------------------------------------------------------------------||function AddToCart(strID_NUM, PriceRow, Run) {	var iNumberOrdered = 0;	iNumberOrdered = GetCookie("NumberOrdered");	if ( iNumberOrdered == null )		iNumberOrdered = 0;		iNumberOrdered++;	var xmlDoc			= GetCurrentArticleInfo(strID_NUM, PriceRow, Run);	var strID_NUM		= xmlDoc.getElementsByTagName("id")[0].childNodes[0].nodeValue;	var strQUANTITY		= xmlDoc.getElementsByTagName("run")[0].childNodes[0].nodeValue;	var strPRICE		= xmlDoc.getElementsByTagName("price")[0].childNodes[0].nodeValue;	var strCOLUMN		= xmlDoc.getElementsByTagName("column")[0].childNodes[0].nodeValue;	var strNAME			= xmlDoc.getElementsByTagName("description")[0].childNodes[0].nodeValue;	var strSHIPPING		= xmlDoc.getElementsByTagName("delivery")[0].childNodes[0].nodeValue;	var strADDTLINFO	= xmlDoc.getElementsByTagName("information")[0].childNodes[0].nodeValue;	dbUpdatedOrder = strID_NUM		+ "|" + 					 strQUANTITY	+ "|" +					 strPRICE		+ "|" +					 strCOLUMN		+ "|" +					 strNAME		+ "|" +					 strSHIPPING	+ "|" +					 strADDTLINFO	+ "|" +					 ""				+ "|" +					 ""				+ "|" +					 "";		strNewOrder = "Order." + iNumberOrdered;	SetCookie(strNewOrder, dbUpdatedOrder, null, "/");	SetCookie("NumberOrdered", iNumberOrdered, null, "/");	location.href = "/" + webshop.administration_path + "/shoppingcard.shtm";}//---------------------------------------------------------------------||// FUNCTION:    ModifyFromCart                                         ||// PARAMETERS:  Order Number to Modify                                 ||// RETURNS:     Null                                                   ||// PURPOSE:     Modifies an item from a users shopping cart            ||//---------------------------------------------------------------------||function ModifyFromCart(SelectedOrder) {	var iNumberOrdered = 0;	iNumberOrdered = GetCookie("NumberOrdered");	if ( iNumberOrdered == null )		iNumberOrdered = 0;	SetCookie ("SelectedOrder", SelectedOrder, null, "/");	location.href = "/" + webshop.administration_path + "/modifycard.shtm";}//---------------------------------------------------------------------||// FUNCTION:    RemoveFromCart                                         ||// PARAMETERS:  Order Number to Remove                                 ||// RETURNS:     Null                                                   ||// PURPOSE:     Removes an item from a users shopping cart             ||//---------------------------------------------------------------------||function RemoveFromCart(RemOrder) {	var iNumberOrdered = 0;	iNumberOrdered = GetCookie("NumberOrdered");	if ( iNumberOrdered == null )		iNumberOrdered = 0;			for ( i=RemOrder; i < iNumberOrdered; i++ ) {		NewOrder1 = "Order." + (i+1);		NewOrder2 = "Order." + (i);		database = GetCookie(NewOrder1);		SetCookie (NewOrder2, database, null, "/");	}	NewOrder = "Order." + iNumberOrdered;	SetCookie ("NumberOrdered", iNumberOrdered-1, null, "/");	DeleteCookie(NewOrder, "/");	location.href=location.href;}//---------------------------------------------------------------------||// FUNCTION:    RemoveAllFromCart                                      ||// PARAMETERS:  None                                                   ||// RETURNS:     Null                                                   ||// PURPOSE:     Removes all the items from a users shopping cart       ||//---------------------------------------------------------------------||function RemoveAllFromCart() {	var iNumberOrdered = 0;	iNumberOrdered = GetCookie("NumberOrdered");	if ( iNumberOrdered == null )		iNumberOrdered = 0;			for ( i=0; i < iNumberOrdered; i++ ) {		NewOrder = "Order." + (i + 1);		DeleteCookie(NewOrder, "/");	}	SetCookie ("NumberOrdered", 0, null, "/");	location.href=location.href;}//---------------------------------------------------------------------||// FUNCTION:    InitExtraInfo                                          ||// PARAMETERS:  null                                                   ||// RETURNS:     null                                                   ||// PURPOSE:     Gets the operations and fills it in a list.            ||//---------------------------------------------------------------------||function InitExtraInfo() {	var SelectedOrder = GetCookie('SelectedOrder');		UpdateOrder = "Order." + SelectedOrder;	var database = "";	database = GetCookie(UpdateOrder);		Token0 = database.indexOf("|", 0);	Token1 = database.indexOf("|", Token0+1);	Token2 = database.indexOf("|", Token1+1);	Token3 = database.indexOf("|", Token2+1);	Token4 = database.indexOf("|", Token3+1);	Token5 = database.indexOf("|", Token4+1);	Token6 = database.indexOf("|", Token5+1);	Token7 = database.indexOf("|", Token6+1);	Token8 = database.indexOf("|", Token7+1);	fields = new Array;	fields[0] = database.substring( 0, Token0 );                 // Product ID	fields[1] = database.substring( Token0+1, Token1 );          // Quantity	fields[2] = database.substring( Token1+1, Token2 );          // Price	fields[3] = database.substring( Token2+1, Token3 );          // Column Number	fields[4] = database.substring( Token3+1, Token4 );          // Product Name/Description	fields[5] = database.substring( Token4+1, Token5 );          // Shipping Cost	fields[6] = database.substring( Token5+1, Token6 ); 		 // Additional Information	fields[7] = database.substring( Token6+1, Token7 );          // Title	fields[8] = database.substring( Token7+1, Token8 );          // Remark	fields[9] = database.substring( Token8+1, database.length ); // Extra Operations	var strOutput = "";	//String to be written to page	strOutput += "<b>" + parseFloat(fields[1]).formatMoney(0, ",", ".") + "x " + fields[4] + "</b>";	if (fields[6]!='&nbsp;') { strOutput += "<br/>"  + fields[6]; }	if (fields[5]!='&nbsp;') { strOutput += "<br/>"  + fields[5]; }	document.getElementById('product').innerHTML = strOutput;	document.getElementById('price').innerHTML = "&euro; " + parseFloat(fields[2]).formatMoney(2, ",", ".");	document.getElementById('title').value = fields[7];	document.getElementById('remark').value = fields[8];	document.getElementById('operation1').options[0] = new Option('');	document.getElementById('operation2').options[0] = new Option('');	document.getElementById('operation3').options[0] = new Option('');	document.getElementById('operation4').options[0] = new Option('');	document.getElementById('operation5').options[0] = new Option('');		if (window.XMLHttpRequest) {		xmlHttp=new XMLHttpRequest();	}	else {  // for older IE 5/6		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");	}	var url="/4daction/web_shop_page/" + webshop.administration_id + "/operations/" + fields[0];	xmlHttp.open("POST",url,false);	xmlHttp.send("");	var xmlDoc = xmlHttp.responseXML;	var items = xmlDoc.getElementsByTagName("operations");	for ( i = 0; i < items.length; i++ ) {		var item = items[i];		var object = item.getElementsByTagName("name")[0].firstChild;		if (object!=null) {			extra_operation[i] = object.nodeValue;			extra_price[i] = item.getElementsByTagName("price")[0].firstChild.nodeValue;			if ((item.getElementsByTagName("fixed")[0].firstChild.nodeValue) == 0) extra_price[i] = extra_price[i] * parseFloat(fields[1]);			var object = item.getElementsByTagName("description")[0].firstChild;			if (object!=null)				extra_description[i] = object.nodeValue;        	else        		extra_description[i] = "";        document.getElementById('operation1').options[i+1] = new Option(extra_operation[i]);        document.getElementById('operation2').options[i+1] = new Option(extra_operation[i]);        document.getElementById('operation3').options[i+1] = new Option(extra_operation[i]);        document.getElementById('operation4').options[i+1] = new Option(extra_operation[i]);        document.getElementById('operation5').options[i+1] = new Option(extra_operation[i]);        }        	}	var operations = "";	operations = fields[9];		Token0 = operations.indexOf("\t", 0);	Token1 = operations.indexOf("\t", Token0+1);	Token2 = operations.indexOf("\t", Token1+1);	Token3 = operations.indexOf("\t", Token2+1);	Token4 = operations.indexOf("\t", Token3+1);	Token5 = operations.indexOf("\t", Token4+1);	Token6 = operations.indexOf("\t", Token5+1);	Token7 = operations.indexOf("\t", Token6+1);	Token8 = operations.indexOf("\t", Token7+1);		position = extra_operation.indexOf (operations.substring( 0, Token0 ));	if (position != -1) {		document.getElementById('operation1').selectedIndex = position + 1;		document.getElementById('price1').innerHTML = "&euro; " + parseFloat(extra_price[position]).formatMoney(2, ",", ".");		if (extra_description[position] != '') document.getElementById('image1').style.visibility = "visible";		else document.getElementById('image1').style.visibility = "hidden";	}	else {		document.getElementById('price1').innerHTML = "&nbsp;";		document.getElementById('image1').style.visibility = "hidden";	}		position = extra_operation.indexOf (operations.substring( Token1+1, Token2 ));	if (position != -1) {		document.getElementById('operation2').selectedIndex = position + 1;		document.getElementById('price2').innerHTML = "&euro; " + parseFloat(extra_price[position]).formatMoney(2, ",", ".");		if (extra_description[position] != '') document.getElementById('image2').style.visibility = "visible";		else document.getElementById('image2').style.visibility = "hidden";	}	else {		document.getElementById('price2').innerHTML = "&nbsp;";		document.getElementById('image2').style.visibility = "hidden";	}		position = extra_operation.indexOf (operations.substring( Token3+1, Token4 ));	if (position != -1) {		document.getElementById('operation3').selectedIndex = position + 1;		document.getElementById('price3').innerHTML = "&euro; " + parseFloat(extra_price[position]).formatMoney(2, ",", ".");		if (extra_description[position] != '') document.getElementById('image3').style.visibility = "visible";		else document.getElementById('image3').style.visibility = "hidden";	}	else {		document.getElementById('price3').innerHTML = "&nbsp;";		document.getElementById('image3').style.visibility = "hidden";	}		position = extra_operation.indexOf (operations.substring( Token5+1, Token6 ));	if (position != -1) {		document.getElementById('operation4').selectedIndex = position + 1;		document.getElementById('price4').innerHTML = "&euro; " + parseFloat(extra_price[position]).formatMoney(2, ",", ".");		if (extra_description[position] != '') document.getElementById('image4').style.visibility = "visible";		else document.getElementById('image4').style.visibility = "hidden";	}	else {		document.getElementById('price4').innerHTML = "&nbsp;";		document.getElementById('image4').style.visibility = "hidden";	}		position = extra_operation.indexOf (operations.substring( Token7+1, Token8 ));	if (position != -1) {		document.getElementById('operation5').selectedIndex = position + 1;		document.getElementById('price5').innerHTML = "&euro; " + parseFloat(extra_price[position]).formatMoney(2, ",", ".");		if (extra_description[position] != '') document.getElementById('image5').style.visibility = "visible";		else document.getElementById('image5').style.visibility = "hidden";	}	else {		document.getElementById('price5').innerHTML = "&nbsp;";		document.getElementById('image5').style.visibility = "hidden";	}		return;		}//---------------------------------------------------------------------||// FUNCTION:    UpdateExtraInfo                                        ||// PARAMETERS:  null                                                   ||// RETURNS:     null                                                   ||// PURPOSE:     Updates the extra info fields                          ||//---------------------------------------------------------------------||function UpdateExtraInfo() {	var SelectedOrder = GetCookie('SelectedOrder');		UpdateOrder = "Order." + SelectedOrder;	database = "";	database = GetCookie(UpdateOrder);	Token0 = database.indexOf("|", 0);	Token1 = database.indexOf("|", Token0+1);	Token2 = database.indexOf("|", Token1+1);	Token3 = database.indexOf("|", Token2+1);	Token4 = database.indexOf("|", Token3+1);	Token5 = database.indexOf("|", Token4+1);	Token6 = database.indexOf("|", Token5+1);	Token7 = database.indexOf("|", Token6+1);	Token8 = database.indexOf("|", Token7+1);	fields = new Array;	fields[0] = database.substring( 0, Token0 );                 // Product ID	fields[1] = database.substring( Token0+1, Token1 );          // Quantity	fields[2] = database.substring( Token1+1, Token2 );          // Price	fields[3] = database.substring( Token2+1, Token3 );          // Column Number	fields[4] = database.substring( Token3+1, Token4 );          // Product Name/Description	fields[5] = database.substring( Token4+1, Token5 );          // Shipping Cost	fields[6] = database.substring( Token5+1, Token6 ); 		 // Additional Information	fields[7] = document.getElementById('title').value;          // Title	fields[8] = document.getElementById('remark').value;         // Remark		var operations = "";	operation = document.getElementById('operation1').options[document.getElementById('operation1').selectedIndex].value;	operations = operations + operation + "\t";	position = extra_operation.indexOf (operation);	operations = operations + extra_price[position] + "\t";	operation = document.getElementById('operation2').options[document.getElementById('operation2').selectedIndex].value;	operations = operations + operation + "\t";	position = extra_operation.indexOf (operation);	operations = operations + extra_price[position] + "\t";		operation = document.getElementById('operation3').options[document.getElementById('operation3').selectedIndex].value;	operations = operations + operation + "\t";	position = extra_operation.indexOf (operation);	operations = operations + extra_price[position] + "\t";		operation = document.getElementById('operation4').options[document.getElementById('operation4').selectedIndex].value;	operations = operations + operation + "\t";	position = extra_operation.indexOf (operation);	operations = operations + extra_price[position] + "\t";	operation = document.getElementById('operation5').options[document.getElementById('operation5').selectedIndex].value;	operations = operations + operation + "\t"	position = extra_operation.indexOf (operation);	operations = operations + extra_price[position];	fields[9] = operations;										 // Extra Operations	database = "";	for ( i = 0; i < fields.length; i++ ) {		if(i != 0) {			database = database + "|";		}		database = database + fields[i];	}		SetCookie(UpdateOrder, database, null, "/");		location.href = "/" + webshop.administration_path + "/shoppingcard.shtm";}
