jQuery.bind=function(object,method){
varargs=Array.prototype.slice.call(arguments,2);
returnfunction(){
varargs2=[this].concat(args,$.makeArray(arguments));
returnmethod.apply(object,args2);
};
};
(function($){
SexyLightbox={
getOptions:function(){
return{
name:'SLB',
zIndex:32000,
color:'black',
find:'sexylightbox',
dir:'sexyimages',
emergefrom:'top',
background:'bgSexy.png',
backgroundIE:'bgSexy.gif',
buttons:'buttons.png',
displayed:0,
showDuration:200,
closeDuration:400,
moveDuration:1000,
moveEffect:'easeInOutBack',
resizeDuration:1000,
resizeEffect:'easeInOutBack',
shake:{
distance:10,
duration:100,
transition:'easeInOutBack',
loops:2
},
BoxStyles:{'width':486,'height':320},
Skin:{'white':{'hexcolor':'#FFFFFF','captionColor':'#000000','background-color':'#000000','opacity':0.6},'black':{'hexcolor':'#000000','captionColor':'#FFFFFF','background-color':'#000000','opacity':0.6},'blanco':{'hexcolor':'#FFFFFF','captionColor':'#000000','background-color':'#000000','opacity':0.6},'negro':{'hexcolor':'#000000','captionColor':'#FFFFFF','background-color':'#000000','opacity':0.6}}
};
},
overlay:{
create:function(options){
this.options=options;
this.element=$('<divid="'+newDate().getTime()+'"></div>');
this.element.css($.extend({},{
'position':'absolute',
'top':0,
'left':0,
'opacity':0,
'display':'none',
'z-index':this.options.zIndex
},this.options.style));
this.element.bind('click',$.bind(this,function(obj,event){
if(this.options.hideOnClick){
if(this.options.callback){
this.options.callback();
}else{
this.hide();
}
}
event.preventDefault();
}));
this.hidden=true;
this.inject();
},
inject:function(){
this.target=$(document.body);
this.target.append(this.element);
if($.browser.msie&&$.browser.version=="6.0")
{
varzIndex=parseInt(this.element.css('zIndex'));
if(!zIndex)
{
zIndex=1;
varpos=this.element.css('position');
if(pos=='static'||!pos)
{
this.element.css({'position':'relative'});
}
this.element.css({'zIndex':zIndex});
}
zIndex=(!!(this.options.zIndex||this.options.zIndex===0)&&zIndex>this.options.zIndex)?this.options.zIndex:zIndex-1;
if(zIndex<0)
{
zIndex=1;
}
this.shim=$('<iframeid="IF_'+newDate().getTime()+'"scrolling="no"frameborder=0src=""></div>');
this.shim.css({
zIndex:zIndex,
position:'absolute',
top:0,
left:0,
border:'none',
opacity:0
});
this.shim.insertAfter(this.element);
}
},
resize:function(x,y){
this.element.css({'height':0,'width':0});
if(this.shim)this.shim.css({'height':0,'width':0});
varwin={x:$(document).width(),y:$(document).height()};
varchromebugfix=$.browser.safari?(win.x-25<document.body.clientWidth?document.body.clientWidth:win.x):win.x;
this.element.css({
width:x?x:chromebugfix,height:y?y:win.y
});
if(this.shim)
{
this.shim.css({'height':0,'width':0});
this.shim.css({
width:x?x:chromebugfix,height:y?y:win.y
});
}
returnthis;
},
show:function(){
if(!this.hidden)returnthis;
if(this.transition)this.transition.stop();
this.target.bind('resize',$.bind(this,this.resize));
this.resize();
if(this.shim)this.shim.css({'display':'block'});
this.hidden=false;
this.transition=this.element.fadeIn(this.options.showDuration,$.bind(this,function(){
this.element.trigger('show');
}));
returnthis;
},
hide:function(){
if(this.hidden)returnthis;
if(this.transition)this.transition.stop();
this.target.unbind('resize');
if(this.shim)this.shim.css({'display':'none'});
this.hidden=true;
this.transition=this.element.fadeOut(this.options.closeDuration,$.bind(this,function(){
this.element.trigger('hide');
this.element.css({'height':0,'width':0});
}));
returnthis;
}
},
backwardcompatibility:function(option){
this.options.dir=option.imagesdir||option.path||option.folder||option.dir;
this.options.OverlayStyles=$.extend(this.options.Skin[this.options.color],this.options.OverlayStyles||{});
},
preloadimage:function(url){
img=newImage();
img.src=url;
},
initialize:function(options){
this.options=$.extend(this.getOptions(),options);
this.backwardcompatibility(this.options);
varstrBG=this.options.dir+'/'+this.options.color+'/'+((((window.XMLHttpRequest==undefined)&&(ActiveXObject!=undefined)))?this.options.backgroundIE:this.options.background);
varname=this.options.name;
this.preloadimage(strBG);
this.preloadimage(this.options.dir+'/'+this.options.color+'/'+this.options.buttons);
this.overlay.create({
style:this.options.Skin[this.options.color],
hideOnClick:true,
zIndex:this.options.zIndex-1,
callback:$.bind(this,this.close),
showDuration:this.options.showDuration,
showEffect:this.options.showEffect,
closeDuration:this.options.closeDuration,
closeEffect:this.options.closeEffect
});
this.lightbox={};
$('body').append('<divid="'+name+'-Wrapper"><divid="'+name+'-Background"></div><divid="'+name+'-Contenedor"><divid="'+name+'-Top"style="background-image:url('+strBG+')"><aid="'+name+'-CloseButton"href="#"> </a><divid="'+name+'-TopLeft"style="background-image:url('+strBG+')"></div></div><divid="'+name+'-Contenido"></div><divid="'+name+'-Bottom"style="background-image:url('+strBG+')"><divid="'+name+'-BottomRight"style="background-image:url('+strBG+')"><divid="'+name+'-Navegador"><strongid="'+name+'-Caption"></strong></div></div></div></div></div>');
this.Wrapper=$('#'+name+'-Wrapper');
this.Background=$('#'+name+'-Background');
this.Contenedor=$('#'+name+'-Contenedor');
this.Top=$('#'+name+'-Top');
this.CloseButton=$('#'+name+'-CloseButton');
this.Contenido=$('#'+name+'-Contenido');
this.bb=$('#'+name+'-Bottom');
this.innerbb=$('#'+name+'-BottomRight');
this.Nav=$('#'+name+'-Navegador');
this.Descripcion=$('#'+name+'-Caption');
this.Wrapper.css({
'z-index':this.options.zIndex,
'display':'none'
}).hide();
this.Background.css({
'z-index':this.options.zIndex+1
});
this.Contenedor.css({
'position':'absolute',
'width':this.options.BoxStyles['width'],
'z-index':this.options.zIndex+2
});
this.Contenido.css({
'height':this.options.BoxStyles['height'],
'border-left-color':this.options.Skin[this.options.color].hexcolor,
'border-right-color':this.options.Skin[this.options.color].hexcolor
});
this.CloseButton.css({
'background-image':'url('+this.options.dir+'/'+this.options.color+'/'+this.options.buttons+')'
});
this.Nav.css({
'color':this.options.Skin[this.options.color].captionColor
});
this.Descripcion.css({
'color':this.options.Skin[this.options.color].captionColor
});
this.CloseButton.bind('click',$.bind(this,function(){
this.close();
returnfalse;
}));
$(document).bind('keydown',$.bind(this,function(obj,event){
if(this.options.displayed==1){
if(event.keyCode==27){
this.close();
}
if(event.keyCode==37){
if(this.prev){
this.prev.trigger('click',event);
}
}
if(event.keyCode==39){
if(this.next){
this.next.trigger('click',event);
}
}
}
}));
$(window).bind('resize',$.bind(this,function(){
if(this.options.displayed==1){
this.replaceBox();
this.overlay.resize();
}
}));
$(window).bind('scroll',$.bind(this,function(){
if(this.options.displayed==1){
this.replaceBox();
}
}));
this.refresh();
},
hook:function(enlace){
enlace=$(enlace);
enlace.blur();
this.show((enlace.attr("title")||enlace.attr("name")||""),enlace.attr("href"),(enlace.attr('rel')||false));
},
close:function(){
this.animate(0);
},
refresh:function(){
varself=this;
this.anchors=[];
$("a,area").each(function(){
if($(this).attr('rel')&&newRegExp("^"+self.options.find).test($(this).attr('rel'))){
$(this).click(function(event){
event.preventDefault();
self.hook(this);
});
if(!($(this).attr('id')==self.options.name+"-Left"||$(this).attr('id')==self.options.name+"-Right")){
self.anchors.push(this);
}
}
});
},
animate:function(option){
if(this.options.displayed==0&&option!=0||option==1)
{
this.overlay.show();
this.options.displayed=1;
this.Wrapper.css({'display':'block'});
}
else{
this.Wrapper.css({
'display':'none',
'top':-(this.options.BoxStyles['height']+280)
}).hide();
this.overlay.hide();
this.overlay.element.bind('hide',$.bind(this,function(){
if(this.options.displayed){
if(this.Image)this.Image.remove();
this.options.displayed=0;
}
}));
}
},
/*
Cambiardetamañoyposicionarellightboxenelcentrodelapantalla
*/
replaceBox:function(data){
varsize={x:$(window).width(),y:$(window).height()};
varscroll={x:$(window).scrollLeft(),y:$(window).scrollTop()};
varwidth=this.options.BoxStyles['width'];
varheight=this.options.BoxStyles['height'];
if(this.options.displayed==0)
{
varx=0;
vary=0;
y=scroll.x+((size.x-width)/2);
if(this.options.emergefrom=="bottom")
{
x=(scroll.y+size.y+80);
}
else
{
x=(scroll.y-height)-80;
}
this.Wrapper.css({
'display':'none',
'top':x,
'left':y
});
this.Contenedor.css({
'width':width
});
this.Contenido.css({
'height':height-80
});
}
data=$.extend({},{
'width':this.lightbox.width,
'height':this.lightbox.height,
'resize':0
},data);
if(this.MoveBox)this.MoveBox.stop();
this.MoveBox=this.Wrapper.animate({
'left':(scroll.x+((size.x-data.width)/2)),
'top':(scroll.y+(size.y-(data.height+(this.navigator?80:48)))/2)
},{
duration:this.options.moveDuration,
easing:this.options.moveEffect
});
if(data.resize){
if(this.ResizeBox2)this.ResizeBox2.stop();
this.ResizeBox2=this.Contenido.animate({
height:data.height
},{
duration:this.options.resizeDuration,
easing:this.options.resizeEffect
});
if(this.ResizeBox)this.ResizeBox.stop();
this.ResizeBox=this.Contenedor.animate({
width:data.width
},{
duration:this.options.resizeDuration,
easing:this.options.resizeEffect,
complete:function(){
$(this).trigger('complete');
}
});
}
},
getInfo:function(image,id){
image=$(image);
IEuta=$('<aid="'+this.options.name+'-'+id+'"title="'+image.attr('title')+'"rel="'+image.attr('rel')+'"> </a>');
IEuta.css({'background-image':'url('+this.options.dir+'/'+this.options.color+'/'+this.options.buttons+')'});
IEuta.attr('href',image.attr('href'));
returnIEuta;
},
display:function(url,title,force){
returnthis.show(title,url,'',force);
},
//...continua