﻿function isMSIE() {
	return '\v' == 'v';
}


// **************************************************
// Kleur informatie - KleurenLijstMetFiltering.ascx
// **************************************************

// initialisation function
function InitKleurInfo() {
	if (window.XMLHttpRequest) {
		xmlHttpKleurInfo = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			xmlHttpKleurInfo = new ActiveXObject("Microsof.XMLHTTP");
		}
		catch (e) { }
	}
	divKleurInformatie = document.getElementById('kleurInformatie');
}

// Send request to server
function sendKleurInfoRequest(loadURL) {
	var popupId = ""
	if (jQuery("#DivPopupWindow.divPopupWindowProjecten").size() > 0) {
		popupId = "Kleuren"
	}
	Estate.Plastica.Popup.Open("", popupId);
	Estate.Plastica.KleurLightBox.Init(loadURL, popupId);
	
//	if (xmlHttpKleurInfo) {
//		xmlHttpKleurInfo.open("GET", url, true);
//		xmlHttpKleurInfo.onreadystatechange = UpdateContentKleurInformatieDiv;
//		xmlHttpKleurInfo.send(null);
//	}
	return false;
}

// Update the content of the Kleur Informatie div
//function UpdateContentKleurInformatieDiv() {
//	if (xmlHttpKleurInfo.readyState == 4) {
//		if (xmlHttpKleurInfo.status == 200) {
//			var result = xmlHttpKleurInfo.responseText;
//			divKleurInformatie.innerHTML = result;
//		} else {
//			divError.innerHTML = xmlHttpKleurInfo.status;
//		}
//	}
//}

// *****************************************************
// Project informatie - ProjectenLijstMetFiltering.ascx
// *****************************************************

// initialisation function
function InitProjectInfo() {
	if (window.XMLHttpRequest) {
		xmlHttpProjectInfo = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			xmlHttpProjectInfo = new ActiveXObject("Microsof.XMLHTTP");
		}
		catch (e) { }
	}
	divProjectInformatie = document.getElementById('projectInformatie');
}

// Send request to server
function sendProjectInfoRequest(loadURL) {
	Estate.Plastica.Popup.Open();
	Estate.Plastica.ProjectLightBox.Init(loadURL);

//	if (xmlHttpProjectInfo) {
//		xmlHttpProjectInfo.open("GET", url, true);
//		xmlHttpProjectInfo.onreadystatechange = UpdateContentProjectInformatieDiv;
//		xmlHttpProjectInfo.send(null);
//	}
	return false;
}

// Update the content of the Kleur Informatie div
//function UpdateContentProjectInformatieDiv() {
//	if (xmlHttpProjectInfo.readyState == 4) {
//		if (xmlHttpProjectInfo.status == 200) {
//			var result = xmlHttpProjectInfo.responseText;
//			divProjectInformatie.innerHTML = result;
//		} else {
//			divError.innerHTML = xmlHttpProjectInfo.status;
//		}
//	}
//}

// ***********************************************
// Product informatie - KleurBeschikbaarVoor.ascx
// ***********************************************

// initialisation function
function InitProductInfo() {
	if (window.XMLHttpRequest) {
		xmlHttpProductInfo = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			xmlHttpProductInfo = new ActiveXObject("Microsof.XMLHTTP");
		}
		catch (e) { }
	}
	divProductInformatie = document.getElementById('productInformatie');
}

// Send request to server
function sendProductInfoRequest(e, url) {
	if (e) {
		e.cancelBubble = true;
		e.returnValue = false;
	}

	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}
	jQuery("#productInformatie").load(url + " #mainform > *")
	return false;
}

// Update the content of the Product Informatie div
function UpdateContentProductInformatieDiv() {
	if (xmlHttpProductInfo.readyState == 4) {
		if (xmlHttpProductInfo.status == 200) {
			var result = xmlHttpProductInfo.responseText;
			divProductInformatie.innerHTML = result;
		} else {
			divError.innerHTML = xmlHttpProductInfo.status;
		}
	}
}

// ******************************************
// Algemeen
// ******************************************

// adds the specified function to the onload function of the window with
// while retaining already specified onload functions.
function addOnloadEvent(fnc) {
	if (typeof window.addEventListener != "undefined")
		window.addEventListener("load", fnc, false);
	else if (typeof window.attachEvent != "undefined") {
		window.attachEvent("onload", fnc);
	}
	else {
		if (window.onload != null) {
			var oldOnload = window.onload;
			window.onload = function(e) {
				oldOnload(e);
				window[fnc]();
			};
		}
		else
			window.onload = fnc;
	}
}
