
(function($){$.fn.cerrarCover=function(){$('#cover').animate({'opacity':0},{duration:800,queue:false,complete:function(){$("#cover").css({'display':'none'});}});},$.fn.modalKillLoader=function(){$('.loading-modal').remove();},$.fn.modal=function(opciones){var opciones=$.extend({accion:'',titulo:'Ventana',tipo:'modal',cover:false,timer:0,claseCss:'',contenido:'.',ajax:false,url:'',siCallback:function(){},botonSiHTML:'<img src="js/modal/accept.gif" border="0"><span>Aceptar&nbsp;</span>',noCallback:function(){},botonNoHTML:'<img src="js/modal/cancel.gif" border="0"><span>Cancelar&nbsp;</span>',cerrarCallback:function(){}},opciones);if(opciones.accion!=''){$(this).bind(opciones.accion,function(){new $.unModal(this,opciones);})}else{return new $.unModal(this,opciones);}},$.fn.confirmar=function(opciones){var opciones=$.extend({accion:'click',titulo:'Confirme la operaci&oacute;n',cover:true,contenido:'Error de par&aacute;metros',tipo:'confirmar',claseCss:'infomsg',timer:0,botonSiHTML:'<img src="js/modal/accept.gif" border="0"><span>Aceptar&nbsp;</span>',botonNoHTML:'<img src="js/modal/cancel.gif" border="0"><span>Cancelar&nbsp;</span>',noCallback:function(){}},opciones);return new $.unModal(this,opciones);},$.fn.galeria=function(opciones){var opciones=$.extend({accion:'click',triggerClass:'galeria',titulo:'REVOLUCION!',cover:true,contenido:'Error de par&aacute;metros',tipo:'galeria',claseCss:'infomsg',timer:0,botonSiHTML:'<img src="js/modal/next.gif" border="0"><span>Pr&oacute;xima&nbsp;</span>',botonNoHTML:'<img src="js/modal/prev.gif" border="0"><span>Anterior&nbsp;</span>',siCallback:function(){alert("proxima");},noCallback:function(){alert("anterior");}},opciones);if(opciones.accion!=''){$(this).bind(opciones.accion,function(){new $.unModal(this,opciones);})}else{return new $.unModal(this,opciones);}},$.unModal=function(element,opciones){var self=this;var id=new Date().getTime().toString().substr(8);function getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}var arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}var arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};var covered=false;var mWidth=500;var mHeigth=500;var arrayPageScroll=getPageScroll();var arrayPageSize=getPageSize();$(window).scroll(function(){var arrPageSizes=getPageSize();var arrPageScroll=getPageScroll();$('#cover').css({top:'0px',height:parseInt((arrPageSizes[1]))+'px'});$(modal).css({top:parseInt((arrPageScroll[1]+10))+'px'});});$(window).resize(function(){var arrPageSizes=getPageSize();$('#cover').css({top:'0px',width:arrPageSizes[2],height:arrPageSizes[3]});var mWidth=$(modal).width();$(modal).css({left:parseInt((arrPageSizes[0]-mWidth)/2)+'px'});});if(opciones.cover&&!covered){covered=true;$("#cover").css({'top':arrayPageScroll[1]+'px','height':arrayPageSize[1]+'px','width':arrayPageSize[2]+'px','display':'block'}).animate({opacity:'0.8',duration:'400'}).bind('click',function(){if(opciones.timer<1){covered=false;$.fn.cerrarCover();$('.modal').remove();}});}var modalID=id+'-modal';var modal=$('<div></div>').addClass('modal').attr({'id':modalID}).css({'top':parseInt((arrayPageScroll[1]+10))+'px'}).hide();$('body').prepend(modal);if(opciones.tipo=='mensaje'){$(modal).css({'width':mWidth+'px','left':parseInt((arrayPageSize[0]-mWidth)/2)+'px'}).addClass(opciones.claseCss);$(modal).html('<span>'+opciones.contenido+'</span>');}else if(opciones.tipo=='loading'){$(modal).css({'width':'200px','textAlign':'center','top':'120px','left':parseInt((arrayPageSize[0]-200)/2)+'px'}).addClass('modalLuka').addClass('loading-modal');$(modal).html('<div>'+opciones.contenido+'</div><img src="/img/loading_icon_medium.gif" border="0" alt="Cargando">');}else if(opciones.tipo=='galeria'){var imagenID=$(''+opciones.contenido).attr('id');var img=new Image();img.onload=function(){$(modal).append('<div id="div-'+imagenID+'"></div>');$('#div-'+imagenID).append(img);mWidth=img.width;mHeight=img.height;maxHeight=arrayPageSize[3]-80;maxWidth=arrayPageSize[2]-40;var scrollY='none';var scrollX='none';if(maxWidth<mWidth){mWidth=maxWidth;scrollX='auto';}if(maxHeight<mHeight){mHeight=maxHeight;scrollY='auto';}$(modal).css({'width':mWidth+'px','left':parseInt((arrayPageSize[0]-mWidth)/2)+'px'}).addClass('modalLuka');$('#div-'+imagenID).css({'height':mHeight+30+'px','overflow-x':scrollX,'overflow-y':scrollY});$(modal).show();};img.src=$(''+opciones.contenido).attr('src');}else if(opciones.tipo=='ventana'){$(modal).css({'width':mWidth+'px','left':parseInt((arrayPageSize[0]-mWidth)/2)+'px'}).addClass('modalLuka');$(modal).html('<h1>'+opciones.titulo+'</h1><span>'+opciones.contenido+'</span>');}else if(opciones.tipo=='confirmar'){var botonSi=$('<div class="botonSi">'+opciones.botonSiHTML+'</div>').bind('click',opciones.siCallback);var botonNo=$('<div class="botonNo">'+opciones.botonNoHTML+'</div>').bind('click',opciones.noCallback);$(botonSi).bind('click',function(){$('#'+modalID).remove();$.fn.cerrarCover();});$(botonNo).bind('click',function(){$('#'+modalID).remove();$.fn.cerrarCover();});$(modal).css({'width':mWidth+'px','left':parseInt((arrayPageSize[0]-mWidth)/2)+'px'}).addClass('modalLuka');$(modal).html('<h1>'+opciones.titulo+'</h1><span>'+opciones.contenido+'</span>');$(modal).append('<div class="modal-confirmar"></div>').append(botonSi,botonNo);}else if(opciones.tipo=='prompt'){}else if(opciones.tipo=='ajax'){}$(modal).css({'display':'block'});if(opciones.timer>0){$(modal).prepend('<div class="countdownDiv" style="width:'+mWidth+'px; height:5px; background-color:#FFF;"></div>');$('#'+modalID+'>.countdownDiv').animate({width:'1px'},{duration:opciones.timer,queue:true,complete:function(){$('#'+modalID).remove();$.fn.cerrarCover();}});}else if(opciones.tipo!='confirmar'&&opciones.tipo!='loading'){$(modal).prepend('<img class="botonCerrar" src="js/modal/cancel.gif" style="float:right; margin:5px;" border="0">');$('#'+modalID+'>.botonCerrar').bind("click",function(){$(modal).remove();$.fn.cerrarCover();});}}})(jQuery);$(document).ready(function(){$('body').prepend('<div style="position:absolute;"><div id="cover"></div></div>');$('#cabecera').modal({accion:'click',titulo:'Mensaje',cover:true,contenido:'Mensaje independiente',tipo:'mensaje',claseCss:'infomsg',timer:0});});
