function DeactivateCode(codeId)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var timestamp = new Date().getTime();
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==1)
		document.getElementById(codeId+'_state').innerHTML='Desactivando...';
	
		if(xmlhttp.readyState==4)
		{		document.getElementById(codeId+'_state').innerHTML=xmlhttp.responseText;

xmlhttp = false;
}
	}
	xmlhttp.open("GET",deactivateCodeTarget+"?id="+codeId+"&anti-cache=" + timestamp,true);
	xmlhttp.send(null);


}

function GenerateInvoice(id)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var timestamp = new Date().getTime();
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==1)
		document.getElementById('invoiceResult').innerHTML='Generando...';
	
		if(xmlhttp.readyState==4)
		{		document.getElementById('invoiceResult').innerHTML=xmlhttp.responseText;
xmlhttp = false;
}
	}
	xmlhttp.open("GET",generateInvoiceTarget+"?order-id="+id+"&anti-cache=" + timestamp,true);
	xmlhttp.send(null);


}


function UpdateOrder(id, name, value)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var timestamp = new Date().getTime();
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==1)
		document.getElementById('orderStatusUpdate').innerHTML='...';
	
		if(xmlhttp.readyState==4)
		{		document.getElementById('orderStatusUpdate').innerHTML=xmlhttp.responseText;
xmlhttp = false;
}
	}
	xmlhttp.open("GET",orderUpdateTarget+"?id="+id+"&name="+name+"&value="+value+"&anti-cache=" + timestamp,true);
	xmlhttp.send(null);


}


function DecryptCard(encrypted,num)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

	var timestamp = new Date().getTime();
	xmlhttp.onreadystatechange=function()
	{
		if(xmlhttp.readyState==1)
		{
		document.getElementById('cardNumber'+num).innerHTML='....';
		}
	
		if(xmlhttp.readyState==4)
		{
			document.getElementById('cardNumber'+num).innerHTML=xmlhttp.responseText;
			xmlhttp = false;
		}
	}
	xmlhttp.open("GET",decryptionTarget+"?encstring="+encrypted+"&anti-cache=" + timestamp,true);
	xmlhttp.send(null);


}

function AddToBasket(id, amount, extras)
{
var shown = false;
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var timestamp = new Date().getTime();
	xmlhttp.onreadystatechange=function()
	{
		
		if(xmlhttp.readyState==1)
		{
			if (shown == false)
				shown = $("#shoppingBasket").is(":visible");
			//document.getElementById('miniCesta').innerHTML='Cargando...';
		}
	
		if(xmlhttp.readyState==4)
		{
			document.getElementById('miniCesta').innerHTML=xmlhttp.responseText;
			if (shown)
			{
				$("#shoppingBasket").show();
                                $(".detallesCesta").text("Ocultar detalles");
				shown == false;
			}
				
			
			$(".detallesCesta").click(basketClick);
			xmlhttp = false;
		}
	}
	xmlhttp.open("GET",basketTarget+"?id="+id+"&extras="+extras+"&cantidad="+amount+"&anti-cache=" + timestamp,true);
	xmlhttp.send(null);


}

function UpdateBasketQuantities(quantities)
{
var shown = false;
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var timestamp = new Date().getTime();
	xmlhttp.onreadystatechange=function()
	{
		
		if(xmlhttp.readyState==1)
		{
			//if (shown == false)
			//	shown = $("#shoppingBasket").is(":visible");
			//document.getElementById('miniCesta').innerHTML='Cargando...';
		}
	
		if(xmlhttp.readyState==4)
		{
			document.getElementById('cestaCompleta').innerHTML=xmlhttp.responseText;
			RemoveFromBasketCallback(xmlhttp.responseText);
blink('precioTotal');
			xmlhttp = false;
		}
	}
	xmlhttp.open("GET",basketUpdateTarget+"?update="+quantities+"&anti-cache=" + timestamp,true);
	xmlhttp.send(null);


}


function RemoveFromBasket(id)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var timestamp = new Date().getTime();
	xmlhttp.onreadystatechange=function()
	{
		//if(xmlhttp.readyState==1)
		//document.getElementById('miniCesta').innerHTML='Cargando...';
	
		if(xmlhttp.readyState==4)
		{		
			document.getElementById('miniCesta').innerHTML=xmlhttp.responseText;
			if (xmlhttp.responseText.indexOf('EMPTY') > -1)
			  $('#shoppingBasket').hide();
			else
			$('#shoppingBasket').show();

			$(".detallesCesta").click(basketClick);
                        $(".detallesCesta").text("Ocultar detalles");

//RemoveFromBasketCallback(xmlhttp.responseText);
xmlhttp = false;
}
	}
	xmlhttp.open("GET",basketRemoveTarget+"?id="+id+"&anti-cache=" + timestamp,true);
	xmlhttp.send(null);


}

function RemoveFromBasket1(id)
{
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var timestamp = new Date().getTime();
	xmlhttp.onreadystatechange=function()
	{
		//if(xmlhttp.readyState==1)
		//document.getElementById('cestaCompleta').innerHTML='Cargando...';
	
		if(xmlhttp.readyState==4)
		{		
			document.getElementById('cestaCompleta').innerHTML=xmlhttp.responseText;
			RemoveFromBasketCallback(xmlhttp.responseText);
			xmlhttp = false;
}
	}
	xmlhttp.open("GET",basketRemoveTarget+"?id="+id+"&anti-cache=" + timestamp,true);
	xmlhttp.send(null);


}


function RemoveFromBasketCallback(content)
{
  if (content.indexOf("REDIRECT") > -1)
    window.location.href=homePageURL;
}