// JavaScript Document

//Animation Functions
function navAnimation(positionNum,divID) {
	//alert(positionNum + ", " + divID);
	var intOffset = -104;
	document.getElementById(divID).style.backgroundPosition = "0 " + (parseInt(positionNum)* intOffset) + "px";
}

function navSubAnimation(positionNum,divID) {
	//alert(positionNum + ", " + divID);
	var intOffset = -70;
	document.getElementById(divID).style.backgroundPosition = "0 " + (parseInt(positionNum)* intOffset) + "px";
}
//Clear Default Text: functions for clearing and replacing default text in <input> elements.

function addEvent(element, eventType, lamdaFunction, useCapture) {
    if (element.addEventListener) {
        element.addEventListener(eventType, lamdaFunction, useCapture);
        return true;
    } else if (element.attachEvent) {
        var r = element.attachEvent('on' + eventType, lamdaFunction);
        return r;
    } else {
        return false;
    }
} 
 
addEvent(window, 'load', init, false);

function init() {
    var formInputs = document.getElementsByTagName('input');
    for (var i = 0; i < formInputs.length; i++) {
        var theInput = formInputs[i];
        
        if (theInput.type == 'text' && theInput.className.match(/\bcleardefault\b/)) {  
            /* Add event handlers */          
            addEvent(theInput, 'focus', clearDefaultText, false);
            addEvent(theInput, 'blur', replaceDefaultText, false);
            
            /* Save the current value */
            if (theInput.value != '') {
                theInput.defaultText = theInput.value;
            }
        }
    }
}

function clearDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == target.defaultText) {
        target.value = '';
    }
}

function replaceDefaultText(e) {
    var target = window.event ? window.event.srcElement : e ? e.target : null;
    if (!target) return;
    
    if (target.value == '' && target.defaultText) {
        target.value = target.defaultText;
    }
}

//This is the dynamic function that resizes the viewport based on browser size
function alertSize() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Height = ' + myHeight );
  

 // if (myHeight <= 570) {  Tank value commented by Takehiko 
 // this is the height threshold for getting the browser vertical scrollbar
  if (myHeight <= 550) {
	  //var someValue = document.getElementById('facultyRightColumn');
		if (document.getElementById("content")) {
 // document.getElementById("content").style.height = 350+'px'; commented by Takehiko
			document.getElementById("content").style.height = 320+'px';
		}
		if (document.getElementById("content2Col")) {	
// document.getElementById("content2Col").style.height = 350+'px'; TANK value commented by Takehiko	
			document.getElementById("content2Col").style.height = 380+'px';
		}
		if (document.getElementById("facultyRightColumn")) {

// document.getElementById("facultyRightColumn").style.height = 330+'px'; TANK value commented by Takehiko
		 document.getElementById("facultyRightColumn").style.height = 255+'px';
		}
  } else {
	  
   // newHeight = (myHeight - 595) + 350; TANK value  commented by Takehiko
   // Changing this changes the white space beneath the text footer menu
   // In conjunction, I also needed to chang the following line in doaStyle.css
   // to cope with the Firefox anormally of narrow left-right bringing up vertical scroller
   // #container {.....    margin: 7px auto 3px;

	  newHeight = (myHeight - 595) + 370;
	  
	 if (document.getElementById("content"))
	 {		  
        document.getElementById("content").style.height = newHeight+'px';
	 }			
	if (document.getElementById("content2Col"))		
	{
   // The next line is add by Takehiko to avoid showing the inside scrollbar for bio blurb 
	  if (newHeight <= 380) { newHeight = 380 ; }
	  	document.getElementById("content2Col").style.height = newHeight+'px';
	}		
	if (document.getElementById("facultyRightColumn"))		
	{
	// newHeight = newHeight - 50;   commented by Takehiko Nagakura 
	  	newHeight = newHeight - 71;
		document.getElementById("facultyRightColumn").style.height = newHeight+'px';
	}
  }
}
