/*
/*	Script titel:  JS library
		Auteur:	   Bram van Mensvoort
		Doel:	   Classes of dynamic effects. Especially for forms.
*/

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length) {
	x = navigator.plugins["Shockwave Flash"];
	if (x) {
		flashinstalled = 2;
		if (x.description) {
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	} else {
		flashinstalled = 1;
	}
	if (navigator.plugins["Shockwave Flash 2.0"]) {
		flashinstalled = 2;
		flashversion = 2;
	}
} else if (navigator.mimeTypes && navigator.mimeTypes.length) {
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin) { flashinstalled = 2;} else {flashinstalled = 1;}
} else { 
	MSDetect = "true";
}
// -->

// Detection scripts
var browser;
	var agt=navigator.userAgent.toLowerCase();
	var appVer = navigator.appVersion.toLowerCase();
	var iePos  = appVer.indexOf('msie');
	var is_opera = (agt.indexOf("opera") != -1);
	var is_konq = false;
	var kqPos   = agt.indexOf('konqueror');
    if (kqPos !=-1) {is_konq  = true};
	var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
  var is_khtml  = (is_safari || is_konq);
	var is_ie   = ((iePos!=-1) && (!is_opera) && (!is_khtml));
	if (is_ie) {var browser="IE";} else {var browser="Niet IE, Firefox of een andere browser";};
	
//var screenHeight = getId(new Object()).styles.innerHeight();	//Opnieuw detecteren 		
//var screenWidth = getId(new Object()).styles.innerWidth();	//Opnieuw detecteren 		

function getId(divID) {
	// Voegt  styles()  toe aan het object.
	if (typeof(divID)=="string") {obj=getIdObj(divID)}; 
	if (typeof(divID)=="object") {obj=divID;}
	if (obj==null || obj==undefined) {return false};
	obj.styles = new Object();
	obj.styles.refObj= obj;
	switch (browser) {
		case "IE":	// Internet explorer of geen Mozilla
			obj.styles.border = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.border=content}; return obj.style.border};		
			obj.styles.background = 			function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.background=content}; return obj.style.background};
			obj.styles.backgroundImage = 		function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.backgroundImage="url("+ content +")"}; return obj.style.backgroundImage};
			obj.styles.pixelTop = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.pixelTop=content}; return obj.style.pixelTop};
			obj.styles.pixelLeft = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.pixelLeft=content}; return obj.style.pixelLeft};
			obj.styles.visibility = 			function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.visibility=content}; return obj.style.visibility};
			obj.styles.position = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.position=content}; return obj.style.position};
			obj.styles.cursor = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.cursor=content}; return obj.style.cursor};
			obj.styles.color = 					function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.color=content}; return obj.style.color};
			obj.styles.width = 					function(content) {var obj=this.refObj; if (content!=undefined) {obj.offsetWidth=content}; return obj.offsetWidth};						
			obj.styles.height = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.offsetHeight=content}; return obj.offsetHeight};
			obj.styles.clip = 					function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.clip="rect("+content[0]+" "+content[1]+" "+content[2]+" "+content[3]+")"}; return obj.style.clip};
			obj.styles.display = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.display=content}; return obj.style.display};
			obj.styles.listitem = 				function(content) {var obj=this.refObj; if (content!=undefined) {return obj.childNodes[content];}; return obj.childNodes;};
		break;	
		default:
			obj.styles.border = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.border=content}; return obj.style.border};
			obj.styles.background = 			function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.background=content}; return obj.style.background};
			obj.styles.backgroundImage =		function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.backgroundImage="url("+ content +")"}; return obj.style.backgroundImage};
			obj.styles.pixelTop = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.top=content+"px"}; return parseInt(obj.style.top, 10)};
			obj.styles.pixelLeft = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.left=content+"px"}; return parseInt(obj.style.left, 10)};
			obj.styles.visibility = 			function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.visibility=content}; return obj.style.visibility};
			obj.styles.position = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.position=content}; return obj.style.position};
			obj.styles.cursor = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.cursor="pointer"}; return obj.style.cursor};
			obj.styles.color = 					function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.color=content}; return obj.style.color};
			obj.styles.width = 					function(content) {var obj=this.refObj; if (content!=undefined) {obj.offsetWidth=content}; return obj.offsetWidth};						
			obj.styles.height = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.offsetHeight=content}; return obj.offsetHeight};
			obj.styles.clip = 					function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.clip="rect("+content[0]+" "+content[1]+" "+content[2]+" "+content[3]+")"}; return obj.style.clip};
			obj.styles.display = 				function(content) {var obj=this.refObj; if (content!=undefined) {obj.style.display=content}; return obj.style.display};
			obj.styles.listitem = 				function(content) {var obj=this.refObj; if (content!=undefined) {return obj.childNodes[1+content*2];}; return obj.childNodes;};
		break;
	}	
	//Browser independent
	obj.styles.x= 				function(content) {
		var obj=this.refObj;
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	};
	obj.styles.y= 				function(content) {
		var obj=this.refObj;
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	};
	//Get screen resolution
	if (window.innerWidth) {
		obj.styles.innerHeight = 			function(content) {if (content!=undefined) {window.innerHeight=content}; return window.innerHeight};
		obj.styles.innerWidth = 			function(content) {if (content!=undefined) {window.innerWidth=content}; return window.innerWidth};
	}
	else if (document.documentElement && document.documentElement.clientWidth) {
		obj.styles.innerHeight = 			function(content) {if (content!=undefined) {document.documentElement.clientHeight=content}; return document.documentElement.clientHeight};
		obj.styles.innerWidth = 			function(content) {if (content!=undefined) {document.documentElement.clientWidth=content}; return document.documentElement.clientWidth};
	}
	else if (document.body) {	
		obj.styles.innerHeight = 			function(content) {if (content!=undefined) {document.body.clientHeight=content}; return document.body.clientHeight};
		obj.styles.innerWidth = 			function(content) {if (content!=undefined) {document.body.clientWidth=content}; return document.body.clientWidth};
	}
	
	function followmouse(e){
	var truebody= (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	var xcoord=offsetfrommouse[0]
	var ycoord=offsetfrommouse[1]
	if (typeof(e) != "undefined"){
		xcoord+=e.pageX
		ycoord+=e.pageY
	} else if (typeof window.event !="undefined"){
		xcoord+=truebody().scrollLeft+event.clientX
		ycoord+=truebody().scrollTop+event.clientY
	}
	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
	var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)
	if (xcoord+widthLayer+3 > docwidth || ycoord+widthLayer > docheight) { 	//prevent scrollbars
		obj.objCaller.display="none"
	} else {
		obj.objCaller.display=""
		obj.objCaller.left=xcoord+"px"
		obj.objCaller.top=ycoord+"px"
	}
	}
	
	obj.styles.mouseX = function (e) {
		var truebody= (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
		var docwidth=document.all? truebody.scrollLeft+truebody.clientWidth : pageXOffset+window.innerWidth-15;
		var docheight=document.all? Math.max(truebody.scrollHeight, truebody.clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight);
		if (typeof(e) != "undefined"){
			xcoord=e.pageX
			ycoord=e.pageY
		} else if (typeof(window.event) !="undefined"){
			xcoord=truebody.scrollLeft+event.clientX
			ycoord=truebody.scrollTop+event.clientY
		}
		return xcoord;
	}
	obj.styles.mouseY = function (e) {
		var truebody= (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
		var docwidth=document.all? truebody.scrollLeft+truebody.clientWidth : pageXOffset+window.innerWidth-15;
		var docheight=document.all? Math.max(truebody.scrollHeight, truebody.clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight);
		if (typeof(e) != "undefined"){
			xcoord=e.pageX
			ycoord=e.pageY
		} else if (typeof(window.event) !="undefined"){
			xcoord=truebody.scrollLeft+event.clientX
			ycoord=truebody.scrollTop+event.clientY
		}
		return ycoord;
	}
	if (typeof(divID)=="string") {return getIdObj(divID)}; 
	if (typeof(divID)=="object") {return obj;}
};

function getIdObj(divID) {
    if( document.layers) {		//Netscape layers
        return document.layers[divID]};		
    if( document.getElementById ) {		//DOM; IE5, NS6, Mozilla, Opera
        return document.getElementById(divID)};
    if( document.all ) {		//Proprietary DOM; IE4
        return document.all[divID]};
    if( document[divID] ) {		 //Netscape alternative
        return document[divID]};
    return false;
}


function pag(pagNr, divName) {
	/* function designed to show page pageNr and hide all others, layers have form p1, p2, p3, ...*/
	for (i=1; getId(divName+i) != false; i++) {
		if (i==pagNr) {
			getId(divName+0).innerHTML = "";
			getId(divName+0).i = i;
			setTimeout( function () {i = getId(divName+0).i; getId(divName+0).innerHTML = getId(divName+i).innerHTML}, 10, i)
//			alert (getId("p"+i).innerHTML)
//			getId("p"+i).styles.visibility("visible");
//			getId("p"+i).styles.display("block");
	//		getId("p"+i).styles.position("relative");
		} else {
//			getId("p"+i).styles.visibility("hidden");  
//			getId("p"+i).styles.display("none");
			
//			getId("p"+i).style.overflow="hidden";
//			getId("p"+i).style.clip="rect (10px,10px,10px,10px)";			
//			getId("p"+i).styles.position("absolute");
		}
		
	};
	
}

/*function cPages (divName, instanceName) {
	this.settings=new Object();
	this.settings.divName= (divName==undefined)? "p" : divName;
	this.instanceName = instanceName;
	
	this.setActive = function (intNr, obj) {	this.active = intNr; if (obj!=undefined) {this.activeObj=obj}}
	this.getActive = function () {return this.active;}
	this.pag = function (pagNr, divName) {
		// function designed to show page pageNr and hide all others, layers have form <divName>1, <divName>2, <divName>3, ...
		if (divName==undefined) {divName="p";}
		for (i=1; getId(divName+i) != false; i++) {
			if (i==Number(pagNr)) {
				getId(divName+0).innerHTML = "";
				getId(divName+0).i = i;
				setTimeout( function () {i = getId(divName+0).i; getId(divName+0).innerHTML = getId(divName+i).innerHTML}, 10, i)
			}		
		};
		
	}
	this.show = function (pagNr, obj) {
		// function designed to show page pageNr and hide all others, layers have form <divName>1, <divName>2, <divName>3, ...
		getId(this.settings.divName+0).innerHTML = "";
		getId(divName+0).instance = instanceName;
		if (obj !=undefined) {
/*		Very buggy in Internet Explorer
		if (this.activeObj!=undefined) { 
				this.activeObj.parentNode.className="";
				this.activeObj.parentNode.parentNode.className="";}
			obj.parentNode.className = "selected"; 
			obj.parentNode.parentNode.className = "selected";
*//*		}
		this.setActive(pagNr, obj);
		eval("setTimeout (function() {"+this.instanceName+".showPage(\""+this.settings.divName+"\", "+this.active+")}, 10)")
//		setTimeout( function () {divName=eval(this.settings.divName); active= eval(pagNr); getId(divName+0).innerHTML = getId(divName+active).innerHTML}, 10)
	};
	this.next = function () {}
	this.prev = function () {}
	this.start = function (pagNr) {
		if (pagNr==undefined) {pagNr=1;}
		this.setActive(pagNr);
		eval("setTimeout (function() {"+this.instanceName+".showPage(\""+this.settings.divName+"\", "+this.active+")}, 10)")
	}	
	this.showPage = function (divName, active) {
		getId(divName+0).innerHTML = getId(divName+active).innerHTML;
	}
}*/
function cPages (divName, instanceName) {
	this.settings=new Object();
	this.settings.divName= (divName==undefined)? "p" : divName;
	this.instanceName = instanceName;

	this.setActive = function (intNr, obj) {	this.active = intNr; if (obj!=undefined) {this.activeObj=obj}}
	this.getActive = function () {return this.active;}
	this.pag = function (pagNr, divName) {
		if (divName==undefined) {divName="p";}
		for (i=1; getId(divName+i) != false; i++) {
			if (i==Number(pagNr)) {
				getId(divName+0).innerHTML = "";
				getId(divName+0).i = i;
				setTimeout( function () {i = getId(divName+0).i; getId(divName+0).innerHTML = getId(divName+i).innerHTML}, 10, i)
			}
		};

	}
	this.show = function (pagNr, obj) {
		getId(this.settings.divName+0).innerHTML = "";
		getId(divName+0).instance = instanceName;
//		if (obj !=undefined) {
			this.indicatePage(pagNr);
//		}
		this.setActive(pagNr, obj);
		eval("setTimeout (function() {"+this.instanceName+".showPage(\""+this.settings.divName+"\", '"+this.active+"')}, 10)")
	};
	this.indicatePage=function (pagNr) {
//alert (pagNr + "  "+ (pagNr*2+1) +"  "+(Math.floor(pagNr/3)+pagNr%3))

//		alert(getId(divName+"Links").styles.listitem(this.getActive()));
	if (getId(divName+"Links")) {
	  //Assumes that object  <divName>Links exist.  childNodes[<pagNr>] gets activated.  It works for an UL list
		if (getId(divName+"Links").childNodes[this.getActive()]!=undefined && this.getActive()!=0) {
//			getId(divName+"Links").childNodes[this.getActive()].className="noSelect";
			getId(divName+"Links").styles.listitem(this.getActive()).className="noSelect";
//			oldString = getId(divName+"Links").childNodes[this.getActive()].className;
//			getId(divName+"Links").childNodes[this.getActive()].className = oldString.replace("selected", "noSelect");
//			begin=getId(divName+"Links").childNodes[this.getActive()].className.indexOf("selected");
//			getId(divName+"Links").childNodes[this.getActive()].className.substring
//			className="noSelect";
		  	}
//			oldString = getId(divName+"Links").childNodes[this.getActive()].className;
//			getId(divName+"Links").childNodes[this.getActive()].className = oldString.replace("noSelect", "selected");
			getId(divName+"Links").styles.listitem(pagNr).className="selected";
//			getId(divName+"Links").childNodes[pagNr].className="selected";
		}
	}
	this.next = function () {
		if (getId(divName+"Links").styles.listitem(this.getActive()+1) != undefined) {
			if (getId(divName+"Links").styles.listitem(this.getActive()+1).className != "noLink") {
				this.show(this.getActive()+1);
		   }
		}
	}
	this.prev = function () {
		if (getId(divName+"Links").styles.listitem(this.getActive()-1) != undefined) {
			if (getId(divName+"Links").styles.listitem(this.getActive()-1).className != "noLink") {
				this.show(this.getActive()-1);
			}
		}
	}
	this.start = function (pagNr) {
		if (pagNr==undefined) {pagNr=1;}
		this.setActive(pagNr);
		this.indicatePage(pagNr);
		eval("setTimeout (function() {"+this.instanceName+".showPage(\""+this.settings.divName+"\", '"+this.active+"')}, 10)")
	}
	this.showPage = function (divName, active) {
		getId(divName+0).innerHTML = getId(divName+active).innerHTML;
	}
}
/*

function logLink_old () {
//		absolutePath = "/projects/bezig/Prof/Sites/Plekkers.nl/Realisatie/HTML%20concept";
absolutePath = "/Projects/Complete/Sites/Plekkers.nl/Realisatie/Site/";
		wl=window.location.toString();
		rootPath=wl.split(absolutePath)[0]+absolutePath;
		for (linkNr=0; linkNr < document.links.length; linkNr++) {
			if (!document.links[linkNr].logged) {
				url = document.links[linkNr].href;
				if (document.links[linkNr].href.indexOf("javascript") == -1) {
					document.links[linkNr].href = rootPath +"/inc/goto.php?url="+escape(url);
				}
			}
			document.links[linkNr].logged=true;
		}
	}

function logLink () {
		absolutePath = "/Projects/Complete/Sites/Plekkers.nl/Realisatie/Site/";
		wl=window.location.toString();
		rootPath=wl.split(absolutePath)[0]+absolutePath;
		for (linkNr=0; linkNr < document.links.length; linkNr++) {
			if (!document.links[linkNr].logged) {
				url = document.links[linkNr].href;
				if (document.links[linkNr].href.indexOf("javascript") == -1) {
					document.links[linkNr] ="&nbsp;"+document.links[linkNr];
//					document.links[linkNr].href = rootPath +"/inc/goto.php?url="+escape(url);
					document.links[linkNr].href = "http://localhost/Projects/bezig/Eigen/wwwroot/inc/goto2.php?url="+escape(url);
				}
			}
			document.links[linkNr].logged=true;
		}
	}
//	window.onload=logLink;

*/
