function add_tocart(idProducto){
	var lang=document.getElementById('xlangx').value;
	if(lang=='_es'){
		we_have='Sorry, we have only ';
		you_require=" and you require ";
		please_send="  Please send us an email to  ";
		prods_added=" Product(s) Added ";
		please="Please check the quantity";
		mail="sales@cymbag.com";
	}else{
		we_have='Sorry, we have only ';
		you_require=" in stock and you require ";
		please_send=" Please send us an email to  ";
		prods_added=" Product(s) Added ";
		please="Please check the quantity";
		mail="sales@cymbag.com";
	}
	var cantoadd=document.getElementById("cantoadd").value;
	if(!(cantoadd>0)){
		alert(please);
		return false;
	}
	cantoadd=parseInt(document.getElementById("cantoadd").value);
	if (isNaN(cantoadd)) { 
            alert("Please check the quantity");
			return false;
	}	
	var http = false;
	if(navigator.appName == "Microsoft Internet Explorer") {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		http = new XMLHttpRequest();
	}		
	http.abort();
	var arch="ajax/add_to_cart.php";
	cadena=arch+"?idProducto="+idProducto+"&cant="+cantoadd;
	http.open("GET", cadena, true);
	http.onreadystatechange=function(){
		if(http.readyState == 4){
			datos=http.responseText;
			cantytot=datos.split("|");
			if(cantytot[0]=='no_hay'){
				if(cantytot.length>0) document.getElementById('added_to_cart').innerHTML="<font color='red' size='+1'>"+we_have+cantytot[1]+you_require+ cantytot[2] +"."+please_send+"<a href='mailto:"+mail+"'><font color='#EEDD23' size='+1'>"+mail+"</font></a><br></font>";
			}else{
				document.getElementById('cnt_prds').innerHTML='"'+cantytot[0]+'"';
				document.getElementById('cnt_prds1').innerHTML='"'+cantytot[0]+'"';
				document.getElementById('tot_prds').innerHTML='"'+cantytot[1]+'"';
				document.getElementById('tot_ped').innerHTML='"'+cantytot[1]+'"';
                
				
				if(cantytot.length>0) 
				{
				 document.getElementById('added_to_cart').innerHTML="<font color='green' size='+1'>"+cantoadd+prods_added+"</font>";
			 document.getElementById('tsh').style.display='none';
				 mostrar_tshirt(idProducto);
				 //document.getElementById('all_promos').innerHTML = '<meta http-equiv="refresh" content="0">';
				   //setTimeout("document.getElementById('all_promos')",3000); 
			     //setTimeout("document.getElementById('update').style.display = 'block' ",0); 
				// document.getElementById('resultados').style.display="block"; 
				}
			}
		}
	}
	http.send(null);
}

function add_tocart_promo(idProducto)
{
	
	var lang=document.getElementById('xlangx').value;
	if(lang=='_es'){
		we_have='Sorry, we have only ';
		you_require=" and you require ";
		please_send="  Please send us an email to  ";
		prods_added=" Product(s) Added ";
		please="Please check the quantity";
		mail="sales@cymbag.com";
	}else{
		we_have='Sorry, we have only ';
		you_require=" in stock and you require ";
		please_send=" Please send us an email to  ";
		prods_added=" Product(s) Added ";
		please="Please check the quantity";
		mail="sales@cymbag.com";
	}
	var cantoadd=document.getElementById("cantoadd").value;
	if(!(cantoadd>0)){
		alert(please);
		return false;
	}
	cantoadd=parseInt(document.getElementById("cantoadd").value);
	if (isNaN(cantoadd)) { 
            alert("Please check the quantity");
			return false;
	}	
	var http = false;
	if(navigator.appName == "Microsoft Internet Explorer") {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		http = new XMLHttpRequest();
	}		
	http.abort();
	var arch="ajax/add_to_cart_promo.php";
	cadena=arch+"?idProducto="+idProducto;
	http.open("GET", cadena, true);
	http.onreadystatechange=function(){
		if(http.readyState == 4){
			datos=http.responseText;
			cantytot=datos.split("|");
			if(cantytot[0]=='no_hay'){
				if(cantytot.length>0) document.getElementById('added_to_cart').innerHTML="<font color='red' size='+1'>"+we_have+cantytot[1]+you_require+ cantytot[2] +"."+please_send+"<a href='mailto:"+mail+"'><font color='#EEDD23' size='+1'>"+mail+"</font></a><br></font>";
			}else{
				document.getElementById('cnt_prds').innerHTML='"'+cantytot[0]+'"';
				document.getElementById('cnt_prds1').innerHTML='"'+cantytot[0]+'"';
				document.getElementById('tot_prds').innerHTML='"'+cantytot[1]+'"';
				document.getElementById('tot_ped').innerHTML='"'+cantytot[1]+'"';
				
				if(cantytot.length>0) 
				{
				 document.getElementById('added_to_cart').innerHTML="<font color='green' size='+1'>"+cantoadd+prods_added+"</font>";
				 document.getElementById('tsh').style.display='none';
				 mostrar_tshirt(idProducto); 
				 }
				}
			}
		}
	http.send(null);
}

function mostrar_tshirt(idproducto)
{
 var http = false;
	if(navigator.appName == "Microsoft Internet Explorer") {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		http = new XMLHttpRequest();
	}		
	http.abort();
	var arch="ajax/t_shirt.php";
	cadena=arch+"?idProducto="+idproducto;
	http.open("GET", cadena, true);
	http.onreadystatechange=function(){
		if(http.readyState == 4){
			
			document.getElementById('tshirt').innerHTML =http.responseText;
			document.getElementById('tsh').style.display='none';	 

			}
		}
	http.send(null);
}
function VentanaCentrada(theURL,winName,features, myWidth, myHeight, isCenter) 
{ //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true")
  {
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/3;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
   window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
 }

function mostrar_mis_promos()
{
    var http = false;
	if(navigator.appName == "Microsoft Internet Explorer") {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		http = new XMLHttpRequest();
	}
    var arch="ajax/pop_tshirt.php";
	http.open("GET",arch, true);
	 document.getElementById('mostrar_id').innerHTML = '<img src="images/promo_admin/ajax-loader.gif" />';
	http.onreadystatechange=function(){
		if(http.readyState == 4){
			document.getElementById('mostrar_id').innerHTML = http.responseText;
			}
		}
	http.send(null);
  	
}





