var sRepeat=null;
function doScroller(src, amount) {
	if (amount==null) amount=10
	document.getElementById(src).scrollTop-=amount
	if (sRepeat==null)
		sRepeat=setInterval("doScroller('"+src+"',"+amount+")",75)
	return false
}

// Used to end repeating scrolling
window.document.onmouseout = new Function("clearInterval(sRepeat);sRepeat=null")
window.document.ondragstart = new Function("return false")


function emailCheck(s)
{

var filter=/^[A-Za-z][A-Za-z0-9_.-]*@[A-Za-z0-9_-]+\.[A-Za-z0-9_.]+[A-za-z]$/;
if (s.length == 0 ) 
	return false;
if (filter.test(s))
	return true;
else
	alert("La direccion de correo parece incorrecta (revise @ y .)");


return false;
}

function esNumero(cadena)
{
		var plant = /[0-9]{9}/gi;
		if (plant.test(cadena))
					return true;
		else
					return false;
		
}

 function quitarEspacios (inputString, removeChar) 
{
	var returnString = inputString;
	if (removeChar.length)
	{
	  while(''+returnString.charAt(0)==removeChar)
		{
		  returnString=returnString.substring(1,returnString.length);
		}
		while(''+returnString.charAt(returnString.length-1)==removeChar)
	  {
	    returnString=returnString.substring(0,returnString.length-1);
	  }
	}
	return returnString;
}

function checkMail(cadena) {
var plant = /[^\w^@^\.^-]+/gi
if (plant.test(cadena))
     alert(cadena + " contiene caracteres extraños.")
else{
     plant =/(^\w+)(@{1})([\w\.-]+$)/i
     if (plant.test(cadena))
         return true;
     else 
 					return false;
	} 
}

function validar(){

 var msg="";
 with (document.contactar){
 	if(NOMBRE.value=="")
		msg+="No ha indicado nombre / No name \n";
	if(TELEFONO.value=="")
		msg+="No ha indicado telefono de contacto / No phone \n";
	if(!emailCheck(EMAIL.value))
		msg+="No ha indicado email, o ha indicado uno con formato incorrecto / Incorrect mail\n";
	if(COMENTARIOS.value=="")
		msg+="No ha introducido contenido del mensaje / No message \n";
 }
 if(msg!="")
 	alert(msg);
	
 if(msg=="")
   document.contactar.submit();
}

function abre_foto(imagen, comentario){
	finestra=window.open('popap.php?url='+imagen+'&alt='+comentario,"pop", "scrollbars=YES");
	finestra.focus();
}

function login()
{
 with(document.acceso)
 {
	 if(password.value.length < 6)
	 	alert("Revise el password, al menos 6 caracteres");
	else
		submit();
 }
}





function webmail_acceso()
{

 with(document.webmail)
 {
	 if ((login_username.value=="") || (secretkey.value==""))
	  alert("sin usuario o contraseña");
	 else
	  submit();
   }
}

function setValorControl(ident,valor){	
/*	x=MM_findObj(ident);
	if (x!=null){
	*/	document.getElementById(ident).value=valor;
/*	}
	return x;*/
}

function cerrar_elemento(ident){
		x=MM_findObj(ident);
		if (x!=null){	
			document.getElementById(ident).style.display="none";
			MM_swapImage('img_'+ident,'','img/estaticas/icono_mas.gif',1)	
		}
		return;
}
function cerrar_arbol(nelementos){
	for (i=0;i<nelementos;i++){
		x=MM_findObj("table_"+i);
		if (x!=null){
			cerrar_elemento("table_"+i);
		}
	}
}
function abrir_elemento(ident){

	x=MM_findObj(ident);
	if (x!=null){	
		document.getElementById(ident).style.display="";
	}
	return;
}


function cargando(){
	document.getElementById("loaderContainer").style.display = "none";
}
function descargando(){
	document.getElementById("loaderContainer").style.display = "";
}

function interruptor(ident){

		if (document.getElementById(ident).style.display=="none"){
			abrir_elemento(ident);
		}
		else
			cerrar_elemento(ident);
}



nav4 = window.Event ? true : false;
function mascara(evt){ 
    // NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57     
    var key = nav4 ? evt.which : evt.keyCode; 
	//alert(key)
    return ( key <= 13 || (key >= 48 && key <= 57) || key == 46 );
    }

