// Toevoegen en verwijderen van een class op een HTML Element.
function classAdd(sender, classname){if(!sender){return;};sender.className+=' '+classname;}
function classDel(sender, classname){if(!sender){return;};var s = sender.className.split(' ');var clT='';for(var i=0;i<s.length;i++){if((classname!=s[i])&&(s[i]!='')){if(clT!=''){clT+=' ';}clT+=s[i];}}sender.className=clT;}

// Initializes a new instance of the StringBuilder class
// and appends the given value if supplied
function StringBuilder(value){this.strings = new Array("");this.append(value);}

// Appends the given value to the end of this instance.
StringBuilder.prototype.append = function (value){if (value){this.strings.push(value);}}

// Clears the string buffer
StringBuilder.prototype.clear = function (){this.strings.length = 1;}

// Converts this instance to a String.
StringBuilder.prototype.toString = function (){return this.strings.join("");}
// ##################################################


function genadres(ahref,stijl){
	ahref=ahref.replace('\%x.\%x','@');
	ahref=ahref.replace('\$.\$','mailto:');
	document.write('<a '+ahref+' class='+stijl+'>');
}
function genadres2(ahref){
	ahref=ahref.replace('\%x.\%x','@');
	ahref=ahref.replace('\$.\$','mailto:');
	document.write(ahref);
}

function TREScreateCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function TRESreadCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function TRESeraseCookie(name) {
	TREScreateCookie(name,"",-1);
}

function checksize(sizevalue,sizetype,componentid,realwidth,realheight){
	if (realheight>0){
		if(document.getElementById('locksize'+componentid).value=='on'){
			if(sizetype==1){
				realsize=realheight/realwidth;
				if(sizevalue>0){
					document.getElementById('imageheight'+componentid).value=Math.round(realsize * sizevalue);
				}
			}
			if(sizetype==2){
				realsize=realwidth/realheight;
				if(sizevalue>0){
					document.getElementById('imagewidth'+componentid).value=Math.round(realsize * sizevalue);
				}
			}
		}
	}
}

function syncMenu(tempurl){
	var pid,tid;
	var myRegExp = new RegExp("\/pageid=([^\/]*)?", "gi")
	var Arr = myRegExp.exec(tempurl);
	try{
		var pStr = new String(Arr[0]);
		pid = pStr.replace( /[\/]?[^\/]*=/gi ,'')
	}catch(e){pid='';}
	
	myRegExp = new RegExp("\/lang=([^\/]*)?", "gi")
	Arr = myRegExp.exec(tempurl);
	try{
		pStr = new String(Arr[0]);
		tid = pStr.replace( /[\/]?[^\/]*=/gi ,'')
	}catch(e){tid='';}
	
      if (pid!=''){
            var i=0; var ppParent=window;
            while((i<5) && !(ppParent.parent.boom)){
                  i++;
                  ppParent=ppParent.parent;
            }
            if(ppParent.parent.boom){
                  ppParent.menu.selectedpageid=pid;
                  ppParent.statusbalk.syncPage(pid);
                  ppParent.parent.boom.syncPage(pid);
                  ppParent.changeLanguage(pid);
            }
      }
}

function TR3S_checkIfUnderTen(temp){
  if(temp.length>=2)
	return temp
  else
	return '0'+temp;
}

function TR3S_findobject(naam){
  var obj;
  obj=(document.all) ? document.all[naam] : document.getElementById(naam);
  return obj;
}

function checksize(sizevalue,sizetype,componentid,realwidth,realheight){
	if (realheight>0){
		if(document.getElementById('locksize'+componentid).value=='on'){
			if(sizetype==1){
				realsize=realheight/realwidth;
				if(sizevalue>0){
					document.getElementById('imageheight'+componentid).value=Math.round(realsize * sizevalue);
				}
			}
			if(sizetype==2){
				realsize=realwidth/realheight;
				if(sizevalue>0){
					document.getElementById('imagewidth'+componentid).value=Math.round(realsize * sizevalue);
				}
			}
		}
	}
}

function noenter() {
  return !(window.event && window.event.keyCode == 13); }

function returnFalse(){return false;}


function fisIE(){
	return (navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

function getX(e){//positie X
	e= e || window.event;
	if(e.pageX){return e.pageX;}
	return e.clientX + document.body.scrollLeft - document.body.clientLeft;
}

function getY(e){//positie Y
	e= e || window.event;
	if(e.pageY){return e.pageY;}       
	return e.clientY + document.body.scrollTop  - document.body.clientTop;
}

function actualPopup(url, w,h){
	var sOptions ='location=no,menubar=no,toolbar=no,dependent=yes,dialog=yes,minimizable=no,modal=yes,alwaysRaised=yes';
	var ieOptions='help:no;scroll:no;status:no;';
	sOptions += ',width=' + w ;sOptions += ',height=' + h ;
	ieOptions+= 'dialogWidth:'+w+'px;';ieOptions+= 'dialogHeight:'+h+'px;';
	if(url==''){url='about:blank';}
	if(fisIE()){
		window.showModalDialog( url ,window,ieOptions);
	}else{
		var p=window.open( url,'',sOptions, true);
		p.dialogArguments=window;
	}
}

function changeModalLocation(url,w,h){
	ttop = (screen.height-h)/2;
	tleft = (screen.width-w)/2;

	window.dialogTop=ttop + 'px';
	window.dialogLeft=tleft + 'px'; 
	window.dialogWidth = w+'px';
    window.dialogHeight = h+'px';
	//document.write("<META HTTP-EQUIV='refresh'  CONTENT=' 0;URL="+url+"'>");
	document.write("<script>window.name='tmodaldialog';</script><form method=post target=tmodaldialog name=submitmodaldialogform action='"+url+"'></form><script>submitmodaldialogform.submit()</script>");
}

