function popUp(page,width,height){
	if(width==null)
		width=300;
	if(height==null)
	    height=300;
    newWindow = window.open(page, 'aWindow', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width='+width+',height='+height+'');
}

function isAlphanumeric(string, ignoreWhiteSpace) {
	if (string.search) {
		if ((ignoreWhiteSpace && string.search(/[^\w\s]/) != -1) || (!ignoreWhiteSpace && string.search(/\W/) != -1)) return false;
	}
	return true;
}

function containsSpaces(string) {

	return string.search(" ") != -1;
}

function submitTopMenus(form, element, valToSubmit) {
	var elementID = (!document.getElementById) ? document.all[element] : document.getElementById(element);
	var formID = (!document.getElementById) ? document.all[form] : document.getElementById(form);
	var valToSubmitID = (!document.getElementById) ? document.all[valToSubmit] : document.getElementById(valToSubmit);
	valToSubmitID.value = elementID.options[elementID.selectedIndex].value; 
	//toSubmit.value = elementID.options[elementID.selectedIndex].value;
	if (elementID.options[elementID.selectedIndex].value != "") {
		elementID.selectedIndex = 0;
		formID.submit();
	}
}


function trim(s) {
  while (s.substring(0,1) == ' ') {
    s = s.substring(1,s.length);
  }
  while (s.substring(s.length-1,s.length) == ' ') {
    s = s.substring(0,s.length-1);
  }
  return s;
}

	

function showHideContent(id,bOn,filenameOn, filenameOff)
{
	//var bMO = false;

	var oContent = (!document.getElementById) ? document.all[id+"Content"] : document.getElementById(id+"Content");
	//document.getElementById(id+"Content");
	var oImage = (!document.getElementById) ? document.all[id+"Tab3"] : document.getElementById(id+"Tab3");
	//document.getElementById(id+"Tab3");
	
	//if (!oContent) return;

		//bOn = (oContent.style.display.toLowerCase() == "none");
		
	var Crum = getCrumb("EppoCookie",id);
	//alert("show CrumbFor"+id+"="+Crum);
	if (Crum == "on")
	{
		oContent.style.display = "none";
		setCrumb("EppoCookie",id,"off");
		//oImage.src =  filenameOff;
	}
	else if(Crum == "off")
	{
		oContent.style.display = "block";
		setCrumb("EppoCookie",id,"on");
		//oImage.src = filenameOn;
	}
}

function setShowHideContent(id,bOn,filenameOn, filenameOff)
{
	//var bMO = false;

	var oContent = (!document.getElementById) ? document.all[id+"Content"] : document.getElementById(id+"Content");
	//document.getElementById(id+"Content");
	var oImage = (!document.getElementById) ? document.all[id+"Tab3"] : document.getElementById(id+"Tab3");
	//document.getElementById(id+"Tab3");
	
	//if (!oContent) return;

		//bOn = (oContent.style.display.toLowerCase() == "none");
		
	
		
	var Crum = getCrumb("EppoCookie",id);
	//alert("set CrumbFor"+id+"="+Crum);
	if (Crum == "on")
	{
		oContent.style.display = "block";		
		//oImage.src =  filenameOff;
	}
	else
	{
		oContent.style.display = "none";
		//oImage.src = filenameOn;
	}
}


//Div functions-----------------------------------------------
window.onerror = null;

//initialise all variables

var olddiv = 0;   //this will become a reference to the object that is being shown or was last shown
                  //in all cases, the object that is shown/hidden will be a <div ..> element

function getRefToDivNest( divID, oDoc ) {
	if( !oDoc ) { oDoc = document; }
	if( document.layers ) {
		if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
			for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
				y = getRefToDivNest(divID,oDoc.layers[x].document); }
			return y; } }
	if( document.getElementById ) { return document.getElementById(divID); }
	if( document.all ) { return document.all[divID]; }
	return document[divID];
}

function showdiv(thisdiv) {
	//this function shows the div
	hidediv(); //first, hide the last one
	//Convert the name of the div into a reference to it. Basically, get a reference to the object
	olddiv = getRefToDivNest(thisdiv);
	//alert(olddiv+ "hier");
	if( !olddiv ) {
		//Nothing found. This browser is not compliant with any!
		notifyFail();
		return;
	}
	//stripname for backcolor tabs
	var name = "tab"+thisdiv.substring(3);
	
	//Make the object visible
	if( olddiv.style ) {
		//DOM compliant
		olddiv.style.visibility = 'visible';
		//document.getElementById(name).style.backgroundColor = '#f0f9fc';
		document.getElementById(name).style.borderBottomWidth = '0px';
	} else {
		if( olddiv.visibility ) {
			//Netscape and old versions of Mozilla compliant
			olddiv.visibility = 'show';
			//document.getElementById(name).style.backgroundColor = '#f0f9fc';
			document.getElementById(name).style.borderBottomWidth = '0px';
			
		} else {
			//Nothing found, no known way of changing the style
			notifyFail();
			return;
		}
	}
	divshown = 1;
}

function hidediv() {
	if( olddiv ) {
		//stripname for backcolor tabs
		var name = "tab"+olddiv.id.substring(3);
		if( olddiv.style ) {
			//DOM compliant
			olddiv.style.visibility = 'hidden';
			//document.getElementById(name).style.backgroundColor = '#f0f9fc';
			document.getElementById(name).style.borderBottomWidth = '2px';
		} else {
			//Netscape and old versions of Mozilla compliant
			olddiv.visibility = 'hide';
			//document.getElementById(name).style.backgroundColor = '#f0f9fc';
			document.getElementById(name).style.borderBottomWidth = '2px';
		}
		//No need for else notifyFail()
		//If it was going to fail, it would have failed while it was being shown
	}
	olddiv = false;
}

function notifyFail() {
	//oops, I guess nothing works in this browser
	if( window.myalternative ) {
		if( window.confirm( "You are having problems displaying some components of this page.\n"+
			"\nWould you like to try the other page design?" ) ) { location.href = myalternative; }
	} else {
		window.alert( "You are having problems displaying some components of this page.\n\n"+
			"Sorry, but there is not yet an alternative page." );
	}
}

//DRIL DOWN function--------------------
function toggleDetail(id,number,img) {
	img = document.getElementById(img);
	body=document.getElementById(id+number);
	if(body.style.display == 'none')
		img.src='images/minus.gif';
	else
		img.src='images/plus.gif';
	for (i=1;i<=number;i++) {
    	body=document.getElementById(id+i);
        if (body) {
        	if (body.style.display == 'none') {
	            // To make tr tags disappear
	            // we set display to none, as usual
	            // to make them appear again
	            // we set style to block for IE
	            // but for firefox we use table-row
            	try {
              		body.style.display='table-row';
            	} 
            	catch(e) {
             	 	body.style.display = 'block';
             	}
            }
            else {
            	body.style.display = 'none';
       		}
		}
        
	}
}
