function ocular_selects(){
	selec = document.getElementsByTagName('SELECT');	
	var gko = navigator.userAgent.toLowerCase();
	if (gko.indexOf('gecko')==-1)
		for(i=0;i<selec.length;i++)
			selec[i].style.visibility='hidden';//hacemos el setAttribute normalmente	
}

function mostrar_selects(){
	selec = document.getElementsByTagName('SELECT');	
	var gko = navigator.userAgent.toLowerCase();
	if (gko.indexOf('gecko')==-1)
		for(i=0;i<selec.length;i++)		
			selec[i].style.visibility='visible';//hacemos el setAttribute normalmente
}

function confirmarDel(ae,campo,id) {
	var conf=confirm('¿Seguro que desea eliminar est'+ae+' '+campo+'?');
	if (conf) { window.location = '?iddel='+id; }
}

function str_replace(busca, repla, orig){
	str 	= new String(orig);
	rExp	= "/"+busca+"/g";
	rExp	= eval(rExp);
	newS	= String(repla);
	str = new String(str.replace(rExp, newS));
	return str;
}

var nav4 = window.Event ? true : false;
function soloNum(evt){
   var key = nav4 ? evt.which : evt.keyCode;
   return (key <= 13 || (key >= 48 && key <= 57));
}
function moneda(evt,id_campo){     
   str=document.getElementById(id_campo).value;	
   var key = nav4 ? evt.which : evt.keyCode;   
   if((key==46 || key==44) && str.match('.')==null){
   	   document.getElementById(id_campo).value+='.';	  
   }
   return (key <= 13 || (key >= 48 && key <= 57) || key==46);
}
function val_caracter(evt){
   var key = nav4 ? evt.which : evt.keyCode;
   return (key==32|| key <= 13 || (key >= 65 && key <= 90)||(key >= 97 && key <= 122)|| (key >= 40 && key <= 57) || (key>=130&&key<=250)||key==95 ||key==241 ||key==209);
}
function val_caract_email(evt){
   var key = nav4 ? evt.which : evt.keyCode;
   return (key <= 13 || (key >= 64 && key <= 90)||(key >= 97 && key <= 122)|| (key >= 48 && key <= 57)||key==95||key==46);
}
function val_numero_letra(evt){
   var key = nav4 ? evt.which : evt.keyCode;
   return (key <= 13 || (key >= 65 && key <= 90)||(key >= 97 && key <= 122)|| (key >= 48 && key <= 57) ||key==241 ||key==209);
}

function val_dominio(evt){
   var key = nav4 ? evt.which : evt.keyCode;
   return (key <= 13 || (key >= 65 && key <= 90)||(key >= 97 && key <= 122)||(key >= 48 && key <= 57));
}

function soloLetras(evt){
   var key = nav4 ? evt.which : evt.keyCode;
   return (key==32||key <= 13 || (key >= 65 && key <= 90)||(key >= 97 && key <= 122)||(key>=193&&key<=250)||key==95 ||key==241 ||key==209);
}
function soloDecimal(evt, id_campo){
   var key = nav4 ? evt.which : evt.keyCode;
   cadena=document.getElementById(id_campo).value;
   document.getElementById(id_campo).value= str_replace('.', ',', cadena);
   if(key==46){
      key=44;
   }
   if ((checkForCharacters(cadena, ',') != -1 && key ==44)||(cadena.length== 0 && key ==44)){
      return false;

   }
   return (key <= 13 || (key >= 48 && key <= 57)|| key==45 || key==44);
}

function abre_popup(URL,titulo,ancho,alto){
   ventana_win=window.open(URL, titulo, "scrollbars=yes, menubar=no, directories=no , channelmode=no, location=no");
   ventana_win.resizeTo(ancho, alto);
   centrox=(screen.width/2)-(ancho/2);
   centroy=(screen.height/2)-(alto/2);
   ventana_win.moveTo(centrox, centroy);
}

function validarEmail(valor){
  if(/^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/.test(valor))
    return (true);
  else
    return (false);
}

function validarURL(valor){
	//return valor.match(/^([a-zA-Z0-9][a-zA-Z0-9\-]{3,})\.([a-zA-Z0-9]{2,4}(\.[a-zA-Z0-9]{2})?)$/) == true;
  if(valor.match(/^([a-zA-Z0-9][a-zA-Z0-9\-]{3,})\.([a-zA-Z0-9]{2,4}(\.[a-zA-Z0-9]{2})?)$/)){	 
   return (true)
  } else {
    return (false);
  }
}

function ltrim(s){
   return s.replace(/^\s+/, "");
}

function rtrim(s){
   return s.replace(/\s+$/, "");
}

function trim(s){
   return rtrim(ltrim(s));
}

function findPos(obj) {
   var curleft = curtop = 0;
   if (obj.offsetParent){
      curleft = obj.offsetLeft;
      curtop = obj.offsetTop;
      while (obj = obj.offsetParent) {
         curleft += obj.offsetLeft;
         curtop += obj.offsetTop;
      }
   }
   return [curleft, curtop];
}

function setCheckedValue(formu,radioObjt, newValue) {
	evaluado=eval("document."+formu+"."+radioObjt);
	for(i=0; i<evaluado.length; i++)		
		evaluado[i].checked = (evaluado[i].value == newValue.toString());	
}
function checkbox_checked(formu,nombre_checkbox,valor){
   calculo=valor.split("|");
   evaluado=eval("document."+formu+"."+nombre_checkbox);
   for(i=0; i<evaluado.length; i++)
      for(f=0; f<calculo.length; f++){
		 if(evaluado[i].value == calculo[f].toString()) 
		 	evaluado[i].checked = true;			 
	  }
}

function select_selected(nomb_sel,valor){
 select_tipo = document.getElementById(nomb_sel).getElementsByTagName('OPTION');  
   for (i=0; i<select_tipo.length; i++)
	    select_tipo[i].selected=(select_tipo[i].getAttribute('value')==valor.toString());   			
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
