
var FLVlistener={onInit:function(){FLVcontroller.getFlashObject().SetVariable('method:setUrl',FLVcontroller.src);$('#lightboxctrlwrapper').prepend($(document.createElement('ul')).attr('id','flv-player-ctrl').append($(document.createElement('li')).attr('id','flv-player-playbtn').click(function(){FLVcontroller.pause();})).append($(document.createElement('li')).attr('id','flv-player-volume').append($(document.createElement('div')).slider({stop:function(){FLVcontroller.setVolume($(this).slider('value'));}}))).append($(document.createElement('li')).attr('id','flv-player-seek').append($(document.createElement('div')).attr('id','flv-player-elapsed')).append($(document.createElement('div')).attr('id','flv-player-seekslide').slider({slide:function(){FLVcontroller.setPosition($(this).slider('value'));}})).append($(document.createElement('div')).attr('id','flv-player-timer'))));FLVcontroller.setVolume('80');FLVcontroller.play();},onClick:function(){},onKeyUp:function(){},onFinished:function(){},onUpdate:function(){function two(x){return((x>9)?"":"0")+x};function time(ms){var sec=Math.floor(ms/1000);ms=ms%1000;var min=Math.floor(sec/60);sec=sec%60;min=min%60;return two(min)+':'+two(sec);};$('#flv-player-volume').slider('value',this.volume);$('#flv-player-seekslide').slider('value',Math.round(100*this.position/this.duration));$('#flv-player-elapsed').text(time(this.position));$('#flv-player-timer').text('-'+time(this.duration-this.position));}};var FLVcontroller={src:null,getFlashObject:function(){return document.getElementById('flv-player-js');},play:function(){this.getFlashObject().SetVariable('method:play','');$('#flv-player-playbtn').text('pause').addClass('isplaying');},pause:function(){if(FLVlistener.isPlaying=="true"){this.getFlashObject().SetVariable('method:pause','');$('#flv-player-playbtn').text('play').removeClass('isplaying');}else{FLVcontroller.play();}},setVolume:function(vol){this.getFlashObject().SetVariable('method:setVolume',vol);},setPosition:function(seek){this.getFlashObject().SetVariable('method:setPosition',(seek*FLVlistener.duration/100));}};(function($) {$.fn.lightbox=function(params){var params=$.extend({closeLabel:'close',imgFadeInDelay:1000,imgFadeOutDelay:250,imgMargin:8,ctrlFadeInDelay:300,ctrlFadeOutDelay:300,boxResizeDelay:700,player:'/madsgraphics.com/themes/fantasy/files/player_flv_js.swf'},params);var lightBox=$(document.createElement('div')).attr('id','lightbox').css({width:'40px',height:'40px',position:'absolute',left:'50%',marginLeft:'-20px',top:$(document).scrollTop()+($(window).height()/2),marginTop:'-20px'}).mouseover(function(){$('#lightboxctrl').css('margin-left','-'+$('#lightboxctrl').width()/2+'px').fadeTo(params.ctrlFadeInDelay,1);$('#lightboxclose').css('margin-left','-'+$('#lightboxclose').width()/2+'px').fadeTo(params.ctrlFadeInDelay,1);}).mouseleave(function(){$('#lightboxctrl').fadeTo(params.ctrlFadeOutDelay,0);$('#lightboxclose').fadeTo(params.ctrlFadeOutDelay,0);}).append($(document.createElement('div')).attr('id','lightboxwrapper').append($(document.createElement('div')).attr('id','lightboxtop').append($(document.createElement('div')).attr('id','lightboxtopright')).append($(document.createElement('div')).attr('id','lightboxtopleft')).append($(document.createElement('div')).attr('id','lightboxtopbetween'))).append($(document.createElement('div')).attr('id','lightboximgwrapper').append($(document.createElement('div')).attr('id','lightboximg'))).append($(document.createElement('div')).attr('id','lightboxbottom').append($(document.createElement('div')).attr('id','lightboxbottomright')).append($(document.createElement('div')).attr('id','lightboxbottomleft')).append($(document.createElement('div')).attr('id','lightboxbottombetween'))));var lightBoxClose=$(document.createElement('div')).attr('id','lightboxclose').text(params.closeLabel).css({position:'absolute',top:params.imgMargin,left:'50%',opacity:0}).click(function(){closeBox();});function openBox(jElt){$(document.createElement('div')).attr('id','lightboxopacity').css({backgroundColor:'#eee',width:$('body').width(),height:$('body').height(),position:'absolute',top:0,left:0,opacity:0,zIndex:7000}).appendTo('body').fadeTo(500,0.80);lightBox.appendTo('body');lightBoxClose.appendTo(lightBox);var lightBoxCtrl=$(document.createElement('div')).attr('id','lightboxctrl').css('opacity',0).append($(document.createElement('div')).attr('id','lightboxctrltopwrapper').append($(document.createElement('div')).attr('id','lightboxctrltopright')).append($(document.createElement('div')).attr('id','lightboxctrltopleft')).append($(document.createElement('div')).attr('id','lightboxctrltopbetween'))).append($(document.createElement('div')).attr('id','lightboxctrlwrapper')).append($(document.createElement('div')).attr('id','lightboxctrlbottomwrapper').append($(document.createElement('div')).attr('id','lightboxctrlbottomright')).append($(document.createElement('div')).attr('id','lightboxctrlbottomleft')).append($(document.createElement('div')).attr('id','lightboxctrlbottombetween'))).appendTo(lightBox);var switcher=jElt.clone().appendTo('#lightboxctrlwrapper').attr('id','lightboxswitcher');switcher.find('li:first a').addClass('current');switcher.find('a:not(.link)').click(function(event){event.preventDefault();switcher.find('a.current').removeClass('current');$(this).addClass('current');if($(this).hasClass('image')){switchImage($(this).attr('href'));}else if($(this).hasClass('movie')){switchMovie($(this).attr('href'));}});};function closeBox(){$('#lightboxctrl').fadeTo(params.imgFadeOutDelay-100,0,function(){$(this).remove();});$('#lightboxclose').fadeTo(params.imgFadeOutDelay-100,0,function(){$(this).remove();});$('#lightboximg').fadeTo(params.imgFadeOutDelay,0,function(){$('#lightbox').animate({width:0,height:0,marginLeft:0,marginTop:0},params.boxResizeDelay,function(){$(this).remove();$('#lightboxopacity').fadeTo(350,0,function(){$(this).remove();});});});};function resizeBox(html,w,h){$('#lightboxctrl').fadeTo(params.imgFadeOutDelay-100,0,function(){$('#flv-player-ctrl').remove();});$('#lightboxclose').fadeTo(params.imgFadeOutDelay-100,0);$('#lightboximg').fadeTo(params.imgFadeOutDelay,0,function(){$('#lightboximg').html(html);});$('#lightboximg').queue(function(){var lightBoxHeight=h;var lightBoxWidth=w+params.imgMargin*2;$('#lightbox').animate({width:lightBoxWidth,height:lightBoxHeight,marginLeft:'-'+(lightBoxWidth/2)+'px',marginTop:'-'+(lightBoxHeight/2)+'px'},params.boxResizeDelay,'easeOutBack');$(this).animate({width:w,height:h},params.boxResizeDelay);$(this).dequeue();});$('#lightboximg').queue(function(){$(this).fadeTo(params.imgFadeInDelay,1);$(this).dequeue();});};function switchImage(url){IMG=new Image();IMG.src=url;IMG.onload=function(){resizeBox(IMG,IMG.width,IMG.height);};};function switchMovie(url){FLVcontroller.src=url;var flashObject=$(document.createElement('div')).flash({swf:params.player,width:640,height:360,flashvars:{listener:'FLVlistener',interval:500,useHandCursor:0,buffer:5,bgcolor:'000000'},attrs:{id:'flv-player-js'}});resizeBox(flashObject.html(),640,360);};return this.each(function(){var jElt=$(this);openBox(jElt);switchImage(jElt.find('li:first a').attr('href'));});}})(jQuery);