function _rootDir(pg)
{
var pg;
switch (pg){
	case 'home':
	 var rootDir = rootDir_home;
	 var _cPages = cpagesDir_home;
	 var _filename = inline_home;
	 var lowResHeight = lowResHeight_home;
     var highResHeight = highResHeight_home;
	  break;
case 'aboutOffice':
     var rootDir = rootDir_aboutoffice;
     var _cPages = cpagesDir_aboutoffice;
     var _filename = inline_aboutoffice;  
	 var lowResHeight = lowResHeight_aboutoffice;
     var highResHeight = highResHeight_aboutoffice;
      break;
case 'resources':
     var rootDir = rootDir_facultystaff;
     var _cPages = cpagesDir_facultystaff ;
     var _filename = inline_facultystaff;
	 var lowResHeight = lowResHeight_facultystaff;
     var highResHeight = highResHeight_facultystaff;
     break;
case 'contact':
    var rootDir = rootDir_contact;
     var _cPages = cpagesDir_contact;
     var _filename = inline_contact;
	 var lowResHeight = lowResHeight_contact;
     var highResHeight = highResHeight_contact;
      break;
case 'ea':
     var rootDir = rootDir_ea;
     var _cPages = cpagesDir_ea;
     var _filename = inline_ea;
	 var lowResHeight = lowResHeight_ea;
     var highResHeight = highResHeight_ea;
      break;
case 'iss':
     var rootDir = rootDir_iss;
     var _cPages = cpagesDir_iss;
     var _filename = inline_iss;
	 var lowResHeight = lowResHeight_iss;
     var highResHeight = highResHeight_iss;
      break;
default:
     var rootDir = 'http://'+document.domain+'/';
    var _cPages = cpagesDir_home;
	 var _filename = inline_home;
	 var lowResHeight = lowResHeight_home;
     var highResHeight = highResHeight_home;
      break;
}
return [rootDir,_cPages,_filename,lowResHeight,highResHeight];
}



 function antiInjectJs(cleanme) {
    var cleanme;
    if(cleanme)
    {
    cleanme.replace("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\"");

    cleanme = cleanme.replace(/script(.*)/g, "");
    cleanme = cleanme.replace(/eval\((.*)\)/g, "");
    // instead of going through a whole routine, I am just replacing these words with http: so that the isLocalUrl function will catch them
    // and take action to prevent malicious usage of the IFRAME
    cleanme = cleanme.replace("ftp:", "http:");
    cleanme = cleanme.replace("file:", "http:");
    //
	cleanme = cleanme.replace("<", "").replace(">", "");

    return cleanme;
    }else{
        return false;
    }
  }

function get(key_str) {
key_str = antiInjectJs(key_str);
	if(window.location.search) {
		var query = window.location.search.substr(1);
		var pairs = query.split("&");
		for(var i = 0; i < pairs.length; i++) {
			var pair = pairs[i].split("=");
			if(unescape(pair[0]) == key_str)

				return unescape(pair[1]);
		}
	}
}


function _isLocalUrl(url)
{
	var url;
	urlString = url.substring(7,url.length);
	urlDomain = urlString.substring(0,document.domain.length);
	if(urlDomain == document.domain)
	{
	return true;
	}
	 else
	 {
	return false;
	}
}


/*
 dynamicPage:  variable in url that contains content urls for use in the content iframe(must be local domain)
 staticPage:  local page to redirect to if url var is not present(pages are stored in the cPages directory/page directory.
 If the dynamicPage url is not this domain an error message will show in the IFRMAE
 by design, if the flash swf loads, then the urls are passed to the swf and the swf loads the content IFRAMe when its menu movements are completed
 if by chance the movie does not load and the page is using a default html/javascript menu. The pages will load directly into the IFRAME after security checks
*/

function sizeAndLoadIframe(getVar,page){

var getVar;
var page;
var scrolling ='no'

if(getVar == false && page == false)
{
thePage = 'about:blank';
noIframe = "were sorry but your browser does not support inline frames.";
}
else
{
	
	
if(getVar != '' && getVar != undefined)
{
if(getVar.substring(0,4) == 'http')
{

if(_isLocalUrl(getVar))
{
thePage = getVar;
scrolling ='auto';
}
else
{
thePage = rootDir+'cPages/misc/iframesecurity.htm';
}

	noIframe = 'Were sorry but your browser does not support Inline Frames.<br> You may view the content at:<br><br><a href="'+getVar+'">'+getVar+'</a>';
	}
	else
	{ 
	thePage = getVar;
	if(getVar.substring(0,4) == 'http'){
		 noIframe = 'Were sorry but your browser does not support Inline Frames.<br> You may view the content at:<br><br><a href="'+getVar+'">'+getVar+'</a>';
	}
	else
	{
		noIframe = "were sorry but your browser does not support inline frames.";
	}
 }

}
else
{
thePage = page;

	if(page.substring(0,4) == 'http'){
	    scrolling ='auto';
		 noIframe = 'Were sorry but your browser does not support Inline Frames.<br> You may view the content at:<br><br><a href="'+page+'">'+page+'</a>';
	}
	else
	{
		noIframe = "were sorry but your browser does not support inline frames.";
	}
}
}




if ((screen.width>=sWidth) && (screen.height>=sHeight))
{
return document.write('<iframe width="'+iWidth+'" height="'+highResHeight+'" id="content" name="content" src="'+thePage+'" frameborder="0" onload="DYNIFS.resize(\'content\')" scrolling="no" style="width:740px;height:'+highResHeight+'px;border:0px;">'+noIframe+'</iframe>');
}
else
{
return document.write('<iframe width="'+iWidth+'" height="'+lowResHeight+'" id="content" name="content" src="'+thePage+'" frameborder="0" onload="DYNIFS.resize(\'content\')" scrolling="no" style="width:740px;height:'+lowResHeight+'px;border:0px;">'+noIframe+'</iframe>');
}

}





/* AJAX SRIPTS */

var xmlHttp

/*
loadMenu
________
name: identifies name of menu as indicated in database
defaultOpen: groupname(in database) of the default open submenu
prePath (OPTIONAL): path that leads you to the includes directory

*/
function loadMenu(name,defaultOpen,prePath)
{
	var o=document.getElementById("_MAIN_MENU_CONTAINER");
			if (o)
				o.innerHTML=("Loading Menu...");
	xmlHttp=GetXmlHttpObject()

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}

	//var url="/include/menu.php?"
	var url=(typeof(prePath)=='undefined'?"../":prePath) + "include/menu.php?";
	url=url+"&n="+name;
	url=url+"&d="+defaultOpen;
	
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
			var o=document.getElementById("_MAIN_MENU_CONTAINER");
			if (o)
				o.innerHTML=(xmlHttp.responseText);
		}

	};
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)

}

function stateChanged()
{
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("photoinfo").innerHTML=xmlHttp.responseText
	}
}

function GetXmlHttpObject()
{
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
		objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}


/* END AJAX SCRIPTS */

/* MENU FUNCTIONS */


function getParent(o)
{
	do
	{
		do
		{
			o=o.parentNode;
		}
		while(o.nodeName!="TBODY")
	}
	while(!o.attributes['MENUCONTAINER'])

	return o;

}
function toggleVisibility(o)
{

	//alert (o.style.display);
	if (o.style.display=="none")
		o.style.display="";
	else
		o.style.display="none";

}
function resizeIframe() {
	if(self==parent) 
	{
		return false; /* Checks that page is in iframe. */
	}
	else// if(document.getElementById&&document.all) /* Sniffs for IE5+.*/
	{
		frameBodyArray=document.getElementsByTagName("body"); 
		framePage=document.body;
		var FramePageHeight = parseInt(framePage.scrollHeight);// + 10; /* framePage is the ID of the framed page's BODY tag. The added 10 pixels prevent an unnecessary scrollbar. */
		parent.document.getElementById('content').style.height=FramePageHeight;
	}
} 
function toggleMenu(o,groupName)
{

	o=getParent(o);

	list=o.childNodes;
	//alert(o.nodeName);
	for(ct=0;ct<list.length;ct++)
	{
		if (list[ct] && list[ct].nodeName=="TR")
		{
		if (list[ct].attributes['group'] && list[ct].attributes['group'].nodeValue==groupName)
			toggleVisibility(list[ct]);
		}
	}
	resizeIframe();
}


/* END MENU FUNCTIONS */

function getParameter(name) {
   var url = top.location.href;
   var paramsStart = url.indexOf("?");
   if(paramsStart != -1){

      var paramString = url.substr(paramsStart + 1);
      var tokenStart = paramString.indexOf(name);
	
      if(tokenStart != -1){

         paramToEnd = paramString.substr(tokenStart + name.length + 1);
         var delimiterPos = paramToEnd.indexOf("&");

         if(delimiterPos == -1){
            return paramToEnd;
         }
         else {
            return paramToEnd.substr(0, delimiterPos);
         }
      }
   }
}

function getParameters() {

   var params = new Array();
   var url = window.location.href;
   var paramsStart = url.indexOf("?");
   var hasMoreParams = true;

   if(paramsStart != -1){

     var paramString = url.substr(paramsStart + 1);
     var params = paramString.split("&");
     for(var i = 0 ; i < params.length ; i++) {

       var pairArray = params[i].split("=");

       if(pairArray.length == 2){
         params[pairArray[0]] = pairArray[1];
       }

     }
     return params;
   }
   return null;
}