var rotator_index = 0;
var $_ROTATOR_AUTOLOAD = new Array();
var indexes=0;
var rotatorProperty = {"rotatorPath":"/rotator/","flashVideoPlayerJS":"flashPlayer.js","loadFlashVideoPlayer":false};
var debug=0;
var active_category = 0;
var active_slide = 0;
var active_slide_id = -1;
var total_slides=0;
var topSlide = 40000;
var firstChild=true;
var rotator_interval=false;
var skipOne=true;
var clickEnabled=true;
(function( $ ){
$.fn.rotator = function(callback,slidechange) {
total_slides = rotatorData.panels.length;
var j=topSlide;
var resourceBase = rotatorData.playerConfig.resourceBase;
var width = rotatorData.playerConfig.panelWidth;
var height = rotatorData.playerConfig.panelHeight;
// creating the categories
var categoriesHTML = '
';
rotatorButtons += '';
var rotator = categoriesHTML
+''
+ rotatorButtons
+ '
'
+ '
'
+ slidesContainer
+ '
'
+'
';
// adding the dom tree to the rotator panel
$(this).append(rotator);
// Setting the first slide as startup
//activateSlide(0);
/////////////////////////// ACTIONS //////////////////////////////
// CLICK on categories
$('a.category-link').click(function(){
if (active_category != $(this).attr('categoryid'))
{
// loading slide
loadSlide($(this).attr('categoryid'),-1);
// now applying 'active' class
$('a.category-link').removeClass('active');
$(this).addClass('active');
}
return false;
});
// CLICK on panels
$('.slide').click(function(){
// we do not want to do anything while animation is happening
if(!clickEnabled) return;
// now performing click action
var panelid = $(this).attr('panelid');
var categoryid = $(this).attr('categoryid');
var id = $(this).attr('id');
var type = $(this).attr('type');
var panelindex = $(this).attr('panelindex');
// if this is video panel, play it
if(type=='flashVideo'){
// hiding the play button
$('.playbutton').css('display','none');
loadVideo($(this));
$(this).unbind('click');
}
// if it is an image with link, just go there
else if(rotatorData.panels[panelindex].type=='image' && rotatorData.panels[panelindex].link!='')
window.location.href = rotatorData.panels[panelindex].link;
});
// HOVER on video 'play' div
$('.vlashVideoPlayer').hover(
function(){
$(this).addClass('over');
$(this).removeClass('out');
},
function(){
$(this).addClass('out');
$(this).removeClass('over');
}
);
/* Homepage: Rotator Button Controls */
$('a.rotator-button').click(function(){
if(!clickEnabled) return;
clearInterval(rotator_interval);
var categoryid = $(this).attr('categoryid');
var panelid = $(this).attr('panelid');
loadSlide(categoryid,panelid);
});
//*
rotator_interval = setInterval(function(){
if(skipOne) {
skipOne=false;
return;
}
nextSlide(active_slide);
}, rotatorData.playerConfig.slideDelay)
//*/
$('.rotator-item').css({'width':rotatorData.playerConfig.panelWidth,'height':rotatorData.playerConfig.panelHeight});
$.getScript(rotatorProperty.rotatorPath+'js/'+rotatorProperty.flashVideoPlayerJS);
// now setting correct state
var categoryid = $('.slide:first-child').attr('categoryid');
var panelid = $('.slide:first-child').attr('panelid');
rotatorState(categoryid,panelid);
//$( $_ROTATOR_AUTOLOAD[rotator_index] ).trigger('click');
//$('#categories ul li a:first-child').click();
// now we are calling our own callback function
if(typeof callback == 'function'){
callback.call();
}
};
})( jQuery );
function loadSlide(catid,panelid){
// do something once user clicked and animation is done
if(!clickEnabled) return;
stopVideos();
clickEnabled=false;
rotatorState(catid,panelid);
// don't do anything if we are alredy on that slide
if(active_slide_id==panelid && active_category==catid)return;
active_slide_id=panelid;
active_category=catid;;
// we do not need to rotate anymore
clearInterval(rotator_interval);
if(panelid<0) panelid = $('.rotatorButtonSet[categoryid='+catid+'] .firstChild').attr('panelid');
// now we need to create a clone of the slide that's been requested,
// then we will slide it in
var tempslide = $('#panel-'+catid+'-'+panelid).clone(true);
topSlide++;
tempslide.attr('id','');
tempslide.addClass('cloneSlide');
tempslide.css({'z-index':topSlide,'left':rotatorData.playerConfig.panelWidth});
$('.rotator-slide-container').prepend(tempslide);
tempslide.animate({left:0},rotatorData.playerConfig.animationTime,'swing',function(){
// showing the play button
$('.playbutton').css('display','block');
// now removing all other slides except this panel
//$('.cloneSlide[panelid!='+$(this).attr('panelid')+']').remove();
clickEnabled=true;
});
}
function rotatorState(catid,panelid){
//if(!clickEnabled) return;
// now loading right thumbnail bar
activateElement('.rotatorButtonSet','categoryid',catid);
// activating right category
activateElement('a.category-link','categoryid',catid);
// activating the right thumbnail panel
if(active_category!=catid){
$('.rotatorButtonSet').hide();
$('.rotatorButtonSet[categoryid="'+catid+'"]').show();
active_category=catid;
}
// activating the thumbnail
activateElement('.rotator-button','panelid',panelid);
}
function nextSlide(){
if(!clickEnabled) return;
clickEnabled=false;
var oldslide=active_slide;
if(active_slide==(total_slides-1)) active_slide=0;
else active_slide++;
var button = $('.slide:eq('+active_slide+')');
catid = button.attr('categoryid');
panelid = button.attr('panelid');
rotatorState(catid,panelid);
// sliding
/*
var bg = rotatorData.panels[slideindex].image;
bg = 'url("'+rotatorData.playerConfig.resourceBase+rotatorData.playerConfig.imageFolder+bg+'")';
$('.rotator-slide-container').css('background-image',bg);
*/
button = $('.slide:eq('+oldslide+')');
catid = button.attr('categoryid');
panelid = button.attr('panelid');
//clickEnabled=false;
button.animate({left:rotatorData.playerConfig.panelWidth},rotatorData.playerConfig.animationTime,'swing',function(){
clickEnabled=true;
$(this).css({'z-index':($(this).css('z-index')-total_slides),'left':'0px'});
stopVideos();
});
}
function activateElement(selector,name,value){
$(selector).removeClass('active');
$(selector+'['+name+'='+value+']').addClass('active');
}