// JavaScript Document

var panePrefix = 'divPane';
var panes = 1;
var currentPane = 0;
var nextPane = 0;
var tmout;
var navHeight = 30;
var leftofsset = -5;
var topoffset = -4;
var bWidth = navHeight - 10;
var bHeight = navHeight - 10;
var videoPlayer="notactive";
var theSourceDiv='';
var theSourceDivID='';

function changePanes(paneOut,paneIn){

	if (videoPlayer=="active"){
		//window.alert("hello active player");
		//window.alert(prevContent);
		replaceDivContent(theSourceDivID,prevContent);
		//theRemoveMyDiv("featured_videos_playback"+paneOut);
		videoPlayer="notactive";		
		theRemoveMyDiv("featured_videos_playback"+paneOut);
		//theRemoveMyDiv("featured_videos_playback"+currentPane);
		
	}



	var elPaneOut = panePrefix + paneOut;
	var elPaneIn = panePrefix + paneIn;
	new Effect.Fade(document.getElementById(elPaneOut).id);
	document.getElementById('buttonPane' + paneOut).style.backgroundImage = 'url(http://www.sellingpower.com/img/site/buttons/carousel_inactive.gif)';
	document.getElementById('buttonPane' + paneOut).style.backgroundColor = '#333333';  //#0066CB	
	document.getElementById('buttonPane' + paneOut).style.color = 'black';
	
	new Effect.Appear(document.getElementById(elPaneIn).id);
	document.getElementById('buttonPane' + paneIn).style.backgroundImage = 'url(http://www.sellingpower.com/img/site/buttons/carousel_active.gif)';  //#0066CB
	document.getElementById('buttonPane' + paneIn).style.backgroundColor = '#333333';  //#0066CB	
	document.getElementById('buttonPane' + paneIn).style.color = 'white';
	currentPane = paneIn;

return;
	//startRotation();
//currentPane = paneIn;
}  //rotateCarousel(paneOut,paneIn)


function HoverPane(nxtPane){
	//window.status = 'goToPane';
	document.getElementById('buttonPane' + nxtPane).style.backgroundImage = 'url(http://www.sellingpower.com/img/site/buttons/carousel_hover.gif)';  //#0066CB
}  //goToPane(pane)

function ClearPane(nxtPane){
	//window.status = 'goToPane';
	if (nxtPane != currentPane)	{
		document.getElementById('buttonPane' + nxtPane).style.backgroundImage = 'url(http://www.sellingpower.com/img/site/buttons/carousel_inactive.gif)';  //#0066CB
	} else {
		document.getElementById('buttonPane' + nxtPane).style.backgroundImage = 'url(http://www.sellingpower.com/img/site/buttons/carousel_active.gif)';  //#0066CB
	}
}  //goToPane(pane)


function rotateCarousel() {
	var nextPane = currentPane + 1;
	if (nextPane == panes) {
		nextPane = 0;
	}
	changePanes(currentPane, nextPane);
	tmout = setTimeout("rotateCarousel()",10*600);
}  //rotateCarousel()

function stopRotation() {
	if (tmout) clearTimeout(tmout);
	//theRemoveMyDiv('featured_videos_playback');
}  //stopRotation()

function startRotation() {
	rotateCarousel();
}  //stopRotation()

function moveCarouselLeft() {
	stopRotation();
	var nextPane = currentPane - 1;
	if (nextPane < 0) {
		nextPane = (panes - 1);
	}
	changePanes(currentPane, nextPane);
}  //

function moveCarouselRight() {
	//window.status = 'moveCarouselRight';
	stopRotation();
	var nextPane = currentPane + 1;
	if (nextPane == panes) {
		nextPane = 0;
	}
	changePanes(currentPane, nextPane);
}  //moveCarouselRight()

function goToPane(nxtPane) {
	//window.status = 'goToPane';
	stopRotation();
	if (nxtPane != currentPane) {
		var nextPane = nxtPane;
		if (nextPane == panes) {
			nextPane = 0;
		}
		if (nextPane < 0) {
			nextPane = (panes - 1);
		}
		changePanes(currentPane, nextPane);
		tmout = setTimeout("rotateCarousel()",10*600);
	}
}  //goToPane(pane)


function replaceDivContent(theSourceDiv,prevContent){
//	window.alert("hello replace");
//	return;
//	window.alert("hello replace "+theSourceDiv);
//	window.alert("hello prev content "+prevContent);
	if (theSourceDiv !='' && prevContent !=''){
		//window.alert("hello replace");
	//	document.getElementById(divID).innerHTML='<div id="sponsorvid-blurb-0" style="width:'.trim($selectedvideoInfo[0]['width']).';font-size:12px;color:#000000;padding:0px 0px 0px 0px;border:0;margin:0px;" align="center"><img id="sponsorvid-image-0" src="'.theMediaImage.'" alt="sponsor_video0-screenshot" height="'.trim($selectedvideoInfo[0]['height']).'" width="'.trim($selectedvideoInfo[0]['width']).'" style="cursor:pointer;padding:0px;margin:0px;border:none;"></div>';	
		document.getElementById(theSourceDiv).innerHTML=prevContent;
		//document.getElementById(theSourceDiv).style.visibility='visible';
		document.getElementById(theSourceDiv).style.display='block';
	}

return;
}

function theRemoveMyDiv(thedivID){
	//window.alert("hello remove div");
	//return;
	if (document.getElementById(thedivID)) {
		//document.getElementById(thedivID).style.visibility='hidden';
		document.getElementById(thedivID).style.display='none';
		document.getElementById(thedivID).innerHTML='';
		//setTimeout("document.body.removeChild(document.getElementById(divID));",10*6);
		//document.body.removeChild(document.getElementById(thedivID));
	}
	//nxtPane--;
	return;
}
