// JavaScript Document

//HOME PAGE FELLOWS

NumberOfFellows = 5;

//array to make the home page fellow names
var FellowsArray= new Array(NumberOfFellows+1);
FellowsArray[1]=new Array("Emran Razzaghi, Iran","fellows_razzaghi.html"); 
FellowsArray[2]=new Array("Ilir Dugolli, Kosovo","fellows_dugolli.html"); 
FellowsArray[3]=new Array("Olivier Cattaneo, France","fellows_cattaneo.html");
FellowsArray[4]=new Array("Michael Ma, China","fellows_ma.html");  
FellowsArray[5]=new Array("Paul Kwengwere, Malawi","fellows_kwengwere.html");

//MENU FUNCTIONS

menulength = 9;

//array to make the main menu
baseURL = "http://www.yale.edu/worldfellows/"
var MenuItems= new Array(menulength+1);
MenuItems[1]=new Array("about","About","y",baseURL+"about.html"); 
MenuItems[2]=new Array("fellows","The World Fellows","","http://ris-systech2.its.yale.edu/worldfellows/fellows/search.asp"); 
MenuItems[3]=new Array("program","The Program","y",baseURL+"program.html"); 
MenuItems[4]=new Array("newsmedia","News &amp; Media","",baseURL+"newsmedia.html");
MenuItems[5]=new Array("events","Events","",baseURL+"events.html");  
MenuItems[6]=new Array("application","Application Process","",baseURL+"application.html");
MenuItems[7]=new Array("involved","Getting Involved","",baseURL+"involved.html");  
MenuItems[8]=new Array("internationalization","Internationalization at Yale University","",baseURL+"internationalization.html");  
MenuItems[9]=new Array("contact","Contact","",baseURL+"contact.html");

//arrays to make the submenus

var programSubMenu= new Array();
programSubMenu[1]=new Array("curriculum","program_curriculum.html","Curriculum"); 
programSubMenu[2]=new Array("trips","program_trips.html","Trips");
programSubMenu[3]=new Array("speakers","program_speakers.html","Speakers");
programSubMenu[4]=new Array("activities","program_activities.html","Activities on Campus");

var aboutSubMenu= new Array();
aboutSubMenu[1]=new Array("mission","about_mission.html","Mission/History/Overview"); 
aboutSubMenu[2]=new Array("committee","about_committee.html","Faculty Advisory Committee");
aboutSubMenu[3]=new Array("betts","about_betts.html","Betts House/Yale University");
aboutSubMenu[4]=new Array("partners","about_partners.html","Partners");



//************************ DON'T CHANGE ANYTHING BELOW THIS LINE !!! *****************************
//************************************************************************************************
//************************************************************************************************



// function to write flash obj passing query string vars
function writeFlash() {
	
	// appearance vars, these can be customized to your liking
	var width = '271'
	var height = '336'
	var src = 'home_fellows.swf'
	var rannumber = (Math.floor(Math.random()*10000)+1);
	//alert(rannumber);
	// queries -- type in the variables you want to send to flash here
	//var queries = '?text='+QueryString('year')+'&month='+QueryString('month')+'';
	var queries = '?NumberOfFellows='+NumberOfFellows+'&rand='+rannumber+''
	for (i = 1; i <= NumberOfFellows; i++)
	{
		queries = queries + '&name'+i+'='+FellowsArray[i][0]+''
		queries = queries + '&url'+i+'='+FellowsArray[i][1]+''
	}
	//alert(queries);
	// assemble flash obj
	var l1 = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'">'
	var l2 = '<param name="movie" value="'+src+queries+'" />'
	var l3 = '<param name="quality" value="high" /><param name="wmode" value="transparent" />'
	var l4 = '<embed src="'+src+queries+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed>'
	var l5 = '</object>'

	// write all lines
	
	var flashcount = 0;
	//CREATE TEST STRINGS TO TEST FOR FLASH VERSION 5 UP TO FLASH VERSION 20
	for (i = 6; i <= 20; i++) {
		flashstring = 'Flash ' + i;
		shockstring = 'ShockwaveFlash.ShockwaveFlash.' + i;
		if(WM_pluginDetect(flashstring, 'swf','application/x-shockwave-flash',shockstring)) {
			flashcount++;
		}
	}

	if(flashcount>0)  
	{ 
	//alert(src+queries);
		document.write(l1+l2+l3+l4+l5)
	} else {
		document.write('<i>You need to download and install the free Macromedia Flash browser plug-in to view the photo gallery. <a href="http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Click here to download this plug-in.</a></i>');
	}
}

function MakeMainMenu(thepage,subpage) {
	
	document.write('<ul>');
	
	for (x=1; x<=menulength; x++) {
		document.write('<li');
		if ((MenuItems[x][2]=="y")&&(thepage==MenuItems[x][0])) {
			document.write(' class="nounderline"');
		}
		document.write('><a href="' + MenuItems[x][3] + '"');
		if (thepage==MenuItems[x][0]) {
			document.write(' style="color: #2991f1;"');
		}
		document.write('>' + MenuItems[x][1] + '</a></li>');
		if ((MenuItems[x][2]=="y")&&(thepage==MenuItems[x][0])) {
			document.write('<div id="submenu_'+MenuItems[x][0]+'" class="submenu">');
			thisArrayName = eval(MenuItems[x][0]+"SubMenu");
			for (y=1; y<=(thisArrayName.length-1); y++) {
				document.write('<a href="'+thisArrayName[y][1]+'"');
				if (subpage==thisArrayName[y][0]) {
					document.write(' style="color: #4ba6d2;"');
				}
				
				
				document.write('>'+thisArrayName[y][2]+'</a><br />');
			}
			document.write('<div id="submenuline"></div>');
			
			document.write('</div>');
		}
		
	}
	
	if (thepage!="homepage") {
		document.write('<li><a href="'+baseURL+'index.html">Home Page</a></li>');
	}
	
	document.write('</ul>');
	
	
	
}





//SEARCH FIELD FUNCTIONS
// clear default value from field when selected
function MPClearField(field) {
	if (field.value == "World Fellows Site") { 
	field.value = '';
	}
}

// clear all defaults when form is submitted
function MPClearAll(theForm) {
  if (theForm.q.value == "World Fellows Site")
  {
	theForm.q.value = '';
    return (true);
  }
}



//SLIDING DIV FUNCTIONS
ns4 = (document.layers)? true:false;
ie4 = (document.all)? true:false;
W3C = document.getElementById ? 1 : 0;

function showSpan(thespan){
	if (ns4) {
	//doesn't work
	} else if (ie4) {
	eval("document.all."+thespan+".style.display = 'block'");
	} else if (W3C) {
		eval("document.getElementById('"+thespan+"').style.display = 'block'");
	}
}

function hideSpan(thespan){
	if (ns4) {
	//doesn't work
	} else if (ie4) {
	eval("document.all."+thespan+".style.display = 'none'");
	} else if (W3C) {
		eval("document.getElementById('"+thespan+"').style.display = 'none'");
	}
}