	// script code structure  - Author: Sreedhar Vankayala
	/*	Browser Detect
		----------------------------------------------
				GLOBAL VARIABLES
		----------------------------------------------
				OBJECT BUILD SCRIPTS
		----------------------------------------------
				OTHER SCRIPTS
		----------------------------------------------
	*/

	/*	Dashboard coding
		----------------------------------------------
				GLOBAL VARIABLES
		----------------------------------------------
				GENERIC SCRIPTS
		----------------------------------------------
				OBJECT BUILD SCRIPTS
		----------------------------------------------
				HANDLING EVENT SCRIPTS
		----------------------------------------------
				ONLOAD AND ONUNLOAD SCRIPTS
		----------------------------------------------
				OTHER SCRIPTS
		----------------------------------------------
	*/		

	//	Browser Detect
	/*	----------------------------------------------
				GLOBAL VARIABLES
		----------------------------------------------
	*/
	var oBrowser; // global variable that contains the browser details.
	
	/*
		----------------------------------------------
				OBJECT BUILD SCRIPTS
		----------------------------------------------
	*/
	/*	
		function: checkBrowser ()
		usage:		var oBrowser=new checkBrowser();
		purpose:	Use this function to retrieve
				the browser details as on object.
		details:	basic details;
	*/
	function checkBrowser()
	{
		var agent 		= navigator.userAgent.toLowerCase ();
		this.agent		= navigator.userAgent;

		// Browser version
		this.ver		= navigator.appVersion;
		var ver			= navigator.appVersion.toLowerCase ();
		this.versionMajor 	= parseInt(navigator.appVersion);
		this.versionMinor 	= parseFloat(navigator.appVersion);

		this.dom		= document.getElementById?true:false;

		// IE
		this.ie 		= (agent.indexOf("msie") != -1);
		this.ie6		= (this.ver.indexOf("MSIE 6")>-1 && this.dom)?true:false;
		this.ie55		= (this.ver.indexOf("MSIE 5.5")>-1 && this.dom)?true:false;
		this.ie5		= (this.ver.indexOf("MSIE 5")>-1 && this.dom)?true:false;
		this.ie4		= (document.all && !this.dom)?true:false;
		this.ie4Plus		= this.ie4||this.ie5||this.ie55||this.ie6;

		if (this.ie)
		{
			var iePos	  = ver.indexOf("msie");
			this.versionMajor = parseInt(ver.substring(iePos+5,ver.indexOf(';',iePos)));
			this.versionMinor = parseFloat(ver.substring(iePos+5,ver.indexOf(';',iePos)));
		}

		// Netscape
		this.ns 		= ((agent.indexOf('mozilla')!=-1) &&
			(agent.indexOf('spoofer')==-1) &&
			(agent.indexOf('compatible') == -1) &&
			(agent.indexOf('opera')==-1)
			&& (agent.indexOf('webtv')==-1)) || (navigator.appName.toUpperCase () == "NETSCAPE");
		this.ns5		=(this.ns && this.dom && parseInt(this.ver) >= 5) ?true:false;
		this.ns4		=(this.ns && document.layers && !this.dom)?true:false;
		this.ns4Plus 		= this.ns4||this.ns5;

		// Netscape 6, 7.xb
		if (this.ns5)
		{
			if (agent.indexOf('netscape6') > 0)
			{
				var nav6Pos = agent.indexOf('netscape6');
				this.versionMajor = parseInt(agent.substring(nav6Pos+10));
				this.versionMinor = parseFloat(agent.substring(nav6Pos+10));
			}
			else if (agent.indexOf('netscape') > 0)
			{
				var nav6Pos = agent.indexOf('netscape');
				this.versionMajor = parseInt(agent.substring(nav6Pos+9));
				this.versionMinor = parseFloat(agent.substring(nav6Pos+9));
			}
		}
		
		// AOL		
		this.aol		= (agent.indexOf("aol") != -1);
		if (this.aol)
		{
			//if (agent.indexOf("aol 5") != -1) browser.isIE = true;
			//if (agent.indexOf("aol 6") != -1) browser.isIE = true;

			var aolPos	= agent.indexOf("aol");
			this.versionMajor 	= parseInt(agent.substring(aolPos+3,agent.indexOf(';',aolPos)));
			this.versionMinor 	= parseFloat(agent.substring(aolPos+3,agent.indexOf(';',aolPos)));
		}

		this.opera 		= (agent.indexOf("opera") != -1);

		// Platform type
		this.win 		= ( (agent.indexOf("win")!=-1) || (agent.indexOf("16bit")!=-1) );
		this.win32 		= ((agent.indexOf("win95")!=-1) ||
				(agent.indexOf("windows 95")!=-1) ||
				(agent.indexOf("win98")!=-1) ||
				(agent.indexOf("windows 98")!=-1) ||
				(agent.indexOf("winnt")!=-1) ||
				(agent.indexOf("windows nt")!=-1) ||
				((this.versionMajor >= 4) && (navigator.platform == "Win32")) ||
				(agent.indexOf("win32")!=-1) || (agent.indexOf("32bit")!=-1));
		this.mac 		= (agent.indexOf("mac")!=-1);
		this.os2 		= (agent.indexOf("os/2")!=-1);
		this.otherOS		= ( this.win || this.win32 || this.mac || this.os2 )?false:true;

		this.goodbw		= ((this.ie4Plus || this.ns4Plus)); // && ! this.opera );

		this.bGetAdvanced = false;
		this.getAdvancedProp = function ()
			{
				this.checkBrowserAdvanced = checkBrowserAdvanced;
				this.checkBrowserAdvanced();
				if (this.ie4Plus || this.ns4Plus)
					delete this.checkBrowserAdvanced;  
			}	
		return this;
	}

	/* ------------------------------------------------------- */
	// Note we are defining the properties as default.
	// If needed, Pages that needed more properties/events/methods can be added
	//		after creating the object. Do not change this code.

	function checkBrowserAdvanced()
	{
		if (this.bGetAdvanced) return;

		if (!this.versionMajor) 
		{
			this.checkBrowser = checkBrowser;
			this.checkBrowser ();	
			if (this.ie4Plus || this.ns4Plus)
				delete this.checkBrowser;  
		}
		
		this.bGetAdvanced = true;

		var agent 	= navigator.userAgent.toLowerCase ();

		this.appName		= navigator.appName;
		this.appCodeName	= navigator.appCodeName;
		this.platform		= navigator.platform;

		this.isNavLessThan4	= (parseInt(navigator.appVersion) < 4 );

		this.ie5Plus	= this.ie5||this.ie55||this.ie6;
		this.ie6Plus	= this.ie6;

		this.ns6   	=(this.ns && (this.versionMajor == 6||this.versionMajor == 5));    // new 010118 mhp
		this.ns7   	=(this.ns && (this.versionMajor == 7));    
		this.ns5Plus 	= this.ns5 || this.ns6 || this.ns7;
		this.ns6Plus	= this.ns6 || this.ns7;

		// for all guys who really want the word netscape 6
		this.netscape6	= (agent.indexOf('netscape6') != -1);

		// Other Browsers
		this.webtv 	= (agent.indexOf("webtv") != -1);
		this.gecko 	= (agent.indexOf("gecko") != -1);
		this.aoltv 	= ((agent.indexOf("navio") != -1) || (agent.indexOf("navio_aoltv") != -1));
		this.tvnavigator= ((agent.indexOf("navio") != -1) || (agent.indexOf("navio_aoltv") != -1));
		this.hotjava 	= (agent.indexOf("hotjava") != -1);

		// Js Versions
		this.jsVersion	= "--";

		// Platform type
		this.win16 	= ((agent.indexOf("win16")!=-1) ||
               (agent.indexOf("16bit")!=-1) || (agent.indexOf("windows 3.1")!=-1) ||
               (agent.indexOf("windows 16-bit")!=-1) );

		// ???
		// this.win95, this.win98, this.win31, this.winnt, this.win2k, this.wince, this.winme, this.winXP, this.MSPIE
		this.sun_OS  	= (agent.indexOf("sunos")!=-1);
		this.irix_OS 	= (agent.indexOf("irix") !=-1);    // SGI
		this.hpux_OS 	= (agent.indexOf("hp-ux")!=-1);
		this.aix_OS  	= (agent.indexOf("aix") !=-1);      // IBM
		this.linux_OS	= (agent.indexOf("inux")!=-1);
		this.sco_OS  	= (agent.indexOf("sco")!=-1) || (agent.indexOf("unix_sv")!=-1);
		this.unixware_OS	= (agent.indexOf("unix_system_v")!=-1);
		this.mpras_OS   	= (agent.indexOf("ncr")!=-1);
		this.reliant_OS 	= (agent.indexOf("reliantunix")!=-1);
		this.dec_OS 		= ((agent.indexOf("dec")!=-1) || (agent.indexOf("osf1")!=-1) ||
			   (agent.indexOf("dec_alpha")!=-1) || (agent.indexOf("alphaserver")!=-1) ||
			   (agent.indexOf("ultrix")!=-1) || (agent.indexOf("alphastation")!=-1));
		this.sinix_OS	= (agent.indexOf("sinix")!=-1);
		this.freebsd_OS	= (agent.indexOf("freebsd")!=-1);
		this.bsd_OS		= (agent.indexOf("bsd")!=-1);
		this.unix_OS		= ((agent.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux ||
				 this.sco || this.unixware || this.mpras || this.reliant ||
				 this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd);
		this.vms_OS		= ((agent.indexOf("vax")!=-1) || (agent.indexOf("openvms")!=-1));

		// Navigator properties
		this.innerWidth		= (this.ns4Plus) ? innerWidth : (this.ie4Plus && document.body) ? document.body.clientWidth : -1;
		this.innerHeight 	= (this.ns4Plus) ? innerHeight : (this.ie4Plus && document.body) ? document.body.clientHeight : -1;

		this.scriptEngine = (this.ie4Plus && ! this.opera)?ScriptEngine():"--";
		this.scriptVersion = (this.ie4Plus && ! this.opera)?ScriptEngineMajorVersion() + "." + ScriptEngineMinorVersion() + "." + ScriptEngineBuildVersion():"--";

		this.getElementById		= document.getElementById?true:false;
		this.getElementsByTagName	= document.getElementsByTagName?true:false;
		this.documentElement		= document.documentElement?true:false;
		this.all			= document.all?true:false;
		this.layers			= document.layers?true:false;

		this.anchors			= document.anchors?true:false;
		document.cookie = "cookies=true";
		this.cookie			= document.cookie?true:false;
		this.forms			= document.forms?true:false;
		this.images			= document.images?true:false;
		this.links			= document.links?true:false;
		this.regexp 			= window.RegExp?true:false;
		this.option 			= window.Option?true:false;
		this.java 			= navigator.javaEnabled();

		this.screen			= window.screen?true:false;
		this.screenHeight		= window.screen?(screen.height<600)?600:screen.height:600;
		this.screenWidth		= window.screen?(screen.width<800)?800:screen.width:800;
		this.screenAvailHeight		= window.screen?(screen.availHeight<600)?600:screen.availHeight:600;
		this.screenAvailWidth		= window.screen?(screen.availWidth<800)?800:screen.availWidth:800;
		this.screenColorDepth		= window.screen?screen.colorDepth:600;

		this.documentDomain		= document.domain;
		this.documentURL		= document.URL;

		// Note we are defining the above properties as default.
		// If needed, Pages that needed more properties/events/methods can be added
		//		after creating the object. Do not change this code.

		return this;
	}

	/* ------------------------------------------------------- */
	var oBrowser = new checkBrowser();
	
	// To get the advanced Properties
	//	- Invoke this function at the end of the page, to get better results.
	// oBrowser.getAdvancedProp ();
	
	/*	Dashboard coding
		----------------------------------------------
				GLOBAL VARIABLES
		----------------------------------------------
				GENERIC SCRIPTS
		----------------------------------------------
				OBJECT BUILD SCRIPTS
		----------------------------------------------
				HANDLING EVENT SCRIPTS
		----------------------------------------------
				ONLOAD AND ONUNLOAD SCRIPTS
		----------------------------------------------
				OTHER SCRIPTS
		----------------------------------------------
	*/		

/*
	----------------------------------------------
			GLOBAL VARIABLES
	----------------------------------------------
*/
	var oLevel0Menus = new Array ();	 
	var oLevel1Menus = new Array ();	
	var oLevel2Menus = new Array (); 

	// TO IDENTIFY THE SELECTED MENUS - SERVER GENERATES THE FOLLOWING VARIABLES
	//  -- selTabIdOnload, selCabinetIdOnload, selDoorIdOnload, selFolderIdOnload, selPageIdOnload
	var selTabIdOnload 	= "";
	var selCabinetIdOnload 	= "";
	var selDoorIdOnload 	= "";
/*
	----------------------------------------------
			GENERIC SCRIPTS
	----------------------------------------------
*/
			// ----------------------------------------------
	/*
		INTERNAL USE
	function: showObjProperties ( obj, objName )
	usage:
		showObjProperties ( obj, objName )
	purpose:
		Use this function to return the
		properties of a object.
	*/

	function showObjProperties ( obj, objName )
	{
		var resultStr = "";
		for ( var i in obj )
			resultStr += objName + "." + i + " = " + obj[i] + "\n"

		return resultStr;
	}

			// ----------------------------------------------
	/*
	function: switchDisplay(obj)
	usage:
		switchDisplay('<< ID of the html tag that has to switch display>>')
	purpose:
		Use this function to switch display.
		if display is on, turn it off or vice versa.
	*/
	function switchDisplay(obj)
	{
		if ( obj )
		if ( obj.style )
		if (obj.style.display=="none")
			obj.style.display="";
		else
			obj.style.display="none";
	}

			// ----------------------------------------------

	/*
	function: checkBrowserRedirect()
	usage:
		checkBrowserRedirect()
	purpose:
		Use this function to block the browsers that are not supported.
	*/

	function checkBrowserRedirect()
	{
		var bw_sIEInfoPage 	= "/standard/browser_block.html";
		var bw_sNSInfoPage	= "/standard/browser_block.html";

		var bw_MaxVersionNotApplicable = 9999; 
			// use this variable, if you dont want to check Max version

		// Versions - windows
		var bw_win_IEMinVersion	= 4.5;
		var bw_win_IEMaxVersion	= bw_MaxVersionNotApplicable ; 

		var bw_win_NSMinVersion	= 6.1;
		var bw_win_NSMaxVersion	= bw_MaxVersionNotApplicable ; 

		var bw_win_AOLMinVersion= 5.0;
		var bw_win_AOLMaxVersion= bw_MaxVersionNotApplicable;

		bw_isNavLessThan4	= (parseInt(navigator.appVersion) < 4 );

		var bw_redirectPage 	= "";
		var bw_defaultRedirect	= bw_sIEInfoPage;
		if (navigator.appName.toUpperCase () == "NETSCAPE" ) 
			bw_defaultRedirect	 = bw_sNSInfoPage;

		if (!navigator)
		{
			bw_redirectPage = bw_defaultRedirect;
		}
		else if (bw_isNavLessThan4) // less than version 4 browsers
		{
			bw_redirectPage = bw_defaultRedirect;
		}
		else if (oBrowser.ns) 
		{
			if (oBrowser.versionMinor < bw_win_NSMinVersion || oBrowser.versionMajor > bw_win_NSMaxVersion)
			{
				bw_redirectPage = bw_defaultRedirect;
			}
		}
		else if (oBrowser.aol)
		{
			if (oBrowser.versionMinor < bw_win_AOLMinVersion || oBrowser.versionMajor > bw_win_AOLMaxVersion)
			{
				bw_redirectPage = bw_defaultRedirect;
			}
		}
		else if (oBrowser.ie) 
		{
			if (oBrowser.versionMinor < bw_win_IEMinVersion || oBrowser.versionMajor > bw_win_IEMaxVersion)
			{
				bw_redirectPage = bw_defaultRedirect;
			}
		}
		else 
		{
			//unrecognized browser
			bw_redirectPage = bw_defaultRedirect;
		}

		if (bw_redirectPage != "")
		{
		    document.location.href = bw_redirectPage;
		}

		return ;
	}

		// ----------------------------------------------

/*
	----------------------------------------------
			OBJECT BUILD SCRIPTS
	----------------------------------------------
*/
	function renderMenu ( widgetId, widgetLevel, widgetTemplate,
		widgetText, widgetLinkUrl, isSelected, isDisplayed, sHTML )
	{
		/*
		Test harness code - need to be deleted.
		alert ('widgetId: ' + widgetId + '\n' + 'widgetLevel: ' + widgetLevel + '\n' + 'widgetTemplate: ' + widgetTemplate + '\n' + 'widgetText: ' + widgetText + '\n' + 'widgetLinkUrl: ' + widgetLinkUrl + '\n' + 'isSelected: ' + isSelected + '\n' + 'isDisplayed: ' + isDisplayed + '\n' + 'sHTML: ' + sHTML );
		*/	

		var sDrawHTML = "";

		if (widgetId == "" || "undefined" == widgetId)
			return;

		if (widgetLevel == "LEVEL0MENU")
		{
			oLevel0Menus [ oLevel0Menus.length ] = new buildMenuObj ( widgetId, widgetLevel, widgetTemplate, 
				widgetText, widgetLinkUrl, isSelected, isDisplayed, sHTML );

			sDrawHTML = templateFns (widgetTemplate, isSelected);

			sDrawHTML = replaceTokens (sDrawHTML, widgetId, widgetLinkUrl, widgetText);

			document.write ( sDrawHTML );
		}
		else if ( widgetLevel == "LEVEL1MENU" )
		{
			oLevel1Menus [ oLevel1Menus.length ] = new buildMenuObj ( widgetId, widgetLevel, widgetTemplate, 
				widgetText, widgetLinkUrl, isSelected, isDisplayed, sHTML );

			sDrawHTML = templateFns (widgetTemplate, isSelected);

			sDrawHTML = replaceTokens (sDrawHTML, widgetId, widgetLinkUrl, widgetText);
			
			document.write ( sDrawHTML );
		}	
		else if ( widgetLevel == "LEVEL2MENU" )
		{
			oLevel2Menus [ oLevel2Menus.length ] = new buildMenuObj ( widgetId, widgetLevel, widgetTemplate, 
				widgetText, widgetLinkUrl, isSelected, isDisplayed, sHTML );

			if ( isDisplayed != "Y" && isDisplayed != "N" ) isDisplayed = "N";
			if ( isSelected != "Y" && isSelected != "N" ) isSelected = "N";

			sDrawHTML = templateFns (widgetTemplate, isSelected);

			sDrawHTML = replaceTokens (sDrawHTML, widgetId, widgetLinkUrl, widgetText);

			document.write ( sDrawHTML );
		}
	}

	function renderMenuBottom (widgetTemplate)
	{
		document.write( templateFns (widgetTemplate) + "\n");
	}

			// ----------------------------------------------
	/*
	function: buildMenuObj ( widgetId, widgetLevel, widgetTemplate, 
		widgetText, widgetLinkUrl, isSelected, isDisplayed, sHTML )

	returns	: object containing menu details
	
	usage	:
		new buildMenuObj ( 
		<<widgetId	- Id of the widget >>, 
		<<widgetLevel	- TAB | CABINET | DRAWER >>, 
		<<widgetTemplate  - Template or pattern that has to be used for rendering >>, 
		<<widgetText	- Display Text >>, 
		<<widgetLinkUrl	- Url for the Widget >>, 
		<<isSelected	- Y :: Selected, N :: Unselected. cool. Is the data correct ??? No Idea ?? >>, 
		<<isDisplayed	- Y :: renders to the client, N :: not renders to the client, else :: assumes as N >>,
		<<sHTML		- Before the whole HTML. from now on, it is any htmlattributes for the TD
					currently not implemented. we need to think about it. Ignore for the time being >>
		);
	
	purpose	:
		To create a Menu Object 
	*/
			
	function buildMenuObj ( widgetId, widgetLevel, widgetTemplate, 
		widgetText, widgetLinkUrl, isSelected, isDisplayed, sHTML )
	{
		this.widgetId 		= widgetId;
		this.widgetLevel	= widgetLevel;
		this.widgetTemplate	= widgetTemplate;
		this.widgetText		= widgetText;
		this.widgetLinkUrl	= widgetLinkUrl;
		this.isSelected		= isSelected;
		this.isDisplayed	= isDisplayed;
		this.sHTML		= sHTML;
		this.state		= "";
		this.parentId		= "";
	}

			// ----------------------------------------------

	function getTodayDate ()
	{
		var arrMonths = new Array();
		var objDate, todayDate, todayDay, todayMonth, todayYY, todayYYYY;

		arrMonths[1] = "January";  arrMonths[7]  = "July";
		arrMonths[2] = "February"; arrMonths[8]  = "August";
		arrMonths[3] = "March";    arrMonths[9]  = "September";
		arrMonths[4] = "April";    arrMonths[10] = "October";
		arrMonths[5] = "May";      arrMonths[11] = "November";
		arrMonths[6] = "June";     arrMonths[12] = "December";

		objDate 	= new Date();
		todayDate	= objDate.getDate();
		todayDay	= objDate.getDay() + 1;
		todayMonth	= objDate.getMonth() + 1;
		todayYY		= objDate.getYear();
		todayYYYY	= (todayYY < 1000) ? todayYY + 1900 : todayYY;

		return arrMonths[todayMonth] + " " + todayDate + ", " + todayYYYY;
	}

/*
	----------------------------------------------
			HANDLING EVENT SCRIPTS
	----------------------------------------------
*/

			// ----------------------------------------------

	function changeImg ( objImgHandle, imgSrc )
	{
		if (objImgHandle && objImgHandle.src )
		{
			objImgHandle.src = imgSrc;
		}
		else if ( document.images.objImgHandle )
			document.images.objImgHandle.src = imgSrc;
		
		return;
	}

/*
	----------------------------------------------
			ONLOAD AND ONUNLOAD SCRIPTS
	----------------------------------------------
*/
		// ----------------------------------------------
/*
	----------------------------------------------
			OTHER SCRIPTS
	----------------------------------------------
*/
	// Get the advanced properties of Browser
	oBrowser.getAdvancedProp ();

	// ----------------------------------------------

	checkBrowserRedirect();