﻿// JScript File

/************************************************************************************************/
/* BEGIN Controls */
/************************************************************************************************/
function Select_Contains(selectbox, value) {
	var bContains = false;
	try {
		for(var ii=0; ii< selectbox.options.length; ii++) {
			if(selectbox.options[ii].value == value) {bContains = true;}
		}
	} catch(ex) {
		LogError(ex, "Select_Contains");
	}
	return bContains;
}

function Select_Clear(selectbox) {
	try {
		for(var ii=selectbox.options.length; ii>0; ii--) {
			selectbox.remove(selectbox.options[ii]);
		}
	} catch(ex) {
		LogError(ex, "Select_Clear");
	}
}

function Select_Fill(selectbox, array) {
	try {
		for(var ii=0; ii<array.length; ii++) {
			Select_Add(selectbox, array[ii][0], array[ii][1]);
		}
	} catch(ex) {
		LogError(ex, "Select_Fill");
	}
}

function Select_Add(selectbox, value, text) {
	try {
		var option = new Option();
		option.value = value;
		option.text = text;
		try {
			selectbox.add(option, null); //w3c
		} catch(ex) {
			selectbox.add(option); //ie
		}
	} catch(ex) {
		LogError(ex, "Select_Add");
	}
}
/************************************************************************************************/
/* END Controls */
/************************************************************************************************/

/************************************************************************************************/
/* BEGIN Checks */
/************************************************************************************************/
function checkAkkoord() {
    //if (document.getElementById("ctl00_CPHContentLeft_chkAkkoord").checked) {
    if (document.getElementById("CPHContentLeft_chkAkkoord").checked) {
        return true;
    } else {
        alert('U dient eerst nog akkoord gaan met de voorwaarden!');
        return false;
    }
}

function checkEmailChange() {
    alert('U hebt uw emailadres/gebruikersnaam aangepast. \n U dient opnieuw in te loggen met uw nieuwe emailadres/gebruikersnaam.');
    return false;
}

/************************************************************************************************/
/* END Checks */
/************************************************************************************************/

/************************************************************************************************/
/* BEGIN styles */
/************************************************************************************************/
function setBackgroundColor(e, color) {
    e.style.backgroundColor = color;
}

function setClassname(e, className) {
    e.className = className;
}
/************************************************************************************************/
/* END styles */
/************************************************************************************************/

/************************************************************************************************/
/* BEGIN Popup */
/************************************************************************************************/
var arPopups = new Array();

function popup() {
	this.type = 1;
	this.url = "";
	this.name = "Popup_" + (arPopups.length + 1);
	this.html = "";

	this.parameters = new popup_parameters();

	this.show = popup_show;
	this.get_parameters = popup_get_parameters;
	this.window = null;
	
	arPopups[arPopups.length] = this;
	
	function popup_show() {
		switch(this.type) {
			case 1:
				this.window = window.open(this.url, this.name, this.get_parameters());
				break;
		}
		
	}
	
	function popup_get_parameters() {
		var sParams = "width={0},height={1}";
		sParams = sParams.replace("{0}", this.parameters.width);
		sParams = sParams.replace("{1}", this.parameters.height);
		if(this.parameters.left != null) {sParams += ",left="+this.parameters.left;}
		if(this.parameters.top != null) {sParams += ",top="+this.parameters.top;}
		if(this.parameters.channelmode != null) {sParams += ",channelmode="+(this.parameters.channelmode?"yes":"no");}
		if(this.parameters.directories != null) {sParams += ",directories="+(this.parameters.directories?"yes":"no");}
		if(this.parameters.fullscreen != null) {sParams += ",fullscreen="+(this.parameters.fullscreen?"yes":"no");}
		if(this.parameters.location != null) {sParams += ",location="+(this.parameters.location?"yes":"no");}
		if(this.parameters.menubar != null) {sParams += ",menubar="+(this.parameters.menubar?"yes":"no");}
		if(this.parameters.resizable != null) {sParams += ",resizable="+(this.parameters.resizable?"yes":"no");}
		if(this.parameters.scrollbars != null) {sParams += ",scrollbars="+(this.parameters.scrollbars?"yes":"no");}
		if(this.parameters.status != null) {sParams += ",status="+(this.parameters.status?"yes":"no");}
		if(this.parameters.titlebar != null) {sParams += ",titlebar="+(this.parameters.titlebar?"yes":"no");}
		if(this.parameters.toolbar != null) {sParams += ",toolbar="+(this.parameters.toolbar?"yes":"no");}
		return sParams;
	}
}

function popup_parameters() {
	this.width = 600;
	this.height = 400;
	this.left = null;
	this.top = null;
	this.channelmode = null;
	this.directories = null;
	this.fullscreen = null;
	this.location = null;
	this.menubar = null;
	this.resizable = null;
	this.scrollbars = null;
	this.status = null;
	this.titlebar = null;
	this.toolbar = null;
}
/************************************************************************************************/
/* END Popup */
/************************************************************************************************/

/************************************************************************************************/
/* BEGIN XML */
/************************************************************************************************/
function xml_firstChild(e) {
	e = e.firstChild;
	while (e.nodeType != 1) {e = e.nextSibling;}
	return e;
}
/************************************************************************************************/
/* END XML */
/************************************************************************************************/

/************************************************************************************************/
/* BEGIN XML document */
/************************************************************************************************/
/**
* Create a new Document object. If no arguments are specified,
* the document will be empty. If a root tag is specified, the document
* will contain that single root tag. If the root tag has a namespace
* prefix, the second argument must specify the URL that identifies the
* namespace.
*/
function XMLnewDocument(rootTagName, namespaceURL) { 
	if (!rootTagName) rootTagName = ""; 
	if (!namespaceURL) namespaceURL = ""; 
	if (document.implementation && document.implementation.createDocument) { 
		// This is the W3C standard way to do it 
		return document.implementation.createDocument(namespaceURL, rootTagName, null); 
	} else { // This is the IE way to do it 
		// Create an empty document as an ActiveX object 
		// If there is no root element, this is all we have to do 
		var doc = new ActiveXObject("MSXML2.DOMDocument"); 
		// If there is a root tag, initialize the document 
		if (rootTagName) { 
			// Look for a namespace prefix 
			var prefix = ""; 
			var tagname = rootTagName; 
			var p = rootTagName.indexOf(':'); 
			if (p != -1) { 
				prefix = rootTagName.substring(0, p); 
				tagname = rootTagName.substring(p+1); 
			} 
			// If we have a namespace, we must have a namespace prefix 
			// If we don't have a namespace, we discard any prefix 
			if (namespaceURL) { 
				if (!prefix) prefix = "a0"; // What Firefox uses 
			} else prefix = ""; 
			// Create the root element (with optional namespace) as a 
			// string of text 
			var text = "<" + (prefix?(prefix+":"):"") +  tagname + (namespaceURL ?(" xmlns:" + prefix + '="' + namespaceURL +'"') :"") + "/>"; 
			// And parse that text into the empty document 
			doc.loadXML(text); 
		}
		return doc;
	}
}

/**
* Synchronously load the XML document at the specified URL and
* return it as a Document object
*/ 
function XMLload(url) { 
	// Create a new document with the previously defined function 
	var xmldoc = XMLnewDocument(); 
	xmldoc.async = false;  // We want to load synchronously 
	xmldoc.load(url);      // Load and parse 
	return xmldoc;         // Return the document 
}

/**
* Parse the XML document contained in the string argument and return
* a Document object that represents it.
*/ 
function XMLparse(text) { 
	if (typeof DOMParser != "undefined") { 
	// Mozilla, Firefox, and related browsers 
		return (new DOMParser()).parseFromString(text, "application/xml"); 
	} else if (typeof ActiveXObject != "undefined") { 
		// Internet Explorer. 
		var doc = XMLnewDocument();  // Create an empty document 
		doc.loadXML(text);            // Parse text into it 
		return doc;                   // Return it 
	} else { 
		// As a last resort, try loading the document from a data: URL 
		// This is supposed to work in Safari. Thanks to Manos Batsis and 
		// his Sarissa library (sarissa.sourceforge.net) for this technique. 
		var url = "data:text/xml;charset=utf-8," + encodeURIComponent(text); 
		var request = new XMLHttpRequest(); 
		request.open("GET", url, false); 
		request.send(null); 
		return request.responseXML; 
	} 
}
/************************************************************************************************/
/* END XML document */
/************************************************************************************************/



