var areaUrl='';var animationTime=1000;var scrollBarAnimationTime=500;var xhrRequestObject=null;var NLPostXMLHttpRequest=null;var displayHeight=0;var minTop=0;jQuery.easing.def='easeInOutQuad';jQuery(function(){jQuery('.newsletter').find('.nlText:first').attr('status','close').click(function(){var clicker=jQuery(this);var wrapper=clicker.parent().find('.wrapper');if(clicker.attr('status')=='close'){clicker.attr('status','open');clicker.parent().stop().animate({bottom:0},750,jQuery.easing.def);wrapper.stop().animate({height:76},750,jQuery.easing.def);}else{clicker.attr('status','close');clicker.parent().stop().animate({bottom:76},750,jQuery.easing.def);wrapper.stop().animate({height:0},750,jQuery.easing.def);}}).parent().find('.wrapper').height(0);var randomSkin=Math.floor(Math.random()*9+1);randomSkin+=4;jQuery('body').attr('class','style'+randomSkin);jQuery('.backgroundclicker').click(function(){var index=jQuery('.backgroundclicker').index(jQuery(this));jQuery('.backgroundclicker').removeClass('active');jQuery(jQuery('.backgroundclicker').get(index)).addClass('active');jQuery('body').attr('class','style'+(index+1));});jQuery('#slideArea').css('opacity',0);jQuery('#area1').css('opacity',0);jQuery('#area2').css('opacity',0);jQuery.address.change(function(event){areaUrl=event.value.split('/')[1];SetDisplayHeight();CloseViewports();jQuery('.menuItem a[rel="address:/'+areaUrl+'"]').addClass('selected').parent().addClass('selected');var index=jQuery('.menuItem').index(jQuery('.menuItem a[rel="address:/'+areaUrl+'"]').parent());if(index!=-1)
{jQuery('body').attr('class','style'+(index+5));jQuery('.backgroundclicker').removeClass('active');jQuery('meta[name="fragment"]').remove();}
else
{jQuery('<meta name="fragment" content="!">').prependTo('head');}});jQuery('.menuItem a').click(function(){jQuery(this).addClass('selected');});jQuery('.socialNetworks').hover(function(){jQuery(this).stop().animate({right:0},250,jQuery.easing.def);},function(){jQuery(this).stop().animate({right:-155},250,jQuery.easing.def);});jQuery('#nlText').focus(function(){var item=jQuery(this);if(item.val()=='insert email'){item.val('');}}).blur(function(){var item=jQuery(this);if(item.val()==''||strlen(item.val())<=0){item.val('insert email');}});jQuery('#nlSend').click(function(){if(NLPostXMLHttpRequest!=null){NLPostXMLHttpRequest.abort();NLPostXMLHttpRequest=null;}
NLPostXMLHttpRequest=jQuery.post('public/remoting/newsletterpost.php',{email:jQuery('#nlText').val()},function(data,textStatus,XMLHttpRequest){alert(data.message);jQuery('#nlText').val('').blur();jQuery('.newsletter').find('.nlText:first').click();},'json');});});function SetDisplayHeight(){var windowHeight=jQuery(window).height();if(windowHeight<800)windowHeight=800;if(windowHeight>940)windowHeight=940;var nlSize;var nlBottom;jQuery('.siteContainer').height(windowHeight);if(jQuery('.newsletter').find('.nlText:first').attr('status')=='close'){nlBottom=76;nlSize=jQuery('.newsletter').outerHeight()+76;}else{nlBottom=0;nlSize=jQuery('.newsletter').outerHeight();}
jQuery('.newsletter').css('display','block').css('bottom',nlBottom);jQuery('.menu').css('display','block').css('bottom',nlSize+5);jQuery('.logo').css('display','block').css('bottom',nlSize+5+jQuery('.menu').outerHeight()+5);jQuery('.flowRecordsLink').css('display','block').css('bottom',nlSize+5+jQuery('.menu').outerHeight()+5);jQuery('.socialNetworks').css('display','block').css('bottom',nlSize+5+jQuery('.menu').outerHeight()+5);minTop=windowHeight-(nlSize+5+jQuery('.menu').outerHeight()+5+jQuery('.logo').outerHeight()+5);displayHeight=windowHeight-(jQuery('.mediaPlayer').outerHeight()+5);displayHeight-=(jQuery('.backgroundChanger').outerHeight()+5);displayHeight-=(jQuery('.logo').outerHeight()+5);displayHeight-=(jQuery('.menu').outerHeight()+5);displayHeight-=(nlSize+5);jQuery('#slideArea').height(displayHeight);jQuery('#area1').height(displayHeight);jQuery('#area2').height(displayHeight);}
jQuery(window).resize(function(){SetDisplayHeight();SetupSlider();});function CloseViewports(){ShowPreloader();var area2=jQuery('#area2');var area1=jQuery('#area1');var slider=jQuery('#slideArea');var trigger=false;jQuery('.menuItem a').removeClass('selected').parent().removeClass('selected');if(area2.attr('status')=='open'){area2.stop().animate({'width':0,'opacity':0},animationTime,jQuery.easing.def,function(){area2.attr('status','close');area2.css('display','none');area2.empty();trigger=true;});}else{trigger=true;}
slider.stop().animate({opacity:0},scrollBarAnimationTime,jQuery.easing.def,function(){slider.css('display','none');});area1.stop().animate({top:minTop,height:0,opacity:0},animationTime,jQuery.easing.def,function(){area1.attr('status','close');area1.css('display','none');jQuery('#area1 #scroller').empty();RemoteCallback();});}
function ShowMainViewport(){HidePreloader();var area1=jQuery('#area1').css('display','block');area1.stop().attr('status','open').animate({top:80,height:displayHeight,opacity:1},animationTime,jQuery.easing.def,SetupSlider);}
function ShowSecondViewport(vpWidth){HidePreloader();var area2=jQuery('#area2').css('display','block');area2.stop().attr('status','open').animate({width:vpWidth,opacity:1},animationTime,jQuery.easing.def);}
function RemoteCallback(){if(areaUrl!=''){if(xhrRequestObject!=null)xhrRequestObject.abort();xhrRequestObject=jQuery.ajax({cache:false,complete:function(){HidePreloader();xhrRequestObject=null;jQuery('.menuItem a[rel="address:/'+areaUrl+'"]').addClass('selected');ShowMainViewport();},data:'type='+areaUrl,dataType:'html',success:function(data){jQuery(data).appendTo(jQuery('#area1 #scroller'));},url:'public/remoting/remoting.php'});}else{jQuery.address.title('DJPena :: Homepage');HidePreloader();}}
function SetupSlider(){var scrollBar=jQuery('#slideArea');var viewport=jQuery('#area1');var content=jQuery('#area1 #scroller');var dragKnob=jQuery('#slideArea #knob');if(content.outerHeight()<viewport.outerHeight()){scrollBar.animate({opacity:0},scrollBarAnimationTime,jQuery.easing.def,function(){scrollBar.css('display','none');});}else{scrollBar.css('display','block').animate({opacity:1},scrollBarAnimationTime,jQuery.easing.def);dragKnob.css('top',0);var viewportHeight=viewport.outerHeight();var contentHeight=content.outerHeight();var cst;if(jQuery.browser.safari){cst=(contentHeight-viewportHeight)/(displayHeight-dragKnob.height());}else{cst=(contentHeight-viewportHeight)/(displayHeight-dragKnob.height());}
if(dragKnob.data('isdrag')==true){dragKnob.draggable('destroy');}
dragKnob.draggable({axis:'y',containment:'parent',drag:function(event,ui){viewport.scrollTop(cst*ui.position.top);},refreshPositions:true});dragKnob.data('isdrag',true);viewport.unbind('mwheelIntent');viewport.mwheelIntent(function(event,delta){viewport.stop();dragKnob.stop();if(delta>0){var knobPos=dragKnob.offset().top-scrollBar.offset().top;knobPos-=25;if(knobPos<0)
knobPos=0;dragKnob.animate({top:knobPos},50,function(){viewport.scrollTop(cst*knobPos);});}else{var knobPos=dragKnob.offset().top-scrollBar.offset().top;knobPos+=25;if(knobPos>(displayHeight-dragKnob.height()))
knobPos=(displayHeight-dragKnob.height());dragKnob.animate({top:knobPos},50,function(){viewport.scrollTop(cst*knobPos);});}});if(dragKnob&&dragKnob.offset()&&scrollBar&&scrollBar.offset()){var knobPos=dragKnob.offset().top-scrollBar.offset().top;}else{var knobPos=0;}
dragKnob.animate({top:knobPos},50,function(){viewport.scrollTop(cst*knobPos);});}}
jQuery(function(){var index=0
var maxIndex=playlistmaxindex;jQuery('.mediaPlayer').css('display','block');jQuery('.playerbutton img.pause').css('display','none');jQuery('.playerbutton#play').click(function(){if(jQuery(this).attr('status')=='play'){jQuery(this).attr('status','pause');jQuery('.playerbutton img.play').css('display','block');jQuery('.playerbutton img.pause').css('display','none');jwplayer('jwplayer').play(false);}else{jQuery(this).attr('status','play');jQuery('.playerbutton img.play').css('display','none');jQuery('.playerbutton img.pause').css('display','block');jwplayer('jwplayer').play(true);AnimateSongName();}});jQuery('.playerbutton#next').click(function(){index++;if(index>maxIndex)index=0;jwplayer('jwplayer').playlistItem(index);jQuery('.playerbutton#play').attr('status','play');jQuery('.playerbutton img.play').css('display','none');jQuery('.playerbutton img.pause').css('display','block');AnimateSongName();});jQuery('.playerbutton#previous').click(function(){index--;if(index<0)index=maxIndex;jQuery('.playerbutton#play').attr('status','play');jQuery('.playerbutton img.play').css('display','none');jQuery('.playerbutton img.pause').css('display','block');jwplayer('jwplayer').playlistItem(index);AnimateSongName();});function AnimateSongName(){var songs=jQuery('.mediaPlayer .scroller .songName').css('display','none');var song=jQuery(jQuery('.mediaPlayer .scroller .songName').get(index)).css('display','block');if(song.outerWidth()>235){song.animate({left:-(song.width()-229)},3000,jQuery.easing.def,function(){song.animate({left:0},3000,jQuery.easing.def,function(){AnimateSongName();});});}}
jQuery('.playlistDisplay').hide(0).mouseleave(function(){jQuery(this).hide(500);});jQuery('.mediaPlayer .label').click(function(){jQuery('.playlistDisplay').show(500);});jQuery('.playlistDisplay .songName').click(function(){index=jQuery('.playlistDisplay .songName').index(jQuery(this));jQuery('.playerbutton#play').attr('status','play');jQuery('.playerbutton img.play').css('display','none');jQuery('.playerbutton img.pause').css('display','block');jwplayer('jwplayer').playlistItem(index);jQuery(this).parent().hide(500);AnimateSongName();});});function HidePreloader(){jQuery('.flowRecordsLink').stopTime().find('.message').fadeOut(100);var imgs=jQuery('.flowRecordsLink img.anim');imgs.not(jQuery(imgs.get(0)).css('display','block')).css('display','none');}
function ShowPreloader(){var index=-1;jQuery('.flowRecordsLink').everyTime('50ms',function(){index++;if(index==8)index=0;var imgs=jQuery('.flowRecordsLink img.anim');imgs.not(jQuery(imgs.get(index)).css('display','block')).css('display','none');}).find('.message').fadeIn(500);}
jQuery(function(){HidePreloader();});var FOPathStatic="http://www.djpena.net/";var img=[];img[1]=new Image();img[1].src=FOPathStatic+'public/media/system/logo.png';img[2]=new Image();img[2].src=FOPathStatic+'public/media/system/backgrounds/background1.jpg';img[3]=new Image();img[3].src=FOPathStatic+'public/media/system/backgrounds/background2.jpg';img[4]=new Image();img[4].src=FOPathStatic+'public/media/system/backgrounds/background3.jpg';img[5]=new Image();img[5].src=FOPathStatic+'public/media/system/backgrounds/background4.jpg';img[6]=new Image();img[6].src=FOPathStatic+'public/media/system/backgrounds/background5.jpg';img[7]=new Image();img[7].src=FOPathStatic+'public/media/system/backgrounds/background6.jpg';img[8]=new Image();img[8].src=FOPathStatic+'public/media/system/backgrounds/background7.jpg';img[9]=new Image();img[9].src=FOPathStatic+'public/media/system/backgrounds/background8.jpg';img[10]=new Image();img[10].src=FOPathStatic+'public/media/system/backgrounds/background9.jpg';img[11]=new Image();img[11].src=FOPathStatic+'public/media/system/backgrounds/background10.jpg';img[12]=new Image();img[12].src=FOPathStatic+'public/media/system/backgrounds/background11.jpg';img[13]=new Image();img[13].src=FOPathStatic+'public/media/system/backgrounds/background12.jpg';img[14]=new Image();img[14].src=FOPathStatic+'public/media/system/backgrounds/background13.jpg';
