var ROOT_PATH = ""
var OpenCat = null;
var oOpenCat;

function DETALLE_OVER (obj) { obj.setAttribute("src",ROOT_PATH + "/img/b-detalle-over.gif"); }	 
function DETALLE_OUT (obj)  { obj.setAttribute("src",ROOT_PATH + "/img/b-detalle.gif"); }	 

function COMPRAR_OVER (obj) { obj.setAttribute("src",ROOT_PATH + "/img/b-comprar-over.gif"); }	 
function COMPRAR_OUT (obj)  { obj.setAttribute("src",ROOT_PATH + "/img/b-comprar.gif"); }	 


function showCategoria(id,parent) {
   document.mainform.frm_cat.value = id;
   document.mainform.frm_catP.value = parent;
   document.mainform.frm_subsecc.value = -1;
   document.mainform.action = ROOT_PATH  + "/index.asp";
   SubmitForm();
}

function showCesta() {
   document.mainform.action = ROOT_PATH + "/compra/show_cesta.asp";
   SubmitForm();
}

function showDetalle(id) {
   document.mainform.frm_producto.value = id;
   document.mainform.action = "detalle.asp";
   SubmitForm();
}

function ampliarFoto(id) {
   var nw = open("","fotoGrande","width=650,height=500");
       nw.focus();
   window.name="mainAQ";
   document.mainform.frm_producto.value = id;
   document.mainform.action = "detalleFoto.asp";
   document.mainform.target = "fotoGrande";

   SubmitForm();
   document.mainform.action = "detalle.asp";
   document.mainform.target = "";      
}

function comprar(id,pres) {
  document.mainform.frm_producto.value = id;
  document.mainform.frm_presentacion.value = pres;
  document.mainform.action = ROOT_PATH + "/compra/insert_cesta.asp";   
  SubmitForm();
}

function cesta_chgCant(item) {
   document.mainform.frm_item.value=item;
   document.mainform.action = ROOT_PATH + "/compra/chgCantidad.asp";
   document.mainform.submit();   
}

function cesta_delItem(item) {
   document.mainform.frm_item.value=item;
   document.mainform.action = ROOT_PATH + "/compra/delItem.asp";
   SubmitForm();
}

function seguir_compra() {
   document.mainform.action = ROOT_PATH + "/index.asp";
   document.mainform.submit();
}

var vPaso;
function goPaso(paso) {
   var oPaso;
   if (paso == vPaso) { return; }
    			  				     
   oPaso = document.getElementById("paso" + vPaso);
   oPaso.style.setAttribute("display","none");
   oPaso = document.getElementById("paso" + paso);
   oPaso.style.setAttribute("display","block");   
   
   oPaso = document.getElementById("linkpaso" + vPaso);
   oPaso.setAttribute("className","paso_off");
   oPaso = document.getElementById("linkpaso" + paso);
   oPaso.setAttribute("className","paso_on");
   
   vPaso = paso;
   
   oPaso = document.getElementById("boton_ant");
   if (vPaso > 1) { oPaso.style.setAttribute("display","block"); }	
   else           { oPaso.style.setAttribute("display","none"); }	
   
   if (vPaso == 3) {
     oPaso = document.getElementById("boton_sig");
	 oPaso.style.setAttribute("display","none");	 
	 
	 oPaso = document.getElementById("boton_conf");
	 oPaso.style.setAttribute("display","block");	
	 
   } else {
     oPaso = document.getElementById("boton_sig");
	 oPaso.style.setAttribute("display","block");	 
	 
	 oPaso = document.getElementById("boton_conf");
	 oPaso.style.setAttribute("display","none");	
   }
   
   
   document.mainform.frm_paso.value = paso; 
         
}

function movePaso(dif) { goPaso(vPaso + dif); }

function copyDataClient(o) { 
    tForm = document.mainform;
    tForm.frm_nombre_e.value    = (o.checked) ? tForm.frm_nombre_c.value     : "";
	tForm.frm_apellidos_e.value = (o.checked) ? tForm.frm_apellidos_c.value  : "";
	tForm.frm_direccion_e.value = (o.checked) ? tForm.frm_direccion_c.value  : "";
	tForm.frm_poblacion_e.value = (o.checked) ? tForm.frm_poblacion_c.value  : "";
	tForm.frm_cp_e.value        = (o.checked) ? tForm.frm_cp_c.value         : "";	   
	tForm.frm_telef_e.value     = (o.checked) ? tForm.frm_telef_c.value      : "";	   

}

function callBanco() {
   ventana = window.open("","ventanaBanco","width=620, height=560");
   document.pago.target = "ventanaBanco";
   document.pago.submit();
}




/**************************************************************/


function openDetalle(id) {
   var nw = open("","detalle","width=650,height=500");
       nw.focus();
   window.name="mainAQ";
   document.mainform.frm_producto.value = id;
   document.mainform.action = "detalle.asp";
   document.mainform.target = "detalle";

   SubmitForm();
   document.mainform.action = "index.asp";
   document.mainform.target = "";      
}


function updateProdsAdsByClick(id) {
   var obj = eval('document.mainform.frm_productoE');	
   var reg = new RegExp(id + "-*", "i");   
   if (eval(obj.length)) {
     for (i=0; i<obj.length; i++) { if (reg.test(obj[i].value)) { obj[i].checked = !obj[i].checked; } 								  }
   } else { if (reg.test(obj.value)) { obj.checked = !obj[i].checked; }
   }
   updateProdsAds();
}

function updateProdsAds() {
   document.mainform.action = ROOT_PATH + "/compra/update_cesta.asp";   
   SubmitForm();
}



function chgBlockFechas(block) {
	document.mainform.frm_block_fechas.value = block;
	document.mainform.submit();
}

/* DESDE AQUI LAS QUE NO SE HAN REVISADO */


function comprar_fdetalle() {
   document.mainform.action = "compra/insert_cesta.asp";
   SubmitForm();
}






function ckeckSelection(item,submitf) {
   var oCheck = eval("document.mainform." + item.name);
   for(i=0; i<oCheck.length; i++) { oCheck[i].checked = false; }
   item.checked = true;
   if (submitf) { SubmitForm(); }
}



function confirmCompra(form) {
  form.action = "confirm.asp";
  SubmitForm();
}
function CestaDetallada(t) {
  document.mainform.cestaDet.value = t;
  document.mainform.action = location.href;
  SubmitForm();
}
