function SubmitSearch(isBlueBox, searchResultsPageUrl) 
{
    if( isBlueBox == "True")
    {
        location.href=searchResultsPageUrl + '&Term=' + document.getElementById('SearchBox').value;
    }
    else
    {
        location.href=searchResultsPageUrl + '?Term=' + document.getElementById('SearchBox').value;
    }
}
function disableEnterKey(e)
{
     var key;

     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox

     if(key == 13)
          return false;
     else
          return true;
}
function searchKeyPress(evt)
{
     // If it's Mozilla/FF use evt; else use window.event
     evt = evt ? evt : event;

     var keyCode = evt.keyCode;

     // figure out which key code goes with which key
     // alert(evt.keyCode);

     if(keyCode == 13)
     {
          // do this if it IS the enter key
          SubmitSearch(false,'SearchResults.aspx');
      return false;
     }
   
   return true;
}

function switchSections()
{
    document.location.href = document.getElementById('siteList').options[document.getElementById('siteList').options.selectedIndex].value;
}
sfHover = function() {
    try
    {
      var sfEls = document.getElementById("nav").getElementsByTagName("LI");
      for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
          this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
          this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
      }
    }
    catch(err) {}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

function setVis(id, vis, displayNone) {
    if (id != '') {
        if (displayNone == undefined || (displayNone != true && displayNone != false)) {
            displayNone = true;
        }
      obj = MM_findObj(id);
      if (obj == undefined) {
          return;
      }
      
      if(document.getElementById || document.all){//all the modern browsers
        obj.style.visibility = vis ? "visible" : "hidden";
        if (displayNone) {
            obj.style.display = vis ? "block" : "none";
        }
      }
      else if(document.layers){//this is NS4
        obj.visibility = vis ? "show" : "hide";
        if (displayNone) {
            obj.display = vis ? "block" : "hide";
            }
      }  
  }
}

function changeVis(id) {
    if (id != '') {

      obj = MM_findObj(id);
      if (obj == undefined) {
          return;
      }
      
      if(document.getElementById || document.all){//all the modern browsers
        obj.style.display = obj.style.display == "none" ? "block" : "none";
      }
      else if(document.layers){//this is NS4
        obj.display = obj.display == "hide" ? "block" : "hide";
      }  
  }
}

function changeExpandable(expandableId, linkId, collapsedText, expandedText)
{
    if (expandableId != '') 
    {
      obj = MM_findObj(expandableId);
      if (obj == undefined) {
          return;
      }
      
      link = MM_findObj(linkId);
      
      var cText = '+ <a href="javascript:changeExpandable(\'' + expandableId + '\',\'' + linkId + '\',\'' + collapsedText + '\',\'' + expandedText + '\');">' + collapsedText + '</a>';
        var eText = '- <a href="javascript:changeExpandable(\'' + expandableId + '\',\'' + linkId + '\',\'' + collapsedText + '\',\'' + expandedText + '\');">' + expandedText + '</a>'
      
      if(document.getElementById || document.all){//all the modern browsers
        obj.style.display = obj.style.display == "none" ? "block" : "none";
        if(link != undefined)
          {
              link.innerHTML = obj.style.display == "none" ? cText : eText;
          }
      }
      else if(document.layers){//this is NS4
        obj.display = obj.display == "hide" ? "block" : "hide";
        if(link != undefined)
          {
              link.innerHTML = obj.style.display == "none" ? cText : eText;
          }
      }  
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
    window.onload = func;
  else 
  {
    window.onload = function() 
    {
      if (oldonload) 
        oldonload();
      func();
    }
  }
}

function OpenChat()
{
    var windowW = 240;
    var windowH = 316;
    window.open('/InstantMessaging.aspx','Chat','width=' + windowW + ',height=' + windowH + ',toolbar=no,menubar=no,resizeable=no,status=no');
}

function OpenForm(formName)
{
    var windowW = 620;
    var windowH = 700;
    switch(formName)
    {
        case 'EmailSignup':
            window.open('Forms/EmailSignup.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrolling=yes');
            break;
        case 'Employment':
            window.open('Forms/Employment.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'GiftingAppt':
            window.open('Forms/GiftingAppt.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'NominateAlum':
            window.open('Forms/NominateAlum.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'Careers':
            window.open('Forms/Employment.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'ReferAlumni':
            window.open('Forms/ReferStudent.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'UpdateInfo':
            window.open('Forms/UpdateInfo.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'VisitDegreeCompletion':
            window.open('Forms/VisitCampus.aspx?Audience=DegreeCompletion','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'VisitGraduate':
            window.open('Forms/VisitCampus.aspx?Audience=Graduate','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'VisitUndergrad':
            window.open('Forms/VisitCampus.aspx?Audience=Undergrad','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'RequestInfoDegreeCompletion':
            window.open('Forms/RequestInfo.aspx?Audience=DegreeCompletion','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'RequestInfoGraduate':
            window.open('Forms/RequestInfo.aspx?Audience=Graduate','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'RequestInfoGeneral':
            window.open('Forms/RequestInfo.aspx?Audience=Undergrad','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'WebsiteFeedback':
            window.open('Forms/WebsiteFeedback.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        case 'Giving':
            window.open('Forms/Giving.aspx','FormWindow','width=' + windowW + ',height=' + windowH + ',scrollbars=yes');
            break;
        default:
            break;
    }
}

function addBookmark(title, url) {
    if (window.sidebar) { // firefox
          window.sidebar.addPanel(title, url,"");
    } else if( document.all ) { //MSIE
            window.external.AddFavorite( url, title);
    } else {
           alert("Sorry, your browser doesn't support this");
    }
}

/*
  CONTROL OF FLASH MOVIE
*/
function getMovie(movieName) {
    var isIE = navigator.appName.indexOf("Microsoft") != -1;
    return (isIE) ? window[movieName] : document[movieName];
}
function stopRollover()
{
  var flashMovie = getMovie('SplashFlashMovie');
  if(flashMovie)
  {
    flashMovie.dropdownOpen();
  }
}
function startRollover()
{
  var flashMovie = getMovie('SplashFlashMovie');
  if(flashMovie)
  {
    flashMovie.dropdownClose();
  }   
}
