function EnviaAmigos(){
   with (document.forms["formulario1"]){
	   str=mail2.value
		 for (var i=0;i<str.length;i++){
 		 		 str = str.replace(/^\s*|\s*$/g,"");
 				 str = str.replace(",",";");
 				 str = str.replace(" ",";");
     }
     if (validaForm()==true){
       data=name.value+"{:s:}"+str;
	     data="contacto||"+data;
       sendToActionScript(data);
     }
   }		
}

function validaForm(){
		with (document.forms["formulario1"]){
  		   if(name.value==""){
				    alert("Ingrese Nombre");
						name.focus();
						return false;
				 }
			   else if (mail2.value==""){
				    alert("Ingrese email de amigos");
						mail2.focus();
						return false;				 
			   }
				 else if (mail2.value!=""){
				    cadena=mail2.value
		     for (var i=0;i<cadena.length;i++){
 		 		    cadena = cadena.replace(/^\s*|\s*$/g,"");
 				    cadena = cadena.replace(",",";");
 				    cadena = cadena.replace(" ",";");
         }
				    aux=cadena.substr((cadena.length)-1,1)
						if(aux==";"){
						   cadena=cadena.substr(0,(cadena.length)-1)
						}
						cadena = cadena.split(";");
			    for (var i=0;i<cadena.length;i++){
							aux2=cadena[i];
   			      if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(aux2)){
			    		}
              else{
                   alert("Uno de los email no es válido");
						       mail2.focus();
						       return false;
									 break;
							}		 
					}
					return true;
			   }					 
				 else 
				    return true;
			   }	
}

function mostrarAsunto(){
    with (document.forms["formulario"]){
		    if(asunto2.value==5){
			 		asunto.style.visibility = "visible";
					asunto.value="";
					document.getElementById("ast1").style.visibility = "hidden";
					document.getElementById("ast2").style.visibility = "visible";
					fono.style.visibility = "visible";
					document.getElementById("fono1").style.visibility = "visible";					
					asunto.focus();
			 }
			 else if(asunto2.value==6){
			    fono.style.visibility = "hidden";
					document.getElementById("fono1").style.visibility = "hidden";
					asunto.style.visibility = "hidden";
					document.getElementById("ast2").style.visibility = "hidden";
			 }
			 else{
			    asunto.style.visibility = "hidden";
					document.getElementById("ast2").style.visibility = "hidden";
					document.getElementById("ast1").style.visibility = "visible";
					fono.style.visibility = "visible";
					document.getElementById("fono1").style.visibility = "visible";
			 }
		}
}

function enviacontact(){
   with (document.forms["formulario"]){
     //checar();
     if (checar()==true){
		   if (asunto2.value==1){
			    msg2="Quiero publicarme en SexService."
			 }
			 else if(asunto2.value==2){
			 		msg2="Quiero publicitar mi sitio en SexService"	
			 }
		   else if (asunto2.value==3){
			    msg2="Consulta sobre sitio SexService"
			 }
			 else if(asunto2.value==4){
			 		msg2="Comentario sobre sitio SexService"	
			 }			 
			 else if(asunto2.value==5){
			 		msg2=asunto.value;
			 }
			 else if(asunto2.value==6){
			    msg2="Quiero ser afiliador de SexService."
			 }
       data=nombre.value+"{:s:}"+email.value+"{:s:}"+fono.value+"{:s:}"+msg2+"{:s:}"+consulta.value
	     data="contacto||"+data;
       sendToActionScript(data);
     }
   }		
}

function validar(e){
		tecla_codigo = (document.all) ? e.keyCode : e.which;
		if(tecla_codigo==8)return true;
		patron =/[0-9.-]/;
		tecla_valor = String.fromCharCode(tecla_codigo);
		return patron.test(tecla_valor);
}

function checar(){
		with (document.forms["formulario"]){
		     if (asunto2.value==0){
				 		alert("seleccione un tipo de consulta");
						asunto2.focus();
						return false				    
				 }
				 else if (valida_mail(email.value)==false){
				 		alert("Ingrese una dirección de correo válida");
						email.focus();
						return false;
				 }
				 else if(nombre.value==""){
			 		  alert("Ingrese Nombre");
						nombre.focus();
						return false;
				 }
				 else if(email.value=="" && fono.value==""){
				    if(asunto2.value==6){
      					 alert("Ingrese Email Válido");
						}
						else{
				 				 alert("Ingrese Email o Teléfono Válido");
						}
  					email.focus();
						return false;
				 }
				 else if (fono.value.length<7 && email.value==""){
				 		alert("Ingrese Teléfono Válido");
						fono.focus();
						return false;				 
				 }
				 else if(asunto2.value==5 && asunto.value==""){
				 		alert("Ingrese Asunto");
						asunto.focus();
						return false;
				 }
				 if(consulta.value==""){
				 		alert("Ingrese Consulta");
						consulta.focus();
						return false;
				}	else 
				    return true;
}

function valida_mail(theElement){
		var s = theElement;
		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 true;
		if (filter.test(s))
		   return true;
		else
		   return false;
    }
}
function contactxxx(){
	  if (document.all) {		//Explorer
		alert("explorer")
	      newUrl="http://www.sexservice.cl/sxs/SexServiceMemory.html"
	  }
	  else if(document.getElementById){		//Netscape
		alert("Netscape")
    	  newUrl="http://www.sexservice.cl/sxs/SexServiceMemory.php"
    }
	  location.replace(newUrl);
}
function contact(){
    if(document.getElementById){
        //Netscape
				posy=window.pageYOffset;
				masolayer = document.getElementById("pax0");
        estelayer = document.getElementById("contac");
				otrolayer = document.getElementById("pax");
				cajita = document.getElementById("capa");
				estelayer.style.left = "-100px";
    }
    if (document.all) {
		    //Explorer
				posy=document.body.scrollTop;
				masolayer = document.all["pax0"];
        estelayer = document.all["contac"];
				otrolayer = document.all["pax"];
				cajita = document.all["capa"];
    }
		estelayer.style.width=screen.width+90;
		scroll (0, 0); 	
		masolayer.style.visibility = "hidden";		
		cajita.style.visibility = "hidden";				
		otrolayer.style.visibility = "hidden";
    estelayer.style.visibility = "visible";
    sendToActionScript("panic");
}

function backcontact(){
		with (document.forms["formulario"]){
       nombre.value="";
			 email.value="";
			 fono.value="";
			 asunto.value="";
			 consulta.value="";
			 asunto.style.visibility = "hidden";
			 document.getElementById("ast2").style.visibility = "hidden";
			 document.getElementById("ast1").style.visibility = "visible";
			 fono.style.visibility = "visible";
  		 document.getElementById("fono1").style.visibility = "visible";
			 asunto2.value=0;
       if(document.getElementById){
          //Netscape
  				masolayer = document.getElementById("pax0");
          estelayer = document.getElementById("contac");
  				otrolayer = document.getElementById("pax");
  				cajita = document.getElementById("capa");
       }
       if (document.all) {
        //Explorer
  				masolayer = document.all["pax0"];
          estelayer = document.all["contac"];
  				otrolayer = document.all["pax"];
  				cajita = document.all["capa"];
       }
    	 estelayer.style.visibility = "hidden"; 	
   		 masolayer.style.visibility = "visible";		
  		 cajita.style.visibility = "visible";				
  		 otrolayer.style.visibility = "visible";
  	} 
		with (document.forms["formulario1"]){
       name.value="";
			 mail2.value="";
		}
}

function google(valor){
    if(document.getElementById){
        //Netscape
				posy=window.pageYOffset;
				masolayer = document.getElementById("pax0");
        estelayer = document.getElementById("pax1");
				otrolayer = document.getElementById("pax");
				cajita = document.getElementById("capa");
    }
    if (document.all) {
        //Explorer
				posy=document.body.scrollTop;
				masolayer = document.all["pax0"];
        estelayer = document.all["pax1"];
				otrolayer = document.all["pax"];
				cajita = document.all["capa"];
    }
		estelayer.style.width=screen.width;
		scroll (0, 0); 	
		masolayer.style.visibility = "hidden";		
		cajita.style.visibility = "hidden";				
		otrolayer.style.visibility = "hidden";
    estelayer.style.visibility = "visible";
		document.title = "Google";
		if (valor=="actionscript"){
				valor="";
		}
		else{
		   sendToActionScript("panic");
		}
}

function backgoogle(Capa){
    if(document.getElementById){
        //Netscape
				masolayer = document.getElementById("pax0");
        estelayer = document.getElementById("pax1");
				otrolayer = document.getElementById("pax");
				cajita = document.getElementById("capa");
    }
    if (document.all) {
        //Explorer
				masolayer = document.all["pax0"];
        estelayer = document.all["pax1"];
				otrolayer = document.all["pax"];
				cajita = document.all["capa"];
    }
	 	estelayer.style.visibility = "hidden"; 	
		masolayer.style.visibility = "visible";		
	  cajita.style.visibility = "visible";				
	  otrolayer.style.visibility = "visible";
		document.title = "SexService - Publicidad de acompañantes. Versiones en español, inglés y para ciegos";
}

function buscar(Capa){
    Capa="http://www.google.cl/search?hl=es&q="+Capa+"&btnG=Buscar+con+Google&meta="
    location.replace(Capa);
}

function Ocultar(Capa) {  
    if(document.getElementById){
        //Netscape
        puplayer = document.getElementById(Capa);
    }
    if (document.all) {
        //Explorer
        puplayer = document.all[Capa];
    }
    puplayer.style.visibility = "hidden";  
}  

function Mostrar(Capa) {  
    if(document.getElementById){
        //Netscape
        puplayer = document.getElementById(Capa);
    }
    if (document.all) {
        //Explorer
        puplayer = document.all[Capa];
    }
    puplayer.style.visibility = "visible";  
} 

function Izquierda(Capa) {  
    if(document.getElementById){
        //Netscape
        puplayer = document.getElementById(Capa);
    }
    if (document.all) {
        //Explorer
        puplayer = document.all[Capa];
    }
    puplayer.style.left = "825px";  
}

function Derecha(Capa) { 
    if(document.getElementById){
        //Netscape
        puplayer = document.getElementById(Capa);
    }
    if (document.all) {
        //Explorer
        puplayer = document.all[Capa];
    }
    puplayer.style.left = "995px";  
} 

var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 115;

function resizeWindowMas()  {  
  window.resizeBy(+100,+100)  
}    

function resizeWindowMenos()  {  
  window.resizeBy(-100,-100)  
} 

var jsReady = false;

function isReady() {
   return true;
}

function pageInit() {
  jsReady = true;
}

function thisMovie(movieName) {
  if (navigator.appName.indexOf("Microsoft") != -1) {
     return window[movieName];
  } else {
     return document[movieName];
  }
}

function sendToActionScript(value) {
  thisMovie("gale").sendToActionScript(value);
}

function sendToJavaScript(str) {
  if (str.substr(0,4)=="WID=") {
	    ancho=str.substr(4);
  		posicLayer(str.substr(4));
	}
	else if (str=="panic"){
			google("actionscript");
	}
	else if (str=="contactoOK"){
      alert ("Tu mensaje ha sido enviado, Gracias por visitar SexService.cl");
			backcontact();
	}
	/*else if(str.substr(0,9)=="LinkToUrl"){
	  //newUrl=str.substr(9,str.length)
	  if (document.all) {		//Explorer
	      newUrl="http://www.sexservice.cl/sxs/SexServiceMemory.html"
	  }
	  else if(document.getElementById){		//Netscape
    	  newUrl="http://www.sexservice.cl/sxs/SexServiceMemory.php"
    }
	  location.replace(newUrl);
	}*/
}

function sendToJavaScriptWithRet(str) {
 if (str=="SCROLLPOS") {
			return ""+document.body.scrollLeft+";"+document.body.scrollTop+";";
 }
 if (str=="LANG") {
			return SSLANG;
 }
 if(str=="GetBrowser"){
 	  if (document.all) {		//Explorer
	     return "IE";
	  }
	  else if(document.getElementById){		//Netscape
    	 return "OT";
    }
  }
 return "NOKjs";
}

function posicLayer(xPos) {  
	document.gale.width=xPos;
	var sPos=""+xPos+"px"
  if(document.getElementById){
     //Netscape
     puplayer = document.getElementById("capa2");
  }
  if (document.all) {
     //Explorer
     puplayer = document.all["capa2"];
  }
  puplayer.style.left = sPos;
}

function esconde () {
    if(document.getElementById){
        //Netscape
        puplayer = document.getElementById("pax0");
        paxlayer = document.getElementById("pax");
    }
    if (document.all) {
        //Explorer
        puplayer = document.all["pax0"];
        paxlayer = document.all["pax"];
    }
    puplayer.style.display = "none";
    paxlayer.style.display = "none";
}

function cambiapax () {
    if(document.getElementById){
        //Netscape
        estelayer = document.getElementById("pax");
				otrolayer = document.getElementById("pax0");
        cajita = document.getElementById("capa");
    }
    if (document.all) {
        //Explorer
        estelayer = document.all["pax"];
				otrolayer = document.all["pax0"];
        cajita = document.all["capa"];
    }
		otrolayer.style.visibility = "hidden";
		cajita.style.visibility = "visible";
		document.gale.width=840;
		document.gale.height=1619;
		cajita.style.height = "100px";
  	cajita.style.width = "825px";
    estelayer.style.visibility = "visible";
		estelayer.style.display = "block";
}

function cambiapup () {
    if(document.getElementById){
        //Netscape
        estelayer = document.getElementById("pup");
        cajita = document.getElementById("otra2");
    }
    if (document.all) {
        //Explorer
        estelayer = document.all["pup"];
        cajita = document.all["otra2"];
    }
    if (cajita.checked==true) {
        estelayer.style.display = "block";
    } else {
        estelayer.style.display = "none";
    }
}  
