

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open( theURL,winName,features);
}
function MM_openNewWindow(theURL) { //v2.0
  MM_openBrWindow( theURL,'newWindow','location=no,menubar=no,resizable=yes');
}
function MM_openWindowWithSize(target,width,height) {
	MM_openBrWindow(target,'newWindow','scrollbars=yes,width=' + width + ',height=' + height + '')
}

function MM_openWindow(target) {
	MM_openBrWindow(target,'newWindow','scrollbars=yes,width=394,height=680')
}
function MM_openLargeImage(productId) {
	MM_openBrWindow('catalogViewLargeImage.do?productId=' + productId,'largeImage','scrollbars=no,width=580,height=650')
}
function popupHelp(url) {
		MM_openBrWindow(url ,'popupHelp','scrollbars=no,width=580,height=480')
}
function MM_openLargeProductImage(productIndex) {
	MM_openLargeImage(imageArray[productIndex][PRODUCT_LARGE_IMAGE],imageArray[productIndex][PRODUCT_CATEGORY],imageArray[productIndex][PRODUCT_NAME],imageArray[productIndex][PRODUCT_WIDE_IMAGE])
}


function getElement(id){
	//fetch elements in line with IE and NS protocols
	if (document.all) {
	  element=document.all[id];
	}

	if (document.getElementById) {
		element=document.getElementById(id);
	}
	return element;
}

//IMAGE SCROLL FUNCTIONS

function stopScroll(){
	if (scrolling){
		scrolling=false
		getElement("scrollTable").style.cursor = "hand"
		if(timeOut) clearTimeout(timeOut);
	}
}

function callStopScroll(){
//this gives us time to prevent stopping if mouse returns to 'over' position quickly, thus preventing jerkiness
	stopScrollTimeout = setTimeout("stopScroll()",100)
	
}


var xPos



var firstScrollTimeout
function firstScroll(){
	rolloverActive=false;
	speed = 20
	spanLeft = getElement("scrollSpan").style.left;
	numPix = spanLeft.split("p")[0];
	if((numPix * 1) + speed < scrollMax){
		getElement("scrollSpan").style.left = (numPix * 1) + speed
		firstScrollTimeout = setTimeout("firstScroll()",100)
	}
	else
	{
		getElement("scrollSpan").style.left = scrollMax
		getElement("scrollLeftImage").src = "images/spacer.gif"
		getElement("brandsLoadingSpan").innerHTML = ""
		getElement("brandsLoadingSpan").style.visibility = "hidden"
//		getElement("instructionsSpan").style.visibility = "visible"
		rolloverActive = true
	}
}

function setStartScroll(){
	getElement("scrollSpan").style.left = scrollMax
	getElement("scrollLeftImage").src = "images/spacer.gif"
	rolloverActive = true
}

var viewTogglePos = 0
function toggleView(){

	if(viewTogglePos==0){
				
		getElement("listSpan").style.visibility="visible"
		getElement("toggleViewSpan").innerHTML ="View Brand Map"
		getElement("instructionsSpan").style.visibility = "hidden"
		rolloverActive = true;
		viewTogglePos=1
	}
	else{
		getElement("listSpan").style.visibility="hidden"
		getElement("toggleViewSpan").innerHTML ="View Brand List"
		getElement("instructionsSpan").style.visibility = "visible"
		viewTogglePos=0
	}
}

//NOT SURE IF I WANT THESE
function doClick(productIndex){
image = imageArray[productIndex][PRODUCT_LARGE_IMAGE]

MM_openLargeProductImage(productIndex)
//window.open('images/' + image,'enlargedImage','width=400,height=540,menubar=no,scrollbar=no,resizeabe=no,titlebar=no,status=no,toolbar=no');
//if (rolloverActive == false) return 0;
//
//lastproductIndex = productIndex;
//managerName = productArray[productIndex][MANAGER_NAME]
//getElement("headingSpan").innerHTML = "<B>" + managerName + "<B>"
//	buttonSpanHTML = ""
//
//	if (productArray[productIndex][MANAGER_PLAN_IDS]){
//		currentIndexList = productArray[productIndex][MANAGER_PLAN_IDS].split(",")
//		currentIndexListPos = -1
//		setManagerPlansDetails(productIndex);
//		//cycleThroughManagerPlans();
//	}
//	getElement("subheadingSpan").innerHTML = "Plan List";
//	
//	buttonSpanHTML += "<TABLE border=0>"
//	
//	//SHORTLIST BUTTON
//	buttonSpanHTML += "<TR><TD><img src='/images/spacer.gif' width=10 height=2><img src='/images/map_addtosl.gif' //onmouseover='this.src=" + IC + "/images/map_addtosl_hover.gif" + IC + "' onmouseout='this.src=" + IC + //"/images/map_addtosl.gif" + IC + "' onClick='processOptionClick(" + IC + "addToShortlist" + IC +")'></TD></TR>"
//	
//	//BACK TO MAP BUTTON
//	//if(viewTogglePos==0){
//		buttonSpanHTML += "<TR><TD><img src='/images/spacer.gif' width=10 height=2><img //src='/images/vendor_return.gif' onmouseover='this.src=" + IC + "/images/vendor_return_hover.gif" + IC + "' //onmouseout='this.src=" + IC + "/images/vendor_return.gif" + IC + "' onClick='returnToInteractiveMap()'></TD>"
//	//}
//
//	buttonSpanHTML += "</TR></TABLE>"
//	
//	getElement("buttonSpan").innerHTML =  buttonSpanHTML;
//	rolloverActive=false;
}

function scrollView(){
	if(!rolloverActive) return false;
	
	if(timeOut) clearTimeout(timeOut)
	if(stopScrollTimeout) clearTimeout(stopScrollTimeout)
		
	var diff = 0;
	if(xPos > xMax){
		diff = (-Math.round(xPos/100 * xPos/100)+3)
	}
	else if(xPos < xMin){
		diff = (Math.round((850-xPos)/100 * (850-xPos)/100))
	}
	else{
		stopScroll();
		return 1;
	}
	if (scrolling==false){
		getElement("scrollLeftImage").src = "images/scroll_arrow_left.gif"
		getElement("scrollRightImage").src = "images/scroll_arrow_right.gif"
//		getElement("scrollLeftBig").src = "images/scroll_arrow_left_big.gif"
//		getElement("scrollRightBig").src = "images/scroll_arrow_right_big.gif"
	}
	scrolling = true
	spanLeft = getElement("scrollSpan").style.left;
	numPix = spanLeft.split("p")[0];

	if(diff < 0){

		if((numPix * 1) + diff > scrollMin){
			getElement("scrollTable").style.cursor = "e-resize"
			getElement("scrollSpan").style.left = (numPix * 1) + diff
			timeOut = setTimeout("scrollView()",100)
			
		}
		else
		{

			getElement("scrollSpan").style.left = scrollMin
			getElement("scrollTable").style.cursor = "hand"
			getElement("scrollRightImage").src = "images/spacer.gif"

//			getElement("scrollRightBig").src = "images/scroll_arrow_right_big_disabled.gif"
		}

		return 1;
	}
	if(diff > 0){
		if((numPix * 1) + diff < scrollMax){
			getElement("scrollTable").style.cursor = "w-resize"
			getElement("scrollSpan").style.left = (numPix * 1) + diff
			timeOut = setTimeout("scrollView()",100)
		}
		else
		{
			getElement("scrollSpan").style.left = scrollMax
			getElement("scrollTable").style.cursor = "hand"
			getElement("scrollLeftImage").src = "images/spacer.gif"
//			getElement("scrollLeftBig").src = "images/scroll_arrow_left_big_disabled.gif"
		}
		return 1;
	}


}

function clearHighlight(){


if (rolloverActive == false || lastImageIndex < 0) return 0;
	getElement("headingSpan").innerHTML = "<B>State-by-state 529 plans</B>"
	getElement("subheadingSpan").innerHTML = ""
//	getElement("infoSpan").innerHTML = "<BR>&nbsp;Choose Vendor"
	getElement("logocell_" + lastImageIndex).style.borderColor= "#CCCCCC" 
}

function doRollover(imageIndex){
//alert(1)
	if (rolloverActive == false) return 0;	
	imageCategory = imageArray[imageIndex][PRODUCT_CATEGORY]
	imageName = imageArray[imageIndex][PRODUCT_NAME]
//alert(2)
	if (lastImageIndex > -1) clearHighlight();
//alert(3)
	
	getElement("logocell_" + imageIndex).style.borderColor= "#FF0000" 	
	getElement("headingSpan").innerHTML = "<B>" + imageCategory + "<B>"
	getElement("subheadingSpan").innerHTML = imageName;
//alert(4)
//alert(41)
//		currentIndexList = imageArray[productIndex][MANAGER_PLAN_IDS].split(",")
//alert(42)
//		currentIndexListPos = -1
//alert(44)
//alert(productIndex)
//alert(44)
		//getNextManagerPlan(1,"rollover");
		//cycleThroughManagerPlans();
//		setManagerPlansCount(productIndex)
//alert(44)
//	}
//	else
//	{

//		getElement("infoSpan").innerHTML = "No information available"
//	}
//alert(5)

	lastImageIndex = imageIndex;

}
function turnOnDiv(divID){
			getElement(divID).style.visibility="visible";
			getElement(divID).style.display="block";
			getElement(divID).style.height="auto";	
			getElement(divID).style.width="100%";	
			//firefox layout fix
			if(!document.all)getElement(divID).style.overflow = "visible";
}
function turnOffDiv(divID){
			getElement(divID).style.visibility="hidden";
			getElement(divID).style.display="none";
			getElement(divID).style.height="0";	
			getElement(divID).style.width="0";	
			//firefox layout fix
			if(!document.all)getElement(divID).style.overflow = "hidden";		
}
function toggleDiv(divID){
		if(getElement(divID).style.visibility=="visible"){
			turnOffDiv(divID)
			}
		else {
			turnOnDiv(divID)
		}
}