(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,imageLoading:Web.UI.ResourceManager.Image.build("loadingeggs.gif"),imageBtnClose:Web.UI.ResourceManager.Image.build("close2.gif"),containerBorderSize:15,containerResizeSpeed:400,keyToClose:'c',imageArray:[],activeImage:0,url:"",width:330,height:308,isActived:false},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false};function _start(objClicked,jQueryMatchedObj){var web=Web.Environment.Browser;if(web.currentVersion()==Web.Enum.Browser.IE_6||web.currentVersion()==Web.Enum.Browser.IE_5_5){$('embed, object, select').css({'visibility':'hidden'})}if(settings.isActived){_finish()}settings.url=objClicked.getAttribute('href');_set_iframe_interface();settings.isActived=true};function _set_iframe_interface(){var re=/^.*\?(.*)$/ig;var qsb=new Web.QueryStringBuilder(settings.url.replace(re,"$1"));var tw=qsb.get("width")-0,th=qsb.get("height")-0;var width=(isNaN(tw)||tw==0)?settings.width:tw;var height=(isNaN(th)||th==0)?settings.height:th;$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-iframe-box"><div id="lightbox-title-bar"><div id="lightbox-title-bar-logo"><img src="'+Web.UI.ResourceManager.Image.build("logo_thumb.png")+'" alt="Newegg.com" class="floatPNG"><a href="javascript:jQuery.fn.lightBox.close();" title="Close" id="lightbox-close-button"><img src="'+settings.imageBtnClose+'" border="0" /></a></div><div id="lightbox-title">'+qsb.get("title")+'</div></div><div id="lightbox-container-iframe"><div id="lightbox-loading"><a href="#" id="lightbox-loading-link" class="noline"><img src="'+settings.imageLoading+'"></a></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();var popWidth=document.getElementById("lightbox-container-iframe-box").clientWidth;$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:Web.Environment.Browser.isIE()?arrPageScroll[0]:arrPageSizes[0]/2-popWidth/2}).show();$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:Web.Environment.Browser.isIE()?arrPageScroll[0]:arrPageSizes[0]/2-popWidth/2})});var boxwidth=width;var boxheight=height+$("#lightbox-title-bar").height();$("#lightbox-container-iframe").append('<iframe id="lightbox-iframe" src="'+settings.url+'" onload="jQuery.fn.lightBox.onLoading('+boxwidth+', '+boxheight+');" frameborder="0" hspace="0" style="display:none;width:'+width+'px;height:'+height+'px"></iframe>');if(Web.Environment.Browser.isIE()){$("#lightbox-container-iframe-box").draggable()}else{$("#jquery-lightbox").draggable(Web.Environment.Browser.isFirefox()?{"nonDestructive":true}:null)}};$.fn.lightBox["onLoading"]=function(width,height){var cwidth=$('#lightbox-container-iframe-box').width();var cheight=$('#lightbox-container-iframe-box').height();var width=(width+(settings.containerBorderSize*2));var height=(height+(settings.containerBorderSize*2));var diffw=cwidth-width;var diffh=cheight-height;$('#lightbox-container-iframe-box').animate({"height":height},settings.containerResizeSpeed,function(){_show_iframe()});if((diffw==0)&&(diffh==0)){if($.browser.msie){___pause(250)}else{___pause(100)}}};function _show_iframe(){$('#lightbox-loading').hide();$('#lightbox-iframe').fadeIn()};function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent)})};function _disable_keyboard_navigation(){$(document).unbind()};function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE}key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(keycode==escapeKey)){_finish()}};$.fn.lightBox["close"]=function(){_finish()};function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove()});var web=Web.Environment.Browser;if(web.currentVersion()==Web.Enum.Browser.IE_6||web.currentVersion()==Web.Enum.Browser.IE_5_5){$('embed, object, select').css({'visibility':'visible'})}settings.isActived=false};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}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}arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date()}while(curDate-date<ms)};return this.unbind('click').click(_initialize)}})(jQuery);