/* tso2006.js */


/*-------- Menu selection --------*/


//Array with values that needs to be selected. Array only applies to external pages.
var secNames = new Array("howitworks","courses","resources","news","help" );

function menuSelection (){
	var url = window.location.toString(); 	
	var menuList = document.getElementById('header_nav'); //get the menu container
	var menuItems;
	
	if(menuList){ //then create an array of menu items...
		menuItems = menuList.getElementsByTagName("li");
	
		var ext = false; //use this to skip external menu selection if necesscary...
		if(eval(document.mover) ){ //if the mover form is set, then handle incourse menu by using refMV....
			for(var k=0; k<menuItems.length; k++ ){ //loop through menuitems and compare href string to refMV
				var linkObj = menuItems[k].getElementsByTagName("a");			
				if( linkObj[0].href.indexOf( "document.mover.mv.value=\'" + document.mover.refMV.value + "\'") != -1 ){
					menuItems[k].id = "selected";
					ext = true;				
				}			
			}					
		}
		if (!ext){ //if we are not incourse, then check external menu....
			var found = false;
			for (var i=0; i<secNames.length; i++ ){ // loop through secNames array and find matches for url....
				if ( url.indexOf('/' + secNames[i]) != -1 ){ 
					for(var k=0; k<menuItems.length; k++ ){ //loop through menuitems and compare to link url
						var linkObj = menuItems[k].getElementsByTagName("a");
						if (linkObj[0].href.indexOf( '/' + secNames[i]) != -1){
							menuItems[k].id = "selected";
							found = true;
							return;
						}
					}			
				}
			}		
		}
	}		
}
/* ---------------- End of Menu selection ------------*/

menuSelection();




/* ---------------- For Enroll Now Buttons ------------*/

function assignMouseOvers() {
	var imgs = document.getElementsByTagName('IMG');
	for(var i=0;i<imgs.length;i++) {
		if(imgs[i].src.indexOf('enroll-now') != -1 || imgs[i].src.indexOf('oprima-ahora') != -1) {
			imgs[i].onmouseover = function() {
				this.src = this.src.replace(/.gif/,'-over.gif');
			}
			imgs[i].onmouseout = function() {
				this.src = this.src.replace(/-over.gif/,'.gif');
			}
		}
	}
}
addToOnload(assignMouseOvers);

/* ---------------- For Enroll Now Buttons ------------*/

function addToOnload(func) {
	if(typeof window.onload == 'function') {
		oldonload = window.onload;
		onload = function() {
			oldonload();
			func();
		}
	} else {
		onload = func;
	}
}