// JavaScript Document
function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight+', scrollbars=0, resizable=0');
}

function OpenBrWindow2(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
	if(window.screen)if(isCenter)if(isCenter=="true"){
		var myLeft = (screen.width-myWidth)/2;
		var myTop = (screen.height-myHeight)/2;
		features+=(features!='')?',':'';
		features+=',left='+myLeft+',top='+myTop;
	}
	window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight+', scrollbars=1, resizable=0');
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function guarda_datos()
{
    compilar('scripts/php/funciones/ajax_paypal.php', '&pago='+document.fvalida.pago.value+'&pass='+document.fvalida.pass.value+'&usuario='+document.fvalida.usuario.value+'&sugerencia='+document.fvalida.sugerencia.value+'&profesion='+document.fvalida.profesion.value+'&email='+document.fvalida.email.value+'&movil='+document.fvalida.movil.value+'&telefono='+document.fvalida.telefono.value+'&address1='+document.fvalida.address1.value+'&last_name='+document.fvalida.last_name.value+'&first_name='+document.fvalida.first_name.value+'&country='+document.fvalida.country.value+'&city='+document.fvalida.city.value, 'sub_verificador', 'get', '0', 'carga', '');
}
function sub_verificador(texto)
{
    document.getElementById('carga').innerHTML = '';
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function foco(elemento) {
	elemento.style.border = "1px solid #000000";
	elemento.style.background = "#ebebeb";
	elemento.style.color = "#5b5b5b";
}
function no_foco(elemento) {
	elemento.style.border = "1px solid #000000";
	elemento.style.background = "#ffffff";
	elemento.style.color = "#000000";
}

function mail(texto){ 
    var mailres = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-"; 
     
    var arroba = texto.indexOf("@",0); 
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1; 
     
    var punto = texto.lastIndexOf("."); 
                 
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = false; 
            break; 
     } 
    } 

    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 2 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)) 
    return mailres = true; 
    else 
    return mailres = false; 
}

//////////////////////////////////////////////////////////////////
function banner_click(texto, url_web)
{
		compilar(url_web, '&txt='+texto, '', 'get', '0', '', '');
}
//////////////////////////////////////////////////////////////////////

function telefono(texto){
    var mailres = true;             
    var cadena = "0123456789--"; 
         
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = false;
		    texto = texto.substr(0, texto.length-1);
            break; 
			return texto;
       }else if(texto.substr(contador, 2)=='--'){
		    texto = texto.substr(0, texto.length-1);
	   }
    } 
	return texto;
}

function depurar(texto){ 
    if(texto.lastIndexOf("@")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf(" ")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf(",")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf(".")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf(";")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("'")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("´´")>=0){
		return texto.substr(0, texto.length-2);
	}
    if(texto.lastIndexOf("´")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("{")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("}")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("?")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("ż")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("[")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("]")>=0){
		return texto.substr(0, texto.length-1);
	}
    if(texto.lastIndexOf("=")>=0){
		return texto.substr(0, texto.length-1);
	}
	return texto;
}

