﻿
function initMenu() {
	var topNav1Div = document.getElementById('topNav1');
	var cells1 = document.getElementById('topNav1').getElementsByTagName('TABLE')[0].rows[0].cells;
	var cells2 = document.getElementById('topNav2').getElementsByTagName('TABLE')[0].rows[0].cells;
	var totalWidth = 0;
	var topOffsetLeft = topNav1Div.offsetLeft;
	for (var i=0; i < cells1.length; i++) {
		cells2[i].getElementsByTagName('IMG')[0].width = cells1[i].offsetWidth;
		if (cells1[i].id != '') {
			var offleft = topOffsetLeft + cells1[i].getElementsByTagName('IMG')[0].offsetLeft;
			var offtop = cells1[i].getElementsByTagName('IMG')[0].offsetParent.offsetTop
			try{
				document.getElementById(cells1[i].id+'SubNav1').style.width = cells1[i].offsetWidth+'px';
				document.getElementById(cells1[i].id+'SubNav1').style.left = offleft + 'px';
				document.getElementById(cells1[i].id+'SubNav1').style.top = offtop + 20 + 'px';
				document.getElementById(cells1[i].id+'SubNav2').style.left = offleft + 'px';
				document.getElementById(cells1[i].id+'SubNav2').style.top = offtop + 20 + 'px';
			}
			catch (err)
			{
				//alert(err);
			}
		}
		totalWidth += cells1[i].offsetWidth;
	}
	//cells1[cells1.length-1].childNodes[0].style.width = (700+2-totalWidth)+'px';
}





var calloutTimer = new Object();
function displayCalenderItemCallout(elem) {
	if(calloutTimer[elem.id] != null)
		stopTimer(elem.id);
	elem.style.display = 'block';
}
function hideCalenderItemCallout(elem) {	
	startTimer(elem);
}
function setCalendarItemHidden(id){
	var elem = document.getElementById(id)
	elem.style.display = 'none';
}
function startTimer(elem){
	calloutTimer[elem.id] = setTimeout('setCalendarItemHidden(\''+elem.id+'\')', 200);
}
function stopTimer(id){
	clearTimeout(calloutTimer[id]);	
}

function onCalloutMouseOver(elem){
	if(calloutTimer[elem.id] != null)
		stopTimer(elem.id);
}
function onCalloutMouseOut(elem){
	startTimer(elem);
}

function positionCalendarCallout(displayedElem, calloutElem){
	elem1 = document.getElementById(displayedElem);
	elem2 = document.getElementById(calloutElem);
	if(elem1 != null && elem2 != null)
		elem2.style.left = elem1.offsetWidth+'px';
}
	function changeImage(imgDocID,imgObjName,imgObjName2) { document.images[imgDocID].src = (imgObjName); }

	// This Function opens a new window and checks to see if the window already exists
	//sireesha
	var win=null;
	function OpenWindow(mypage,myname,w,h,scroll) 
	{
		LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
		TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
		settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable,menubar=yes';

		if(!win || win.closed) 
		{
			win = window.open(mypage,myname,settings);
			if(win.window.focus){ win.window.focus(); }
		}
		else 
		{
			win.close();
			win = null;
			//  "Why", you may ask, "is all this in a setTimeout?"
			//  "Because Macs are sluggish and unresponsive!", I reply.
			//  [sethd] 19th July 2001
			//win = window.open(mypage,myname,settings);
			//if(win.window.focus) { win.window.focus(); }
			setTimeout("win = window.open('"+mypage+"','"+myname+"','"+settings+"');if(win.window.focus) { win.window.focus(); }",400);
		}
	}

	function changeImageButton(imgDocID,imgObjName,layerName) 
	{
		if (document.layers) 
		{
			window.document.layers[layerName].document.getElementById[imgDocID].src = (imgObjName);
		}
		else 
		{
			eval('document.getElementById("' + imgDocID + '").src = "' + imgObjName + '"');
		}
	}


	function changeImage(imgDocID,imgObjName,layerName) 
	{

		if (document.layers && layerName) 
		{
			window.document.layers[layerName].document.images[imgDocID].src = (imgObjName);
		}
		else 
		{
			document.images[imgDocID].src = (imgObjName);
		}
	}

