// Author Stephen Barraclough // November 10, 2005  // Trinex Internet Solutions

//vars and arrays
var hideSubnavTimeout;

//top level
var NavList = new Array("Home","VIVRS","Programs & Services","Community Partners","Related Links","Contact Us");
var NavListLinks = new Array("/index.asp","/vivrs_about.asp","/ps_progserve.asp","/affiliates.asp","/links.asp","/contact.asp");
//section names used for top level nav
var SecNames = new Array("home","vivrs","progserve","affiliate","links","contact");	
	
//submenus
var SubVivrs = new Array("About VIVRS","Our Staff","Employer Services","Testimonials","Community Involvement","VIVRS in the News","Success Indicators");
var SubVivrsLinks = new Array("/vivrs_about.asp","/vivrs_staff.asp","/vivrs_employerservices.asp","/vivrs_testimonials.asp","/vivrs_community.asp","/vivrs_inthenews.asp","/vivrs_success_indicators.asp");

var SubProg = new Array("Provincial Programs - EmployAbility", "Provincial Programs - CES", "Provincial Programs - CAP","Federal Programs","Private Consulting","TeamWorks!","Eating Healthy on a Budget");

var SubProgLinks = new Array("/ps_employability.asp","/ps_customized_employment_services.asp","/ps_communityassistance_cap.asp","/ps_cppd.asp","/ps_privateconsulting.asp","/ps_teamworks.asp","/ps_eatinghealthy.asp");

function Nav(sec) {
		
		var navTopLevel = ""; var onitclass = ""; var ActiveSection = sec; var NavLength = NavList.length;
		document.write("<div id='navGlobal'>");
		
		for(var i=0; i < NavLength; i++) {
		
			navTopLevel = NavList[i];
			navSecNames = SecNames[i];
			//toplevel Nav
			if(ActiveSection == navSecNames) {
					onitclass = "class='onit'"
					} else {  
					 onitclass = "";
					}
			document.write("<div "+onitclass+"><a id='topnavitem"+i+"' href='"+NavListLinks[i]+"' onmouseover=showSubnav('"+i+"'); onmouseout='hideSubnav();'>"+navTopLevel+"</a></div>");
					//subnav holder div
					document.write("<div id='Nav"+i+"' onmouseover=showSubnav('"+i+"'); onmouseout='hideSubnav();'>");
					
					switch(navTopLevel) {	
						case "VIVRS":
							for(var t=0; t < SubVivrs.length; t++)	{
								document.write("<div class='subnavitem'><a href='"+SubVivrsLinks[t]+"'>"+SubVivrs[t]+"</a></div>");
							}
						break;				
						case "Programs & Services":
							for(var t=0; t < SubProg.length; t++)	{
							document.write("<div class='subnavitem'><a href='"+SubProgLinks[t]+"'>"+SubProg[t]+"</a></div>");
						}
						break;
						default:
						break;
						}
				document.write("</div>"); //close each sub
			} //
		document.write("</div>"); //close navholder
	} //close nav

	
function Fo(w,h,ver,path,bgc) {
		document.write("<object type=\"application/x-shockwave-flash\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version="+ver+",0,0,0\" width=\""+w+"\" height=\""+h+"\">");
		document.write("<param name=movie value=\"" + path + "\" />"); 
   		document.write("<param name=menu value=false />"); 
  		document.write("<param name=quality value=best />"); 
		document.write("<param name=scale value=exactfit />");
		document.write("<param name=salign value=LT />");
		document.write("<param name=wmode value=transparent />");
		document.write("<param name=bgcolor value=\"#"+bgc+"\" />");
  		document.write("<embed src=\"" + path + "\" menu=false wmode=transparent quality=best bgcolor=\"#"+bgc+"\" scale=exactfit salign=LT pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\""+w+"\" height=\""+h+"\">"); 
   		document.write("</embed></object>"); 
		}
	
function initGlobalNav(){
	hideAll(); //hack for IE5/Mac
	//document.getElementById('navGlobal').style.visibility = 'visible';
}	

function ActiveNav(navitem) {
	var getObj = document.getElementById('topnavitem'+navitem);
		getObj.style.background = '#FFFFFF';
		getObj.style.color = '#000000';
		getObj.style.borderBottom = '1px solid #CCCCCC';
}


function showSubnav(navitem){
	hideAll();
	strActiveSubnav = navitem;
	document.getElementById('Nav'+navitem).style.visibility = 'visible';
	//Styles
	var getObj = document.getElementById('topnavitem'+navitem);
		getObj.style.background = '#FFFFFF';
		getObj.style.color = '#000000';
		getObj.style.borderBottom = '1px solid #000000';
}

function hideAll() {
	for(var h=0; h < NavList.length; h++) {
		document.getElementById('Nav'+h).style.visibility = 'hidden';
		//Styles
		var getObj = document.getElementById('topnavitem'+h);
			getObj.style.background = 'transparent';
			getObj.style.color = '#000000';
			getObj.style.borderBottom = '1px solid #CCCCCC';
	}
}	

function hideSubnav(state){
	clearTimeout(hideSubnavTimeout);
	strActiveSubnav = '';
	if(state == 'force'){
		hideSubnav2();
	} else {
		hideSubnavTimeout = setTimeout('hideSubnav2()', 250);
	}
}

function hideSubnav2(){
	if (strActiveSubnav == ''){
		hideAll();
	}
}	


function EmailFormat(eName,eAddress,eText) {
		var ToName = eName;
		var ToAddress = eAddress;
		var ToDisplayText = eText;
		document.write("<a href=\"mailto:"+eName+"@"+ToAddress+"\">"+eText+"</a>");
	}

//onload
function pageInit(){
	initGlobalNav();
}	

window.onload = pageInit;		