// --- IMAGE SWAP ---

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

// include()
// voor het aanroepen van externe stylesheets en javascripts in een pagina
// syntax:  include("scriptnaam.js","stylenaam.css",....);
// return: -
// resultaat: de bijhorende script en style tags worden in de pagina geschreven.
// hierbij wordt aangenomen dat javascripts in de js map zitten en stylesheets in de css map
function include(){
	for (i=0 ; i<arguments.length ; i++){
		if (arguments[i].indexOf(".js") != -1){
			document.write("<" + "script language=\"javascript1.2\" src=\"" +getWebroot()+ "js/" + arguments[i] + "\"></script>");
		}else if (arguments[i].indexOf(".css") != -1){
			document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" +getWebroot()+ "css/" + arguments[i] + "\">");
      if(getStyleExt()){
        var extensionPos=arguments[i].indexOf(".css");
				var styleName=arguments[i].substr(0,extensionPos);
        document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"" +getWebroot()+ "css/" + styleName + getStyleExt() + ".css\">");
      }
		}
	}
}

function getStyleExt(){
  if (is.ns4 && browserStyles.Ns) return "Ns";
  else if (is.gecko && browserStyles.Gko)  return "Gko";
  else if (is.nsmac && browserStyles.NsM)  return "NsM";
  else if (is.iemac && browserStyles.IeM)  return "IeM";
}

function getWebroot(){
  if (!requestWebroot) return "";
  else if (requestWebroot.indexOf("#")== 0) return "";
  else return requestWebroot;
}
// end include()

// isObj()
// test of een object bestaat
// syntax: isObj('document.bla.bla.bla');
// return: true of false
function isObj(objString) {
	var a=objString.split('.');
	var i=1;
	var theString=a[0];
	while (i<a.length && (i<a.length && eval('typeof ' + theString) == 'object')){
		theString += "." + a[i];
		i++;
	}
	return eval('typeof ' + theString) == 'object';
}
// end isObj()

// openWindow()
// MM rip om een window te openen met een nieuwe URL
function openWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
// end openWindow()

// printPage()
// opens a new window for printning perposes
function printPage(){
  var printWindow = window.open('#request.webroot#handler.cfm?event=onPrint&id=#o.id#','printWindow','height=600,width=400,scrollbars=yes,resizable');
}
// end printPage()

// Begin popout() function
// function provided by UU to enable a popup on an unload event.
// contact: Peter Lok (P.Lok@csc.uu.nl)
function popout() {
window.open(getWebroot()+'enquete/form1.cfm','','toolbar=no,menubar=no,location=no,height=370,width=400');
}
// End popout()

function popup(URL, id, setScroll, size, popupWidth, popupHeight) {
  if (window.top.openedPopup != null) {
    window.top.openedPopup.close();
  }
 
  // set the size in pixels if popupHeight or popupWidth is not defined
  if (!popupWidth || !popupHeight) {
  	switch(size) {
	  	case 1:
        var popupWidth = 275;
        var popupHeight = 300;
			  break;
  		case 2:
        var popupWidth = 275;
        var popupHeight = 650;
	  		break;
		  case 3:
        var popupWidth = 750;
        var popupHeight = 500;
			  break;
  	}
  }

  // put the window in the middle of the screen
  var winLeft = (screen.width - popupWidth) / 2;
  var winTop = (screen.height - popupHeight) / 2;

  eval("page" + id + " = window.open('" + URL + "', '" + id + "', 'toolbar=0,scrollbars=" + setScroll + ",location=0,statusbar=0,menubar=0,resizable=0,width=" + popupWidth + ",height=" + popupHeight + ",left = " + winLeft + ",top = " + winTop + "');");
  eval("page" + id).focus();
}

function safemail(name, server, domain, classname, extra, linkname) {
  var email = name+'@'+server+'.'+domain
  if(typeof(extra)=="undefined") extra = "";
  if(typeof(linkname)=="undefined") linkname = name;
  var style;
  if(typeof(classname)=="undefined")
    style = "";
  else style = " class=\"" + classname + "\"";
  
  document.write('<a href="mailto:' + email + extra + '"' + style +'>' +linkname+ '</a>');
}
