/* ---------------- Menu Selection ----------------- */

/*
The following was created to make the menu selection work for the DEO site. 
It's kinda scarry but it works both in course and out of course.... 
Just add a unique part of the file name that are being referenced to (in href) to the array, and the menu item should be selected.
*/
//Array with parts of the href that needs to be selected. All numerical values are incourse mv page nums.....
var secNames = new Array("howitworks","parents","teens","enroll.html","resources","news" );

function menuSelection (){
	var url = window.location.toString(); 	
	var menuList = document.getElementById('prime_nav'); //get the menu container
	var menuItems;
	
	if(menuList){ //then create an array of menu items...
		menuItems = menuList.getElementsByTagName("li");
	} 
	var ext = false;
	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 ){
				linkObj[0].style.backgroundPosition = '0 -33px';
				ext = true;
			}			
		}					
	}
	if (!ext){ //if we are not incourse, then check external menu....
		for (var i=0; i<secNames.length; i++ ){ // loop through secNames and find matches for url....
			if ( url.indexOf('/' + secNames[i]) != -1 ){ //out of course part....
				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){
						document.getElementById('ihome').getElementsByTagName("a")[0].className = ''; //since home is always highlighted as default
						linkObj[0].style.backgroundPosition = '0 -33px';					
					}				
				}			
			}
		}
	}
}
/* ---------------- End of Menu selection ------------*/

function clearLoginBox(loginBox) {
	//clears the login box on focus();
	if (loginBox.value == "Type Login ID"){
		loginBox.value = "";
		return;
	}else{ return; }
}

/* --------------- Send email to a friend function ------------ */
/*
Takes the sitename that should be displayed in the e-mail and opens the users email client with prefilled values.
*/
function emailToFriend(siteName) {
	var url = window.location.toString();
	var subjStr = "Check this out from " + siteName;
	var bodyStr = "Hi!%0D%0A%0D%0AI saw this on " + siteName + ". Thought you might be interested in reading this. %0D%0A%0D%0ACheck out the link below: %0D%0A%0D%0A" + url + ".";
	var compEmailStr = "mailto:Your friends e-mail address?subject=" + subjStr + "&body=" + bodyStr;
	window.location = compEmailStr;
}
/* --------------- End of Send email to a friend function ------------ */


menuSelection();

