
var tipo_papel;var imagen_actual_mediana;var posx;var posy;var strComparar="";var intSKU=0;var imagen_actual_mediana;document.onclick=GetMousePosition;$(document).ready(function(){ResolutionSet();});function ResolutionSet(){w=$(window).width();h=$(window).height();$.post("i_browser_ajax.asp",{w:w,h:h},function(data){});}
function GetMousePosition(e)
{if(!e)var e=window.event;if(e.pageX||e.pageY)
{posx=e.pageX;posy=e.pageY;}
else if(e.clientX||e.clientY)
{posx=e.clientX+document.body.scrollLeft;posy=e.clientY+document.body.scrollTop;}}
function SolicitudPersonalizacion(sku){if(sku!=""){var url="solicitud_pers.asp";$.post(url,{ajax:"S",sku:sku},function(data){data=unescape(data);});}}
function WinOpen(strArchivo,strVentana,strPropiedades)
{a=window.open(strArchivo,strVentana,strPropiedades);}
function valNumerico(evento){evento=window.event?evento.keyCode:evento.which;if((evento==46||evento==8||evento==9)||(evento>34&&evento<41)||(evento>47&&evento<58)||(evento>95&&evento<106)||(evento>=112&&evento<=123)){return true;}else{return false;}}
function Set_Cookie(name,value,expires,path,domain,secure)
{var today=new Date();today.setTime(today.getTime());if(expires)
{expires=expires*1000*60*60*24;}
var expires_date=new Date(today.getTime()+(expires));document.cookie=name+"="+escape(value)+
((expires)?";expires="+expires_date.toGMTString():"")+
((path)?";path="+path:"")+
((domain)?";domain="+domain:"")+
((secure)?";secure":"");}
function Get_Cookie(check_name){var a_all_cookies=document.cookie.split(';');var a_temp_cookie='';var cookie_name='';var cookie_value='';var b_cookie_found=false;for(i=0;i<a_all_cookies.length;i++)
{a_temp_cookie=a_all_cookies[i].split('=');cookie_name=a_temp_cookie[0].replace(/^\s+|\s+$/g,'');if(cookie_name==check_name)
{b_cookie_found=true;if(a_temp_cookie.length>1)
{cookie_value=unescape(a_temp_cookie[1].replace(/^\s+|\s+$/g,''));}
return cookie_value;break;}
a_temp_cookie=null;cookie_name='';}
if(!b_cookie_found)
{return null;}}
function Delete_Cookie(name,path,domain){if(Get_Cookie(name))document.cookie=name+"="+
((path)?";path="+path:"")+
((domain)?";domain="+domain:"")+";expires=Thu, 01-Jan-1970 00:00:01 GMT";}
function CallMe(){var url="callme.asp";$.post(url,{ajax:"S",h:h},function(data){data=unescape(data);alert(data);});}
function cambia_cmbMarca(equipo_id){if(equipo_id!=""){var url="/i_insumos_ajax.asp";$.post(url,{equipo_id:equipo_id},function(data){var divInsumos=document.getElementById("divInsumos");if(divInsumos!=null){divInsumos.style.visibility="hidden";}
var cmbMarca=document.getElementById("cmbMarca");while(cmbMarca.length>1){cmbMarca.options[1]=null;}
var cmbModelo=document.getElementById("cmbModelo");if(cmbModelo!=null){while(cmbModelo.length>1){cmbModelo.options[1]=null;}}
var arrRegistros=data.split("#");if(arrRegistros.length>0){for(var i=0;i<arrRegistros.length;i++){var arrItem=arrRegistros[i].split("|");if(arrItem[0]!=""){oOption=new Option(arrItem[1],arrItem[0]);try{cmbMarca.add(oOption,null);}catch(ex){cmbMarca.add(oOption);}}}}});}}
function cambia_cmbModelo(marca_id){if(marca_id!=""){var url="/i_insumos_ajax.asp";$.post(url,{marca_id:marca_id},function(data){var cmbModelo=document.getElementById("cmbModelo");var divInsumos=document.getElementById("divInsumos");if(divInsumos!=null){divInsumos.style.visibility="hidden";}
while(cmbModelo.length>1){cmbModelo.options[1]=null;}
var arrRegistros=data.split("#");if(arrRegistros.length>0){for(var i=0;i<arrRegistros.length;i++){var arrItem=arrRegistros[i].split("|");if(arrItem[0]!=""){oOption=new Option(arrItem[1],arrItem[0]);try{cmbModelo.add(oOption,null);}catch(ex){cmbModelo.add(oOption);}}}}});}}
function ShowRecordatorios(){var div=document.getElementById("divRecordatoriosmail");if(div.style.display=="inline"){div.style.display="none";div.style.visibility="hidden";}else{div.style.display="inline";div.style.visibility="visible";}}
function ShowAvisoStock(){var div=document.getElementById("divAvisoStock");if(div.style.display=="inline"){div.style.display="none";div.style.visibility="hidden";}else{div.style.display="inline";div.style.visibility="visible";}}
function autorizar_pedido()
{document.getElementById("btnAutorizar").value="S";document.frmAutorizar.submit();}
function cancelar_pedido()
{document.getElementById("btnCancelar").value="S";document.frmAutorizar.submit();}
function limpiar()
{document.getElementById("txtPregNueva").value="";}
function ShowRecomendar()
{var div=document.getElementById("divRecomendarProduct");if(div.style.display=="inline"){div.style.display="none";}else{div.style.display="inline";}}
function Pasar_imagen(archivo)
{document.images["producto_g"].src='images/p/'+archivo+'.jpg';imagen_actual_mediana=archivo;}
function Pasar_imagen_autos(archivo)
{document.images["producto_g"].src='images/'+archivo+'.jpg';}
function Pasar_imagen_original()
{document.images["producto_g"].src='images/10_27_landing_auto1g.jpg';}
function SolapaContenicoFaq(div)
{if(document.getElementById(div).style.display=="inline")
{document.getElementById(div).style.display="none";document.getElementById('ver_pregunta').style.display="Inline";document.getElementById('ocultar_pregunta').style.display="none";document.getElementById("boton_minimizar").style.display='none';}
else
{document.getElementById(div).style.display="inline";document.getElementById('ver_pregunta').style.display="none";document.getElementById('ocultar_pregunta').style.display="inline";document.getElementById("boton_minimizar").style.display='inline';}}
function SolapaContenicoTec(nombrediv)
{if(document.getElementById(nombrediv).style.display=="inline")
{document.getElementById("ver_tecnicas").innerHTML='Ver notas tecnicas'
document.getElementById(nombrediv).style.display="none";}
else
{document.getElementById("ver_tecnicas").innerHTML='Ocultar notas tecnicas'
document.getElementById(nombrediv).style.display="inline";document.getElementById("boton_minimizar").style.display='inline';}}
function SolapaPrincipal(nombrediv)
{document.getElementById("boton_minimizar").style.display='inline';if(nombrediv=="especificaciones")
{document.getElementById("prod_bkg_con_b").style.display='inline';document.getElementById("prod_bkg_sin_b").style.display='none';document.getElementById("info_faq").style.display='none';document.getElementById("prod_Tec").style.display='inline';}
else
{if(document.getElementById('ver_pregunta')!=null)
{document.getElementById('ver_pregunta').style.display="none";document.getElementById('ocultar_pregunta').style.display="inline";}
document.getElementById("prod_bkg_sin_b").style.display='inline';document.getElementById("prod_bkg_con_b").style.display='none';document.getElementById("prod_Tec").style.display='none';document.getElementById("info_faq").style.display='inline';document.getElementById("info_preguntas_frecuentes").style.display='inline';}
document.getElementById("Tec_mas_tec").style.display='none';}
function minimizar(codigo)
{document.getElementById("boton_minimizar").style.display='none';if(codigo==2)
{if(document.getElementById("prod_bkg_con_b").style.display=='inline'||document.getElementById("prod_Tec").style.display=='')
{document.getElementById("prod_Tec").style.display='none';document.getElementById("prod_Tec").style.position='relative';document.getElementById("Tec_mas_tec").style.display='inline';document.getElementById("ver_tecnicas").innerHTML='Ver notas tecnicas'}
else
{document.getElementById("info_preguntas_frecuentes").style.display="none";document.getElementById('ver_pregunta').style.display="Inline";document.getElementById('ocultar_pregunta').style.display="none";}}
else
{document.getElementById("info_preguntas_frecuentes").style.display="none";document.getElementById('ver_pregunta').style.display="Inline";document.getElementById('ocultar_pregunta').style.display="none";}}
function abrirImagenGrande(strSKU,strName)
{WinOpen('product_ampliar.asp?'+'sku='+imagen_actual_mediana,'ProductAmpliar','width=540,height=600,left=158,top=1,screenX=0,screenY=00,resizable=Yes,scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=yes')}
function abrirInfoProductTiendas(tiendas)
{WinOpen('info_tiendas_stock.asp?'+'tiendas='+tiendas,'ProductAmpliar','width=680,height=700,left=158,top=4,screenX=0,screenY=00,resizable=Yes,scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=yes')}
function AbrirComoLLegar(tienda)
{alert(document.getElementById("direccion").innerHTML);WinOpen('como_llegar_tienda.asp?'+'tiendas='+tiendas+'&direccion='+document.getElementById("direccion").innerHTML,'ProductAmpliar','width=680,height=700,left=158,top=4,screenX=0,screenY=00,resizable=Yes,scrollbars=yes, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=yes')}
function imprime_boleto(strLink)
{window.open(strLink,"Boleto","left=0,top=0,height=500,width=700,status=no,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=yes");}
function imprimir(numero)
{var url="receipt_imprimir.asp?numero="+numero;var a=window.open(url,null,"LOCATION=no,TOOLBAR=no,DIRECTORIES=no,MENUBAR=no,SCROLLBARS=yes,RESIZABLE=no");}
function generaExcel()
{document.getElementById("strExcel").value="S";document.getElementById("frm").submit();}
function Setea_accion(accion)
{document.getElementById("tipo_accion").value=accion;document.formacciones.submit();}
function marca_hit(word)
{var url="similar_hit.asp";$.post(url,{strWord:word},function(data){});}
function seleccion_comparar(objChk,strSKU)
{if(!objChk.checked){strComparar=replaceString(strComparar,strSKU+",","");intSKU--;}else if(intSKU==4){alert("Debe seleccionar como máximo 4 artículos para comparar");objChk.checked=false;}else{strComparar+=strSKU+",";intSKU++;}}
function replaceString(sString,sReplaceThis,sWithThis){if(sReplaceThis!=""&&sReplaceThis!=sWithThis){var counter=0;var start=0;var before="";var after="";while(counter<sString.length){start=sString.indexOf(sReplaceThis,counter);if(start==-1){break;}else{before=sString.substr(0,start);after=sString.substr(start+sReplaceThis.length,sString.length);sString=before+sWithThis+after;counter=before.length+sWithThis.length;}}}
return sString;}
function control_comparar()
{if(intSKU<2){alert("Debe seleccionar como mínimo 2 artículos para comparar");}else{document.location.href="comparar.asp?chkSKU="+strComparar;}}
function imprime_boleto(strLink)
{window.open(strLink,"Boleto","left=0,top=0,height=500,width=700,status=no,toolbar=no,menubar=yes,location=no,scrollbars=yes,resizable=yes");}
function CierreCompra()
{document.frmBasket.target.value="cierre_compra.asp";document.frmBasket.submit();}
function CierreCompraSplit(strUns)
{document.frmBasket.target.value="xt_orderform_split.asp";document.frmBasket.uns.value=strUns;document.frmBasket.submit();}
function CambiaAnio(equipo,anio){var url="mis_maquinas_anio_ajax.asp";$.post(url,{modelo_id:equipo,anio:anio},function(data){});}
function AvisoStockOpen(sku){document.frmAvisoStock.txtAvisoStockSKU.value=sku;document.frmAvisoStock.submit();return;var div=document.getElementById("divAvisoStock");div.style.position="absolute";div.style.left=posx-200;div.style.top=posy;div.style.display="inline";div.style.visibility="visible";document.frmAvisoStock.txtAvisoStockSKU.value=sku;}
function AvisoStockClose(){var div=document.getElementById("divAvisoStock");div.style.position="absolute";div.style.left=posx-200;div.style.top=posy;div.style.visibility="hidden";div.style.display="none";document.frmAvisoStock.txtAvisoStockSKU.value="";}
function BannersCarga(){if(typeof ClickTaleExec=='function')ClickTaleExec("BannersCarga()");ResolutionSet();var url="default_banners.asp";$.post(url,{},function(data){$('#banners').html(data);});}
function BorrarCodigo(intI){eval("document.frmRapidoCodigo.qty"+intI+".value = ''");eval("document.frmRapidoCodigo.sku"+intI+".value = ''");document.getElementById("divVal"+intI).innerHTML="";document.getElementById("divSustituto"+intI).innerHTML="";document.getElementById("divAccion"+intI).innerHTML="";document.getElementById("divAccion"+intI).innerHTML="";document.getElementById("divPrecio"+intI).innerHTML="";}
function ValidaProductos(){document.frmRapidoCodigo.accion.value='mas productos';document.frmRapidoCodigo.submit();}
function Mas_productos(){document.frmRapidoCodigo.ProdCant.value='30';document.frmRapidoCodigo.submit();}
function cambia_cmbformato(papel_id,gramaje_id){tipo_papel=papel_id
if(document.getElementById("formato_id_"+papel_id).value=="0")
{if(papel_id!=""){var url="i_papel_ajax.asp";$.post(url,{papel_id:papel_id,gramaje_id:gramaje_id},function(data){var divResultado=document.getElementById("divResultado");if(divResultado!=null){divResultado.style.visibility="hidden";}
var formato_id_=document.getElementById("formato_id_"+tipo_papel);if(formato_id_!=null){while(formato_id_.length>1){formato_id_.options[1]=null;}}
var arrRegistros=res.split("#");if(arrRegistros.length>0){for(var i=0;i<arrRegistros.length;i++){var arrItem=arrRegistros[i].split("|");if(arrItem[0]!=""){oOption=new Option(arrItem[1],arrItem[0]);try{formato_id_.add(oOption,null);}catch(ex){formato_id_.add(oOption);}}}}});}}}
function cambia_cmbformato_Process(){var res;if(res=ajax_handler()){}}
function cambia_cmbGramaje(papel_id,formato_id){tipo_papel=papel_id;if(document.getElementById("gramaje_id_"+tipo_papel).value=="0")
{if(papel_id!=""){if(formato_id==15){document.getElementById("gramaje_id_"+papel_id).style.display="inline";}
if(formato_id==17){document.getElementById("gramaje_id_"+papel_id).style.display="none";}
if(formato_id==16){document.getElementById("gramaje_id_"+papel_id).style.display="none";}
var url="i_papel_ajax.asp";$.post(url,{papel_id:papel_id,formato_id:formato_id},function(data){var divResultado=document.getElementById("divResultado");if(divResultado!=null){divResultado.style.visibility="hidden";}
var gramaje_id=document.getElementById("gramaje_id_"+tipo_papel);if(gramaje_id!=null){while(gramaje_id.length>1){gramaje_id.options[1]=null;}}
var arrRegistros=data.split("#");if(arrRegistros.length>0){for(var i=0;i<arrRegistros.length;i++){var arrItem=arrRegistros[i].split("|");if(arrItem[0]!=""){oOption=new Option(arrItem[1],arrItem[0]);try{gramaje_id.add(oOption,null);}catch(ex){gramaje_id.add(oOption);}}}}});}}}

function buscador_papel_tamano(tipo_id) {
	$.post("i_buscador_papel_ajax.asp", { tipo_id: tipo_id},
	function(data){
		$('#cmbTamano').children().remove();
		$('#cmbTamano').append("<option value=''>Tamaño</option>");
		$('#cmbTamano').append(data);
	});
}

function buscador_papel_gramaje(formato_id) {
	var tipo_id = $('#cmbTipo').val();
	if(formato_id!="") {
		$.post("i_buscador_papel_ajax.asp", { tipo_id: tipo_id, formato_id: formato_id},
		function(data){
			$('#cmbGramaje').children().remove();
			$('#cmbGramaje').append("<option value=''>Gramaje</option>");
			$('#cmbGramaje').append(data);
		});
	}
}

