﻿// JavaScript Document
<!--
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; }
}


function switchIt() {
// in millisecondes - originally set to 10 secs - changed 08/30/05 to 6 secs
 timer=setTimeout("MM_showHideLayers('bottom','','hide','top','','show')",6000);
}

function P7_JumpMenu(selObj,restore){ //v1.4 by Project Seven
    var theFullString = selObj.options[selObj.selectedIndex].value;
    if (restore) selObj.selectedIndex=0;
    var theLength = theFullString.length;
    var endPos = theFullString.lastIndexOf("~");
    var theUrl, theTarget, theParent;
    if (endPos > 0) {theUrl = theFullString.substring(0,endPos);}
    else {theUrl = theFullString;}
    endPos++
    if (endPos < theLength) {theTarget = theFullString.substring(endPos,theLength)}
    else {theTarget = "window:Main";}
    if (theTarget == "window:New") {window.open(theUrl);}
    else if (theTarget == "window:Main") {eval("parent.location='"+theUrl+"'");}
    else {eval("parent.frames[\'"+theTarget+"\'].location='"+theUrl+"'");}
}

function checkQuery() {
var queryFld = document.keyword.query
if (queryFld.value == "") {
alert ("Please enter a query")
queryFld.focus()
return(false)
}
return(true)
}

function checkName() {
var nameFld = document.ccso.NAME
if (nameFld.value == "") {
alert ("Please enter a name")
nameFld.focus()
return(false)
}
return(true)
}

function convertString( temp ) {
var newString = "";
var i=0;
for( i=0; i < temp.length; i++ ) {
if( temp.charAt(i) != " " ) {
newString += temp.charAt(i);
}
else {
newString += "+";
}
}
return newString;
}

function startSearch() {

//manhattan.edu via Google
if( document.keyword.searchnav[0].checked ) {
if( checkQuery() ) {
var header = "http://www.google.com/u/manhattan?";
var options = "&sitesearch=manhattan.edu&domains=manhattan.edu";
var searchVal = "q=" + convertString(document.keyword.query.value);
eval( "location = " + "\"" + header + searchVal + options + "\"");
}
}

//people
if( document.keyword.searchnav[1].checked ) {
if( checkQuery() ) {
var header = "http://www.manhattan.edu/cindy/php_test/index.php?page=alpha_mc_search&";
options = "PEOPLE=ALL";
searchVal = "&sn=" + convertString(document.keyword.query.value);
eval( "location = " + "\"" + header + options + searchVal + "\"" );
}
}

//searchSearch

}

function setMCRadio(ip){
if (ip.indexOf("149.61.")<0) {
document.keyword.searchnav[0].checked = true;
} else {
document.keyword.searchnav[1].checked = true;
}
}

var newWindow = null;

function closeWin(){
    if (newWindow != null){
        if(!newWindow.closed)
            newWindow.close();
    }
}

function popUp(strURL,strType,strHeight,strWidth) {
closeWin();
var strOptions="";
if (strType=="console") strOptions="resizable,height="+strHeight+",width="+strWidth;
if (strType=="fixed") strOptions="status,height="+strHeight+",width="+strWidth;
if (strType=="elastic") strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}

function popUpWin(url, type, strWidth, strHeight){
    
    closeWin();
    
    if (type == "fullScreen"){
        strWidth = screen.availWidth - 10;
        strHeight = screen.availHeight - 160;
    }
    
    var tools="";
    if (type == "standard" || type == "fullScreen") tools = "resizable,toolbar=yes,location=yes,scrollbars=yes,menubar=yes,width="+strWidth+",height="+strHeight+",top=0,left=0";
    if (type == "console") tools = "resizable,toolbar=no,location=no,scrollbars=no,width="+strWidth+",height="+strHeight+"";
    newWindow = window.open(url, 'newWin', tools);
    newWindow.focus();
}
//end of add 102405

// tables

 // this function is needed to work around 
  // a bug in IE related to element attributes
  function hasClass(obj) {
     var result = false;
     if (obj.getAttributeNode("class") != null) {
         result = obj.getAttributeNode("class").value;
     }
     return result;
  }   

 function stripe(id) {

    // the flag we'll use to keep track of 
    // whether the current row is odd or even
    var even = false;
  
    // if arguments are provided to specify the colours
    // of the even & odd rows, then use the them;
    // otherwise use the following defaults:
    var evenColor = arguments[1] ? arguments[1] : "#fff";
    var oddColor = arguments[2] ? arguments[2] : "#eee";
  
    // obtain a reference to the desired table
    // if no such table exists, abort
    var table = document.getElementById(id);
    if (! table) { return; }
    
    // by definition, tables can have more than one tbody
    // element, so we'll have to get the list of child
    // &lt;tbody&gt;s 
    var tbodies = table.getElementsByTagName("tbody");

    // and iterate through them...
    for (var h = 0; h < tbodies.length; h++) {
    
     // find all the &lt;tr&gt; elements... 
      var trs = tbodies[h].getElementsByTagName("tr");
      
      // ... and iterate through them
      for (var i = 0; i < trs.length; i++) {

        // avoid rows that have a class attribute
        // or backgroundColor style
        if (! hasClass(trs[i]) &&
            ! trs[i].style.backgroundColor) {
           
          // get all the cells in this row...
          var tds = trs[i].getElementsByTagName("td");
        
          // and iterate through them...
          for (var j = 0; j < tds.length; j++) {
        
            var mytd = tds[j];

            // avoid cells that have a class attribute
            // or backgroundColor style
            if (! hasClass(mytd) &&
                ! mytd.style.backgroundColor) {
        
              mytd.style.backgroundColor =
                even ? evenColor : oddColor;
            
            }
          }
        }
        // flip from odd to even, or vice-versa
        even =  ! even;
      }
    }
  }
  
  
function applyZebra() { 
    var tables = document.getElementsByTagName("table"); 
    for(var i=0, length=tables.length; i<length; i++) { 
        if (tables[i].className.indexOf("zebra")>=0) { 
            var tbody = tables[i].getElementsByTagName("tbody"); 
            var table = (tbody[0]?tbody[0]:tables[i]); 
            var trs = table.getElementsByTagName("tr"); 
            for(var j=0, lengthj=trs.length; j<lengthj; j++) { 
                if (j%2==0) 
                    trs[j].className='zebrarow'; 
            } 
        } 
    } 
}  
//-->
