function abrirpromo(idpromo)
{
//if (i>1)
//    window.open ("http://localhost/promocionesen/nuevo/fichapromocion.php?estoydentro=1&idpromo="  + idpromo  ,"_self");
//else
  window.open ("http://www.promocionesenelche.com/fichapromocion.php?estoydentro=1&idpromo="  + idpromo  ,"_self");
}


function publicapromociones()
{
var i=0;
i=5;
if (i==5)     window.open ("publicarpromociones.php","_self");
}



function abrirfichero (fichero)
{
    window.open ("http://www.haypisos.com/fotospromo/"  + fichero ,"_blank");
}


function abrirsitioweb(web)
{
        window.open (web  ,"_blank");
}

function objetoAjax(){
    var xmlhttp=false;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
          }
    }

    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp;
}


function publicapromociones()
{
var i=0;
i=5;
if (i==5)     window.open ("publicarpromociones.php","_self");
}

function solonumeros(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 enviarsolicitud(tipo,agencia,codigo)
{

var telefono="";
var email="";
var nombre="";
var notificar="";
var precio="";
var hacer=0;
var descripcion="";

if (document.getElementById("telefono")!=null) telefono=document.getElementById("telefono").value;
if (document.getElementById("telefonoinicio")!=null) telefono=document.getElementById("telefonoinicio").value;
if ((document.getElementById("email")!=null)  && (email.length===0)) email=document.getElementById("email").value;
if ((document.getElementById("nombre")!=null) && (nombre.length===0)) nombre=document.getElementById("nombre").value;
if ((document.getElementById("nombreinicio")!=null) && (nombre.length===0)) nombre=document.getElementById("nombreinicio").value;
if ((document.getElementById("nombredos")!=null) && (nombre.length===0)) nombre=document.getElementById("nombredos").value;
if ((document.getElementById("nombretres")!=null) && (nombre.length===0)) nombre=document.getElementById("nombretres").value;
if (document.getElementById("precio")!=null) precio=document.getElementById("precio").value;
if ((document.getElementById("descripcion")!=null)  && (descripcion.length===0)) descripcion=document.getElementById("descripcion").value;
if ((document.getElementById("descripcioninicio")!=null)  && (descripcion.length===0)) descripcion=document.getElementById("descripcioninicio").value;
if ((document.getElementById("descripciondos")!=null)  && (descripcion.length===0))  descripcion=document.getElementById("descripciondos").value;
if ((document.getElementById("telefonodos")!=null)   && (telefono.length===0)) telefono=document.getElementById("telefonodos").value;
if ((document.getElementById("telefonotres")!=null)   && (telefono.length===0)) telefono=document.getElementById("telefonotres").value;
if ((document.getElementById("emaildos")!=null)   && (email.length===0))email=document.getElementById("emaildos").value;
if ((document.getElementById("emailinicio")!=null)   && (email.length===0))email=document.getElementById("emailinicio").value;
if ((document.getElementById("emailtres")!=null)  && (email.length===0)) email=document.getElementById("emailtres").value;
if ((document.getElementById("preciodos")!=null) && (precio.length===0)) precio=document.getElementById("preciodos").value;



    if (email.length>0) hacer= compruebaemail(email);
    if (comprobartelefono(telefono)==0)
                 {
                 alert ('Debes de Introducir un telefono valido');
                 hacer=1
                 }




if (hacer==0)
    {

        cargarventanaajax ("frmportal",rutapath() + "formularios/enviarsolicitud.php?tipo=" + tipo + "&telefono=" + telefono + "&agencia=" + agencia  + "&codigo=" + codigo +"&nombre=" + nombre + "&email=" + email + "&notificar=" + notificar + "&precio=" + precio + "&descripcion=" + descripcion);
    }
}

function compruebaemail(mxa)
{
var cade
var nohacer
nohacer=0;


if ((mxa.indexOf('@')<1) && (nohacer==0))      nohacer=1;
if ((mxa.indexOf('.')<1) && (nohacer==0))      nohacer=1;
if ((mxa.indexOf(' ')>0) && (nohacer==0))       nohacer=1;
if ((mxa.length<5) && (nohacer==0))      nohacer=1;

if (nohacer==1)
    {
    alert ("Error en el E-mail");
        return 1;
    }
else
    return 0;

}

function cargarventanaajax (id,parametro)
{


	url= parametro;

    selectResultado = document.getElementById( id );
    ajax = objetoAjax();

    ajax.open("GET", url );
    ajax.onreadystatechange = function() {

        if ( ajax.readyState == 4 ) {

            document.getElementById(id).innerHTML = ajax.responseText;
            document.getElementById(id).style.position="absolute";
            document.getElementById(id).style.display="block";
            centrarventana(id);
        }
    }
    ajax.send(null)
}

function rutapath ()
{
        cadruta="/";


return cadruta;
}

function centrarventana(id)
{
//document.getElementById(id).style.visibility='hidden';
document.getElementById(id).style.position="absolute";
document.getElementById(id).style.display="block";

auxaltura=document.documentElement.scrollTop;
limitealtura=(document.documentElement.clientHeight-document.getElementById(id).offsetHeight)/2;
document.getElementById(id).style.top=limitealtura+ auxaltura +"px";
auxaltura=(document.documentElement.clientWidth-document.getElementById(id).offsetWidth)/2;
document.getElementById(id).style.left=auxaltura +"px";

}

function cerrarventana(texto,tipo)
{

document.getElementById(texto).style.display='none';
document.getElementById(texto).style.visibility="hidden";
}

function enviarresultados(numfiltro,tipo,agencia,codigo)
{

var telefono="";
var email="";
var nombre="";
var notificar="";
var precio="";
var hacer=0;
var descripcion="";


if (document.getElementById("telefonoinicio" + numfiltro)!=null) telefono=document.getElementById("telefonoinicio"  + numfiltro).value;
if (document.getElementById("nombreinicio" + numfiltro)!=null)  nombre=document.getElementById("nombreinicio"  + numfiltro).value;
if (document.getElementById("descripcioninicio" + numfiltro)!=null)   descripcion=document.getElementById("descripcioninicio" + numfiltro).value;
if (document.getElementById("emailinicio" + numfiltro)!=null)  email=document.getElementById("emailinicio" + numfiltro).value;



    if (email.length>0) hacer= compruebaemail(email);
    if (comprobartelefono(telefono)==0)
                 {
                 alert ('Debes de Introducir un telefono valido');
                 hacer=1
                 }



if (hacer==0)
    {

        cargarventanaajax ("frmportal",rutapath() + "formularios/enviarsolicitud.php?tipo=" + tipo + "&telefono=" + telefono + "&agencia=" + agencia  + "&codigo=" + codigo +"&nombre=" + nombre + "&email=" + email + "&notificar=" + notificar + "&precio=" + precio + "&descripcion=" + descripcion);
    if (document.getElementById("telefonoinicio" + numfiltro)!=null) document.getElementById("telefonoinicio"  + numfiltro).value="";
    if (document.getElementById("nombreinicio" + numfiltro)!=null)  document.getElementById("nombreinicio"  + numfiltro).value="";
    if (document.getElementById("descripcioninicio" + numfiltro)!=null)   document.getElementById("descripcioninicio" + numfiltro).value="";
    if (document.getElementById("emailinicio" + numfiltro)!=null)  document.getElementById("emailinicio" + numfiltro).value="";

    }
}


function bannergrande()
{
document.write ('<center>');
document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="700" height="47" title="news" onclick="clickit()">');
document.write ('<param rel=nofolow name="movie" value="banner.swf">');
document.write ('<param name="quality" value="high">');
document.write ('<embed rel=nofolow src="banner.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="700" height="47" wmode="green"></embed>');
document.write ('</object>');
document.write ('</center>');

}

function ponebanner()
{
document.write ('<center>');
document.write ('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="700" height="47" title="news" onclick="clickit()">');
document.write ('<param rel=nofolow name="movie" value="banner.swf">');
document.write ('<param name="quality" value="high">');
document.write ('<embed rel=nofolow src="banner.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="700" height="47" wmode="green"></embed>');
document.write ('</object>');
document.write ('</center>');

}

function comprobartelefono(telefono)
{
var si=0;

if (telefono.length<9) return 0;
if (telefono=="999999999") return 0;
if (telefono=="888888888") return 0;
if (telefono=="666666666") return 0;
if (telefono=="000000000") return 0;
if (telefono.indexOf('00000')>0) return 0;
if (telefono.indexOf('11111')>0) return 0;
if (telefono.indexOf('22222')>0) return 0;
if (telefono.indexOf('33333')>0) return 0;
if (telefono.indexOf('44444')>0) return 0;
if (telefono.indexOf('55555')>0) return 0;
if (telefono.indexOf('66666')>0) return 0;
if (telefono.indexOf('77777')>0) return 0;
if (telefono.indexOf('88888')>0) return 0;
if (telefono.indexOf('99999')>0) return 0;
if (telefono.indexOf('00000')>0) return 0;
if (telefono.indexOf('12345')>0) return 0;
if (telefono.indexOf('23456')>0) return 0;
if (telefono.indexOf('34567')>0) return 0;
if (telefono.indexOf('45678')>0) return 0;
if (telefono.indexOf('56789')>0) return 0;
if (telefono.indexOf('67890')>0) return 0;
if (telefono.indexOf('01234')>0) return 0;
if (telefono.indexOf('09876')>0) return 0;
if (telefono.indexOf('98765')>0) return 0;
if (telefono.indexOf('87654')>0) return 0;
if (telefono.indexOf('76543')>0) return 0;
if (telefono.indexOf('65432')>0) return 0;
if (telefono.indexOf('54321')>0) return 0;


if (telefono.length==9)
{

 if (telefono.substr(0,1)=="9") si=1;

  if (telefono.substr(0,1)=="8") si=1;

   if (telefono.substr(0,1)=="6") si=1;


}

return si;
}