var popup=(function(){function Popup(){imgdir='http://'+location.host+"/images/skin/";imgNames={t:"tb.png",tl:"tlb.png",tr:"trb.png",l:"lb.png",r:"rb.png",b:"bb.png",bl:"blb.png",br:"brb.png",close:"imgzoom-close.png",left:"left.png",right:"right.png",loader:"loader.gif",play:"play.png"};this.pic=[];for(var i in imgNames){this.pic[i]=new Image();this.pic[i].src=imgdir+imgNames[i];}
this.easingOpen='easeInOutQuart';this.easingFit='easeOutBounce';this.easingTransfer='easeInOutExpo';this.easingClose='easeInOutQuart';this.timeOpen=1000;this.timeFit=1000;this.timeTransfer=1000;this.timeClose=500;this.$popUpTop=$("<tr>");this.$popUpTopLeft=$("<td>");this.$popUpTopCenter=$("<td>&nbsp;</td>");this.$popUpTopRight=$("<td>");this.$popUpMid=$("<tr>");this.$popUpMidLeft=$("<td>");this.$popUpMidCenter=$("<td>&nbsp;</td>");this.$popUpMidRight=$("<td>");this.$popUpBot=$("<tr>");this.$popUpBotLeft=$("<td>");this.$popUpBotCenter=$("<td>&nbsp;</td>");this.$popUpBotRight=$("<td>");this.$popUpTop.append(this.$popUpTopLeft);this.$popUpTop.append(this.$popUpTopCenter);this.$popUpTop.append(this.$popUpTopRight);this.$popUpMid.append(this.$popUpMidLeft);this.$popUpMid.append(this.$popUpMidCenter);this.$popUpMid.append(this.$popUpMidRight);this.$popUpBot.append(this.$popUpBotLeft);this.$popUpBot.append(this.$popUpBotCenter);this.$popUpBot.append(this.$popUpBotRight);this.$popCov=$('<div></div>');this.$popCov.attr('id','pop_cov');this.$popCov.css({"position":"fixed","top":"0px","left":"0px","width":$(window).width(),"height":$(window).height(),"background-color":"black","opacity":0,'z-index':'999'});this.$popUp=$("<table>");this.$popUp.attr('id','pop_up');this.$popUp.attr('cellpadding','0');this.$popUp.attr('cellspacing','0');this.$popUp.css({'position':'absolute'})
this.$popUp.append(this.$popUpTop);this.$popUp.append(this.$popUpMid);this.$popUp.append(this.$popUpBot);this.$closeImg=$('<div>');this.$closeImg.attr('id','popup-close-img');this.$content=$('<div>');this.$leftButton=$('<div>');this.$leftButton.addClass('popup-left-button');this.$leftButton.append(this.pic['left']);this.$leftButton.mouseover(function(){$(this).stop();$(this).fadeTo(300,1);});this.$leftButton.mouseout(function(){$(this).stop();$(this).fadeTo(300,0.5);});this.$leftButton.click(function(){newSrc=popup.nextSrc('-');popup.$content.before(popup.$loader);popup.$loader.css({'width':popup.$content.width()});if(newSrc){popup.newImg=new Image();popup.newImg.onload=function(){popup.changeContent('-')}
popup.newImg.src=newSrc;$(this).css({'opacity':'0.5'})
popup.imgPos--;}});this.$leftButton.attr('id','popup-left-button');this.$rightButton=$('<div>');this.$rightButton.addClass('popup-left-button');this.$rightButton.append(this.pic['right']);this.$rightButton.mouseover(function(){$(this).stop();$(this).fadeTo(300,1);});this.$rightButton.mouseout(function(){$(this).stop();$(this).fadeTo(300,0.5);});this.$rightButton.click(function(){newSrc=popup.nextSrc('+');popup.$content.before(popup.$loader);popup.$loader.css({'width':popup.$content.width()});if(newSrc){popup.newImg=new Image();popup.newImg.onload=function(){popup.changeContent('+');}
popup.newImg.src=newSrc;$(this).css({'opacity':'0.5'})
popup.imgPos++;}});this.$rightButton.attr('id','popup-right-button');this.pic['left'];this.pic['right'];this.$loader=$('<div><img src="'+this.pic['loader'].src+'"></div>');this.pop=function(obj,size,link,type,after){$(obj).click(function(){popup.after=after;popup.setSkinCSS();if(!type){if(link.constructor==Array){popup.type='img';popup.links=link;}
else if(link.constructor==Object){if(isYT(link.link)){popup.vid=link;popup.vid.ID=isYT(link.link);popup.vid.width=size[0];popup.vid.height=size[1];popup.type='ytvid';}else popup.type=false;}
else if((getExtension(link)=='.jpg')||(getExtension(link)=='.png')){popup.type='img';popup.links=[link];}
else if(isYT(link)){popup.type='ytvid';popup.vid={ID:isYT(link),width:size[0],height:size[1]};}
else if(isURL(link)){popup.type='link';popup.postLink=link;}
else popup.type=false;}
popup.$closeImg.click(function(){popup.$closeImg.css({'background-position':'0 0'});popup.$closeImg.remove();popup.$leftButton.detach();popup.$rightButton.detach();popup.$popUpMidCenter.html('&nbsp');popup.$content.empty();popup.$popCov.css({'opacity':'0'})
if(popup.type=='ytvid'){popup.$videoCover.remove();popup.$content.removeAttr('id');popup.$content.removeAttr('style');}
popup.$content.css({'opacity':'0'})
popup.$popUp.animate({'top':popup.pTop,'left':popup.pLeft,'width':popup.pWidth,'height':popup.pHeight},popup.timeClose,popup.easingClose,function(){popup.$popUp.remove();popup.$popCov.detach();})});popup.$closeImg.mouseover(function(){$(this).css({'background-position':'0 '+popup.pic['close'].height/2+'px'})});popup.$closeImg.mouseout(function(){$(this).css({'background-position':'0 0'})});if(popup.type=='img'){popup.currImg=new Image();popup.currImg.src=popup.links[0];popup.imgPos=0;popup.$content.append(popup.currImg);}
popup.nWidth=size[0]+popup.pic['l'].width+popup.pic['r'].width;if('v'=='\v')popup.nHeight=size[1];else popup.nHeight=size[1]+popup.pic['t'].height+popup.pic['b'].height;popup.nLeft=($(window).width()-popup.nWidth)/2;popup.pWidth=$(obj).width()+popup.pic['l'].width+popup.pic['r'].width;if('v'=='\v')popup.pHeight=$(obj).height();else popup.pHeight=$(obj).height()+popup.pic['t'].height+popup.pic['b'].height;popup.pTop=$(obj).offset().top-20;popup.pLeft=$(obj).offset().left-20;popup.$popUp.css({'top':popup.pTop,'left':popup.pLeft,'position':'absolute','width':popup.pWidth,'height':popup.pHeight,'z-index':'1000'});popup.$content.css({'opacity':'0','overflow':'hidden'});$('body').append(popup.$popCov);$('body').append(popup.$popUp);popup.$popUp.animate({'left':popup.nLeft,'top':((size[2])?size[2]:($(window).height()-popup.nHeight)/2)+$(window).scrollTop(),'width':popup.nWidth,'height':popup.nHeight},popup.timeOpen,popup.easingOpen,function(){popup.$popCov.fadeTo(500,0.8);popup.$content.ready(function(){popup.$popUpMidCenter.css({'text-align':'center'});popup.$popUpMidCenter.append(popup.pic['loader']);popup.changeContent();})});});}
this.popOpen=function(obj,size,link,type){popup.setSkinCSS();if(!type){if(link.constructor==Array){popup.type='img';popup.links=link;}
else if(link.constructor==Object){if(isYT(link.link)){popup.vid=link;popup.vid.ID=isYT(link.link);popup.vid.width=size[0];popup.vid.height=size[1];popup.type='ytvid';}else popup.type=false;}
else if((getExtension(link)=='.jpg')||(getExtension(link)=='.png')){popup.type='img';popup.links=[link];}
else if(isYT(link)){popup.type='ytvid';popup.vid={ID:isYT(link),width:size[0],height:size[1]};}
else if(isURL(link)){popup.type='link';popup.postLink=link;}
else popup.type=false;}
popup.$closeImg.click(function(){popup.$closeImg.css({'background-position':'0 0'});popup.$closeImg.remove();popup.$leftButton.detach();popup.$rightButton.detach();popup.$popUpMidCenter.html('&nbsp');popup.$content.empty();popup.$popCov.css({'opacity':'0'})
if(popup.type=='ytvid'){popup.$videoCover.remove();popup.$content.removeAttr('id');popup.$content.removeAttr('style');}
popup.$content.css({'opacity':'0'})
popup.$popUp.animate({'top':popup.pTop,'left':popup.pLeft,'width':popup.pWidth,'height':popup.pHeight},popup.timeClose,popup.easingClose,function(){popup.$popUp.remove();popup.$popCov.detach();})});popup.$closeImg.mouseover(function(){$(this).css({'background-position':'0 '+popup.pic['close'].height/2+'px'})});popup.$closeImg.mouseout(function(){$(this).css({'background-position':'0 0'})});if(popup.type=='img'){popup.currImg=new Image();popup.currImg.src=popup.links[0];popup.imgPos=0;popup.$content.append(popup.currImg);}
popup.nWidth=size[0]+popup.pic['l'].width+popup.pic['r'].width;if('v'=='\v')popup.nHeight=size[1];else popup.nHeight=size[1]+popup.pic['t'].height+popup.pic['b'].height;popup.nLeft=($(window).width()-popup.nWidth)/2;popup.pWidth=$(obj).width()+popup.pic['l'].width+popup.pic['r'].width;if('v'=='\v')popup.pHeight=$(obj).height();else popup.pHeight=$(obj).height()+popup.pic['t'].height+popup.pic['b'].height;popup.pTop=$(obj).offset().top-20;popup.pLeft=$(obj).offset().left-20;popup.$popUp.css({'top':popup.pTop,'left':popup.pLeft,'position':'absolute','width':popup.pWidth,'height':popup.pHeight,'z-index':'1000'});popup.$content.css({'opacity':'0','overflow':'hidden'});$('body').append(popup.$popCov);$('body').append(popup.$popUp);popup.$popUp.animate({'left':popup.nLeft,'top':((size[2])?size[2]:($(window).height()-popup.nHeight)/2)+$(window).scrollTop(),'width':popup.nWidth,'height':popup.nHeight},popup.timeOpen,popup.easingOpen,function(){popup.$popCov.fadeTo(500,0.8);popup.$content.ready(function(){popup.$popUpMidCenter.css({'text-align':'center'});popup.$popUpMidCenter.append(popup.pic['loader']);popup.changeContent();})});}
this.close=function(){popup.$closeImg.css({'background-position':'0 0'});popup.$closeImg.remove();popup.$leftButton.detach();popup.$rightButton.detach();popup.$popUpMidCenter.html('&nbsp');popup.$content.empty();popup.$popCov.css({'opacity':'0'})
if(popup.type=='ytvid'){popup.$videoCover.remove();popup.$content.removeAttr('id');popup.$content.removeAttr('style');}
popup.$content.css({'opacity':'0'})
popup.$popUp.animate({'top':popup.pTop,'left':popup.pLeft,'width':popup.pWidth,'height':popup.pHeight},popup.timeClose,popup.easingClose,function(){popup.$popUp.remove();popup.$popCov.detach();})}
this.changeContent=function(direction){if('v'=='\v')var borderHeight=0;else var borderHeight=40;if(this.type=='img'){popup.$content.css({'position':'absolute'});if(!direction){popup.$popUp.animate({'width':popup.currImg.width+popup.pic['l'].width+popup.pic['r'].width,'height':popup.currImg.height+borderHeight,'left':($(window).width()-popup.currImg.width-(popup.pic['l'].width+popup.pic['r'].width))/2},popup.timeFit,popup.easingFit,function(){popup.$leftButton.css({'top':-popup.currImg.height,'height':popup.currImg.height-(popup.currImg.height/2-38),'padding-top':popup.currImg.height/2-38,'width':popup.currImg.width/2});popup.$rightButton.css({'top':popup.nextSrc('-')?-popup.currImg.height*2:-popup.currImg.height,'left':popup.currImg.width/2,'width':popup.currImg.width/2,'height':popup.currImg.height-(popup.currImg.height/2-38),'padding-top':popup.currImg.height/2-38});popup.$popUpMidCenter.html('');popup.$popUpMidCenter.append(popup.$content);popup.$content.fadeTo(1000,1);if(popup.nextSrc('-'))popup.$content.append(popup.$leftButton);if(popup.nextSrc('+'))popup.$content.append(popup.$rightButton);popup.$popUpTopRight.append(popup.$closeImg);});}else{popup.$leftButton.detach();popup.$rightButton.detach();popup.$closeImg.detach();$(popup.pic['loader']).detach();var $newBg=$('<div>');$newBg.css({'background-image':'url("'+popup.newImg.src+'")','background-repeat':'no-repeat','background-position':'center','width':0,'height':popup.currImg.height,'float':'left'});var $oldBg=$('<div>');$oldBg.css({'background-image':'url("'+popup.currImg.src+'")','background-repeat':'no-repeat','background-position':'center','width':popup.currImg.width,'height':popup.currImg.height,'float':'left'});$(popup.currImg).remove();if(direction=='+'){popup.$content.append($oldBg);popup.$content.append($newBg);}
if(direction=='-'){popup.$content.append($newBg);popup.$content.append($oldBg);}
popup.$loader.remove();popup.$popUp.animate({'width':popup.newImg.width+popup.pic['l'].width+popup.pic['r'].width,'height':popup.newImg.height+borderHeight,'left':($(window).width()-popup.newImg.width-(popup.pic['l'].width+popup.pic['r'].width))/2},popup.timeTransfer,popup.easingTransfer,function(){$oldBg.remove();$newBg.remove();popup.$content.append(popup.newImg);popup.currImg=popup.newImg;popup.$leftButton.css({'top':-popup.currImg.height,'width':popup.currImg.width/2,'height':popup.currImg.height-(popup.currImg.height/2-38),'padding-top':popup.currImg.height/2-38});popup.$rightButton.css({'top':popup.nextSrc('-')?-popup.currImg.height*2:-popup.currImg.height,'left':popup.currImg.width/2,'width':popup.currImg.width/2,'height':popup.currImg.height-(popup.currImg.height/2-38),'padding-top':popup.currImg.height/2-38});if(popup.nextSrc('-'))popup.$content.append(popup.$leftButton);if(popup.nextSrc('+'))popup.$content.append(popup.$rightButton);popup.$popUpTopRight.append(popup.$closeImg);});$oldBg.animate({'width':0,'height':popup.newImg.height},popup.timeTransfer,popup.easingTransfer);$newBg.animate({'width':popup.newImg.width,'height':popup.newImg.height},popup.timeTransfer,popup.easingTransfer);}}else if(this.type=='link'){$.post(popup.postLink,function(data){popup.$content.html(data);popup.$popUpMidCenter.html('');popup.$popUpMidCenter.append(popup.$content);popup.$content.css({'display':'table-cell'});popup.tWidth=popup.$content.width();popup.tHeight=popup.$content.height();popup.$content.detach();popup.$popUpMidCenter.html('&nbsp;');popup.$popUp.animate({'width':popup.tWidth+40,'height':popup.tHeight+borderHeight,'left':($(window).width()-popup.tWidth-40)/2},popup.timeFit,popup.easingFit,function(){popup.$popUpMidCenter.html('');popup.$popUpMidCenter.append(popup.$content);popup.$content.fadeTo(1000,1);popup.$popUpTopRight.append(popup.$closeImg);if(popup.after)if(popup.after.constructor===Function)popup.after();});});}else if(this.type=='ytvid'){popup.$videoCover=$('<div>');popup.$videoCover.css({"position":'absolute',"width":this.vid.width,"height":this.vid.height,"background-color":"#FFFFFF","opacity":"0.99","z-index":"1000"});popup.$videoCover.append(popup.pic['loader']);popup.$content.attr("id","popupVidContent");popup.$popUpMidCenter.html('');popup.$popUpTopRight.append(popup.$closeImg);popup.$content.css({'text-align':'center'});popup.$popUpMidCenter.append(popup.$content);var params={allowScriptAccess:"always",allowfullscreen:"true",wmode:"transparent"};popup.$content.before(popup.$videoCover);if(swfobject)swfobject.embedSWF("http://www.youtube.com/apiplayer?video_id="+this.vid.ID+"?version=3&enablejsapi=1&playerapiid=ytplayer&autoplay=0","popupVidContent",this.vid.width,this.vid.height,"8",null,null,params,null);else alert('No swfobject detected')}else{popup.$popUpMidCenter.html('');popup.$popUpTopRight.append(popup.$closeImg);popup.$content.html('nothing to POP');popup.$content.css({'text-align':'center'});popup.$popUpMidCenter.append(popup.$content);popup.$content.fadeTo(1000,1);}}
this.nextSrc=function(direction){if(!popup.imgPos)popup.imgPos=0;if(((popup.links.length>popup.imgPos)||(popup.imgPos>=0))&&(direction=='+'))return popup.links[popup.imgPos+1];else if(((popup.links.length>popup.imgPos)||(popup.imgPos>=0))&&(direction=='-'))return popup.links[popup.imgPos-1];else return false;}
this.setSkinCSS=function(){if(!this.$popUpTopLeft.attr('style'))
this.$popUpTopLeft.css({'background':'url('+this.pic['tl'].src+') no-repeat scroll 0 0 transparent','height':this.pic['tl'].height,'overflow':'hidden','width':this.pic['tl'].width,'font-size':'1px','padding':'0'});if(!this.$popUpTopCenter.attr('style'))this.$popUpTopCenter.css({'background':'url('+this.pic['t'].src+') repeat-x scroll 0 0 transparent','height':this.pic['t'].height,'overflow':'hidden','font-size':'1px','padding':'0'});if(!this.$popUpTopRight.attr('style'))this.$popUpTopRight.css({'background':'url('+this.pic['tr'].src+') no-repeat scroll 100% 0 transparent','height':this.pic['tr'].height,'overflow':'visible','width':this.pic['tr'].width,'font-size':'1px','padding':'0'});if(!this.$popUpMidLeft.attr('style'))this.$popUpMidLeft.css({'background':'url('+this.pic['l'].src+') repeat-y scroll 0 0 transparent','width':this.pic['l'].width,'overflow':'hidden','font-size':'1px','padding':'0'});if(!this.$popUpMidCenter.attr('style'))this.$popUpMidCenter.css({'vertical-align':'top','height':'100%','background-color':'#FFFFFF','padding':'0'});if(!this.$popUpMidRight.attr('style'))this.$popUpMidRight.css({'background':'url('+this.pic['r'].src+') repeat-y scroll 100% 0 transparent','overflow':'hidden','width':this.pic['r'].width,'font-size':'1px','padding':'0'});if(!this.$popUpBotLeft.attr('style'))this.$popUpBotLeft.css({'background':'url('+this.pic['bl'].src+') no-repeat scroll 0 100% transparent','height':this.pic['bl'].height,'width':this.pic['bl'].width,'overflow':'hidden','font-size':'1px','padding':'0'});if(!this.$popUpBotCenter.attr('style'))this.$popUpBotCenter.css({'background':'url('+this.pic['b'].src+') repeat-x scroll 0 100% transparent','height':this.pic['b'].height,'overflow':'hidden','font-size':'1px','padding':'0'});if(!this.$popUpBotRight.attr('style'))this.$popUpBotRight.css({'background':'url('+this.pic['br'].src+') no-repeat scroll 100% 100% transparent','height':this.pic['br'].height,'overflow':'hidden','width':this.pic['br'].width,'font-size':'1px','padding':'0'});if(!this.$closeImg.attr('style')){marginTop=-(this.pic['close'].height/8);if(/MSIE (\d+\.\d+);/.test(navigator.userAgent))if(new Number(RegExp.$1)<8)marginTop=0;this.$closeImg.css({'background':'url("'+this.pic['close'].src+'")','position':'absolute','height':this.pic['close'].height/2,'width':this.pic['close'].width,'margin-left':-(this.pic['close'].width/2),'margin-top':marginTop,'cursor':'pointer','z-index':'1001'});}
if(!this.$rightButton.attr('style'))this.$rightButton.css({'opacity':'0.5','z-index':'1001','position':'relative','text-align':'right'});if(!this.$leftButton.attr('style'))this.$leftButton.css({'opacity':'0.5','z-index':'1001','position':'relative','text-align':'left'});if(!this.$loader.attr('style'))this.$loader.css({'position':'absolute','background-color':'white','opacity':'1'});}
function isURL(s){var regexp=/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/;return regexp.test(s);}
function isYT(s){if(s.indexOf('youtube')!=-1){var from=s.indexOf('?v=')+3;var to=s.indexOf('&');if(to==-1)to=s.length;var id=s.substring(from,to);if(id.length>0)return id;else return false}
else return false;}
function getExtension(s){if((!s)||(s.length==0))return"";else{var dot=s.lastIndexOf(".");if(dot==-1)return"";else{var extension=s.substr(dot,s.length).split('?');return extension[0];}}}}return new Popup();}());$(window).resize(function(){var $wind=$(window);if($('#pop_cov')){popup.$popCov.css({"width":$wind.width(),"height":$wind.height()});}
if($('#popup-close-img').length!=0){popup.$popUp.stop();popup.$popUp.animate({'top':$wind.scrollTop()+popup.nTop,'left':($wind.width()-$('#pop_up').width())/2},300);}});function onYouTubePlayerReady(playerId){ytplayer=document.getElementById("popupVidContent");ytplayer.addEventListener("onStateChange","onytplayerStateChange");ytplayer.addEventListener("onError","onPlayerError");ytplayer.loadVideoById(popup.vid.ID,0);$(popup.pic['play']).click(function(){if(ytplayer.state===2){ytplayer.playVideo();$(this).detach();}});popup.$videoCover.click(function(){if(ytplayer.state===1){ytplayer.pauseVideo();popup.$videoCover.before(popup.pic['play']);$(popup.pic['play']).css({'cursor':'pointer','position':'absolute','z-index':'1001','margin-top':(popup.nHeight-popup.pic['play'].height)/2-popup.pic['t'].height,'margin-left':(popup.nWidth-popup.pic['play'].width)/2-popup.pic['l'].width});popup.$videoCover.css('cursor','default');}});}
function onytplayerStateChange(newState){ytplayer.state=newState;if(newState==1){popup.$videoCover.fadeTo(400,0);popup.$videoCover.css('cursor','pointer');}}
