// JavaScript Document



// AJAX PLAYER FUNCTION START

// Global variable

var prevId = '1';

var panelId = '';

var totalCount = 0;



$(document).ready(function() { 	

	

	/*// Top Ajax Player Configuration Intialization

	var ajaxPlayerParentID = '#ajax_player_top';

	var totalCount 		= 4;

	var slideIDPrefix 	= '#slide';

	var numberingEle 	= '#ajax_player_top div.pagination a';

	var activeClass 	= 'active';

	var leftArrowEle 	= numberingEle + '.leftarrow';

	var rightArrowEle 	= numberingEle + '.rightarrow';

	// intialize player now

	//intializeAjaxPlayer(ajaxPlayerParentID, totalCount, slideIDPrefix, numberingEle, activeClass, leftArrowEle, rightArrowEle);	

	*/

	//$("#ajax_player_top").scrollable({circular: true}).navigator(".pagination").autoscroll();

	

	

	$("#ajax_player_top").scrollable({ circular: false, mousewheel: true , speed :700}).autoscroll({ autoplay: true, interval: 6000 }).navigator({ navi: ".contrbar #flowtabs" , naviItem: 'a', activeClass: 'active', history: false});
	$("#ajax_right_player").scrollable({ circular: false, mousewheel: true, speed :700});//.autoscroll({ autoplay: false, interval: 6000 }); //.navigator({navi:"#player_nav", history:false})
	$("#ajax_mid_player").scrollable({ circular: false, mousewheel: true, speed :700});//.autoscroll({ autoplay: false, interval: 6000 }); //.navigator({navi:"#player_nav", history:false})

	//$('#ajax_mid_gallery').spacegallery({loadingClass: 'loading'});

});











































//declare function to auto call panel

function callPanel(num, slideIDPrefix, numberingEle, activeClass)

{

	var newId = (prevId < num) ? (parseInt(prevId) + 1) : 1;

	showPanel(newId, slideIDPrefix, numberingEle, activeClass);

}



//declare function to show panel

function showPanel(id, slideIDPrefix, numberingEle, activeClass)

{	

	if (numberingEle != '') {

		$(numberingEle).removeClass(activeClass);		

		$('#' + id).addClass(activeClass);	

	}

	//show/hide div

	$(slideIDPrefix + prevId).hide();

	$(slideIDPrefix + id).fadeIn("slow");

	//store default id

	prevId = id;

}



function intializeAjaxPlayer(ajaxPlayerParentID, totalCount, slideIDPrefix, numberingEle, activeClass, leftArrowEle, rightArrowEle)

{

	

	if (ajaxPlayerParentID != '' && totalCount != '' && totalCount > 0 && slideIDPrefix != '')

	{

		window.clearInterval(panelId);

		

		/* AJAX PLAYER Initalization */		

		$(ajaxPlayerParentID + ' ' + slideIDPrefix + '1').css('display', 'block');

		panelId = window.setInterval('callPanel(' + totalCount + ', "' + slideIDPrefix + '", "' + numberingEle + '", "' + activeClass + '")', 6000);

	

		if (numberingEle != '')

		{

			// onClick of Slide Numbers set Ajax Plyaer behaviour

			$(numberingEle).click(function(){		

				$(numberingEle).removeClass(activeClass);		

				

				$(this).addClass(activeClass);	

				var ID = $(this).attr('id');	

				

				if (!isNaN(parseInt(ID))) {

				// show slide

					showPanel(parseInt(ID), slideIDPrefix, numberingEle, activeClass);

				}

				

				// stop auto play

				window.clearInterval(panelId);

				return false;

			});

		}

		

		if (leftArrowEle != '') 

		{ 

			// onClick of Slider Left Arrow, set  AJAX PLAYER behaviour

			$(leftArrowEle).click(function()

			{

				var slideID = 1;

				

				if (parseInt(prevId) <= 1) {

					slideID = parseInt(totalCount);

				} else {

					slideID = parseInt(prevId) - 1;

				}

				

				// show respective slide

				showPanel(slideID, slideIDPrefix, numberingEle, activeClass);

				// stop auto play

				window.clearInterval(panelId);

				return false;

			});

		}

		

		

		if (rightArrowEle != '')

		{

			// onClick of Slider Right Arrow, set  AJAX PLAYER behaviour

			$(rightArrowEle).click(function()

			{

				var slideID = 1;		

				if (parseInt(prevId) >= parseInt(totalCount)) {

					slideID = 1;

				} else {

					slideID = parseInt(prevId) + 1;

				}

				

				// show respective slide

				showPanel(slideID, slideIDPrefix, numberingEle, activeClass);

				// stop auto play

				window.clearInterval(panelId);

				return false;

			});

		}

	}

}


