// jip.js: les diverses fonctions d'ouverture de fenêtres annexes
//------------------------------------

//------------------------------------
// ouverture de la page Photos
function OpenPhotos(theURL,id,lang)
{
    sendTag(lang,"IGTU",id);
    w=window.open(theURL,"Photos","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=462,height=462");
    MSIE=(navigator.appVersion.indexOf("MSIE")!=-1);
    VERS=parseInt(navigator.appVersion);
    if ((!MSIE) || (VERS >=5)) w.focus();
}
//------------------------------------
// ouverture de la page Info Consommateur
function OpenInfoconso(theURL)
{
    w=window.open(theURL,"Photos","toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no,width=320,height=250");
    MSIE=(navigator.appVersion.indexOf("MSIE")!=-1);
    VERS=parseInt(navigator.appVersion);
    if ((!MSIE) || (VERS >=5)) w.focus();
}
//------------------------------------
// ouverture de la page envoyer mail
function OpenEnvoyerAmi() 
{
    MM_validateForm('correo','','RisEmail','email','','RisEmail');
}
//------------------------------------
// envoi du mail
function sendMail() 
{
    top.document.location="javascript:doSubmit();";
}
//------------------------------------
// fermeture de la page Photos
function MM_callJS(jsStr) //v2.0
{
    return eval(jsStr);
}
//------------------------------------
// Imprimer
function printWindow()
{
    bV = parseInt(navigator.appVersion)
    if (bV >= 4) top.focus();
}
//------------------------------------
// Itineraire
function pj_switch_menu (le_titre1, le_titre2) {
    document.getElementById(le_titre1);
    document.getElementById(le_titre2);
    var le_form1= document.getElementById("form_"+le_titre1);
    var le_form2= document.getElementById("form_"+le_titre2);
    le_form1.style.display='block';
    le_form2.style.display='none';
}
//------------------------------------
// Recherche d'un objet HTML
function MM_findObj(n, d) //v4.0
{
    var p,i,x;  

    if(!d) d=document;
    if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document;
        n=n.substring(0,p);
    }
    if(!(x=d[n])&&d.all) x=d.all[n];
    for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && document.getElementById) x=document.getElementById(n); 

    return x;
}
//------------------------------------
// Envoi un nouvelle tag sur le log
function sendTag(lang, t, id){       
    if (t != null && t.length > 0) {
      peticion_http = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         peticion_http = new XMLHttpRequest();
         if (peticion_http.overrideMimeType) {
            peticion_http.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            peticion_http = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               peticion_http = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }

      if (!peticion_http) {
         //alert('Cannot create XMLHTTP instance');
         alert ("Se ha producido un error al mostrar la página, seleccionela de nuevo");
      }

        // Preparar la funcion de respuesta
        //peticion_http.onreadystatechange = muestraContenido();        
        // Realizar peticion HTTP
	    var url = window.location.href;
	    var car = url.indexOf("/",8);
	    var urlfinal=url.substring(0,car+1); 

    	urlfinal = urlfinal + 'ServiciosInfo.aspx?d='+(Math.random()*100000)+'&Lang=' + lang + '&p=Q&typ=' + t + '&ref=' + id;
//         if (url.indexOf('www')!=-1)
//		    urlfinal = 'http://www.infoplus.qdq.com/ServiciosInfo.aspx?d='+(Math.random()*100000)+'&Lang=' + lang + '&p=Q&typ=' + t + '&ref=' + id;
//	     else
//		    urlfinal= 'http://infoplus.qdq.com/ServiciosInfo.aspx?d='+(Math.random()*100000)+'&Lang=' + lang + '&p=Q&typ=' + t + '&ref=' + id
        peticion_http.open('GET', urlfinal , true);        
//        peticion_http.open('GET', 'http://www.infoplus.qdq.com/ServiciosInfo.aspx?d='+(Math.random()*100000)+'&Lang=' + lang + '&p=Q&typ=' + t + '&ref=' + id , true);
        //peticion_http.open('GET', 'http://localhost/InfoplusGoogle/ServiciosInfo.aspx?d='+(Math.random()*100000)+'&Lang=' + lang + '&p=Q&typ=' + t + '&ref=' + id , true);
        peticion_http.send(null);
        function muestraContenido() {
            if(peticion_http.readyState == 4) {
                if(peticion_http.status == 200) {
                }
            }
        }
    }
}
//        alert("Entra");

//        var tag = new Image();
//        tag.src="http://www.qdq.com/scripts/anuncio.aspx?Lang=" + lang + "&p=Q&t=" + t + "&r=" + id;
        //tag.src="http://www.qdq.com/scripts/ServiciosQDQ.aspx?Lang=" + lang + "&p=Q&typ=" + t + "&r=" + id;
//        tag.src="http://www.qdq.com/scripts/ServiciosQDQ.aspx?Lang=" + lang + "&p=Q&typ=" + t + "&ref=" + id + "&origen=infogoogle";
        //tag.src="http://pc0636.indimedia.com/scripts/anuncio.aspx?Lang=" + lang + "&p=Q&t=" + t + "&r=" + id;


function pim_click()
{
    var pim = document.getElementById('ag_pim_type').value;
    var url = ag_server + '/inserter/xagent_insert.jsp?' + ag_button_params + '&pim=' + pim;
    if (navigator.appName.indexOf('Internet') == -1)
        url = ag_server + '/inserter/cards/insert_card.jsp?' + ag_button_params;
    window.open(url, "pim", "toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=yes,width=400,height=400");	
    return false;
}

function replaceAll( text, str1, str2 )
{
    var command = "text.replace(/"+str1+"/g,\""+str2+"\")";
    return eval(command);
}

function jlimpacampominus(strin) 
{
    var str1conv='ÁÀÃÂÄáàãâäÉÈÊËéèêëÌÍÎÏìíîïÒÓÔÕÖòóôõöÙÚÜÛÇÑùúüûçñ;:.\\"[](){}<>!&^%$#`\'?/-';
    var str2conv='AAAAAaaaaaEEEEeeeeIIIIiiiiOOOOOoooooUUUUCNuuuucn                          ';
    var strout='';
    

    for     (i=0; i < strin.length; i++) 
    {
        j=str1conv.indexOf(strin.charAt(i));
        if (j==-1) 
            strout=strout+strin.charAt(i);
        else 
            strout=strout+str2conv.charAt(j);
    }
    var tmp =strout.substring(0,1);
    strout = strout.toLowerCase();
    tmp = tmp.toUpperCase();
    tmp = tmp + strout.substring(1,strout.length);
    return (tmp);
}

