/** XHConn - Simple XMLHTTP Interface - bfults@gmail.com - 2005-04-08        **
 ** Code licensed under Creative Commons Attribution-ShareAlike License      **
 ** http://creativecommons.org/licenses/by-sa/2.0/                           **/
function XHConn()
{
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone)
  {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);

        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
} 


/*---------------------------[Switch imagenes]*/

function muestra_estrella(num){
	for(i=1;i<6;i++)
		document.getElementById('img_'+i).src = '/images/cnx/web/valorar_0.gif';

	for(i=1;i<=num;i++)
		document.getElementById('img_'+i).src = '/images/cnx/web/valorar_1.gif';
		
}

function oculta_estrella(valor){
	for(i=1;i<6;i++)
		document.getElementById('img_'+i).src = '/images/cnx/web/valorar_0.gif';

	for(i=1;i<=valor;i++)
		document.getElementById('img_'+i).src = '/images/cnx/web/valorar_1.gif';
}

/*---------------------------[Switch imagenes]*/



/*---------------------------[Valoracion articulo]--*/

function valorar_articulo(id_articulo,valor){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP no esta disponible. Inténtalo con un navegador más nuevo.");
	//var peticion = function (oXML) {  document.getElementById('galeria').innerHTML = oXML.responseText; };
	//var peticion = function (oXML) {};
	var peticion = function (oXML) {  document.getElementById('estrellas').innerHTML = oXML.responseText; };
	myConn.connect("/3.0/back/valorar_articulo.php" , "GET", 'id_articulo='+id_articulo+'&valor='+valor, peticion );
}

/*---------------------------[ / Valoracion articulo]--*/


/*---------------------------[Feedback]--*/

function envia_comentario(){
/*	document.getElementById('comentarios').innerHTML = '<p><span style="font-weight: bold;line-height:21px; border:#ffffff solid 2px;cursor:wait;background-color:#FF0000;FONT-SIZE: 12pt; COLOR: #FFFFFF;">ingresando comentario...</span></p> ';*/
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP no esta disponible. Inténtalo con un navegador más nuevo.");
	var peticion = function (oXML) {  document.getElementById('contenido').innerHTML = oXML.responseText; };
	myConn.connect("/3.0/back/envia_feedback.php" , 'POST', 'feedback=1&feedback_nombre='+document.getElementById('feedback_nombre').value+"&feedback_email="+document.getElementById('feedback_email').value+"&feedback_empresa="+document.getElementById('feedback_empresa').value+"&feedback_pais="+document.getElementById('feedback_pais').value+"&feedback_comentario="+document.getElementById('feedback_comentario').value+"&feedback_content="+document.getElementById('feedback_content').value, peticion);
	/*document.getElementById('form_nombre').value='';
	document.getElementById('form_mensaje').value='';*/
	 document.getElementById('contenido').style["display"]="block";
}
/*---------------------------[Feedback]--*/



/*---------------------------[buscar tags]--*/

function busca_tag(region){
	var text=document.getElementById('busca_tag').value;
	 window.location="/latam/"+region+"/tag/"+text;
}


/*---------------------------[ / buscar tags]--*/



/*---------------------------[enviar x mail]--*/
function envia_x_mail(){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP no esta disponible. Inténtalo con un navegador más nuevo.");
	var peticion = function (oXML) {  document.getElementById('contenido').innerHTML = oXML.responseText; };
	myConn.connect("/3.0/back/envia_x_mail.php" , 'POST', 'mail=1&mail_content='+document.getElementById('mail_content').value+"&mail_lang="+document.getElementById('mail_lang').value+"&mail_region="+document.getElementById('mail_region').value+"&de_nombre="+document.getElementById('de_nombre').value+"&para_email="+document.getElementById('para_email').value, peticion);
	 document.getElementById('contenido').style["display"]="block";
}
/*---------------------------[enviar x mail]--*/


/*---------------------------[enviar x mail]--*/
function recuperar_pass(){
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP no esta disponible. Inténtalo con un navegador más nuevo.");
	var peticion = function (oXML) {  document.getElementById('contenido').innerHTML = oXML.responseText; };
	myConn.connect("/3.0/back/form_olvido_pass.php" , 'POST', 'pass=1&pass_lang='+document.getElementById('pass_lang').value+"&pass_email="+document.getElementById('pass_email').value, peticion);
	 document.getElementById('contenido').style["display"]="block";
}
/*---------------------------[enviar x mail]--*/

/*---------------------------[escribe resolucion de pantalla]--*/

function writescreen(){
	var today = new Date();
	var the_date = new Date("December 31, 2023");
	var the_cookie_date = the_date.toGMTString();
	var the_cookie = "resolution="+screen.width +"-"+ screen.height;
	var the_cookie = the_cookie + ";expires=" + the_cookie_date + ";path=/";
	document.cookie=the_cookie
} 

writescreen();

/*---------------------------[escribe resolucion de pantalla]--*/

