// image rollovers for utility bar
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;
    var j=d.MM_p.length;
    var 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];}
}
// end of rollover code

function emailThisPage(asUrl)
{
	var mywindow = window.open('','mywindow','width=325,height=350');
	var tempString = "<html><head><title>Kettering University - Email This Page</title>\n";
	tempString+= "<link href=\"http://www.kettering.edu/main.css\" rel=\"stylesheet\" type=\"text/css\" />";
	tempString+= "<script type=\"text/javascript\" src=\"http://www.kettering.edu/toolbox/javascripts/validator.js\"></script></head><body class=\"popupscreen\">\n";
	tempString+= "<div class=\"popupcontent\">\n";
	tempString+= "<h1>Email This Page to a Friend</h1>\n";
	tempString+= "<p><form style=\"table\" act"  + "ion=\"http://www.kettering.edu/visitors/refera";
	tempString+= "friend.jsp\" method=\"post\" onsubmit=\"return referafriend(this)\">\n";
	tempString+= "<table>\n";
	tempString+= "\t<tr><td>Your Name<span class=\"required\">*</span></label></td><td><input name=\"fromNam"+"e\" id=\"\" size=\"17\"  maxlength=\"250\" type=\"text\" /></td></tr>\n";
	tempString+= "\t<tr><td>Your Email<span class=\"required\">*</span></label></td><td><input name=\"fromEma"+"il\" id=\"\" size=\"17\" maxlength=\"250\" type=\"text\" /></td></tr>\n";
	tempString+= "\t<tr><td><label>Your Friend&rsquo;s Email<span class=\"required\">*</span></label></td><td><input name=\"toEma"+"il\" id=\"\" size=\"17\" type=\"text\" /></td></tr>\n";
	tempString+= "\t<tr><td><label>Subject</label></td><td><input id=\"\" size=\"17\" maxlength=\"40\" type=\"text\" name=\"sub"+"ject\" value=\"A friend has referred you to a webpage\" /></div>\n";
	tempString+= "\t<input type=\"hidden\" id=\"\" name=\"pag" +  "e\" value=\"" + asUrl + "\"/><input type=\"hidden\" id=\"\" name=\"hist" +  "oryID\" value=\"" + getRandomID() +"\"/></td></tr>\n";
	tempString+= "\t<tr><td><label>Your Message<br />(Max. 100 Characters)</label></td><td><textarea name=\"mess"  + "age\" id=\"\" cols=\"16\" rows=\"5\" /></textarea></td></tr>\n";
	tempString+= "\t<tr><td><input type=\"submit\" value=\"submit\"/></td></tr>\n</table>\n";
	tempString+= "</form><span class=\"required\">*required</span></p></div></body></html>";
	mywindow.document.open();
	mywindow.document.write(tempString);
	mywindow.document.close();
	mywindow.focus();
}

function addBookmark(title, url) {
        if (window.sidebar) { // firefox
              window.sidebar.addPanel(title, url,"");
        } else if( document.all ) { //MSIE
                window.external.AddFavorite( url, title);
        } else if( window.opera && window.print ) {
		return true;	
        }
return true;
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

// usage send ID of element and starting opacity
function fadeIn(objId,opacity) {
  var obj;
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}

// usage send ID of element and starting opacity
function fadeOut(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity >=0) {
      setOpacity(obj, opacity);
      opacity -= 3;
      window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 100);
    }
  }
}

// send an element's id and it will turn its display on or off
function toggleHidden(objId){
		obj = document.getElementById(objId);
		if(obj.style.visibility == 'hidden'){
			obj.style.display = 'block';
			obj.style.visibility = 'visible';
		}
		else {
			obj.style.display = 'none';
			obj.style.visibility = 'hidden';
		}
}

function toggleHide(objId) {
               obj = document.getElementById(objId);
               obj.style.display = 'none';
               obj.style.visibility = 'hidden';
}

function toggleShow(objId) {
               obj = document.getElementById(objId);
               obj.style.display = 'block';
               obj.style.visibility = 'visible';
}



function showSubtab(listId, tabNum){
		var obj = document.getElementById(listId);
		var ul = obj.getElementsByTagName('LI');
		var contentPaneName;
		var contentPaneObj;
		//var testing = 'result is: \n';
		for(var i=0; i < ul.length; i++){
			if(i == tabNum){
				ul[i].className = 'subtab_current';
				contentPaneName = 'subtab' + i + '_content';
				contentPaneObj = document.getElementById(contentPaneName);
				contentPaneObj.className = 'subtabcontent_current';
			}
			else{
				ul[i].className = 'subtab';
				contentPaneName = 'subtab' + i + '_content';
				contentPaneObj = document.getElementById(contentPaneName);
				contentPaneObj.className = 'subtabcontent';
			}
			//testing = testing + ul[i].className + '\n';
		}
		//alert(testing);
		return true;
}

function OnLoad(searchTerm) {
	if(searchTerm == null){
		searchTerm = 'Kettering University';
	}
	var options = {
		largeResultSet : true,
		autoExecuteList : {
		cycleTime : GSvideoBar.CYCLE_TIME_SHORT,
		executeList : [ searchTerm ]
		}
	}
      var videoBar;
      var barContainer = document.getElementById("videoBar");
      var playerContainer = document.getElementById("videoPlayer");

      videoBar = new GSvideoBar(barContainer, playerContainer, options);
      videoBar.execute();
    }

function writeSignon(){
	document.write("<iframe id=\"login\" src=\"/login.jsp\" style=\"float:right; border:0px; clear:right; width:235px;\"  marginwidth=\"0\" marginheight=\"0\" align=\"middle\" frameborder=\"0\" scrolling=\"no\" height=\"111\" width=\"235\" ></iframe>");	
}


function set_select(selectId, value){
      var ct = document.getElementById(selectId).length;
	  for (var i = 0; i < ct; i++) {
	      if (document.getElementById(selectId)[i].value == value) {
		     document.getElementById(selectId)[i].selected = true;
		  }
	  }
}

function resizeiframe(id) {
	var height=window.innerWidth;//Firefox
	if (document.body.clientHeight)
	{
		height=document.body.clientHeight;//IE
	}
	//resize the iframe according to the size of the
	//window (all these should be on the same line)
	document.getElementById(id).style.height=parseInt(height-document.getElementById(id).offsetTop-8)+"px";
}

function flvVideo(width, height, video, autoplay) {
  var video_skin = "/media/SkinUnderPlayStopSeekFullVol.swf";
  var flash_height = height + 40;
  document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\""+width+"\" height=\""+flash_height+"\" id=\"flvplayer\" align=\"middle\">");
  document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
  document.write("<param name=\"movie\" value=\"/media/video_player.swf\" />");
  document.write("<param name=\"quality\" value=\"high\" />");
  document.write("<param name=\"allowFullScreen\" value=\"true\" />");
  document.write("<param name=\"FlashVars\" value=\"video="+video+"&video_autoplay="+autoplay+"&video_height="+height+"&video_width="+width+"&video_skin="+video_skin+"\" />");
  document.write("<embed src=\"/media/video_player.swf\" FlashVars=\"video="+video+"&video_autoplay="+autoplay+"&video_height="+height+"&video_width="+width+"&video_skin="+video_skin+"\" quality=\"high\" width=\""+width+"\" height=\""+flash_height+"\" allowScriptAccess=\"sameDomain\" allowFullScreen=\"true\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" /></object>");
}
