//-- TRACKING CODE-------------------------------------------------------------
//-- TRACKING CODE-------------------------------------------------------------
//-- TRACKING CODE-------------------------------------------------------------
var debug = false;
var skipnav_counter=1;

//-- ROLLOVER CODE-------------------------------------------------------------
//-- ROLLOVER CODE-------------------------------------------------------------
//-- ROLLOVER CODE-------------------------------------------------------------

var pageRollOvers = [];
var rollOverCounter = 0;

/**
 * Called by document.onLoad to create the rollover objects
 * Createing a rollover object cause it's on image to be
 * preloaded
 * 
 * @param rollOverArray - an array of rollovers records in the form:
 *		  [0] = the name/id of the image object as is in the img tag
 *		  [1] = the off rollover image href
 *	      [2] = the on rollover image href
 */
function createRollOvers(rollOverArray)
{
	for (var i=0; i<rollOverArray.length; i++)
		addRollOver(new RollOver(rollOverArray[i][0], rollOverArray[i][1], rollOverArray[i][2]));
}
/** 
 * helper for createRollOvers
 */
function addRollOver(rollOver){  pageRollOvers[rollOverCounter++] = rollOver;}


/**
 * used by the anchor tags onMouseOver and onMouseOut calls
 * to retrieve the RollOver object that you can call rollOn()
 * or rollOff on
 *
 * @param rolloverName - the name/id of the img href associate
 * 	      with a rollover
 *
 * @return a RollOver object
 */
function getRollOver(rollOverName)
{
	for (var i=0; i<rollOverCounter; i++)
	{
		if (pageRollOvers[i].imageObject == rollOverName)
			return pageRollOvers[i];
	}
	return null;
}

/**
 * RollOver object, a simple object that can toggle
 * the src of an ImageObject
 * 
 * @param imgObject - the name/id of the image as it
 *		  appears in the img tag
 * @param offImageSrc - the href of the off state image
 * @param onImageSrc - the href of the on state image
 */
function RollOver(imgObject, offImageSrc, onImageSrc)
{
	//preload rollover images
	this.preLoadOnImg     = new Image();
	this.preLoadOnImg.src = onImageSrc;

	//object properties	
	this.imageObject = imgObject;
	this.offImageSrc = offImageSrc;
	this.onImageSrc  = onImageSrc;

	//object methods	
	this.rollOn = RollOver_rollOn;
	this.rollOff = RollOver_rollOff;
}

function RollOver_rollOn(){  var img =  DOMGetElement(this.imageObject); if (img)img.src=this.onImageSrc;}
function RollOver_rollOff(){ var img =  DOMGetElement(this.imageObject); if (img)img.src=this.offImageSrc;}





//--MENU CODE -----------------------------------------------------------------
//--MENU CODE -----------------------------------------------------------------
//--MENU CODE -----------------------------------------------------------------



/**
 * Menu Data Structures
 *
 *  Menu Record
 * [0] = arbitrary, unique, identifier of the menu state.  This 
 *	     determines which menu element is "active" and which sub
 *		 menus are displayed
 * [1] = OPTIONAL(if this is a text menu): Image name and id as 
 *		 designated in the img tag
 * [2] = OPTIONAL(if this is a text menu): image width
 * [3] = OPTIONAL(if this is a text menu): image height
 * [4] = OPTIONAL(if this is a text menu): href to the image 
 *		 minus the naming convention extensions such as '_dn'
 * 		 and the file type.  The default menu printing functions 
 *		 will create RollOver obejcts according to the '_dn' & '_ro'
 *		 naming convention.  All menu graphics are assumed to be gifs.
 * [5] = The 'alt' value of an img tag if this is a graphic menu or the 
 *		 menu text if this is a text menu
 * [6] = The link for this menu option to link to 
 * [7] = OPTIONAL: An array of nested menu elements.  This is used to create
 *       a single level of nesting on the left nav but it could
 *       be used to create create tree menus of arbitrary depth		 
 */

/**
 * Menu Object, prints out a menu based on the above menu data structure.
 * The menus were done in an object oriented way to maximize flexibility
 * and reusability of functions.  LeftNavMenu modifies the behavior
 * of Menu by using a different printMenuOption method
 * 
 * @param inMenuOptions = an array of menu options.  Each array 
 *		  element is a 7 element list as outlined above 
 * @param choice = an indicator of the current page.  The 
 *        choice will be compared against the first element
 * 		  of each menu option record.
 * @returns an initialized menu object that can print a menu
 */
function Menu(inMenuOptions, choice)
{
	//Object Properties
	this.menuOptions  = inMenuOptions
	this.choice       = choice;
	
	//Object Functions
	this.print           	= Menu_Print;
	this.printMenuOption    = Menu_PrintMenuOption;
	this.optionSelected  	= Menu_optionSelected;
}

/**
 * Used by menu objects to loop over an array of menu 
 * option arrays...to loop over each menu choice and 
 * have a replaceable helper function print out the 
 * menu line item.  A helper function does the printing
 * so that the object can switch out the function to 
 * print differet types of menus
 */
function Menu_Print()
{
	document.write('<span><a href=\"#skip_group_'+ skipnav_counter + '\" title=\"skip navigation links\"> </a></span>');
	//document.write('<div id="mnpMenuTop" class="mnpMenuTop" style="OVERFLOW-X: hidden; WIDTH: 181px" url="/caas"	dir="ltr" parent="/caas/"><div class="mnpInherit">');
	for (var i=0; i<this.menuOptions.length; i++)
		this.printMenuOption(this.menuOptions[i], this.choice);

	document.write('<span><a name=\"skip_group_'+ skipnav_counter +'\"> </a></span>');
	//document.write('<div class="mnpMenuBorder" style="MARGIN-BOTTOM: 0px; WIDTH: 181px"></div></div></div>');
	skipnav_counter++;
}

/**
 * Seaches a menuOption and it's sub menus (contained in an 
 * array in item [7], for a menu option that has matches
 * this objects currently selected option.  The function 
 * is recursive and work for an menu structure of 
 * arbitrary depth.
 *
 * @param the record to search fro this.choice
 */
function Menu_optionSelected(menuOption)
{
	if (menuOption[0] == this.choice)
		return true;
	else if (menuOption[7]!=null)
		for (var i=0; i<menuOption[7].length; i++)
			if (this.optionSelected(menuOption[7][i]))
				return true;
	return false;
}

/**
 * This method is designed to print out each
 * option in a graphical horizontal menu
 */
function Menu_PrintMenuOption(menuOption)
{
	if (this.optionSelected(menuOption))
	{
		if (NS4)
		{
			document.write('<td><a href="'+menuOption[6]+'">');
			document.write('<img src="'+menuOption[4]+'_dn.gif" width="'+menuOption[2]+'" height="'+menuOption[3]+'" border="0" name="' + menuOption[1] + '" id="' + menuOption[1] + '" alt="'+ menuOption[5]+'"></a></td>');
		}
		else
		{
		document.write('<td><a href="javascript:navigate(\'' + menuOption[6] + '\', false, \'' + menuOption[1] + '\', top)" onMouseOver="'+menuOption[1]+'_am.hideSubMenu(); '+menuOption[1]+'_am.show(); '+menuOption[1]+'_am.activeColor(); selectHide();" onMouseOut="'+menuOption[1]+'_am.menubar.startTimer(); '+menuOption[1]+'_am.normalColor(); selectShow();">');
		document.write('<img src="'+menuOption[4]+'_dn.gif" width="'+menuOption[2]+'" height="'+menuOption[3]+'" border="0" name="' + menuOption[1] + '" id="' + menuOption[1] + '" alt="'+ menuOption[5]+'"></a></td>');
		}
	}
	else
	{
		if (NS4)
		{
			addRollOver(new RollOver(menuOption[1], menuOption[4]+'.gif', menuOption[4]+'_ro.gif'));
			document.write('<td><a href="'+menuOption[6]+'" onMouseOut="getRollOver(\'' + menuOption[1] + '\').rollOff(); selectShow();" onMouseOver="getRollOver(\'' + menuOption[1] + '\').rollOn(); selectHide();">');
			document.write('<img src="'+menuOption[4]+'.gif" width="'+menuOption[2]+'" height="'+menuOption[3]+'" border="0" name="' + menuOption[1] + '" id="' + menuOption[1] + '" alt="'+ menuOption[5]+'"></a></td>');
		}
		else
		{	
		addRollOver(new RollOver(menuOption[1], menuOption[4]+'.gif', menuOption[4]+'_ro.gif'));
		document.write('<td><a href="javascript:navigate(\'' + menuOption[6] + '\', false, \'' + menuOption[1] + '\', top)" onMouseOut="getRollOver(\'' + menuOption[1] + '\').rollOff(); '+menuOption[1]+'_am.menubar.startTimer(); '+menuOption[1]+'_am.normalColor(); selectShow();" onMouseOver="getRollOver(\'' + menuOption[1] + '\').rollOn(); '+menuOption[1]+'_am.hideSubMenu(); '+menuOption[1]+'_am.show(); '+menuOption[1]+'_am.activeColor(); selectHide();">');
		document.write('<img src="'+menuOption[4]+'.gif" width="'+menuOption[2]+'" height="'+menuOption[3]+'" border="0" name="' + menuOption[1] + '" id="' + menuOption[1] + '" alt="'+ menuOption[5]+'"></a></td>');
		}
	}
}

/** 
 * A specialization of the Menu object that replaces
 * the printmenuOptions method with one that is 
 * designed to print out a vertical text based menu
 * 
 * @param inMenuOptions = an array of menu options.  Eacy array 
 *		  element is a 7 element list as outlined above 
 * @param choice = an indicator of the current page.  The 
 *        choice will be compared against the first element
 * 		  of each menu option record.
 * @returns an initialized menu object that can print a menu
 */
function LeftNavMenu(inMenuOptions, choice)
{
	//data
	this.menuOptions  = inMenuOptions
	this.choice       = choice;
	
	//functions
	this.print           = Menu_Print;
	this.optionSelected     = Menu_optionSelected;
	this.printMenuOption    = LeftNavMenu_printMenuOption;
	this.printSubOptions = LeftNavMenu_printSubOptions;

}

/**
 * Prints a vertical text tree menu.  
 *
 * TODO-make the output routine and table structure 
 * support arbitrary nesting depths
 */
function LeftNavMenu_printMenuOption(menuOption)
{
	if (this.optionSelected(menuOption))
	{
		if (menuOption[7]) //has sub items
		{
				document.write('<div class="mnpMenuBorder" style="WIDTH: 181px"></div>');
				document.write('<div class="mnpMenuRow" style="BORDER-LEFT-COLOR: #f1f1f1;  OVERFLOW-X: hidden;  BORDER-BOTTOM-COLOR: #f1f1f1;  WIDTH: 181px;  BORDER-TOP-COLOR: #f1f1f1;  BORDER-RIGHT-COLOR: #f1f1f1">'+'<a href="'+menuOption[6]+'">'+menuOption[5]+'</a></div>');
				this.printSubOptions(menuOption[7]);
		}
		else
		{		
			document.write('<div class="mnpMenuBorder" style="WIDTH: 181px"></div>');
			document.write('<div class="mnpMenuRowOn" style="color: blue;BORDER-LEFT-COLOR: #f1f1f1;  OVERFLOW-X: hidden;  BORDER-BOTTOM-COLOR: #f1f1f1;  WIDTH: 181px;  BORDER-TOP-COLOR: #f1f1f1;  BORDER-RIGHT-COLOR: #f1f1f1">'+'<a href="'+menuOption[6]+'">'+menuOption[5]+'</a></div>');
		}
	}
	else
	{
		document.write('<div class="mnpMenuBorder" style="WIDTH: 181px"></div>');
		document.write('<div class="mnpMenuRow" style="BORDER-LEFT-COLOR: #f1f1f1;  OVERFLOW-X: hidden;  BORDER-BOTTOM-COLOR: #f1f1f1;  WIDTH: 181px;  BORDER-TOP-COLOR: #f1f1f1;  BORDER-RIGHT-COLOR: #f1f1f1">'+'<a href="'+menuOption[6]+'">'+menuOption[5]+'</a></div>');
	}     
}

function LeftNavMenu_printSubOptions(menuOption)
{
	for (var i=0; i<menuOption.length; i++)
	{
		//debug(menuOption[7][i]); 
		if (this.optionSelected(menuOption[i]))
		{
			// print submenu item header
			document.write('<div class="mnpMenuSubRow" style="BORDER-LEFT-COLOR: #f1f1f1;  OVERFLOW-X: hidden;  BORDER-BOTTOM-COLOR: #f1f1f1;  WIDTH: 181px;  BORDER-TOP-COLOR: #f1f1f1;  BORDER-RIGHT-COLOR: #f1f1f1">');
				
			if(menuOption[i][7])  //如果子菜单被选中，不能高亮
			{
				document.write('<img src="/caas/images/arrowDn.gif" width="7" height="4" class="mnpMenuArrow"  style="LEFT: 6px"> ');
				document.write('<a href="'+menuOption[i][6]+'" class="copy-navtree">'+menuOption[i][5]+'</a>');

				for(var j=0;j<menuOption[i][7].length;j++)
				{
				   //alert('j='+j);
				  // alert('menu '+menuOption[i][7][j]);
				    if(this.optionSelected(menuOption[i][7][j]))
				    {
				 		document.write('<br><a href="'+menuOption[i][7][j][6]+'" class="copy-navtree-on" style="LEFT:2px">&#183;'+menuOption[i][7][j][5]+'</a>');
				    }
				    else
				 	{
				 		document.write('<br><a href="'+menuOption[i][7][j][6]+'" class="copy-navtree" style="LEFT:2px">&#183;'+menuOption[i][7][j][5]+'</a>');
					}
				}
			}
			else
			{
				document.write('<img width="4" height="7" border="0" alt="*" title="" class="mnpMenuArrow" src="/caas/images/arrowLTR.gif" style="LEFT: 8px"> ');
				document.write('<a href="'+menuOption[i][6]+'" class="copy-navtree-on">'+menuOption[i][5]+'</a>');
			}
			//print submenu item footer
			document.write('</div>');
		}
		else
		{
			document.write('<div class="mnpMenuSubRow" style="BORDER-LEFT-COLOR: #f1f1f1;  OVERFLOW-X: hidden;  BORDER-BOTTOM-COLOR: #f1f1f1;  WIDTH: 181px;  BORDER-TOP-COLOR: #f1f1f1;  BORDER-RIGHT-COLOR: #f1f1f1">');
			document.write('<img width="4" height="7" valign=middle border="0" alt="*" title="" class="mnpMenuArrow" src="/caas/images/arrowLTR.gif"');
			document.write('style="LEFT: 8px">');
			document.write('<a href="'+menuOption[i][6]+'" class="copy-navtree">'+menuOption[i][5]+'</a></div>');
		}
	}
}
function LeftNavMenu_printSubOptionHeader(menuOption,highlighted)  // menu levels: menu row, menu subrow, menu lvl2subrow
{
	if(highlighted)
	{}
	else
	{}
}
//This will bury error messages so the users cannot see them

window.onerror = null;

/**
 * Menu printing functions. 
 * Call each function where the menu should be printed out.
 * the identifier of the current page should be passed into the call
 *
 * The data that drives the menus and sets up the page identifiers
 * should b passed in in the menu_data.js file
 */
function printLevel1Menu(currentPage){new Menu(level1MenuOptionsArray, currentPage).print();}
function printLevel2Menu(currentPage){new Menu(level2MenuOptionsArray, currentPage).print();}
function printLevel3Menu(currentPage){new LeftNavMenu(level3MenuOptionsArray, currentPage).print();}

function sitemap()
{
	var url = '/sitemap/index.html';
	openPopup(url, 'sitemap', 'width=770,height=480,status=no,menubar=no,toolbar=no,resizable=no,scrollbars=no,location=no');
}

function print(url)
{
	openPopup(url,'print','width=520,height=400,status=no,menubar=yes,toolbar=yes,resizable=yes,scrollbars=yes,location=no');
}

function openPopup(url, name, style) 
{
/*
toolbar[=yes|no]|[=1|0]  location[=yes|no]|[=1|0]  directories[=yes|no]|[=1|0]  status[=yes|no]|[=1|0]  menubar[=yes|no]|[=1|0]  scrollbars[=yes|no]|[=1|0]  resizable[=yes|no]|[=1|0]  width=pixels  height=pixels
*/	
//so each window can be unique
if (!name)	name = new Date().getTime() + '';
if (!style)
	style = 'width=520,height=400,status=yes,menubar=no,toolbar=no,resizable=no,scrollbars=yes,location=no';
	var popupWindow = window.open(url,name,style);
	popupWindow.focus();
}
function gothere() {
  window.location=document.sel.edu.options[document.sel.edu.selectedIndex].value
}
function timeline(val) {  var timelineWin = window.open(val, 'timeline', 'width=790,height=500,toolbar=no,scrollbars=no,menubar=no,left=30,top=30,resizable=no,directories=no'); }
function popupVPT(val) {  var popupVPT = window.open(val, 'popupVPT', 'width=727,height=557,toolbar=no,scrollbars=no,menubar=no,left=30,top=30,resizable=no,directories=no'); }
function youth(val) { var youthWin = window.open(val, 'youth', 'width=810,height=620,toolbar=yes,scrollbars=yes,menubar=yes,location=yes,status=yes,copyhistory=yes,left=30,top=30,resizable=yes,directories=yes'); }
function askcokepopup() { var askpopupWin = window.open('http://questions.coca-cola.com', 'askcoke', 'width=520,height=400,toolbar=no,scrollbars=yes,menubar=no,left=30,top=30,resizable=no'); }
function popup(val) {  popupWin = window.open(val, 'popup','width=520,height=400,scrollbars=yes,menubar=yes,left=30,top=30,resizable=no'); }
function popupAT(val) {  popupAT = window.open(val, 'popupAT','width=727,height=557,scrollbars=auto,menubar=no,left=30,top=30,resizable=yes'); }

