// JavaScript Document

// code for the right menu. Each menu item opens a sub-menu : a div with a table

// what browser are we using?
My_ns4=(document.layers)?true:false; 
My_ie4=(document.all)?true:false;
My_ns6=(!document.all&&document.getElementById)?true:false;

var My_timer=null;
var My_long_time = 50; //   delay between mouseout of a menu and clearing the submenu
var My_short_time = 1000; //  0.5 sec delay between mouseout of a submenu and clearing the submenu
var My_initial = true;
var My_width;
var My_height;
var default_image = '';

function My_Size() {

  var myWidth = 0, myHeight = 0;
 
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
//  window.alert( 'Width = ' + myWidth );
 // window.alert( 'Height = ' + myHeight );
  My_width = myWidth;
  My_height = myHeight;
}

function set_default_image(name){
	default_image = name;
}

// hides all submenues
function My_hideall()
{
   
	// clear current timer
	My_clear_timer();
	
	//  sub menu divs
	My_hide('about');
	My_hide('departments');
	My_hide('faculty'); 
	My_hide('conferences');
	My_hide('graduate');
	My_hide('awards');
	My_hide('news');
	
	// return the top left image to its default
	changeImages('changing',default_image)
}

function My_clear_timer()
{
	// clear current timer
	if (My_timer) {
		clearTimeout(My_timer);
		}
	My_timer = null;
}

function My_timed_hideall(My_close_time)
{
	// clear current timer
	My_clear_timer();
	// and set a new one		
	My_timer=setTimeout('My_hideall()',My_close_time);
}

function My_position_top_menu_english(x_shift)
{
// alight the english top menu relative to the left edge of the window by
// moving the div  named 'topmenu' to the position x_shift
var name = 'topmenu';

	if (My_ie4) 		{
		//alert(document.all[name].style.visibility)
		document.all[name].style.visibility='visible';
		document.all[name].style.left = x_shift;
		//alert(document.all[name].style.visibility)
	}
	else if (My_ns4) 	{
	
		document.layers[name].visibility='show';
		document.layers[name].left = x_shift;
	}
	else if (My_ns6) 	{
	
		document.getElementById(name).style.visibility = "visible";
		document.getElementById(name).style.left = x_shift;
	}
	
	return true;
}


function My_position_top_menu(x_shift)
{
// align the top menu relative to the right edge of the window by
// moving the div  named 'topmenu'  to position --> width  + x_shift
	
var name = 'topmenu';

var myWidth = 0, myHeight = 0;
 
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
//  window.alert( 'Width = ' + myWidth );
 // window.alert( 'Height = ' + myHeight );
  
	
	if (My_ie4) 		{
		//alert(document.all[name].style.visibility)
		document.all[name].style.visibility='visible';
		document.all[name].style.left=myWidth + x_shift;
		//alert(document.all[name].style.visibility)
	}
	else if (My_ns4) 	{
	
		document.layers[name].visibility='show';
		document.layers[name].left=myWidth + x_shift;
	}
	else if (My_ns6) 	{
	
		document.getElementById(name).style.visibility = "visible";
		document.getElementById(name).style.left=myWidth + x_shift;
	}
	
	return true;
}

function My_show(name,x_shift)
{
// align the  menu  item relative to the right edge of the window by
// moving the div  name to position --> width  + x_shift
	
	// clear current timer
	My_clear_timer();
	
	// get window size
	My_Size();
   
    // hide previous sub-menu
	My_hideall()
	
	// show the sub-menu
	if (My_ie4) 		{
		document.all[name].style.visibility='visible';
		document.all[name].style.left=My_width + x_shift;
	}
	else if (My_ns4) 	{
		document.layers[name].visibility='show';
		document.layers[name].left=My_width + x_shift;
	}
	else if (My_ns6) 	{
		document.getElementById(name).style.visibility = "visible";
		document.getElementById(name).style.left=My_width + x_shift;
	}
	
	return true;
}

function My_show_english(name,x_shift)
{
// align the  menu  item relative to the left edge of the window by
// moving the div  name to position  x_shift

	// clear current timer
	My_clear_timer();
	
	// get window size
	My_Size();
   
    // hide previous sub-menu
	My_hideall()
	
	// show the sub-menu
	if (My_ie4) 		{
		document.all[name].style.visibility='visible';
		document.all[name].style.left = x_shift;
	}
	else if (My_ns4) 	{
		document.layers[name].visibility='show';
		document.layers[name].left = x_shift;
	}
	else if (My_ns6) 	{
		document.getElementById(name).style.visibility = "visible";
		document.getElementById(name).style.left =  x_shift;
	}
	
	return true;
}

function My_show_english_line(name,x_shift,x_line,y_line)
{
// align the  menu  item relative to the left edge of the window by
// moving the div  name to position  x_shift

// shows the decorative line x ,y position  x_line,y_line 
	
	// clear current timer
	My_clear_timer();
	
	// get window size
	My_Size();
   
    // hide previous sub-menu
	My_hideall()
	
	// show the sub-menu
	if (My_ie4) 		{
		document.all[name].style.visibility='visible';
		document.all[name].style.left = x_shift;
		
		document.all['line'].style.visibility='visible';
		document.all['line'].style.left = x_line;
		document.all['line'].style.top = y_line;
	}
	else if (My_ns4) 	{
		document.layers[name].visibility='show';
		document.layers[name].left = x_shift;
		
		document.layers['line'].visibility='show';
		document.layers['line'].left = x_line;
		document.layers['line'].top = y_line;
	}
	else if (My_ns6) 	{
		document.getElementById(name).style.visibility = "visible";
		document.getElementById(name).style.left =  x_shift;
		
		document.getElementById('line').style.visibility = "visible";
		document.getElementById('line').style.left = x_line;
		document.getElementById('line').style.top = y_line;
	}
	
	return true;
}


function My_show_english_xy(name,x_shift,y_shift)
{
// align the  menu  item relative to the left edge of the window by
// moving the div  name to position  x_shift
	
	// clear current timer
	My_clear_timer();
	
	// get window size
	My_Size();
   
    // hide previous sub-menu
	My_hideall()
	
	// show the sub-menu
	if (My_ie4) 		{
		document.all[name].style.visibility='visible';
		document.all[name].style.left= x_shift;
		document.all[name].style.top = y_shift;
	}
	else if (My_ns4) 	{
		document.layers[name].visibility='show';
		document.layers[name].left= x_shift;
		document.layers[name].top = y_shift;
	}
	else if (My_ns6) 	{
		document.getElementById(name).style.visibility = "visible";
		document.getElementById(name).style.left= x_shift;
		document.getElementById(name).style.top = y_shift;
	}
	
	return true;
}


function My_hide(name)
{
       // hide the sub-menu
	if (My_ie4) 		{
		document.all[name].style.visibility='hidden';
	}
	else if (My_ns4) 	{
		document.layers[name].visibility='hide';
	}
	else if (My_ns6) 	{
		document.getElementById(name).style.visibility = "hidden";
	}
 
return true;
}


	// ---------code for swaping images

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// using DOM's get element by ID, 
// note also the use of IMG ID instead of IMG name, in the HTML that defines the image below 
function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			theImg=document.getElementById(changeImages.arguments[i]);
			theImg.setAttribute("src",changeImages.arguments[i+1]);
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		
		  // preload the rollover images for the  hat images
		designer1 = newImage("images/nice1.gif");
		designer2 = newImage("images/nice2.gif");
		designer3 = newImage("images/nice3.gif");
		preloadFlag = true;
	}
}

function My_show_menu_item(name,x_shift,image_name,image_src){
	My_show_english(name,x_shift);
	changeImages(image_name, image_src); 
	return true
}

function My_clear_menu_item(image_name,image_src){	
	My_timed_hideall(My_long_time);
	changeImages(image_name, image_src); 
	return true
}
//
