function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}



	var ie5 = (document.getElementById && document.all); 
	var ns6 = (document.getElementById && !document.all); 
	var ua = navigator.userAgent.toLowerCase();
	var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
	
	function getmouseX(e)
	{
	    if(document.getElementById)
	    {
	        var iebody=(document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body;
	        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
	        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
	        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
	        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;
	    }
	    return mousex;
	}
	
	function getmouseY(e)
	{
	    if(document.getElementById)
	    {
	        var iebody=(document.compatMode && document.compatMode != 'BackCompat') ? document.documentElement : document.body;
	        pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
	        pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
	        mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
	        mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;
	    }
	    return mousey;
	}




	function findPosX(obj)
	{
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
			
		return curleft;
	}

  	
	function findPosY(obj)
	{
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}

	
	function findObjWidth(obj){
		var curtop = 0;
		curtop=obj.offsetWidth;
		return curtop;
	}

		
	function findWindowWidth(){
		return document.body.clientWidth;
		
	}
		function findWindowHeight(){
		return document.body.clientHeight;
		
	}
	
 function findObjHeight(obj){
		var curtop = 0;
		curtop=obj.offsetHeight;
		
		//alert(curtop);
		return curtop;
	}

	
	
function addEvent(obj, evType, fn){ 
	 if (obj.addEventListener){ 
	 //	alert("netscape");
	   obj.addEventListener(evType, fn, false); 
	   return true; 
	 }else if (obj.attachEvent){
	 	 var r = obj.attachEvent("on"+evType, fn);
	   return r; 
	 }else { 
	   return false; 
	 } 
}

function getObj(name)
	{
	  if (document.getElementById)
	  {
	 //Explorer
	  	return document.getElementById(name);
		}
	  else if (document.all)
	  {
	//NEtscape,Mozilla
			return document.all[name];
		 }
	  else if (document.layers)
	  {
			return document.layers[name];
		}
	}		
	
	
//devuelve la ventana que abrio la ventana que le pases	
function getOpener(win){
	var obj;
	if(win.opener!=null){
		obj=win.opener;
	}else if(win.dialogArguments!=null){
		obj=win.dialogArguments;
	}else{
		alert("No Opener Window");
		return null;
	}
	return obj;
}


function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function


function afegirZeros(str,num){
	
	if(str.length<parseInt(num)){
		var strret="";
		var numzeros=parseInt(num)-str.length;
		var i=0;
		while(i<numzeros){
			strret+="0";
			i++;	
		}
		strret+=str;
		return strret;
	}
	return str;
}


function getElementsByClassName(clasName)
{
	var arr = new Array();
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
		var elem = elems[i];
		if(elem.className == clasName)
		{
			arr[arr.length] = elem;
		}
	}
	return arr;
}

function switchTab(num){
	//la pestaņa
	var obj=getObj('tab'+num);
	var tabs=getElementsByClassName('tabSelected');
	for(var i=0;i<tabs.length;i++){
		tabs[i].className='tabUnselected';
	}
	obj.className='tabSelected';
	
	//el contenido
	obj=getObj('tabContent'+num);
	tabs=getElementsByClassName('tabContentSelected');
	for(var i=0;i<tabs.length;i++){
		tabs[i].className='tabContent';
		tabs[i].style.display='none';
	}
	obj.className='tabContentSelected';
	obj.style.display='block';
	amagarAjuda();
	
}


function validaCond(obj){
	
	if(obj.cond[0].checked==true){
		location.href='edituser.php';
	}else{
		location.href='index.php';
	}
}


function swapDisplay(nombre){
	var obj=document.getElementById(nombre);
	//alert(obj.style.display);
	if(obj.style.display=='block'){
		obj.style.display='none';
	}else{
		obj.style.display='block';
	}
	
}
