var strFoco="";
//****************************************
function fCambiarImg(istrNombre,istrImagen){document[istrNombre].src = istrImagen;}
//****************************************
function fCambiarImgFile(strNombre,strImagen,strActual){
	strImagen = eval('document.'+strImagen+'.value');
	if (strImagen == ""){
		strImagen = strActual;
	}
	fCambiarImg(strNombre,strImagen);
}
//****************************************
function ventana(vurl,valto,vancho,strScroll,Nombre){
	if (window.screen) {
		var ah=screen.width-(vancho/2);
		var aw=screen.height-(valto/2);
		var xc = (aw - vancho) / 2;
		var yc = (ah - valto) / 2;
	}
	newwindow=window.open(vurl,Nombre,'left=' + xc + ',left='+xc+',top='+yc+',screenX='+xc+',height='+valto+',width='+vancho+',scrollbars='+strScroll+'');
	if (window.focus) {newwindow.focus()}
	return false;
}
//****************************************
function fImprimirYCerrar (){
	top.focus(); 
	window.print();
	self.close();
}
//****************************************
function fCambiarFilaColor (intCual,intCuantos,strColor){
	i=1;
	while (i<=intCuantos){
		eval("fila"+i+"_"+intCual+".bgColor='"+strColor+"'");
		i++;
	}
}
//****************************************
function fNoEscribir(intAlert) {
	if (((window.event.keyCode>=0) && (window.event.keyCode<=47))||((window.event.keyCode>=58)&& (window.event.keyCode<=64)) || ((window.event.keyCode>=91)&& (window.event.keyCode<95)) || (window.event.keyCode==96) || (window.event.keyCode>122) ) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert(fM("NoCaracteresRaros"));return;}
		else{return;}
	}
}
//****************************************
function fSoloNumero(intAlert) {
	if (((window.event.keyCode<48)||(window.event.keyCode>57))&& (window.event.keyCode!=8)) {  
		window.event.keyCode=""; 
		if (intAlert==1){alert(fM("SoloNumeros"));return false;}
		else{return false;}
	}
}
//****************************************
function fSoloDecimal(intAlert,iintNumerico,elemento) 
{	if (((window.event.keyCode<48)||(window.event.keyCode>57))&& (window.event.keyCode!=8)&& (window.event.keyCode!=46))
	{	window.event.keyCode=""; 
		if (intAlert==1)
		{	alert(fM("SoloDecimales"));return false;
		}
		else
		{	return false;
		}
	}
	if (typeof iintNumerico != 'undefined')
	{	if (iintNumerico==1 && window.event.keyCode==46 && elemento.value.lastIndexOf(".")!=-1)
		{	window.event.keyCode="";
			if (intAlert==1)
			{	alert(fM("Numerico"));return false;
			}
			else
			{	return false;
			}
		}
	}
}
//****************************************
function fIntro(intAlert) {
	if (window.event.keyCode!=13){
		if (((window.event.keyCode>=0) && (window.event.keyCode<=47))||((window.event.keyCode>=58)&& (window.event.keyCode<=64)) || ((window.event.keyCode>=91)&& (window.event.keyCode<95)) || (window.event.keyCode==96) || (window.event.keyCode>122) ) {  
			window.event.keyCode=""; 
			if (intAlert==1){alert(fM("LetraRarorikEz"));return;}
			else{return;}
		}
	}else{fValidarUserPass();}
}
//****************************************
function fValidarUserPass (){
	if (document.frmLogin.txtUser.value==""){	
		alert(fM("IntroduzcaUsuario"));
		document.frmLogin.txtUser.focus();
		return false;
	}else{	
		if (document.frmLogin.txtUser.value.lastIndexOf("'")!=-1 || document.frmLogin.txtUser.value.lastIndexOf("=")!=-1 || document.frmLogin.txtUser.value.lastIndexOf("/")!=-1 || document.frmLogin.txtUser.value.lastIndexOf("%")!=-1 || document.frmLogin.txtUser.value.lastIndexOf(".")!=-1 || document.frmLogin.txtUser.value.lastIndexOf(",")!=-1){
			alert(fM("LetraRarorikEz"));
			document.frmLogin.txtUser.focus();
			return false;
		}
	}
	if (document.frmLogin.txtPass.value==""){	
		alert(fM("IntroduzcaContrasenna"));
		document.frmLogin.txtPass.focus();
		return false;
	}else{	
		if (document.frmLogin.txtPass.value.lastIndexOf("'")!=-1 || document.frmLogin.txtPass.value.lastIndexOf("=")!=-1 || document.frmLogin.txtPass.value.lastIndexOf("/")!=-1 || document.frmLogin.txtPass.value.lastIndexOf("%")!=-1 || document.frmLogin.txtPass.value.lastIndexOf(".")!=-1 || document.frmLogin.txtPass.value.lastIndexOf(",")!=-1){	
			alert(fM("NoCaracteresExtrannos"));
			document.frmLogin.txtPass.focus();
			return false;
		}
	}
	//document.frmLogin.submit();
	return true;
}
//****************************************************
function fValidarCorreo(valor){
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(valor)){return true;} 
	else { alert(fM("EmailIncorrecto")); return false ;}
}
//****************************************************
function trim(cadena){ 
	for(i=0; i<cadena.length; ){
	if(cadena.charAt(i)==" ")
	cadena=cadena.substring(i+1, cadena.length);
	else break; }
	for(i=cadena.length-1; i>=0; i=cadena.length-1){
	if(cadena.charAt(i)==" ") cadena=cadena.substring(0,i);
	else break; }
	return cadena;
}
//*************************************
function textCounter(maxlimit,elemento){	
	if (elemento.value.length > maxlimit){elemento.value = elemento.value.substring(0, maxlimit);}
}
//****************************************************
function fSeleccionaInput (objInput){objInput.select();}
//****************************************************
function fFormatoTextoColor(Tipo,Donde){
	if (Donde!="" && typeof Donde != 'undefined')
	{	Donde=Donde+".";
		if (eval(Donde+"strFoco!=''"))
		{	strTexto = eval(Donde+"document.selection.createRange().text");
			if (strTexto ==""){alert (fM("SeleccionaTexto"));return;}
			if (Tipo == "#F76531"){eval(Donde+'document.selection.createRange().text = "[#F76531#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#FE9664"){eval(Donde+'document.selection.createRange().text = "[#FE9664#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#36A986"){eval(Donde+'document.selection.createRange().text = "[#36A986#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#908E8E"){eval(Donde+'document.selection.createRange().text = "[#908E8E#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#A0BE18"){eval(Donde+'document.selection.createRange().text = "[#A0BE18#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#899DCE"){eval(Donde+'document.selection.createRange().text = "[#899DCE#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#123A9C"){eval(Donde+'document.selection.createRange().text = "[#123A9C#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#000000"){eval(Donde+'document.selection.createRange().text = "[#000000#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#892D30"){eval(Donde+'document.selection.createRange().text = "[#892D30#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#C48665"){eval(Donde+'document.selection.createRange().text = "[#C48665#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#935988"){eval(Donde+'document.selection.createRange().text = "[#935988#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#D294BB"){eval(Donde+'document.selection.createRange().text = "[#D294BB#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
			if (Tipo == "#FFFFFF"){eval(Donde+'document.selection.createRange().text = "[#FFFFFF#]" + ' + Donde + 'document.selection.createRange().text + "[/#]"');}
		}
	}else
	{	if (strFoco!="")
		{	strTexto = document.selection.createRange().text;
			if (strTexto ==""){alert (fM("SeleccionaTexto"));return;}
			if (Tipo == "#F76531"){document.selection.createRange().text = "[#F76531#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#FE9664"){document.selection.createRange().text = "[#FE9664#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#36A986"){document.selection.createRange().text = "[#36A986#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#908E8E"){document.selection.createRange().text = "[#908E8E#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#A0BE18"){document.selection.createRange().text = "[#A0BE18#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#899DCE"){document.selection.createRange().text = "[#899DCE#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#123A9C"){document.selection.createRange().text = "[#123A9C#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#000000"){document.selection.createRange().text = "[#000000#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#892D30"){document.selection.createRange().text = "[#892D30#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#C48665"){document.selection.createRange().text = "[#C48665#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#935988"){document.selection.createRange().text = "[#935988#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#D294BB"){document.selection.createRange().text = "[#D294BB#]" + document.selection.createRange().text + "[/#]";}
			if (Tipo == "#FFFFFF"){document.selection.createRange().text = "[#FFFFFF#]" + document.selection.createRange().text + "[/#]";}
		}
	}
}
//****************************************************
function fFormatoTexto(Tipo,Donde,Formu){
	if (Donde!="" && typeof Donde != 'undefined')
	{	Donde=Donde+".";
		if (eval(Donde+"strFoco!=''"))
		{	strTexto = eval(Donde+"document.selection.createRange().text");
			if (strTexto ==""){alert (fM("SeleccionaTexto"));return;}
			if (Tipo == "b"){eval(Donde+'document.selection.createRange().text = "[b]" + ' + Donde + 'document.selection.createRange().text + "[/b]"');}
			if (Tipo == "u"){eval(Donde+'document.selection.createRange().text = "[u]" + ' + Donde + 'document.selection.createRange().text + "[/u]"');}
			if (Tipo == "k"){eval(Donde+'document.selection.createRange().text = "[i]" + ' + Donde + 'document.selection.createRange().text + "[/i]"');}
			if (Tipo == "-t"){eval(Donde+'document.selection.createRange().text = "[-t]" + ' + Donde + 'document.selection.createRange().text + "[/-t]"');}
			if (Tipo == "t"){eval(Donde+'document.selection.createRange().text = "[t]" + ' + Donde + 'document.selection.createRange().text + "[/t]"');}
			if (Tipo == "+t"){eval(Donde+'document.selection.createRange().text = "[+t]" + ' + Donde + 'document.selection.createRange().text + "[/+t]"');}
			if (Tipo == "sup"){eval(Donde+'document.selection.createRange().text = "[sup]" + ' + Donde + 'document.selection.createRange().text + "[/sup]"');}
			if (Tipo == "sub"){eval(Donde+'document.selection.createRange().text = "[sub]" + ' + Donde + 'document.selection.createRange().text + "[/sub]"');}
			if (Tipo == "center"){eval(Donde+'document.selection.createRange().text = "[center]" + ' + Donde + 'document.selection.createRange().text + "[/center]"');}
			if (Tipo == "face"){
				strFace = eval(Donde+'document.'+Formu+'.cboFace.value');
				eval(Donde+'document.selection.createRange().text = "[ff="+strFace+"=ff]" + ' + Donde + 'document.selection.createRange().text + "[/ff]"');
			}
			if (Tipo == "size"){
				strSize = eval(Donde+'document.'+Formu+'.cboSize.value');
				eval(Donde+'document.selection.createRange().text = "[fs="+strSize+"=fs]" + ' + Donde + 'document.selection.createRange().text + "[/fs]"');
			}
			return;
		}
	}
	else
	{	if (strFoco!="")
		{	strTexto = document.selection.createRange().text;
			if (strTexto ==""){alert (fM("SeleccionaTexto"));return;}
			if (Tipo == "b"){document.selection.createRange().text = "[b]" + document.selection.createRange().text + "[/b]";}
			if (Tipo == "u"){document.selection.createRange().text = "[u]" + document.selection.createRange().text + "[/u]";}
			if (Tipo == "k"){document.selection.createRange().text = "[i]" + document.selection.createRange().text + "[/i]";}
			if (Tipo == "-t"){document.selection.createRange().text = "[-t]" + document.selection.createRange().text + "[/-t]";}
			if (Tipo == "t"){document.selection.createRange().text = "[t]" + document.selection.createRange().text + "[/t]";}
			if (Tipo == "+t"){document.selection.createRange().text = "[+t]" + document.selection.createRange().text + "[/+t]";}
			if (Tipo == "sup"){document.selection.createRange().text = "[sup]" + document.selection.createRange().text + "[/sup]";}
			if (Tipo == "sub"){document.selection.createRange().text = "[sub]" + document.selection.createRange().text + "[/sub]";}
			if (Tipo == "center"){document.selection.createRange().text = "[center]" + document.selection.createRange().text + "[/center]";}
			if (Tipo == "face"){
				strFace = eval(Donde+'document.'+Formu+'.cboFace.value');
				eval(Donde+'document.selection.createRange().text = "[ff="+strFace+"=ff]" + ' + Donde + 'document.selection.createRange().text + "[/ff]"');
			}
			if (Tipo == "size"){
				strSize = eval(Donde+'document.'+Formu+'.cboSize.value');
				eval(Donde+'document.selection.createRange().text = "[fs="+strSize+"=fs]" + ' + Donde + 'document.selection.createRange().text + "[/fs]"');
			}
			return;
		}
	}
}
//*************************************************
function fInsertarEnlace(Tipo,Donde){	
	if (strFoco==""){alert(fM("AukeratuNonNahiDuzuLinkaJarri"));return;}
	strEnlace=document.selection.createRange().text;
	var strTexto=prompt(fM("LinkaTextua"),strEnlace);
	if (strTexto!="" && typeof strTexto!='undefined' && strTexto!=null){
		var strUrl=prompt(fM("LinkaURL"),'http://');
	}
	if (strUrl!="" && typeof strUrl!='undefined' && strUrl!=null){
		if(Tipo=="http"){
			strFoco.focus();
			if (strTexto!="" && typeof strTexto!='undefined' && strTexto!=null ){
				if (document.selection.createRange().text!=''){document.selection.createRange().text="[link=" + strUrl +"=link]" + strTexto + "[/link]";}
				else{strFoco.value+="[link=" + strUrl +"=link]" + strTexto + "[/link]";}
			}
			else{
				document.selection.createRange().text="[link=" + strUrl + "=link]" + strUrl + "[/link]";
			}
		}
	}
}
//****************************************************
function fInsertarSimbolo(Tipo,Donde){	
	if (Donde!="" && typeof Donde != 'undefined')
	{	Donde=Donde+".";
		if (eval(Donde+"strFoco==''")){alert(fM("SeleccionaDondeInsertarSimbolo"));return;}
		strAux="";
		switch (Tipo){
			case "mm": strAux="[+-]"; break;
			case "c": strAux="[sq]"; break;
		}
		eval(Donde+"strFoco.focus()");
		if (eval(Donde+"document.selection")){	
			eval(Donde+"document.selection.createRange().text= strAux");
		}else{	
			eval(Donde+"strFoco+=strAux");
		}
	}else{	
		if (strFoco==""){alert(fM("SeleccionaDondeInsertarSimbolo"));return;}
		strAux="";
		switch (Tipo){	
			case "mm": strAux="[+-]"; break;
			case "c": strAux="[sq]"; break;
		}
		strFoco.focus();
		if (document.selection){	
			document.selection.createRange().text= strAux;
		}else{	
			strFoco.value+=strAux;
		}
	}
}
//****************************************
function fAbrirEscritorio (strRaiz){
	intIzquierda=(screen.width-986)/2;
	intArriba=(screen.height-631)/2;
	window.open(strRaiz+"administracion/index.php","arotzgi_administracon","screenX="+intIzquierda+",screenY="+intArriba+",left="+intIzquierda+",top="+intArriba+",resizeable=no,directories=no,height=602,menubar=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=976");
	window.open(strRaiz+"index.php","_parent");
}
//**************************************
function fValidarEnvio (){
	if (document.frmAmigo.txtNombre.value==""){alert(fM("IntroduzcaSuNombre"));return;}
	if (document.frmAmigo.txtEmail.value==""){alert(fM("IntroduzcaSuEmail"));return;}
	else{if(!fValidarCorreo(document.frmAmigo.txtEmail.value)){return;}}
	if (document.frmAmigo.txtNombre2.value==""){alert(fM("IntroduzcaNombreEnvio"));return;}
	if (document.frmAmigo.txtEmail2.value==""){alert(fM("IntroduzcaEmailEnvio"));return;}
	else{if(!fValidarCorreo(document.frmAmigo.txtEmail2.value)){return;}}
	document.frmAmigo.submit();
}
//**************************************
function fEscribirCapa(texto)
{	if(document.layers)
	{   document.tip.document.write(texto+"&nbsp;&nbsp;");
	    document.tip.document.close();
	    document.tip.visibility="visible"
	}
	if(document.all)
	{   document.all("tip").innerHTML=texto+"&nbsp;&nbsp;";
	    document.all("tip").style.visibility="visible"
	}
	if(document.getElementById)
	{   document.getElementById("tip").innerHTML=texto+"&nbsp;&nbsp;";
	    document.getElementById("tip").style.visibility="visible"
	}
	return;
}
//**************************************
function fQuitarCapa (){
	if(document.layers){document.tip.visibility="hidden";}
	if(document.all){document.all("tip").style.visibility="hidden";}
	if(document.getElementById){document.getElementById("tip").style.visibility="hidden";}
}
//**************************************
function fValidarContacto (){
	if (document.frmContacto.txtNombre.value==""){alert(fM("IntroduzcaSuNombre"));return;}
	if (document.frmContacto.txtEmpresa.value==""){alert(fM("IntroduzcaEmpresa"));return;}
	if (document.frmContacto.txtTelefono.value==""){alert(fM("IntroduzcaTelefono"));return;}
	if (document.frmContacto.txtEmail.value==""){alert(fM("IntroduzcaSuEmail"));return;}
	else{if(!fValidarCorreo(document.frmContacto.txtEmail.value)){return;}}
	if (document.frmContacto.txtSolicitud.value==""){alert(fM("IntroduzcaSolicitud"));return;}
	document.frmContacto.submit();
}
//**************************************
function fValidarPeritacion(){
    if (document.frmContacto.txtNombre.value==""){alert(fM("IntroduzcaSuNombre"));return;}
    if (document.frmContacto.txtTema.value==""){alert(fM("IntroduzcaTemaYComentario"));return;}
    if (document.frmContacto.txtTelefono.value==""){alert(fM("IntroduzcaTelefono"));return;}
    if (document.frmContacto.txtEmail.value==""){alert(fM("IntroduzcaSuEmail"));return;}
    else{if(!fValidarCorreo(document.frmContacto.txtEmail.value)){return;}}
    if (document.frmContacto.txtComentarios.value==""){alert(fM("IntroduzcaTemaYComentario"));return;}
    document.frmContacto.submit();
}
//**************************************
function fValidarAsociacion(){
    if (document.frmContacto.txtNombre.value==""){alert(fM("IntroduzcaEmpresa"));return;}
    if (document.frmContacto.txtCIF.value==""){alert(fM("IntroduzcaCIF"));return;}
    if (document.frmContacto.txtDireccion.value==""){alert(fM("IntroduzcaDireccion"));return;}
    if (document.frmContacto.txtPoblacion.value==""){alert(fM("IntroduzcaPoblacion"));return;}
    if (document.frmContacto.txtCodPost.value==""){alert(fM("IntroduzcaCP"));return;}
    if (document.frmContacto.txtTelfEmpresa.value=="" && document.frmContacto.txtTelfParticular.value==""){alert(fM("IntroduzcaTelefono"));return;}
    document.frmContacto.submit();
}
//**************************************
function fCalcularTrabajadores(){
    var intTotal=0;
    if (document.frmContacto.txtAutonomos.value!="" && !isNaN(document.frmContacto.txtAutonomos.value)){intTotal+=parseInt(document.frmContacto.txtAutonomos.value);}
    if (document.frmContacto.txtFijos.value!="" && !isNaN(document.frmContacto.txtFijos.value)){intTotal+=parseInt(document.frmContacto.txtFijos.value);}
    if (document.frmContacto.txtEventuales.value!="" && !isNaN(document.frmContacto.txtEventuales.value)){intTotal+=parseInt(document.frmContacto.txtEventuales.value);}
    document.frmContacto.txtTotal.value=intTotal;
}
//*************************************
function fLimpiarFormulario (strForm){
	eval('document.'+strForm+'.reset()');
	return;
}
// ***************************************
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
