function onLoad()
{
	//Sridhar:36298<--Browser Check added here
	if(!browserCheck())
		return false;
	//-->
	//handle initialization errors from feature object
	if (strInitErrors != "")
	{
		MerlinSystemMsg(strInitErrors)
		return
	}

	//AJ added for embedded login starts: -->
	  var vTemp = strUser;
	//AJ added for embedded login ends: <-- 
	
	if (strErrors) strUser = ""

	if (strUser)
	{
		setTimeout("PostLogin();", 100);
	}
	else
	{
		if (strErrors)
			document.all("ERRORS").value =  strErrors;
	/* 
		AJ added for embedded login starts: -->
		setTimeout("login();", 100);
	*/
		if(bUseIntegrated)
			setTimeout("login();", 100);
		else
		{
			document.getElementById("TableLogin").style.display='';
		        document.all("ERRORS").value =  "";
			document.frmLoginEmbedded.USERID.value = vTemp;
		        MerlinErrorMsgBox(strErrors, 48);
			document.frmLoginEmbedded.USERID.focus();
		}
	/* 
		AJ added for embedded login ends: <-- 
	*/
	}
	
}

function dummyCall() {}

function extractIEVersionStr()
{
	var strBrowser = navigator.appVersion;
	var reIE;

	eval(reIE=new RegExp("(\\s|;)MSIE\\s+([\\.0-9]+);\\s+Windows"));
	if (!reIE)
		return false;
		//ideally we would just check for the feature set we need,
		//but we are really IE dependent

	var match = reIE.exec(strBrowser);
	if (!match)
		return false;

	return match[2]; //2nd set of parens
}

function browserCheck()
{
	var strVersion = extractIEVersionStr();
	var flVersion = 0.0;
   
	eval(flVersion=parseFloat(strVersion));
	
	if (flVersion >= 5.5)
	{
		if (checkBrowserFunctionality()== false) return false;   //Added for browser capability checking
		return true;
	}

	//display dialog, must use alert here since they may not be using IE.   
	MerlinSystemMsg(GetMerlinMsg(10468));
	//allow anyway
	return true;
}

function login()
{
	if (!browserCheck())
		return false;

	if(bUseIntegrated)
	{
		if (strErrors) {
			MerlinSystemMsg(strErrors)
			return false
		}
	
		document.all("UID").value = encodeURIComponent(strUID);
		document.all("OPMODE").value = "PRELOGIN" 
	}
	else
	{
		//AJ: not required anymore: -->
		// as there will be no more popup for login, from now on it will be through DEFAULT.HTM only
		/*
		if (window.screen.width == 800){ 	
			ReturnVal = myShowModalDialog ("prelogin.asp",window.document,"dialogLeft:200;dialogTop:200;dialogheight:190px;dialogwidth:420px;help:no;status:no")
		}
		else {
			ReturnVal = myShowModalDialog ("prelogin.asp",window.document,"dialogLeft:300;dialogTop:250;dialogheight:190px;dialogwidth:420px;help:no;status:no")	
		}
		if (!ReturnVal) 
			document.all("OPMODE").value = "LOGOFF" 
		else
			document.all("OPMODE").value = "PRELOGIN" 
		*/
		return;
		//AJ: not required anymore: <--
	}
	newdate = new Date()
	document.all("CLIENTTZONEOFFSET").value =  newdate.getTimezoneOffset()
	document.all("HIDDENTIME").value =  newdate.valueOf()	
	//loginstatus.style.visibility=""  
	//window.frmLogin.focus()  //Benny - Part of XP SP2 changes
	window.frmLogin.submit()	
}

function PostLogin()
{
	//Should be scrollbars (like open) but IE has it wrong
	var ReturnVal = myShowModalDialog ("postlogin.asp?UID=" + encodeURIComponent(strUser),
	window.document,
	"dialogLeft:350;dialogTop:250;dialogheight:290px;dialogwidth:322px;scroll:yes;help:no;status:no");

	if (ReturnVal)
	{
		document.all("OPMODE").value = "POSTLOGIN" ;
	}
	else
	{
		document.all("OPMODE").value = "CANCELLOGIN";
	}
	//loginstatus.style.visibility="";
	window.frmLogin.submit();
}


//<!--AJ added for embedded login: -->
function jsok()
{
	if(!OK())
		return false;
	document.all("OPMODE").value = "PRELOGIN" 
	newdate = new Date()
	document.all("CLIENTTZONEOFFSET").value =  newdate.getTimezoneOffset()
	document.all("HIDDENTIME").value =  newdate.valueOf()	
	//loginstatus.style.visibility="" ;
	window.frmLogin.submit();
	progress_live();
	return false;
}


var http_request = false;
var groupURL = "login.asp?FILTERGROUP=TRUE&";
var vIsContentChanged = false;
function makeRequest() 
{
	if((frmLoginEmbedded.USERID.value == "") || (vIsContentChanged==false) )
		return;
	
	vIsContentChanged = false; //reset
	
	if (window.XMLHttpRequest)
	{ // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
	} else if (window.ActiveXObject) { // IE
		http_request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	var gURL = groupURL + 'USERNAME=' + encodeURIComponent(frmLoginEmbedded.USERID.value) ;
    
	http_request.onreadystatechange = filterGroups;
	http_request.open('GET', gURL, false);
	http_request.send(null);
}

function filterGroups()
{
	if (http_request.readyState == 4) 
	{
		if (http_request.status == 200) 
        	{
			if(http_request.responseText == "")
			{
				MerlinSystemMsg(12689, 48);
				frmLoginEmbedded.GROUPSEL.innerHTML = "";
		        }
			else
			{
				//alert(http_request.responseText);
				//due to IE bug I am not setting the innerHTML of the <Select>, instead I am setting the innerHTML of <DIV> in which the <SELECT> lies
				var sSelTAG = "<select CLASS=\"SelectReal\" ID=\"GROUPM\" NAME=\"GROUPSEL\" TABINDEX=\"4\" style=\"width:98%\">";
				var strretval = sSelTAG + http_request.responseText + "</select>";
				frmLoginEmbedded.GROUPSEL.outerHTML = strretval;
			}
	        
        } 
        else
        {
			alert('There was a problem to load the user specific groups');
		}
	}
}

function clmExtractAccessKeyFromHtml(html)
{
	var html = html.toUpperCase();
	var li_BefLike=html.indexOf("<U>");
	var li_AfterLike=html.indexOf("</U>");

	if ((li_BefLike== -1) || (li_AfterLike == -1))
	//if the open and close tags not found
	// then no access key should be assigned
		return '';
	
	var str_data=html.substring((li_BefLike+3),li_AfterLike);
	return str_data;
}

function clmSetAccessKeyFromText(curObj, text)
{
	var str_data=clmExtractAccessKeyFromHtml(text);
	if ("" == str_data)
	{
		return false;
	}
	curObj.accessKey=str_data;
	return true;
}


//AJ: for progress bar -->
var iStartProgress = 0
var iTotalNumberOfCells = 30
var iTotalHighlightBoxes = 0

function progress_live()
{
	document.getElementById("divPrg").style.visibility = ""
	setTimeout(DoProgress, 100);
}

function DoProgress()
{
	if (iTotalHighlightBoxes < 30) 
		iTotalHighlightBoxes++
	else {
		/*lowlight(iStartProgress)
		iStartProgress++*/
		for (var i=0; i<iTotalHighlightBoxes && i<iTotalNumberOfCells; i++)
			lowlight(i);
		iStartProgress = iTotalHighlightBoxes = 0
	}

	if (iStartProgress == iTotalNumberOfCells)
		iStartProgress = iTotalHighlightBoxes = 0

	for (var i=iStartProgress; i<iStartProgress + iTotalHighlightBoxes && i<iTotalNumberOfCells; i++)
		highlight(i)
	setTimeout(DoProgress, 200)
}

function highlight(iCell)
{
	document.getElementById("loginPrg").rows(0).cells(iCell).style.background = "#00ff00";
}

function lowlight(iCell)
{
	document.getElementById("loginPrg").rows(0).cells(iCell).style.background = "#ffffff"; //document.bgColor;
}
//AJ: for progress bar ends <--
