////////////////////////////////////////////////////////////////////////////////
//  FUNCIONES INCLUIDAS EN EL ROLLOVER.JS DE LA NUEVA CESTA ////////////////////
////////////////////////////////////////////////////////////////////////////////

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}
/////////////////////////////////////////////////////////////////////////////
// INCLUIDAS EN EL BOX DE LA CESTA //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
function decrement(index) {
 if(document.forms["cart_box"].elements["cart_quantity[]"][index].value >1) {
   document.forms["cart_box"].elements["cart_quantity[]"][index].value--;
   document.cart_box.submit();
 }
}

function increment(index) {
//	alert(index);
   document.forms["cart_box"].elements["cart_quantity[]"][index].value++;
   document.cart_box.submit();
}

function mark(pid) {
   document.forms["remove_product"].elements["cart_delete[]"][0].value=pid;
   document.forms["remove_product"].elements["products_id[]"][0].value=pid;
   document.remove_product.submit();
}

//var sURL = document.URL.toString();
//if (sURL.indexOf("?") > 0){
// urlsplitter = '';
//} else {
// urlsplitter = '?';
//}
//document.write('<form ');
//document.write(' name="remove_product" ');
//document.write(' action="' + document.URL + urlsplitter + '&action=update_product"');
//document.write(' method="post">');
//one element is not an array so add 2 of each!
//document.write('<input type="hidden" name="products_id[]">');
//document.write('<input type="hidden" name="cart_delete[]">');
//document.write('<input type="hidden" name="products_id[]">');
//document.write('<input type="hidden" name="cart_delete[]">');
//document.write('</form>');

//document.write('<form ');
//document.write(' name="cart_box" ');
//document.write(' action="' + document.URL + urlsplitter + '&action=update_product"');
//document.write(' method="post">');
/////////////////////////////////////////////////////////////////////////////
// originalmente en el body onload de la nueva cesta ////////////////////////
/////////////////////////////////////////////////////////////////////////////
MM_preloadImages('images/btn-up.gif','images/btn-dn.gif','images/btn-up-ov.gif', 'images/btn-dn-ov.gif');


/////////////////////////////////////////////////////////////////////////////
// scripts para el doble desplegable ////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
var url = "/includes/boxes/busqueda_desplegables.php?categoria=";
var destinocategoria = "http://www.ibericosdelicatessen.com/index.php?cPath=";
var destinocombo = '';


function handleHttpResponse() {
        if (http.readyState == 4) {
        	if (http.responseText!='') {
        document.getElementById(destinocombo).innerHTML=http.responseText;
		
			}
		 }
        }
        
function recarga(combo, categoria, idioma) {
	destinocombo=combo;
    var myRandom=parseInt(Math.random()*99999999);  // para el cache
    http.open("GET", url + categoria + "&lenguaje="+idioma+"&rand=" + myRandom, true);
    http.onreadystatechange = handleHttpResponse;
    http.send(null);
		
}
        
        
function getHTTPObject() {
        var xmlhttp;
        /*@cc_on
         @if (@_jscript_version >= 5)
          try {
              xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
              } catch (e) {
              try {
                  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (E) {
                  xmlhttp = false;
                  }
              } 
         @else
          xmlhttp = false;
         @end @*/
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
         try {
           xmlhttp = new XMLHttpRequest();
           } catch (e) {
           xmlhttp = false;
           }
          }
          return xmlhttp;
        }

function muestracategoria() {
	var categoria;
	categoria = document.getElementById("subcategorias").options[document.getElementById("subcategorias").selectedIndex].value;
	window.location = destinocategoria+categoria;
}

function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

// inicializando
var http = getHTTPObject(); // Objeto HTTP para el ajax