var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,thestring;
var yPos=0;
var xPos=0;
var isDOM=document.getElementById&&!document.all;
var isIE6withDocType=document.documentElement && document.documentElement.clientHeight;
var timeoutId;
var logoffHandle;

function getBrowserInfo() {
	if (checkIt('konqueror')) {
		browser = "Konqueror";
		OS = "Linux";
	}
	else if (checkIt('safari')) browser 	= "Safari"
	else if (checkIt('omniweb')) browser 	= "OmniWeb"
	else if (checkIt('opera')) browser 		= "Opera"
	else if (checkIt('webtv')) browser 		= "WebTV";
	else if (checkIt('icab')) browser 		= "iCab"
	else if (checkIt('msie')) browser 		= "Internet Explorer"
	else if (!checkIt('compatible')) {
		browser = "Netscape Navigator"
		version = detect.charAt(8);
	}
	else browser = "An unknown browser";

	if (!version) version = detect.charAt(place + thestring.length);

	if (!OS) {
		if (checkIt('linux')) OS 		= "Linux";
		else if (checkIt('x11')) OS 	= "Unix";
		else if (checkIt('mac')) OS 	= "Mac"
		else if (checkIt('win')) OS 	= "Windows"
		else OS 								= "an unknown operating system";
	}
}

function checkIt(string) {

	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


/* Shows the Warning dialog box */
  function showWarning(){
	getBrowserInfo();
    activate();   
  }

function activate(){
		if (browser == 'Internet Explorer'){
			getScroll();			
			setScroll(0,0);
			hideSelects('hidden');			
		}
		//hideObjects('hidden');
		toggleDialogBox('sessionTimeoutWarnPopup',159,282,'');
}

//Gets the Current Scroll Co-ordinates
function getScroll(){
		if (self.pageYOffset) {
			yPos = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){
			yPos = document.documentElement.scrollTop; 
		} else if (document.body) {
			yPos = document.body.scrollTop;
		}
	}


// Hides the select elements which hovers within the dialog box.
	 function hideSelects(visibility){
		selects = document.getElementsByTagName('select');
		for(i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
	}
	//Hides any embeded objects , like SWF etc.
	 function hideObjects(visibility){
		objects = document.getElementsByTagName('object');
		for(i = 0; i < objects.length; i++) {
			objects[i].style.visibility = visibility;
		}
	}


var isDialogDisplayed = false;
var dialogHeight = 0;
var dialogWidth = 0;
var theDialogDiv;
var oldDialogInnerHTML;


function toggleDialogBox(theId,height,width,title)
{
	
    theDialogDiv = document.getElementById(theId);
	dialogHeight = height;
	dialogWidth = width;
	isDialogDisplayed = !isDialogDisplayed;
	dialogBkgdDiv = document.getElementById("dialogBackgroundDiv");

	title = htmlChars(title);
	
	if (isDialogDisplayed) 
	{
	    //addDialogTitle(title); //Remove comment to add Titlebar to the Dialog
        oldDialogInnerHTML = theDialogDiv.innerHTML;
		setDialogSizeAndPos();
	} else
	{        
        theDialogDiv.innerHTML = oldDialogInnerHTML;
	}
	
	toggleDialogBkgd();
	var viz = isDialogDisplayed ? "visible" : "hidden";
	theDialogDiv.style.visibility = viz;

}

function htmlChars(source)
{
   if(source == null)
       return source;
            
   var target = source;

   target = target.replace(/&/g, "&amp;");
   target = target.replace(/</g, "&lt;");
   target = target.replace(/>/g, "&gt;");

   return target;
}

function addDialogTitle(title)
{
	oldDialogInnerHTML = theDialogDiv.innerHTML;
	title = title ? title : "&nbsp;";
	
	var titleDiv = "<div class='table-label-bottom' ";
	titleDiv += "style='vertical-align:top;text-align:left;padding:6px;'>\n";
	titleDiv += "<span class='text_bold_12px'>" + title + "</span>\n";
	titleDiv += "</div>\n";
	titleDiv += "<div style='padding:6px;'>\n";
	theDialogDiv.innerHTML = titleDiv + oldDialogInnerHTML + "\n</div>\n";
}

function toggleDialogBkgd()
{
    var keepGoing = true;
	var dbdViz = isDialogDisplayed ? "visible" : "hidden";
	var hfdViz = isDialogDisplayed ? "none" : "block";

	var divElements = document.getElementsByTagName('SELECT');
	for (i=0; i<divElements.length; i++)
	{
		divElements[i].style.display = hfdViz;
	}
    
    divElements = document.getElementsByTagName('IFRAME');
	for (i=0; i<divElements.length; i++)
	{
		divElements[i].style.display = hfdViz;
	}
    
	if (isDialogDisplayed) 
	{
		divElements = theDialogDiv.getElementsByTagName('SELECT');
		for (i=0; i<divElements.length; i++)
		{
			divElements[i].style.display = "block";
		}
	}
	
	dialogBkgdDiv.style.visibility = dbdViz;
}

function setDialogSizeAndPos()
{
	if (isDialogDisplayed)
	{
		var base;
		
		if (isIE6withDocType)
		{
			base = document.documentElement;
		} else
		{
			base = document.body;
		}
		
		var ch = base.clientHeight;
		var sh = base.scrollHeight;
		var cw = base.clientWidth;
		var sw = base.scrollWidth;

		var theTop;
		var theLeft;
		
		if ( (ch - dialogHeight) < 0 )
		{
			theTop = base.scrollTop;
		} else {
			theTop = parseInt((ch - dialogHeight)/2) + base.scrollTop;				
		}

		if ( (cw - dialogWidth) < 0 )
		{
			theLeft = base.scrollLeft;
		} else {
			theLeft = parseInt((cw - dialogWidth)/2) + base.scrollLeft;				
		}
				
		if (isDOM)
		{
			// Appears to be Mozilla
			dialogBkgdDiv.style.height = ((ch > sh)? ch : sh) + "px";
			dialogBkgdDiv.style.width = ((cw > sw)? cw : sw) + "px";
			theDialogDiv.style.top = theTop + "px";
			theDialogDiv.style.left = theLeft + "px";
			theDialogDiv.style.height = dialogHeight + "px";
			theDialogDiv.style.width = dialogWidth + "px";
		} else
		{
			dialogBkgdDiv.style.height = (ch > sh)? ch : sh;
			dialogBkgdDiv.style.width = (cw > sw)? cw : sw;
			theDialogDiv.style.top = theTop;
			theDialogDiv.style.left = theLeft;
			theDialogDiv.style.height = dialogHeight;
			theDialogDiv.style.width = dialogWidth;
		}
	}
}
 /* --- End Add --*/
	
	 function setScroll(x, y){
		window.scrollTo(x, y); 
      }

	 