
var blnRotation = false;
var numRotationTime = 4000;
var idxCurrentPanel = 0;
var panelCount = 0;
var startPromoAnimation = "";

var iPhonePanelArray = [0,1,2,3,4,5,6];

function resetNegotiatorPanel() {

	var numPanelCount = iPhonePanelArray.length;

	var thisPhonePanel = new Object();
	var thisInfoHeaderImg = new Object();
	var thisInfoTxt = new Object();
	var thisInfoAnchor = new Object();	
	
	
	var strPanelToHide = "";
	var strHeaderToHide = "";
	var strTxtToHide = "";
	var strAnchorToHide = "";


	for (var i=0; i<numPanelCount; i++) {
	
		strPanelToHide = "panel" + iPhonePanelArray[i];
		thisPhonePanel = document.getElementById(strPanelToHide);
		thisPhonePanel.className = "hide";
		thisPhonePanel.setAttribute("class","hide");
		
		strHeaderToHide = "header" + iPhonePanelArray[i];
		thisInfoHeaderImg = document.getElementById(strHeaderToHide);
		thisInfoHeaderImg.className = "hide";
		thisInfoHeaderImg.setAttribute("class","hide");
		
		strTxtToHide = "txt" + iPhonePanelArray[i];
		thisInfoTxt = document.getElementById(strTxtToHide);
		thisInfoTxt.className = "hide";
		thisInfoTxt.setAttribute("class","hide");

		strAnchorToHide = "link" + iPhonePanelArray[i];
		thisInfoAnchor = document.getElementById(strAnchorToHide);
		thisInfoAnchor.className = "";
		thisInfoAnchor.setAttribute("class","");		
	}
}


function iPNavADw() {

	if (idxCurrentPanel == 0 ) {
		idxCurrentPanel = 6;
	} else {
		idxCurrentPanel = idxCurrentPanel - 1;
	}
switchPanels(idxCurrentPanel,false);
}

function iPNavAUp() {

	if (idxCurrentPanel == 6 ) {
		idxCurrentPanel = 0;
	} else {
		idxCurrentPanel = idxCurrentPanel + 1;
	}

switchPanels(idxCurrentPanel, false);

}


function iPNav(panelNum) {

	var strPhonePanel = "panel" + panelNum;
	var strInfoHeaderImg = "header" + panelNum;
	var strInfoTxt = "txt" + panelNum;
	var strInfoAnchor = "link" + panelNum;

	var thisPhonePanel = document.getElementById(strPhonePanel);
	var thisInfoHeaderImg = document.getElementById(strInfoHeaderImg);
	var thisInfoTxt = document.getElementById(strInfoTxt);
	var thisInfoAnchor = document.getElementById(strInfoAnchor);	
	
	resetNegotiatorPanel()

	thisPhonePanel.className = "current";
	thisPhonePanel.setAttribute("class","current");
	
	thisInfoHeaderImg.className = "current";
	thisInfoHeaderImg.setAttribute("class","current");
	
	thisInfoTxt.className = "current";
	thisInfoTxt.setAttribute("class","current");

	thisInfoAnchor.className = "current";
	thisInfoAnchor.setAttribute("class","current");	
	
}

function initPanels() {
	switchPanels(idxCurrentPanel, blnRotation);
}


function switchPanels(panelNumber, keepRotating, wasAutoCalled, isDown) {

//'alert("got switch?");

	var endRotationHack = true;
	var idxOldPanel = idxCurrentPanel;
	idxCurrentPanel = new Number(panelNumber);
	
	if (blnRotation) {
	
	//'alert("got rotation?");

		if (!keepRotating) {
			
			blnRotation = false;
			
		} else {

				var idxNextPanelR = (idxCurrentPanel + 1) % panelCount;

				if (idxNextPanelR == 0) {
					setTimeout('switchPanels(' +idxNextPanelR + ',false,true)',numRotationTime);
				} else {
					setTimeout('switchPanels(' +idxNextPanelR + ',true)',numRotationTime);
				}				
		}
	} else {
		if ((keepRotating) || wasAutoCalled) {
			//'only happens at first re-load after rotation's been killed.
			endRotationHack = false;
		}
	}

	if(endRotationHack) {
	//	Initialization
	
		for (var i=0; i<panelCount; i++) {
	
			if (i == idxOldPanel) {
				document.getElementById("panel"+ i).className = "show";
				document.getElementById("panel"+ i).setAttribute("class","show");
				
				document.getElementById("header"+i).className = "show";
				document.getElementById("header"+i).setAttribute("class","show");
				
				document.getElementById("txt"+i).className = "show";
				document.getElementById("txt"+i).setAttribute("class","show");
								
				document.getElementById("link"+i).className = "current";
				document.getElementById("link"+i).setAttribute("class","current");				
			} else {

				document.getElementById("panel"+ i).className = "hide";
				document.getElementById("panel"+ i).setAttribute("class","hide");
				
				document.getElementById("header"+i).className = "hide";
				document.getElementById("header"+i).setAttribute("class","hide");
				
				document.getElementById("txt"+i).className = "hide";
				document.getElementById("txt"+i).setAttribute("class","hide");
								
				document.getElementById("link"+i).className = "";
				document.getElementById("link"+i).setAttribute("class","");	

			}
			if (i == idxCurrentPanel) {
				document.getElementById("panel"+ i).className = "show";
				document.getElementById("panel"+ i).setAttribute("class","show");
				
				document.getElementById("header"+i).className = "show";
				document.getElementById("header"+i).setAttribute("class","show");
				
				document.getElementById("txt"+i).className = "show";
				document.getElementById("txt"+i).setAttribute("class","show");
								
				document.getElementById("link"+i).className = "current";
				document.getElementById("link"+i).setAttribute("class","current");		
			} else {
				document.getElementById("panel"+ i).className = "hide";
				document.getElementById("panel"+ i).setAttribute("class","hide");
				
				document.getElementById("header"+i).className = "hide";
				document.getElementById("header"+i).setAttribute("class","hide");
				
				document.getElementById("txt"+i).className = "hide";
				document.getElementById("txt"+i).setAttribute("class","hide");
								
				document.getElementById("link"+i).className = "";
				document.getElementById("link"+i).setAttribute("class","");	
			}
		}
		
		if (parseInt(idxCurrentPanel) != parseInt(idxOldPanel)) {
			animatePanels(idxOldPanel, idxCurrentPanel);
		}
	}
}


function animatePanels(numOldPanel, numNewPanel) {
	var objNewPanelOpen = document.getElementById("panel" + numNewPanel.toString());
	var objNewHeaderOpen = document.getElementById("header" + numNewPanel.toString());
	var objNewTxtOpen = document.getElementById("txt" + numNewPanel.toString());
	var objNewLinkOpen = document.getElementById("link" + numNewPanel.toString());
		
				objNewPanelOpen.className = "show";
				objNewPanelOpen.setAttribute("class","show");
				
				objNewHeaderOpen.className = "show";
				objNewHeaderOpen.setAttribute("class","show");
				
				objNewTxtOpen.className = "show";
				objNewTxtOpen.setAttribute("class","show");
								
				objNewLinkOpen.className = "current";
				objNewLinkOpen.setAttribute("class","current");			
		
}
