req = new Array();

function confirmar_url(url,texto)
{
	if (confirm (texto)) {self.location=url;}
}

function url_self()
{
	var text;
	
	text=location.href;
	var array_text=text.split("?");
    return array_text[0];
}

function openZoom(url,w,h)
{
  var str="height="+h+",width="+w+", toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no";
  window.open(url,"_blank",str);
}


function getAjax(url, valores, elemento, cargando) {
	 
	 //alert(valores);
	 
	 try {
     req[elemento] = new XMLHttpRequest(); /* e.g. Firefox */
     } catch(e) {
       try {
       req[elemento] = new ActiveXObject("Msxml2.XMLHTTP");  /* some versions IE */
       } catch (e) {
         try {
         req[elemento] = new ActiveXObject("Microsoft.XMLHTTP");  /* some versions IE */
         } catch (E) {
          req[elemento] = false;
         } 
       } 
     }
	
	 document.getElementById(cargando).style.display="inline";
     errorTxt = "Ocurrio un error";
     
     req[elemento].open("POST",url,true);
     req[elemento].onreadystatechange = function() {respuestaContenido(elemento, errorTxt, cargando);};
     req[elemento].setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     req[elemento].send(valores);
}

  
function respuestaContenido(elemento, errorTxt, cargando) {
   var output = '';
   var codigo_pre = new Array();
   var codigo = new Array();
   
   if(req[elemento].readyState == 4) {
   	  if(req[elemento].status == 200) {
         output = req[elemento].responseText;
         document.getElementById(cargando).style.display="none";
		 document.getElementById(elemento).innerHTML=output;
		 try { 
			 codigo_pre = req[elemento].responseText.split('<!-- JSX');	 
		 	 if(typeof(codigo_pre[1])!='undefined') codigo = codigo_pre[1].split('-->');		
			 if(typeof(codigo[0])!='undefined') eval(codigo[0]);
		 } catch (e) { } 
      }
   }
}

function desplegables(id, nivel1, nivel2, nivel3, nivel4, nivel5) {
	
	if (id != 'null') location.href="index.php?opcion=33&id_cat="+id+"&nivel1="+nivel1+"&nivel2="+nivel2+"&nivel3="+nivel3+"&nivel4="+nivel4+"&nivel5="+nivel5;
}

function pedidoPendientePago(url) {
    //var importe = prompt('Importe total que tendra que ingresar sumando gastos de envio e impuestos');
    //location.href=url+'&importe='+importe;
    document.getElementById('capa_pre').style.display = 'block';
    document.getElementById('url').value = url;
}

function enviarPrompt() {
    var url = document.getElementById('url').value;
    var importe = document.getElementById('prom').value;
	var marc = document.getElementById('marc').value;
	var pet = url+'&importe='+importe+'&marc='+marc;
	//alert(marc);
	location.href=pet;
}

function insertarCookie(nombre, valor, tiempo) {
	var exp = new Date();
	exp.setTime(exp.getTime() + (tiempo*24*60*60*1000));
    document.cookie = nombre + "=" + valor + ";expires=" + exp +";path=/";
}

function clearInfo() {
    document.getElementById('info_login_desactivado').style.display='none';
    document.getElementById('info_login').style.display='none';
}

function limpiarPrompt() {
    document.getElementById('prom').value = '';
    document.getElementById('capa_pre').style.display = 'none';
    document.getElementById('url').value = '';
}