function getStrVal(o,def){return(o!=null&&o!="")?o:def}function getIntVal(o,def){return(o!=null&&o!="")?parseInt(o):def}function getFloVal(o,def){return(o!=null&&o!="")?parseFloat(o):def}function selFocus(p_control){p_control.focus();p_control.select()}$(function(){keepAlive();gl_html.$contenedorAlert.dialog({autoOpen:false,modal:true,width:400,open:function(event,ui){}})});var timeoutKeepAlive=null;function keepAlive(){$.ajax({type:"get",url:gl_conf.rootpath+"general/keepAlive",cache:false,dataType:"text",success:function(data){if(timeoutKeepAlive!=null){clearTimeout(timeoutKeepAlive);timeoutKeepAlive=null}timeoutKeepAlive=setTimeout("keepAlive();",data)},error:function(msg){showAlertError(gl_txt.errErrorEnWeb)}})}function txtInt_keypress(e){var keyCode=(e.keyCode?e.keyCode:e.which);if((keyCode>=48&&keyCode<=57)||(keyCode==8||keyCode==9||keyCode==37||keyCode==39||keyCode==13)){}else{e.preventDefault()}}function txtFloat_keypress(e){var keyCode=(e.keyCode?e.keyCode:e.which);if((keyCode>=48&&keyCode<=57)||(keyCode==8||keyCode==44||keyCode==9||keyCode==37||keyCode==39)){}else{e.preventDefault()}}function txtInt_keydown(e){if(e.ctrlKey){e.originalEvent.returnValue=false}}function toInt(num){var res=parseInt(num);if(isNaN(res)){return 0}return res}function validarCamposObligatorios(p_arrControles){var arrCamposVacios=[];for(var i=0;i<p_arrControles.length;i++){var control=p_arrControles[i];if(control.tipo=="str"){if(control.obj.val()==""){arrCamposVacios.push(control)}}else{if(control.tipo=="int"){if(control.obj.val()==-1){arrCamposVacios.push(control)}}else{if(control.tipo=="lista"){if(control.intNumItems==0){arrCamposVacios.push(control)}}}}}return arrCamposVacios}function string2js(text){return text.replace(/\\/g,"\\\\").replace(/\'/g,"\\'").replace(/\"/g,'\\"')}function toBold(p_texto){return"<b>"+p_texto+"</b>"}function enableControl(p_enabled,p_control){p_control.attr("disabled",(p_enabled)?"":"disabled")}function showAlertInfo(p_mensage){gl_html.$contenedorAlert.html(getHtmlAlertInfo(p_mensage));openAlert()}function showAlertError(p_mensage){gl_html.$contenedorAlert.html(getHtmlAlertError(p_mensage));openAlert()}function getHtmlAlertInfo(p_mensaje){return resultado='<div class="modulo aviso"><div class="popup-aviso"><p><strong>{0}</strong><br />{1}</p><div class="botoneria"><input type="button" value="{2}" onclick="closeAlert()" /></div></div></div>'.replace("{0}",gl_txt.litAviso).replace("{1}",p_mensaje).replace("{2}",gl_txt.litOk)}function getHtmlAlertConfirm(p_mensaje){return resultado='<div class="modulo aviso"><div class="popup-aviso"><p><strong>{0}</strong><br />{1}</p><div class="botoneria"><input type="button" value="{2}" /><input type="button" value="{3}" /></div></div></div>'.replace("{0}",gl_txt.litAviso).replace("{1}",p_mensaje).replace("{2}",gl_txt.litSi).replace("{3}",gl_txt.litNo)}function getHtmlAlertError(p_mensaje){return resultado='<div class="modulo error"><div class="popup-error"><p><strong>{0}</strong><br />{1}</p><div class="botoneria"><input type="button" value="{2}" onclick="closeAlert()" /></div></div></div>'.replace("{0}",gl_txt.litError).replace("{1}",p_mensaje).replace("{2}",gl_txt.litOk)}function openAlert(){gl_html.$contenedorAlert.dialog("open")}function closeAlert(){gl_html.$contenedorAlert.dialog("close")}function getMaxSizeModal(){var $window=$(window);var wWidth=$window.width();var wHeight=$window.height();var maxWidth=wWidth-100;if(maxWidth<800){maxWidth=800}var maxHeight=wHeight-100;if(maxHeight<400){maxHeight=400}return{height:maxHeight,width:maxWidth}}function deseleccionarOpcionesMenuCabecera(){var $lis=$("li.menuCabecera",gl_html.$cabecera);var claseActual;var $li;$lis.each(function(i,val){$li=$(val);claseActual=$li.attr("class");$li.attr("class",claseActual.replace(" seleccion",""));if(claseActual.lastIndexOf("menu-carrito")>-1){$("img",$li).attr("src",gl_conf.rootpath+"images/carrito-pos.png")}})}function getMensajeErrorFondo(p_mensaje){return'<div class="mensaje_error_fondo"><div class="mensaje_error">{0}</div></div>'.replace("{0}",p_mensaje)}(function($){$.fn.defval=function(){var i=0;var a=arguments;var els=this;return(els.each(function(){var d=a[i++];var el=$(this);var elc=null;if(el.attr("type")==="password"){var p="dvclear_";var h=el.parent().html();if(h.indexOf('type="')>=0){h=h.replace('type="password',"type=text").replace(' id="',' id="'+p).replace(' name="',' name="'+p)}else{h=h.replace("type=password","type=text").replace(" id="," id="+p).replace(" name="," name="+p)}el.parent().append(h);elc=$("#"+p+el.attr("id"));el.hide();elc.show();elc.val(d).focus(function(){elc.hide();el.show();el.focus()})}if(elc==null){el.val(d)}el.focus(function(){if(el.val()==d){el.val("")}el.blur(function(){if(el.val()===""){if(elc!=null){el.hide();elc.show()}else{el.val(d)}}})})}))}})(jQuery);
