﻿var xmlHttp;	
function GetXmlHttpObject()	{ 
	var obj = null;
	if (window.XMLHttpRequest) {
		obj = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		obj = new ActiveXObject("Microsoft.XMLHTTP");
	}
	return obj;
}
/* password */
function spw(obj) {
	if (trim(obj.value) == '') {
		alert('Geen e-mail adres ingevuld.\nVul uw e-mail adres in en klik nogmaals op wachtwoord vergeten.');
		obj.focus();
		return;
	} 
	if (!isEmail(obj.value, true)) {
		alert('Het ingevulde e-mail adres is geen geldig email adres.');
		obj.focus();
		return;
	}
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {
				alert(xmlHttp.responseText); 
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/pass.asp?email=" + obj.value + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
/* cart */
function utc(id, cnt) {
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {
				//if (trim(xmlHttp.responseText) != "") { alert(xmlHttp.responseText); }
				self.location.href = self.location.href;
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/cart.asp?act=1&pid=" + id + "&cnt=" + cnt + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
function dtc(id) {
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {
				//if (trim(xmlHttp.responseText) != "") { alert(xmlHttp.responseText); }			
				self.location.href = self.location.href;
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/cart.asp?act=2&pid=" + id + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
function atc(id, color, size) {
	if (!color) color = "";
	if (!size)  size  = "";
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {
				//if (trim(xmlHttp.responseText) != "") { alert(xmlHttp.responseText); }					
				self.location.href = self.location.href;
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/cart.asp?act=3&pid=" + id + "&color=" + color + "&size=" + size + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
function _atc(id, color, size) { // for relations
	if (!color) color = "";
	if (!size)  size  = "";
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {
				//if (trim(xmlHttp.responseText) != "") { alert(xmlHttp.responseText); }					
				//self.location.href = self.location.href;
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/cart.asp?act=3&pid=" + id + "&color=" + color + "&size=" + size + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
function rfc(id) {
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {
				//if (trim(xmlHttp.responseText) != "") { alert(xmlHttp.responseText); }					
				self.location.href = self.location.href;
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/cart.asp?act=4&pid=" + id + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
function _rfc(id) { // for relations
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {
				//if (trim(xmlHttp.responseText) != "") { alert(xmlHttp.responseText); }					
				//self.location.href = self.location.href;
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/cart.asp?act=4&pid=" + id + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
function emc() {
	if (confirm("Weet u het zeker dat u alle artikelen wilt verwijderen?")) {
		xmlHttp = GetXmlHttpObject();
		if (xmlHttp != null) {
			xmlHttp.onreadystatechange = function() { 
				if (xmlHttp.readyState == 4) {	
					//if (trim(xmlHttp.responseText) != "") { alert(xmlHttp.responseText); }
					self.location.href = self.location.href;
				}
			};	
			xmlHttp.open("GET", "/inc/asp/ajax/cart.asp?act=5&nocache=" + Math.random(), true);
			xmlHttp.send(null);
		}
	}
}
function rpw(s) {
	alert(s);
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {	
				alert(xmlHttp.responseText);	
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/cart.asp?act=6&email=" + s + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
/* prik */
function cba(o, v) {
	var cent = '00';
	var price = '' + (o.value * v);
	var pos = price.lastIndexOf('.');
	if (pos < 0) {
		euro = price;
	} else {
		euro = price.substring(0, pos);
		cent = price.substring(pos + 1, pos + 3);
		if (cent.length == 1) cent += '0';
	}
	document.getElementById('totalprice').innerHTML = '&euro; ' + euro + ',' + cent;
}
function rad(id) {
	if (confirm('Weet u HEEL zeker dat u deze advertentie wilt verwijderen?')) {
		go('/prikbord/?act=8&id='+id); 
	}
}
function pgr(s1, s2) {
	//alert(s1 + ":" + s2);
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp != null) {
		xmlHttp.onreadystatechange = function() { 
			if (xmlHttp.readyState == 4) {	
				document.getElementById('SubId').innerHTML = xmlHttp.responseText;	
			}
		};	
		xmlHttp.open("GET", "/inc/asp/ajax/prik.asp?act=1&id=" + s1 + "&subid=" + s2 + "&nocache=" + Math.random(), true);
		xmlHttp.send(null);
	}
}
function cps(o) {
	var n = parseInt(o.options[o.selectedIndex].value);
	switch (n) {
		case 0: case 1:	case 12:
			document.getElementById('pricebox').style.display="block";
			break;
		default:
			document.getElementById('pricebox').style.display="none";
			document.forms.makead.Price.value = "0,00";
			break;
	}
}
function cci(o, e) {
	var key;
	if (window.event) {
		key = window.event.keyCode;
	} else {
		if (e) key = e.which;
	}
	if (key == 8) return true;
	if (key >= 48 && key <= 57) return true;
	if (key == 44 && o.value.indexOf(',') == -1) return true;
	if (key == 46 && o.value.indexOf('.') == -1) return true;
	return false;
}
function cpf(o) {
	var cent = '00';
	var euro = '0';
	// stripspaces
	o.value = o.value.replace(/ /g, '');
	if (o.value == '') {
		o.value = euro + ',' + cent;
		return;
	}
	// find dot/comma pos
	var com = o.value.lastIndexOf(',');
	var dot = o.value.lastIndexOf('.');
	var pos = Math.max(com, dot);
	// remove dot/comma
	if (pos < 0) {
		euro = o.value;
	} else {
		euro = o.value.substring(0, pos);
		cent = o.value.substring(pos + 1, pos + 3);
		if (cent.length == 1) cent += '0';
		euro = euro.replace(/,/g, '');
		euro = euro.replace(/\./g, '');
	}
	// not larger then 9999
	if (parseInt(euro) > 9999) {
		euro = '10000';
		cent = '00';
	}
	// place dots
	var pos = euro.length - 3;
	while (pos > 0) {
		euro = euro.substring(0, pos) + '.' + euro.substring(pos);
		pos -= 3;
	}
	o.value = euro + ',' + cent;
}
/* artinfo */
function verifyCartOptions(id) {
	size   = null;
	color  = null;
	sizes  = document.getElementById('cartSizes');
	colors = document.getElementById('cartColors');
	if (sizes != null) {
		if (sizes.selectedIndex == 0) { 
			alert('Geef eerst aan welke maat u wilt!');
			sizes.focus();
			return;
		}
		size = sizes.options[sizes.selectedIndex].text;
		//alert(sizes.selectedIndex);
		//alert(size);
	}
	if (colors != null) {
		if (colors.selectedIndex == 0) { 
			alert('Geef eerst aan welke kleur u wilt!');
			colors.focus();
			return;
		}
		color = colors.options[colors.selectedIndex].text;
		//alert(colors.selectedIndex);
		//alert(color);

	}
	//alert(id + ":" + color + ":" + size);
	atc(id, color, size);
}
function ovt(obj, v) { 
	if (v) {
		document.getElementById('bigimage').style.backgroundImage = 'url(' + v + ')';
	} else {
		document.getElementById('bigimage').style.backgroundImage = obj.style.backgroundImage.replace('m_', 'f_').replace(' ', '%20');
	}
}
function ovtz(obj, v) { 
	if (v) {
		document.getElementById('bigimage').style.backgroundImage = 'url(' + v + ')';
		document.getElementById('zoomimage').style.display = 'block';
	} else {
		document.getElementById('bigimage').style.backgroundImage = obj.style.backgroundImage.replace('m_', 'f_').replace(' ', '%20');
		//document.getElementById('zoomimage').style.display = '';
		document.getElementById('zoomimage').style.display = 'none';
	}
}

/* inputchecks */

