/**
 * jQuery lightpop plugin
 * This jQuery plugin was inspired on jQuery lightBox plugin by Leandro Vieira Pinho (http://leandrovieira.com/projects/jquery/lightpop/)
 * @name jquery.lightpop-0.3.5.min.js
 * @author wokamoto - http://dogmap.jp
 * @version 0.3.5
 * @date January 9, 2008
 * @category jQuery plugin
 * @copyright (c) 2007-2008 wokamoto (dogmap.jp)
 * @license  Released under the GPL license (http://www.gnu.org/copyleft/gpl.html)
 * @example http://dogmap.jp/lightpop_sample/sample.html
 */
(function(A){A.fn.lightpop=function(S){S=A.extend({overlayBgColor:"#000",overlayOpacity:0.7,contentFrameType:"border",contentBorder:"none",boxBorderSize:6,containerBorderSize:10,containerResizeSpeed:"normal",contentBgColor:"#FFF",imageBox:"images/lightpop-box.gif",imageBorderL:"images/lightpop-border-l.gif",imageBorderR:"images/lightpop-border-r.gif",imageLoading:"images/lightpop-ico-loading.gif",imageBtnPrev:"images/lightpop-btn-prev.gif",imageBtnNext:"images/lightpop-btn-next.gif",imageBtnClose:"images/lightpop-btn-close.gif",imageBlank:"images/lightpop-blank.gif",imageBtnPrevWidth:63,imageBtnNextWidth:63,imageBtnCloseWidth:66,txtImage:"Image",txtOf:"of",keyToClose:"c",keyToPrev:"p",keyToNext:"n",flvplayer:"flvplayer.swf",iconAdd:true},S);var L=(S.contentFrameType.toLowerCase()=="border");var K=new Array();var D=new Array({type:"Image",match:function(W){return(W.match(/\.(jpe?g|gif|png|bmp)[\?]?.*$/i))},set:function(W){M(K[W].href,(function(X){return function(){var Y=J(this.src,new Array(this.width,this.height));K[X]=A.extend(K[X],{content:'<img src="'+this.src.replace(/\?.*$/,"")+'" width="'+Y[0]+'" height="'+Y[1]+'" />',width:Y[0],height:Y[1],later:(A.browser.msie?250:100)});U(X);this.onload=function(){}}})(W))},preload:function(W){M(K[W].href,(function(X){return function(){var Y=J(this.src,new Array(this.width,this.height));K[X]=A.extend(K[X],{content:'<img src="'+this.src.replace(/\?.*$/,"")+'" width="'+Y[0]+'" height="'+Y[1]+'" />',width:Y[0],height:Y[1],later:(A.browser.msie?250:100)});this.onload=function(){}}})(W))}},{type:"Video",match:function(W){return(W.match(/\.(flv|swf|rm|mov|3gp|mp4|asf|avi|mpg|wmv)[\?]?.*$/i))}},{type:"YouTube",match:function(W){return(W.match(/\.youtube\.com\/watch/i))}},{type:"metacafe",match:function(W){return(W.match(/\.metacafe\.com\/watch/i))}},{type:"LiveLeak",match:function(W){return(W.match(/\.liveleak\.com\/view/i))}},{type:"GoogleVideo",match:function(W){return(W.match(/video\.google\.com\/videoplay/i))}},{type:"IFILM",match:function(W){return(W.match(/\.ifilm\.com\/video/i))}},{type:"Dailymotion",match:function(W){return(W.match(/\.dailymotion\.com\/video/i))}},{type:"nicovideo",match:function(W){return(W.match(/\.nicovideo\.jp\/watch/i))}},{type:"Contents",match:function(W){return(W.match(window.location.host))},set:function(W){A.get(K[W].href,function(Z,X){var a=J(K[W].href);var Y='<div width="'+a[0]+'" height="'+a[1]+'">'+Z.replace(/[\r\n]/g,"").replace(/.*<body.*?>(.*?)<\/body>.*$/,"$1").replace(/<script.*?>.*<\/script>/g,"")+"</div>";K[W]=A.extend(K[W],{content:Y,width:a[0],height:a[1],later:500});U(W)})},preload:function(W){},content_css:{"text-align":"left","line-height":"1.2em"}});var C=function(X){M(S.imageBtnPrev,function(){S.imageBtnPrevWidth=(this.width>0?this.width:63);this.onload=function(){}});M(S.imageBtnNext,function(){S.imageBtnNextWidth=(this.width>0?this.width:63);this.onload=function(){}});M(S.imageBtnClose,function(){S.imageBtnCloseWidth=(this.width>0?this.width:66);this.onload=function(){}});if(!L){A.each(new Array(S.imageBox,S.imageBorderL,S.imageBorderR),function(){M(this)})}var Z=new Array();var Y=0;var W=window.location;K.length=0;X.filter("a").each(function(){var c=A(this);if(!c.attr("href").match(/^https?:/i)&&W.protocol.match(/^https?:/i)){if(c.attr("href").match(/^\//i)){c.attr("href",W.protocol+"//"+W.hostname+"/"+c.attr("href"))}else{c.attr("href",W.href.replace(/^(.*\/).*$/i,"$1")+c.attr("href").replace(/^\/?(.*)$/i,"$1"))}}for(var a=D[0],b=0;b<D.length;b++,a=D[b]){if(a.match(c.attr("href"))){if(S.iconAdd&&c.children("img").length==0){c.css({background:"transparent url("+(S["icon"+a.type]?S["icon"+a.type]:"images/icon-"+a.type.toLowerCase()+".png")+") no-repeat scroll 1px 0pt","padding-left":"20px"})}K.push({index:b,type:(a.type?a.type:S.txtImage),href:c.attr("href"),title:(c.attr("title")?c.attr("title"):c.html().replace(/<[^>]*>/ig,""))});c.unbind("click").click((function(d){return function(){N(d);return false}})(Y));Z.push(this);Y++;break}}});return new A(Z)};var N=function(Y){E(A("embed, object, select"),false);if(L){A("body").append(A('<div id="overlay" /><div id="lightpop"><div id="lightpop-box"><div id="lightpop-box-content"><div id="lightpop-content-box"><div id="lightpop-content" /></div></div><div id="lightpop-data-box"><div id="lightpop-data"><div id="lightpop-details"><div id="lightpop-details-caption" /><div id="lightpop-details-number" /></div><div id="lightpop-data-nav"><a href="#" id="lightpop-data-nav-close"><img src="'+S.imageBtnClose+'" /></a></div></div></div><div id="lightpop-nav"><a href="#" id="lightpop-nav-prev" /><a href="#" id="lightpop-nav-next" /></div><div id="lightpop-loading"><a href="#" id="lightpop-loading-link"><img src="'+S.imageLoading+'" /></a></div></div></div>').hide())}else{A("body").append(A('<div id="overlay" /><div id="lightpop"><div id="lightpop-box"><div id="lightpop-box-content"><div id="lightpop-box-hd"><div id="lightpop-box-hdc" /></div><div id="lightpop-box-bd"><div id="lightpop-box-bdc"><div id="lightpop-content-box"><div id="lightpop-content" /></div><div id="lightpop-data-box"><div id="lightpop-data"><div id="lightpop-details"><div id="lightpop-details-caption" /><div id="lightpop-details-number" /></div><div id="lightpop-data-nav"><a href="#" id="lightpop-data-nav-close"><img src="'+S.imageBtnClose+'" /></a></div></div></div></div></div><div id="lightpop-box-ft"><div id="lightpop-box-ftc" /></div></div><div id="lightpop-nav"><a href="#" id="lightpop-nav-prev" /><a href="#" id="lightpop-nav-next" /></div><div id="lightpop-loading"><a href="#" id="lightpop-loading-link"><img src="'+S.imageLoading+'" /></a></div></div></div>').hide());S.contentBorder="none"}var W=H();var X=Q();var Z=250;A("#overlay").css({position:"absolute",top:0,left:0,"background-color":S.overlayBgColor,opacity:S.overlayOpacity,width:W[0],height:W[1],"z-index":90});A("#lightpop").css({position:"absolute",top:X[1]+Math.round(W[3]/10),left:X[0],width:"100%","text-align":"center","line-height":0,border:"none","z-index":100});A("#lightpop a img").css({border:"none"});A("#lightpop-box").css({position:"relative",width:Z,height:Z,top:0,margin:"0 auto",padding:0,"background-color":S.contentBgColor,border:S.contentBorder,overflow:(L?"hidden":"visible")});A("#lightpop-content-box").css({"background-color":"transparent"});A("#lightpop-content").css({margin:(L?0:"0 auto"),padding:(L?0:S.containerBorderSize+"px 0")});A("#lightpop-box-content").css({position:"relative",width:Z,height:Z,"background-color":"transparent",margin:"0 auto",padding:(L?S.containerBorderSize:0),overflow:(L?"hidden":"visible")});if(!L){V(false).css({position:"relative"}).hide();A("#lightpop-box-hd").css({height:S.boxBorderSize,top:0,margin:"0 "+S.boxBorderSize+"px 0 0"});A("#lightpop-box-hdc").css({height:S.boxBorderSize,top:0,margin:"0 "+S.boxBorderSize*-1+"px 0 "+S.boxBorderSize+"px"});A("#lightpop-box-ft").css({height:S.boxBorderSize,bottom:0,margin:"0 "+S.boxBorderSize+"px 0 0"});A("#lightpop-box-ftc").css({height:S.boxBorderSize,bottom:0,margin:"0 "+S.boxBorderSize*-1+"px 0 "+S.boxBorderSize+"px"})}A("#lightpop-nav").css({position:"absolute",top:0,left:0,height:"10px",width:"100%",padding:0,margin:(L?"0":S.boxBorderSize+"px")+" auto","z-index":10});A("#lightpop-nav a").css({display:"block",height:"100%",zoom:1,margin:(L?0:"0 "+S.boxBorderSize+"px"),outline:"none"});A("#lightpop-nav-prev").css({width:S.imageBtnPrevWidth,left:0,"float":"left"});A("#lightpop-nav-next").css({width:S.imageBtnNextWidth,right:0,"float":"right"});A("#lightpop-loading").css({position:"absolute",top:"40%",left:0,height:"20%",width:"100%",margin:"0 auto","text-align":"center","line-height":0});A("#lightpop-data-box").css({font:"10px Verdana, Helvetica, sans-serif","background-color":S.contentBgColor,"line-height":"1.4em",width:"100%",margin:"0 auto",padding:"0 "+S.containerBorderSize+"px 0",overflow:"hidden"}).hide();A("#lightpop-data").css({position:"relative",padding:"0 "+S.containerBorderSize+"px",color:"#666",left:0,bottom:0});A("#lightpop-details").css({width:"70%","float":"left","text-align":"left"});A("#lightpop-details-caption").css({"float":"left","font-weight":"bold",width:"100%"});A("#lightpop-details-number").css({"float":"left",clear:"left",width:"100%","padding-bottom":"1.0em"});A("#lightpop-data-nav-close").css({"float":"right",width:S.imageBtnCloseWidth,"padding":"0.35em 0"});A("#overlay").click(B).fadeIn(S.containerResizeSpeed,function(){A("#lightpop").show()});A("#lightpop-loading-link, #lightpop-data-nav-close").click(function(){B();return false});R(true);G(Y)};var G=function(W){E(A("#lightpop-data, #lightpop-details, #lightpop-details-caption, #lightpop-details-number, #lightpop-data-nav-close"),false);A("#lightpop-nav, #lightpop-nav-prev, #lightpop-nav-next").hide();A("#lightpop-content").hide().children().remove();A("#lightpop-loading, #lightpop-box, #lightpop-box-content").show();V(false);if(!L&&A.browser.safari){A("#lightpop-data-box").height("auto")}U(W)};var U=function(W){(K[W].content?function(X){A("#lightpop-content").append(A(K[X].content));setTimeout(function(){T(X)},K[X].later)}:(D[K[W].index].set?D[K[W].index].set:(function(X){O(X);U(X)})))(W)};var T=function(Y){var X=K[Y].width+(S.containerBorderSize+(L?0:S.boxBorderSize))*2;var W=K[Y].height+S.containerBorderSize*2;A("#lightpop-box").animate({width:X,height:W},S.containerResizeSpeed,function(){A("#lightpop-box-content").css({width:(L?K[Y].width:X),height:K[Y].height});A("#lightpop-content").css({width:K[Y].width,height:K[Y].height});A("#lightpop-data-box").css({width:K[Y].width});if(D[K[Y].index].content_css){A("#lightpop-content").children().css(D[K[Y].index].content_css)}A("#lightpop-loading").hide();if(K[Y].content.match(/<object.*>/i)){A("#lightpop-content").show()}else{A("#lightpop-content").fadeIn()}V(true);A("#lightpop-details-caption").html(K[Y].title);A("#lightpop-details-number").html(K[Y].type+(K.length>1?" "+(Y+1)+" "+S.txtOf+" "+K.length:""));var Z=E(A("#lightpop-data, #lightpop-details, #lightpop-details-caption, #lightpop-details-number, #lightpop-data-nav-close"),false).show();A("#lightpop-data-box").slideDown("fast",function(){var a=(!A.browser.safari?A(this).height():this.scrollHeight);a=(a<28?28:a);W+=a;if(L){A("#lightpop-box").animate({width:X,height:W},"fast",function(){E(Z,true)})}else{if(A.browser.safari){A("#lightpop-data-box").height(a)}E(Z,true)}});A("#lightpop-nav").css({width:X}).show(function(){A("#lightpop-nav-prev, #lightpop-nav-next").css({height:Math.round(W/3),background:"transparent url("+S.imageBlank+") no-repeat"}).unbind();if(Y!=0){A("#lightpop-nav-prev").hover(function(){A(this).css({background:"url("+S.imageBtnPrev+") left 30% no-repeat"})},function(){A(this).css({background:"transparent url("+S.imageBlank+") no-repeat"})}).show().click((function(a){return function(){G(a);return false}})(Y-1))}if(Y!=(K.length-1)){A("#lightpop-nav-next").hover(function(){A(this).css({background:"url("+S.imageBtnNext+") right 30% no-repeat"})},function(){A(this).css({background:"transparent url("+S.imageBlank+") no-repeat"})}).show().click((function(a){return function(){G(a);return false}})(Y+1))}F(true,Y)});if((K.length-1)>Y){I(Y+1)}if(Y>0){I(Y-1)}})};var I=function(W){if(!K[W].content){(D[K[W].index].preload?D[K[W].index].preload:(function(X){O(X)}))(W)}};var J=function(X,W){var Z=0,Y=0;var a=X.toLowerCase().replace(/[\r\n]/g,"").replace(/["']/g,"").match(/(width|height)=(\d+)/ig);if(a){A.each(a,function(){if(this.match(/^width=\d+$/i)){Z=Number(this.replace(/^width=(\d+)$/,"$1"))}if(this.match(/^height=\d+$/i)){Y=Number(this.replace(/^height=(\d+)$/,"$1"))}})}if(Z==0||Y==0){if(W){Z=W[0];Y=W[1]}else{var b=H();Z=Math.round(b[0]/4);Y=Math.round(b[1]/4)}}return new Array(Z,Y)};var O=function(a){var Z=K[a].href.replace(/&.*$/i,"");var b,W,Y=null,X=1500;switch(K[a].type){case"YouTube":b=J(K[a].href,new Array(425,355));W=Z.replace(/^.*\.youtube.*watch.*?v=(.*)$/i,"$1");Z="http://www.youtube.com/v/"+W;Y=P(Z,b[0],b[1]);break;case"metacafe":b=J(K[a].href,new Array(400,345));W=Z.replace(/\?.*$/,"").replace(/\/$/i,"").replace(/^.*\.metacafe.*watch\/(.*)$/i,"$1");Z="http://www.metacafe.com/fplayer/"+W+".swf";Y=P(Z,b[0],b[1]);break;case"LiveLeak":b=J(K[a].href,new Array(450,370));W=Z.replace(/^.*\.liveleak.*view.*?i=(.*)$/i,"$1");Z="http://www.liveleak.com/player.swf?autostart=false&token="+W;Y=P(Z,b[0],b[1],{quality:"high"});break;case"GoogleVideo":b=J(K[a].href,new Array(400,326));W=Z.replace(/^.*video\.google\.com\/videoplay.*docid=(.*)$/i,"$1");Z="http://video.google.com/googleplayer.swf?docId="+W+"&#038;hl=en";Y=P(Z,b[0],b[1],{flashvars:""});break;case"IFILM":b=J(K[a].href,new Array(448,365));W=Z.replace(/\?.*$/,"").replace(/\/$/i,"").replace(/^.*\.ifilm\.com.*video\/(.*)$/i,"$1");Z="http://www.ifilm.com/efp";Y=P(Z,b[0],b[1],{flashvars:"flvbaseclip="+W+"&",quality:"high",bgcolor:"000000"});break;case"Dailymotion":b=J(K[a].href,new Array(420,330));W=Z.replace(/^.*\.dailymotion\.com\/video\/([^_]*).*$/i,"$1");Z="http://www.dailymotion.com/swf/"+W;Y=P(Z,b[0],b[1],{allowFullScreen:"true",allowScriptAccess:"always"});break;case"nicovideo":b=J(K[a].href,new Array(312,176));W=Z.replace(/^.*\.nicovideo\.jp\/watch\/(.*)$/i,"$1");Y='<iframe width="'+b[0]+'" height="'+b[1]+'" src="http://www.nicovideo.jp/thumb/'+W+'" scrolling="no" style="border:solid 1px #CCC;" frameborder="0"><a href="http://www.nicovideo.jp/watch/'+W+'">'+K[a].tytle+"</iframe>";X=500;break;case"Video":b=J(K[a].href,new Array(320,240));Z=Z.replace(/\?.*$/,"");switch(Z.match(/\.(flv|swf|rm|mov|3gp|mp4|asf|avi|mpg|wmv)$/i)[1]){case"flv":Z=S.flvplayer+"?file="+Z;case"swf":Y=P(Z,b[0],b[1],{quality:"high",bgcolor:"#000"});break;case"rm":Y='<object classid="clsid:cfcdaa03-8be4-11cf-b84b-0020afbbccfa" width="'+b[0]+'" height="'+b[1]+'"><param name="src" value="'+Z+'" /><param name="autostart" value="true" /><param name="controls" value="imagewindow,controlpanel" /><embed src="'+Z+'" width="'+b[0]+'" height="'+b[1]+'" autostart="true" controls="imagewindow,controlpanel" type="audio/x-pn-realaudio-plugin"></embed></object>';break;case"mov":case"mp4":case"3gp":b[1]+=20;Y='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'+b[0]+'" height="'+b[1]+'"><param name="src" value="'+Z+'" /><param name="href" value="'+Z+'" /><param name="controller" value="true" /><param name="pluginspage" value="http://www.apple.com/quicktime/download/" /><param name="autoplay" value="true" /><param name="bgcolor" value="000000" /><embed src="'+Z+'" width="'+b[0]+'" height="'+b[1]+'" bgcolor="000000" autoplay="true" controller="true" src="'+Z+'" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>';break;default:b[1]+=20;Y='<object classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="'+b[0]+'" height="'+b[1]+'" type="application/x-oleobject"><param name="url" value="'+Z+'" /><param name="autostart" value="true" /><param name="uiMode" value="full" /><embed src="'+Z+'" width="'+b[0]+'" height="'+b[1]+'" autostart="true" uiMode="full" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/windows/mediaplayer/"></embed></object>';break}X=1000;break}if(Y){K[a]=A.extend(K[a],{content:Y,width:b[0],height:b[1],later:X})}};var P=function(X,Z,W,a){a=A.extend({movie:X,wmode:"transparent"},a);var Y='<object data="'+X+'" type="application/x-shockwave-flash" width="'+Z+'" height="'+W+'" wmode="'+a.wmode+'">';A.each(a,function(b){Y+='<param name="'+b+'" value="'+this+'" />'});Y+="</object>";return Y};var V=function(Z){if(!L){var Y=A("#lightpop-box-hd, #lightpop-box-hdc, #lightpop-box-bd, #lightpop-box-bdc, #lightpop-box-ft, #lightpop-box-ftc");var X="transparent",W=S.contentBgColor;if(Z){A("#lightpop-box").css({"background-color":X});A("#lightpop-box-hd").css({background:X+" url("+S.imageBox+") left top no-repeat"});A("#lightpop-box-hdc").css({background:X+" url("+S.imageBox+") right top no-repeat"});A("#lightpop-box-bd").css({background:W+" url("+S.imageBorderL+") left top repeat-y"});A("#lightpop-box-bdc").css({background:X+" url("+S.imageBorderR+") right top repeat-y"});A("#lightpop-box-ft").css({background:X+" url("+S.imageBox+") left bottom no-repeat"});A("#lightpop-box-ftc").css({background:X+" url("+S.imageBox+") right bottom no-repeat"});Y.show()}else{A("#lightpop-box").css({"background-color":W});Y.css({background:X})}return Y}};var M=function(X,Y){var W=new Image();if(Y){W.onload=Y}W.src=X;return W};var E=function(X,W){return X.css({visibility:(W?"visible":"hidden")})};var F=function(W,X){A(document).unbind("keydown");if(W){A(document).keydown(function(a){var b,Y,Z;if(!a){Y=event.keyCode;Z=27}else{Y=a.keyCode;Z=a.DOM_VK_ESCAPE}b=String.fromCharCode(Y).toLowerCase();if((b==S.keyToClose)||(b=="x")||(Y==Z)){B()}else{if(((b==S.keyToPrev)||(Y==37))&&X!=0){G(X-1)}else{if(((b==S.keyToNext)||(Y==39))&&X!=(K.length-1)){G(X+1)}}}})}};var R=function(W){A(window).unbind("resize");if(W){A(window).resize(function(){var X=H();var Y=Q();A("#overlay").css({width:X[0],height:X[1]});A("#lightpop").css({top:Y[1]+Math.round(X[3]/10),left:Y[0]})})}};var H=function(){var a,W,Y,b,Z,X;if(window.innerHeight&&window.scrollMaxY){a=window.innerWidth+window.scrollMaxX;W=window.innerHeight+window.scrollMaxY}else{if(document.body.scrollHeight>document.body.offsetHeight){a=document.body.scrollWidth;W=document.body.scrollHeight}else{a=document.body.offsetWidth;W=document.body.offsetHeight}}if(self.innerHeight){if(document.documentElement.clientWidth){Y=document.documentElement.clientWidth}else{Y=self.innerWidth}b=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){Y=document.documentElement.clientWidth;b=document.documentElement.clientHeight}else{if(document.body){Y=document.body.clientWidth;b=document.body.clientHeight}}}X=(a<Y?a:Y);Z=(W<b?b:W);return new Array(X,Z,Y,b)};var Q=function(){var X,W;if(self.pageYOffset){W=self.pageYOffset;X=self.pageXOffset}else{if(document.documentElement&&document.documentElement.scrollTop){W=document.documentElement.scrollTop;X=document.documentElement.scrollLeft}else{if(document.body){W=document.body.scrollTop;X=document.body.scrollLeft}}}return new Array(X,W)};var B=function(){E(A("object",A("#lightpop")),false).remove();A("#lightpop").slideUp(function(){A(this).remove();A("#overlay").fadeOut(function(){A(this).remove();E(A("embed, object, select"),true)})});F(false);R(false)};return C(this)}})(jQuery)