//Returns 1 for IE5, 2 for NN6, possibly higher numbers for other types.
//It is not yet fully working.
function getBrowserType() {
	 if (navigator.appName.indexOf("xplorer")>-1) {
		  return 1;
	 }
	 if (navigator.appName.indexOf("etscape")>-1) {
		  return 2;
	 }
}



function hideElement(id) {
	 var el=document.getElementById(id);
	 if(el) {
		  el.setAttribute("old_display_style",el.style.display);
		  el.style.display="none";
	 }
}
function showElement(id) {
	 var el=document.getElementById(id);
	 if(el) {
		  var oldStyle=el.getAttribute("old_display_style");
		  el.style.display=(oldStyle?oldStyle:"inline");
	 }
}



 //Attaches an eventlistenter to a given object. 
 //Compatible with both explorer, w3c and NN6.
//Ensures (in a rather primitive way though) that the same
//event is only assigned once.
 function addEvent(myobject, eventName, func) {
	  if (!myobject.assignedEvents) {
			myobject.assignedEvents=new Object();
	  }
	  if (!(myobject.assignedEvents[getFunctionString(func)])) {
			if (myobject.attachEvent) {// Explorer
				 myobject.attachEvent(eventName, func);
			}
			if (myobject.addEventListener) { 
				 myobject.addEventListener(eventName, func, true);
			} 
			myobject.assignedEvents[getFunctionString(func)]=1;
	  }
	  return myobject;
 }

//Returns a function truncated as 
function getFunctionString(func) {
	 return func.toString().replace(/[^a-zA-Z0-9]/gi,"").substring(0,50);
}



