/*
function which(form) {
	var order=form.navigation.selectedIndex
	if (form.navigation.options[order].value != 0) {
		location=form.navigation.options[order].value;
	}
}
*/
//search box auto clear
function ClearThis(starttxt)  {
	  		if (document.gs.q.value == starttxt) {
	  		document.gs.q.value = "";}
	  		}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


//image swap restore (Dreamweaver)

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


// for swapping homepage photo
function random_image() {
	image_array = new Array();
	image_array[0] = 'images/homepage/photos/graduation.jpg';
	image_array[1] = 'images/homepage/photos/students.jpg';
	image_array[2] = 'images/homepage/photos/teacher.jpg';
	image_array[3] = 'images/homepage/photos/kashyap.jpg';
	image_array[4] = 'images/homepage/photos/listen.jpg';
	image_array[5] = 'images/homepage/photos/lecture.jpg';
	image_array[6] = 'images/homepage/photos/tshirts.jpg';
	image_array[7] = 'images/homepage/photos/hallway.jpg';
	image_array[8] = 'images/homepage/photos/buildingFront.jpg';
	image_array[9] = 'images/homepage/photos/buildingSide.jpg';

// to add new image to the array, enter a new line in the following format:
// image_array[X] = 'images/homepage/photos/NEWIMAGE.jpg';

	count = image_array.length;
	random = Math.floor(Math.random() * count);

	document.getElementById('home').style.backgroundImage = "url(" + image_array[random] + ")";
	document.getElementById('home').style.backgroundRepeat = "no-repeat";
	document.getElementById('home').style.backgroundPosition = "10px 95px";
}



// used for profile popups
var prwinWidth = "640"
var prwinHeight = "580"
function profilePop(winURL) {
window.open(winURL,"","width="+prwinWidth+",height="+prwinHeight+",scrollbars="+winScrollbars+",toolbar="+winToolbar+",resizable="+winResizable+",location="+winLocation+",status="+winStatus)
}


// popups Used for outside links
var winScrollbars = "yes"
var winToolbar = "yes"
var winResizable = "yes"
var winLocation = "yes"
var winStatus = "yes"

var winWidth = "785" // used for external links
var winHeight = "500"
function eLink(winURL) {
window.open(winURL,"","width="+winWidth+",height="+winHeight+",scrollbars="+winScrollbars+",toolbar="+winToolbar+",resizable="+winResizable+",location="+winLocation+",status="+winStatus)
}

// used for photo tours
var pwinWidth = "640"
var pwinHeight = "580"
function pTour(winURL) {
window.open(winURL,"","width="+pwinWidth+",height="+pwinHeight+",scrollbars="+winScrollbars+",toolbar="+winToolbar+",resizable="+winResizable+",location="+winLocation+",status="+winStatus)
}

//used for facility tours
var fwinWidth = "790"
var fwinHeight = "525"
function facilityTour(winURL) {
window.open(winURL,"","width="+fwinWidth+",height="+fwinHeight+",scrollbars='no',toolbar="+winToolbar+",resizable="+winResizable+",location="+winLocation+",status="+winStatus)
}

//used for corporate presentations: catering swap

// onresize for ns4
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "visible";
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) lyr.css.visibility = "hidden";
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}

//to avoid session timeout when linking to Apply Direct pages

function ClearSession(URL) {
window.open("/application","clear","width=700, height=450, scrollbars=1");
window.open(URL,"clear");

}

//show-hide layers
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}


//used for Exec e-List field validation
function validate_required(field,alerttxt) {
	with (field) {
		if (value==null||value=="")
		{alert(alerttxt);return false}
		else {return true}
	}
}

function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		lstr=value.length
		if (apos<1||dotpos-apos<2||lstr-dotpos<2)
		{	alert(alerttxt)
			return false
		} 
		else 
		{ return true }
	}
}

function validate_campus(field,alerttxt) {
	with (field) {
		if (value=="Choose a campus")
		{alert(alerttxt);return false}
		else {return true}
	}
}

function validate_form(thisform) {
	with (thisform) {

		if (validate_required(yourFname,"Please fill out your first name!")==false)
		{   yourFname.focus();
			return false
		}

		if (validate_required(yourLname,"Please fill out your last name!")==false)
		{   yourLname.focus();
			return false
		}

		if (validate_email(youremail,"Please fill out a valid email address!")==false)
		{   youremail.focus();
			return false
		}

		if (validate_campus(campus,"Please choose a campus!")==false)
		{   campus.focus();
			return false
		}
	}
}

//used for all Flash files
function EmbedFlash(filename,height,width) {

document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" style="z-index: 0" width="' + width +'" height="' + height + '">');
document.write('<param name="quality" value="high" />');
document.write('<param name="movie" value="' + filename + '" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<embed src="' + filename + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed></object>');

}


//used for Flash video players
function EmbedFlash8(filename,height,width) {

document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" style="z-index: 0" width="' + width +'" height="' + height + '">');
document.write('<param name="quality" value="high" />');
document.write('<param name="movie" value="' + filename + '" />');
document.write('<param name="wmode" value="transparent" />');
document.write('<embed src="' + filename + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '"></embed></object>');

}

//used for Financial Aid buttons on Admit sites
function changeURL(winName, newURL) {
  win = window.open("", winName);
  win.location.href = newURL;
}


