/* $Id: lightbox.jquery.js,v 1.1.2.1 2008/04/17 22:08:47 gburns Exp $

Unobtrusive Accessible jQuery 1.2.1 drop downs.

Author:
	gburns, lightbox
*/
jQuery.fn.lightbox=function(b){jQuery.lightbox.set(b);jQuery.lightbox.create();var c=jQuery.lightbox.getSettings();var d=/(\.jpg|\.jpeg|\.png|\.gif|\.bmp)$/;return this.each(function(){var a=jQuery(this);if(this.nodeName=='A'){if(this.href.match(d)){a.bind('click',function(){return false})}else{a.bind('click',function(){return false})}}else if(this.nodeName=='FORM'||this.nodeName=='form'){a.bind('submit',function(){return true})}})};jQuery.lightbox={showing:false,$content:null,$lightbox:null,$overlay:null,prepend:'lightbox',width:400,height:300,opacity:0.8,speed:'slow',wrappers:['n','s','e','w','nw','ne','sw','se','content'],closing:false,callback:null,closecallback:null,getSettings:function(a){var b=jQuery.extend({width:jQuery.lightbox.width,height:jQuery.lightbox.height,prepend:jQuery.lightbox.prepend,opacity:jQuery.lightbox.opacity,speed:jQuery.lightbox.speed,callback:jQuery.lightbox.callback,wrappers:jQuery.lightbox.wrappers,closecallback:jQuery.lightbox.closecallback},a||{});return b},set:function(a){var b=jQuery.lightbox.getSettings(a);jQuery.lightbox.width=b.width;jQuery.lightbox.height=b.height;jQuery.lightbox.prepend=b.prepend;jQuery.lightbox.opacity=b.opacity;jQuery.lightbox.speed=b.speed;jQuery.lightbox.wrappers=b.wrappers;jQuery.lightbox.callback=b.callback;jQuery.lightbox.closecallback=b.closecallback},isCreated:function(){if(jQuery.lightbox.$content&&jQuery.lightbox.$lightbox&&jQuery.lightbox.$overlay){return true}},create:function(){if(jQuery.lightbox.isCreated()){return}var a=jQuery('body');jQuery.lightbox.$overlay=jQuery('<div/>').attr({id:jQuery.lightbox.prepend+'_overlay'}).css({position:'absolute',top:0,left:0,opacity:0,display:'none',zIndex:10000}).bind('click',function(){if(!jQuery.lightbox.closing){jQuery.lightbox.hide(this)}});jQuery.lightbox.$lightbox=jQuery('<div/>').attr({id:jQuery.lightbox.prepend+'_container'}).css({position:'absolute',display:'none',zIndex:10001});var b;var c=jQuery.lightbox.$lightbox;var d=jQuery.lightbox.wrappers;for(var div in d){if(d.hasOwnProperty(div)){b=jQuery('<div/>').addClass(jQuery.lightbox.prepend+'_'+d[div]);c.append(b);c=b}}jQuery.lightbox.$content=c;a.append(jQuery.lightbox.$overlay);a.append(jQuery.lightbox.$lightbox)},show:function(a,b){var c=jQuery.lightbox.getSettings(a);if(jQuery.lightbox.showing){return}jQuery.lightbox.showing=true;jQuery('iframe:visible, object:visible, embed:visible, select:visible').attr({lightbox_hide:'true'}).css({visibility:'visible'});jQuery.lightbox.create();var d=jQuery.lightbox.getPageDimensions();var e=jQuery('body');jQuery.lightbox.$overlay.css({width:e.fullWidth()+'px',height:d.ph+'px',opacity:0}).show();jQuery.lightbox.$lightbox.addClass(c.prepend+'_loading').css({opacity:0});jQuery.lightbox.$content.css({width:c.width+'px',height:c.height+'px'});var f=jQuery.lightbox.getPageScroll();jQuery.lightbox.$lightbox.show().css({top:parseInt((d.vph-jQuery.lightbox.$lightbox.fullHeight())/2)+f.y+'px',left:parseInt((d.vpw-jQuery.lightbox.$lightbox.fullWidth())/2)+f.x+'px'});jQuery('.'+c.prepend+'_close',jQuery.lightbox.$content).bind('click',function(){jQuery.lightbox.hide(this);return false});if(c.speed){jQuery.lightbox.$overlay.animate({opacity:c.opacity},c.speed,'linear',function(){jQuery.lightbox.$lightbox.animate({opacity:1},c.speed,'linear',function(){if(jQuery.browser.msie){jQuery.lightbox.$lightbox[0].filters.alpha.enabled=false}if(b){b()}})})}else{jQuery.lightbox.$lightbox.css({opacity:1});if(jQuery.browser.msie){jQuery.lightbox.$lightbox[0].filters.alpha.enabled=false}if(b){b()}jQuery.lightbox.$overlay.css({opacity:c.opacity})}},hide:function(a){var b=jQuery.lightbox.getSettings();if(jQuery.lightbox.$content&&jQuery.lightbox.$lightbox&&jQuery.lightbox.$overlay){jQuery.lightbox.closing=true;jQuery.lightbox.showing=false;if(b.speed){jQuery.lightbox.$lightbox.animate({opacity:0},b.speed,function(){jQuery.lightbox.$lightbox.hide();jQuery.lightbox.$overlay.animate({opacity:0},b.speed,function(){jQuery.lightbox.$overlay.hide();if(b.closecallback){b.closecallback(a)}jQuery.lightbox.$content.html('');jQuery.lightbox.closing=false;jQuery('iframe[lightbox_hide="true"], object[lightbox_hide="true"], embed[lightbox_hide="true"], select[lightbox_hide="true"]').css({visibility:'visible'})})})}else{jQuery.lightbox.$overlay.hide();jQuery.lightbox.$lightbox.hide();if(b.closecallback){b.closecallback(a)}jQuery.lightbox.$content.html('');jQuery.lightbox.closing=false;if(jQuery.browser.msie){jQuery('select[lightbox_iehide="true"]').show()}}}$("body").css("overflow","auto")},showImage:function(a,b){jQuery.lightbox.show();var c=new Image();c.onload=function(){jQuery.lightbox.resize({width:c.width,height:c.height,callback:function(){jQuery.lightbox.$content.append(c)}});c.onload=function(){};jQuery.lightbox.$lightbox.removeClass(jQuery.lightbox.prepend+'_loading')};c.src=a},showDom:function(a,b,c){var d=jQuery(a);if(!d.length){return}jQuery.lightbox.set(b);jQuery.lightbox.create();jQuery.lightbox.$content.append(d);jQuery.lightbox.show(b,function(){jQuery.lightbox.$lightbox.removeClass(jQuery.lightbox.prepend+'_loading');if(c){c()}})},load:function(a,b,c,d){var e=jQuery.lightbox.getSettings(d);var f=jQuery('<div/>');jQuery.lightbox.show(e);if(!a.match(/ +/)){a+=' >:not(script)'}f.load(a,b,function(){jQuery.lightbox.$content.html(f.html());jQuery.lightbox.$lightbox.removeClass(e.prepend+'_loading');jQuery('.'+e.prepend+'_close',jQuery.lightbox.$content).bind('click',function(){jQuery.lightbox.hide(this);return false});if(c){c()}})},resize:function(a){if(!jQuery.lightbox.showing){return}var b=jQuery.extend({width:null,height:null,callback:null},a||{});var c=jQuery.lightbox.getPageDimensions();var d=jQuery.lightbox.getPageScroll();var e=jQuery.lightbox.$lightbox.fullWidth()-jQuery.lightbox.$content.innerWidth();var f=jQuery.lightbox.$lightbox.fullHeight()-jQuery.lightbox.$content.innerHeight();var g=parseInt((c.vpw-b.width-e)/2)+d.x+'px';var h=parseInt((c.vph-b.height-f)/2)+d.y+'px';if(jQuery.lightbox.speed){jQuery.lightbox.$content.animate({width:b.width+'px',height:b.height+'px'},jQuery.lightbox.speed,b.callback);jQuery.lightbox.$lightbox.animate({left:g,top:h},jQuery.lightbox.speed)}else{jQuery.lightbox.$content.css({width:b.width+'px',height:b.height+'px'});jQuery.lightbox.$lightbox.css({left:g,top:h});b.callback()}},getPageDimensions:function(){var a,yScroll;if(window.innerHeight&&window.scrollMaxY){a=document.body.scrollWidth;yScroll=window.innerHeight+window.scrollMaxY}else if(document.body.scrollHeight>document.body.offsetHeight){a=document.body.scrollWidth;yScroll=document.body.scrollHeight}else{a=document.body.offsetWidth;yScroll=document.body.offsetHeight}var b,windowHeight;if(self.innerHeight){b=self.innerWidth;windowHeight=self.innerHeight}else if(document.documentElement&&document.documentElement.clientHeight){b=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight}else if(document.body){b=document.body.clientWidth;windowHeight=document.body.clientHeight}if(yScroll<windowHeight){pageHeight=windowHeight}else{pageHeight=yScroll}if(a<b){pageWidth=b}else{pageWidth=a}return{pw:pageWidth,ph:pageHeight,vpw:b,vph:windowHeight}},getPageScroll:function(){var a,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;a=self.pageXOffset}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;a=document.documentElement.scrollLeft}else if(document.body){yScroll=document.body.scrollTop;a=document.body.scrollLeft}return{x:a,y:yScroll}}};if(!jQuery.fn.fullHeight){jQuery.fn.fullHeight=function(){var a=jQuery(this[0]);return a[0].clientHeight+(parseInt(a.css('borderTopWidth'))||0)+(parseInt(a.css('borderBottomWidth'))||0)+(parseInt(a.css('marginTop'))||0)+(parseInt(a.css('marginBottom'))||0)};jQuery.fn.fullWidth=function(){var a=jQuery(this[0]);return a[0].clientWidth+(parseInt(a.css('borderLeftWidth'))||0)+(parseInt(a.css('borderRightWidth'))||0)+(parseInt(a.css('marginLeft'))||0)+(parseInt(a.css('marginRight'))||0)}}if(!jQuery.fn.innerHeight){jQuery.fn.innerHeight=function(){var a=jQuery(this[0]);return a[0].clientHeight-(parseInt(a.css('paddingTop'))||0)-(parseInt(a.css('paddingBottom'))||0)};jQuery.fn.innerWidth=function(){var a=jQuery(this[0]);return a[0].clientWidth-(parseInt(a.css('paddingLeft'))||0)-(parseInt(a.css('paddingRight'))||0)}}
