<!--
var xmlHttp = new Array();

function GetXmlHttpObject() {
	var HttpObj = null;
	try	{
		HttpObj = new XMLHttpRequest();
	} catch (e) {
		try {
			HttpObj = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e) {
			HttpObj = new ActiveXObject('Microsoft.XMLHTTP');
		}
	}
	return HttpObj;
}

function keyStroke(e, validate) {
	var key = window.event ? e.keyCode : e.which;
	if (key == 8 || key == 0) return true;
	if (key == 124 ) return false;
	if (validate == 1 && key == 32) return false;
	if (validate == 3 || validate == 2) {
		if (key < 48 || key > 57) {
			if (key != 44 && key != 45) {
				return false;
			} else {
				if (validate == 2 && key == 44) {
					return false;
				}
			}
		}
	}
}

function checkSubscribeMail() {
	var check = false;
	check = emailCheck('email',1);
	if(check == false) {
		alert('Je hebt een ongeldig emailadres ingevoerd.');	
	}
	return check;
}

function checkInput(evt, fieldtype, id) {
	var keynum = evt.keyCode ? evt.keyCode :
							 evt.charCode ? evt.charCode :
							 evt.which ? evt.which : void 0;
	if (keynum == 8 || keynum == 9 || keynum == 37 || keynum == 39 || (keynum >= 48 && keynum <= 57)) {
		return true;
	} else {
		if (fieldtype == 2 && keynum == 44) {
			var val = document.getElementById(id).value;
			if (val.indexOf(',') >= 0) return false;
			return true;
		}
	}
	return false;
}

function saveInput(id) {
	var val = document.getElementById(id).value;
	xmlHttp[1] = GetXmlHttpObject();
	var url = '../includes/ajax.asp?script=setgrade&id=' + id + '&val=' + val + '&sid=' + Math.random();
	xmlHttp[1].open('GET', url, true);
	xmlHttp[1].onreadystatechange = function() {
		if (xmlHttp[1].readyState == 4) {
			document.getElementById(id).value = xmlHttp[1].responseText;
		}
	}
	xmlHttp[1].send(null);
}

function shopCheck(sel, visitor_id) {
	var val = 0;
	if (sel) val = 1;
	xmlHttp[1] = GetXmlHttpObject();
	var url = 'includes/shop_ajax.asp?script=shopcheck&val=' + val + '&visitor_id=' + visitor_id + '&sid=' + Math.random();
	xmlHttp[1].open('GET', url, true);
	xmlHttp[1].onreadystatechange = function() {
		if (xmlHttp[1].readyState == 4) {
			document.getElementById('shopCart').innerHTML = xmlHttp[1].responseText;
			updateIDealAmount(visitor_id);
		}
	}
	xmlHttp[1].send(null);
}

function updateIDealAmount(visitor_id) {
	xmlHttp[1] = GetXmlHttpObject();
	var url = 'includes/shop_ajax.asp?script=updateidealamount&visitor_id=' + visitor_id + '&sid=' + Math.random();
	xmlHttp[1].open('GET', url, true);
	xmlHttp[1].onreadystatechange = function() {
		if (xmlHttp[1].readyState == 4) {
			if(document.getElementById('amount')) {
				document.getElementById('amount').value = xmlHttp[1].responseText;
			}
		}
	}
	xmlHttp[1].send(null);
}

function addToCart(visitor_id, product_id, quantity) {
	xmlHttp[1] = GetXmlHttpObject();
	if(quantity == 0) {
		if(document.getElementById('quantity' + product_id)) {
			quantity = parseInt(document.getElementById('quantity' + product_id).value, 10);
			if( isNaN(quantity) == true) {
				quantity = 1;	
			}
			document.getElementById('quantity' + product_id).value = '';
		}
	}
	var url = 'includes/shop_ajax.asp?script=addtocart&visitor_id=' + visitor_id + '&product_id=' + product_id + '&quantity=' + quantity + '&sid=' + Math.random();
	xmlHttp[1].open("GET", url, true);
	xmlHttp[1].onreadystatechange = function() {
		if (xmlHttp[1].readyState == 4) {
			var arr = xmlHttp[1].responseText.split('||##||');
			var div
			if(document.getElementById('shopCart')) {
				div = document.getElementById('shopCart');
			} else {
				div = document.getElementById('checkoutButtonWrapper');
			}
			div.innerHTML = arr[0];
			quantity = parseInt(arr[1]);
			if (document.getElementById('removeFromCart' + product_id)) {
				if (quantity > 0) {
					document.getElementById('removeFromCart' + product_id).style.visibility = 'visible';
				}	else {
					document.getElementById('removeFromCart' + product_id).style.visibility = 'hidden';
				}												
			}
			updateIDealAmount(visitor_id);
			updateTotalProducts(visitor_id);
			flashBar(product_id);
		}
	}
	xmlHttp[1].send(null);
}

function flashBar(product_id) {
	var color = '#00AB81';
	if(document.getElementById('product' + product_id)) {
		var div = document.getElementById('product' + product_id);
		var oldColor = div.style.backgroundColor;
		toggleColor(product_id, color);
		var timeout = setTimeout('toggleColor(\'' + product_id + '\',\'' + oldColor + '\')',500);
	}
}

function toggleColor(product_id, color) {
	var el = document.getElementById('product' + product_id);
	el.style.backgroundColor = color;
}

function updateTotalProducts(visitor_id) {
	xmlHttp[2] = GetXmlHttpObject();
	var url = 'includes/shop_ajax.asp?script=updatetotalproducts&visitor_id=' + visitor_id + '&sid=' + Math.random();
	xmlHttp[2].open("GET", url, true);
	xmlHttp[2].onreadystatechange = function() {
		if (xmlHttp[2].readyState == 4) {
			if(document.getElementById('totalProducts')) {
				document.getElementById('totalProducts').innerHTML = xmlHttp[2].responseText;
				document.getElementById('shopLink').style.display = '';
			}
		}
	}
	xmlHttp[2].send(null);
}

function updateCart(visitor_id, product_id, quantity) {
	if (quantity == '') quantity = 0;
	xmlHttp[2] = GetXmlHttpObject();
	var url = 'includes/shop_ajax.asp?script=updatecart&visitor_id=' + visitor_id + '&product_id=' + product_id + '&quantity=' + quantity + '&sid=' + Math.random();
	xmlHttp[2].open("GET", url, true);
	xmlHttp[2].onreadystatechange = function() {
		if (xmlHttp[2].readyState == 4) {
			quantity = xmlHttp[2].responseText;
			addToCart(visitor_id, product_id, quantity)
		}
	}
	xmlHttp[2].send(null);
}

function changeUrl(value) {
	var cat_id = document.getElementById('cat_id').value;
	var subcat_id = document.getElementById('subcat_id').value;
	xmlHttp[1] = GetXmlHttpObject();
	var url = 'includes/shop_ajax.asp?script=changeurl&cat_id=' + cat_id + '&subcat_id=' + subcat_id + '&brand_id=' + value + '&sid=' + Math.random();
	xmlHttp[1].open('GET', url, true);
	xmlHttp[1].onreadystatechange = function() {
		if (xmlHttp[1].readyState == 4) {
			document.location.href = xmlHttp[1].responseText;
		}
	}
	xmlHttp[1].send(null);	
	//document.location.href='shop.asp?cat_id=' + cat_id + '&subcat_id=' + subcat_id + '&brand_id=' + value;
}

function checkPaymentMethods(val, visitor_id) {
	if(val == 0) { 
		document.getElementById('clientNrField').style.display = 'none';
		document.getElementById('clientNr').value = '';
		document.getElementById('pickupDiv').style.display = '';
	} else if(val == 1) { //IDeal
		document.getElementById('clientNrField').style.display = 'none';
		document.getElementById('pickupDiv').style.display = '';
	} else if(val == 2) { //Op rekening afhalen
		document.getElementById('pickup').checked = true;
		document.getElementById('pickupDiv').style.display = 'none';
		document.getElementById('clientNrField').style.display = '';
	} else if(val == 3) { //Op rekening bezorgen
		document.getElementById('clientNrField').style.display = '';
		document.getElementById('pickup').checked = false;
		document.getElementById('pickupDiv').style.display = 'none';
	}
	shopCheck(document.getElementById('pickup').checked, visitor_id);
}

function checkClientNr(input) {
	if(input.value.match(/T(\d{5})/gi) === null ) {
		alert('U heeft een verkeerde klantcode opgegeven.');
		input.value = '';
		return false;
	}
	return true;
}

function showInfo(product_id) {
	var obj = document.getElementById('productInfo' + product_id);
	var state = obj.style.display;
	if (state == 'none' || state == '') {
		obj.style.display = 'block';
	} else {
		obj.style.display = 'none';	
	}
}

function checkForm(block_id) {
	var formitem = document.getElementById('checkfields' + block_id).value.split('#**#');
	for (var x = 0; x < formitem.length; x++) {
		var formproperties = formitem[x].split('#|#');
		var formfield = formproperties[0];
		var fieldname = formproperties[1];
		var validate = parseInt(formproperties[2]);
		var compulsary = parseInt(formproperties[3]);
		var unique = parseInt(formproperties[4]);
		if (validate != 2) {
			if (document.getElementById(formfield)) {
				var a = doTrim(document.getElementById(formfield));
				document.getElementById(formfield).value = a;
			}
		}
		if (validate == 2) {
			var found = false;
			for (var i = 0; i < document.getElementsByName(formfield).length; i++) {
				if (document.getElementsByName(formfield)[i].checked) found = true;
			}
			if (found == false) {
				translate(2, '', ': ' + fieldname);
				return false;
			}
		}
		if (compulsary == 1) {
			if (document.getElementById(formfield).value == '') {
				if (document.getElementById(formfield).style.visibility != 'hidden') {
					translate(3, '', ': ' + fieldname);
					document.getElementById(formfield).focus();
					return false;
				}
			}
		}
		if (validate == 1) {
			if (emailCheck(formfield, compulsary) == false) {
				translate(4, '', '');
				document.getElementById(formfield).focus();
				return false;
			}
		}
		if (unique == 1) {
			var result = parseInt(document.getElementById(formfield + '_unique').value);
			if (result == 0) {
				translate(5, '', ': ' + fieldname);
				document.getElementById(formfield).focus();
				return false;
			}
		}
	}
	if(block_id == 1) {
		var paymentMethod;
		if(document.getElementById('paymentMethod1').checked == true) {
			paymentMethod = 1;	
		} else if(document.getElementById('paymentMethod2').checked == true) {
			paymentMethod = 2;
		} else if(document.getElementById('paymentMethod3').checked == true) {
			paymentMethod = 3;
		}
		if(paymentMethod > 1) {
			var clientNr = document.getElementById('clientNr');
			return checkClientNr(clientNr);		
		}
		formfield = 'postcode';
		if(formfield == 'postcode') {
			if(document.getElementById(formfield)) {
				var value = document.getElementById(formfield).value;
				if(value.match(/^\d{4}\s?[A-Za-z]{2}$/)) {
					return true;
				} else {
					if(confirm('Het systeem heeft de ingevoerde postcode (' + value + ') niet herkend als zijnde een Nederlandse postcode.\nControleer de postcode op fouten of klik op \'OK\' om door te gaan indien u een buitenlandse postcode heeft ingevuld.')) {
						alert('Omdat u bestelt vanuit het buitenland, zullen wij de verzendkosten voor u berekenen en aan u doorgeven.');
						return true;
					} else {
						return false;	
					}
				}
			}
		}
	}
	return;
}

function checkUnique(dbtable, dbfield, id, formfield) {
	xmlHttp[1] = GetXmlHttpObject();
	var url = 'includes/ajax.asp?script=checkunique&dbtable=' + dbtable + '&dbfield=' + dbfield + '&dbvalue=' + escape(document.getElementById(formfield).value) + '&id=' + id + '&sid=' + Math.random();
	xmlHttp[1].open('GET', url, true);
	xmlHttp[1].onreadystatechange = function() {
		if (xmlHttp[1].readyState == 4) {
			result = xmlHttp[1].responseText;
			document.getElementById(formfield + '_unique').value = result;
		}
	}
	xmlHttp[1].send(null);
}

function emailCheck(formfield, compulsary) {
	var emailStr=document.getElementById(formfield).value
	if (compulsary == 0 && emailStr == '') return true;
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) return false;
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i = 0; i < user.length; i++) {
		if (user.charCodeAt(i) > 127) return false;
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i) > 127) return false;
	}
	if (user.match(userPat)==null) return false;
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i = 1;i <= 4; i++) {
			if (IPArray[i] > 255) return false;
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i = 0; i < len; i++) {
		if (domArr[i].search(atomPat) == -1) return false;
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) return false;
	if (len < 2) return false;
	return true;
}

function translate(id, before, after) {
	xmlHttp[2] = GetXmlHttpObject();
	var url = 'includes/ajax.asp?script=translate&id=' + id + '&rid=' + Math.random();
	xmlHttp[2].open('GET', url, true);
	xmlHttp[2].onreadystatechange = function() {
		if (xmlHttp[2].readyState == 4) {
			response = before + xmlHttp[2].responseText + after;
			alert(response);
		}
	}
	xmlHttp[2].send(null);
}

function tagReaction(reaction_id) {
	xmlHttp[1] = GetXmlHttpObject();
	var url = 'includes/ajax.asp?script=tagreaction&reaction_id=' + reaction_id + '&tagged=1&rid=' + Math.random();
	xmlHttp[1].open('GET', url, true);
	xmlHttp[1].onreadystatechange = function() {
		if (xmlHttp[1].readyState == 4) {
			document.getElementById('ok' + reaction_id).innerHTML = document.getElementById('tagMessage').value;
		}
	}
	xmlHttp[1].send(null);
}

function showAdvanced() {
	if (document.getElementById('advanced').style.display == 'none') {
		document.getElementById('advanced').style.display = 'block';
	} else {
		document.getElementById('advanced').style.display = 'none';
	}
}

function doTrim(obj) {
	var a = trim(obj.value);
	obj.value = a;
	return a;
}

function trim(strValue) {
	if (strValue.length < 1) return '';
	strValue = rTrim(strValue);
	strValue = lTrim(strValue);
	return strValue;
}

function rTrim(strValue) {
	var w_space = String.fromCharCode(32);
	var v_length = strValue.length;
	var strTemp = '';
	if (v_length < 0) return '';
	var iTemp = v_length - 1;
	while(iTemp > -1) {
		if (strValue.charAt(iTemp) != w_space) {
			strTemp = strValue.substring(0, iTemp + 1);
			break;
		}
		iTemp = iTemp - 1;
	}
	return strTemp;
}

function lTrim(strValue) {
	var w_space = String.fromCharCode(32);
	if (v_length < 1) return '';
	var v_length = strValue.length;
	var strTemp = '';
	var iTemp = 0;
	while (iTemp < v_length) {
		if (strValue.charAt(iTemp) != w_space) {
			strTemp = strValue.substring(iTemp, v_length);
			break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}

var BrowserDetect = {
	init: function ()
	{
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data)
	{
		for (var i=0;i<data.length;i++)
		{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString)
			{
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString)
	{
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{	// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{	// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
};

BrowserDetect.init();
//-->

