
function nuevoAjax(){ 
  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 numeros(e) {
tecla = (document.all) ? e.keyCode : e.which;
if (tecla==8) return true;
patron = /[0-9]/; 
te = String.fromCharCode(tecla);
return patron.test(te);
}



function cesta(){

obj=document.getElementById("cesta");
obj.innerHTML = "cargando.....";
ajax=nuevoAjax(); 				
    ajax.open("POST", "cesta.php",true);
	ajax.onreadystatechange=function() { 
    if (ajax.readyState==4) { 
	 if (ajax.status==200){
   obj.innerHTML = ajax.responseText;
  
     } 
  }
}

ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send();
}

function borrar_cesta (p,t) {
  if (confirm('Desea Borrar?')){ 
		location.replace('borrar_cesta.php?id='+p+'&t='+t);
    }
}


function login(donde){
ajax=nuevoAjax(); 				
    ajax.open("POST", "login.php",true);
	ajax.onreadystatechange=function() { 
    if (ajax.readyState==4) { 
	 if (ajax.status==200){
        if(ajax.responseText=='N'){
			$('#popupe').show();
		    $.fn.colorbox({'href':'#popupe', 'open':true, 'inline':true, 'width':'300px', 'height':'240px'});
			} else {
			location.replace('index.php?p=mis_datos'+donde);
		}
     } 
  }
}

ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("email="+document.form2.email.value+"&pass="+document.form2.pass.value);
}


function convertir2(){
ctrl = document.form_c.radio;
if(document.form_c.convertir.value==''){alert('Debe cargar sus puntos');} else {
var c = '';	
for(i=0;i<ctrl.length;i++){if(ctrl[i].checked){c=ctrl[i].value;}}
if(c!=''){puntos(c,document.form_c.convertir.value);} else {alert('Debe tildar una empresa');}
}
}

function puntos(id_c,puntos){

document.form_c.puntos.value = "cargando.....";
ajax=nuevoAjax(); 				
    ajax.open("POST", "puntos.php",true);
	ajax.onreadystatechange=function() { 
    if (ajax.readyState==4) { 
	 if (ajax.status==200){
   document.form_c.puntos.value = ajax.responseText;
  
     } 
  }
}

ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
ajax.send("id_compania="+id_c+"&puntos="+puntos);
}

function borrar_cesta (p,t) {
  if (confirm('Desea Borrar?')){ 
		location.replace('borrar_cesta.php?id='+p+'&t='+t);
		
    }
}
