
	var ie	= document.all
	var ns6	= document.getElementById&&!document.all
	var am = "Trap and show menu..";
	var bV  = parseInt(navigator.appVersion)
	var bNS = navigator.appName=="Netscape"
	var bIE = navigator.appName=="Microsoft Internet Explorer"
	

	function CustomEvent(clientX, clientY,button)
	{
		this.clientX = clientX;
		this.clientY = clientY;
		this.button = button;
	}
	
	
	function getElemRefs(id) 
	{
		var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
		if (el) el.css = (el.style)? el.style: el;
		return el;
	}
	
	function ConvertBoolVBtoJava(sStr)
  	{
		if (sStr == "False") return false;
		if (sStr == "True") return true;
		
		return false;
  	}	
  	
	function DivSetVisible(state,id)
	{
		var DivRef = document.getElementById(id);
		var IfrRef = document.getElementById('DivShim');
		var lyr = getElemRefs(id);
		//alert(state);
		if(state)
		{
			
			DivRef.style.display = "block";
			DivRef.style.visibility = "visible";
			
			if (lyr && lyr.css) 
			{	
				lyr.css.visibility = "visible";
				lyr.style.visibility = "visible";
			}
			
			IfrRef.style.width = DivRef.offsetWidth  - 10;
			IfrRef.style.height = DivRef.offsetHeight;
			IfrRef.style.top = DivRef.style.top;
			IfrRef.style.left = DivRef.style.left;
			IfrRef.style.zIndex = DivRef.style.zIndex - 1;
			IfrRef.style.display = "block";
		}
		else
		{
			DivRef.style.display = "none";
			if (lyr && lyr.css) 
			{	
				lyr.css.visibility = "hidden";
			}
			IfrRef.style.display = "none";
		}
	}

	function showLayer(id,bShowOver) 
	{
		if(bShowOver)
		{
			if(top.frames["DivShim"])
			{
				DivSetVisible(true,id)
				return false;
			}
		}
		//alert("jererer");
		var lyr = getElemRefs(id);
		if (lyr && lyr.css) 
		{	
			lyr.css.visibility = "visible";
		}
		
		//alert("Call");
		return false;
	}

	function hideLayer(id,bShowOver) 
	{
		
		//alert(top.frames["DivShim"] + "    " + bShowOver + "----" + id);

		try
		{

			if(bShowOver)
			{
				if(top.frames["DivShim"])
				{
					DivSetVisible(false,id)
					return false;
				}
			}


			//alert(document.getElementById(id));
			var lyr = document.getElementById(id) //getElemRefs(id);			
			if (lyr && lyr.css) {lyr.css.visibility = "hidden";}
		}
		catch(Ex)
		{
			//alert(Ex.description);
		}
		
	}

	function clickIE4(){
		if (event.button==2)
		{
			return false;
		}
	}

	function clickNS4(e)
	{
		if (document.layers||document.getElementById&&!document.all)
		{
			if (e.which==2||e.which==3)
			{
				return false;
			}
		}
	}
	

	function FSOpenWindow(WinName,sURL,Height,Width,Resizable)
	{
		var scrTop;
		var scrLeft;
		
		var sParam	= '';			
	
		scrTop = ((screen.availHeight - Height)/2) - 15;
		
		scrLeft = (screen.availWidth - Width)/2;
		
		sParam = 'width=' + Width + ',';
		sParam = sParam + 'height=' + Height + ',';
		sParam = sParam + 'left=' + scrLeft + ',';
		sParam = sParam + 'top=' + scrTop + ',';
		sParam = sParam + 'toolbar=no,';
		sParam = sParam + 'location=no,';
		sParam = sParam + 'directories=no,';
		sParam = sParam + 'status=yes,';
		sParam = sParam + 'menubar=no,';
		sParam = sParam + 'scrollbars=auto,';
		sParam = sParam + 'copyhistory=no,';
		sParam = sParam + 'resizable=' + Resizable;
		WinName = WinName + "_" + Math.floor(Height) + "_" + Math.floor(Width)
		var win;
		
		//alert(WinName);
		win = window.open(sURL,WinName,sParam);
		

		try
		{
			win.focus();	
		}	
		catch(e)
		{
				return win;
		}
		
		return win;
		
	}//end of FSOpenWindow

	//Added by Arun to open the window as the modal mode
	function FSOpenDialogWindow(WinName,sURL,Height,Width,Resizable)
	{
		var scrTop;
		var scrLeft;
		
		var sParam	= '';			
	
		scrTop = ((screen.availHeight - Height)/2) - 15;
		
		scrLeft = (screen.availWidth - Width)/2;
		
		sParam = 'dialogWidth=' + Width + ';';
		sParam = sParam + 'dialogHeight=' + Height + ';';
		sParam = sParam + 'center=yes';
	
	//alert(sParam);
		var win;
		
		win = window.showModalDialog(sURL,WinName,sParam);

		return win;
	}//end of FSOpenWindow

	function EncodeinJavaScript(sString)
	{
		
		var sEncodedString;
		sEncodedString = "";
		var rExp = /</gi;
		var rExp_Greater = />/gi;
		
		//sEncodedString = sString.replace(rExp_Extra,"&lt;&nbsp;%");
		sEncodedString = sString.replace(rExp,"&lt;");
		sEncodedString = sEncodedString.replace(rExp_Greater,"&gt;");
		
		return sEncodedString;
	
	}


	//Function to Trap Enter KEY
	function TrapEnterKey()
	{
		try
		{
		
			document.onkeypress = function (evt) 
			{
				var r = '';
				if (document.all) {
					r += event.ctrlKey ? 'Ctrl-' : '';
					r += event.altKey ? 'Alt-' : '';
					r += event.shiftKey ? 'Shift-' : '';
					r += event.keyCode;
				}
				else if (document.getElementById) {
					r += evt.ctrlKey ? 'Ctrl-' : '';
					r += evt.altKey ? 'Alt-' : '';
					r += evt.shiftKey ? 'Shift-' : '';
					r += evt.charCode;
				}
				else if (document.layers) {
					r += evt.modifiers & Event.CONTROL_MASK ? 'Ctrl-' : '';
					r += evt.modifiers & Event.ALT_MASK ? 'Alt-' : '';
					r += evt.modifiers & Event.SHIFT_MASK ? 'Shift-' : '';
					r += evt.which;
				}
				  
				if (r == '13') //Ctrl + U
				{
						//Call the FUnction	 
						EnterKeyPressed();
				}

				return true;		  	
			}		
		}
		catch (Ex)
		{
			//
		}

	}
	
	function findPos(obj) 
	{
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return curtop;
		//return [curleft,curtop];
	}

	function PrepareQueryStringForWindow(ShowBorder,ShowHeader,ShowButtons,HasTab)
	{
		var QueryString;
		QueryString = "";
		//SBORDER=0&SHEADER=0&SBUTTONS=0&STAB=
		if(ShowBorder == true)		{QueryString = "SBORDER=1";}	else	{QueryString = "SBORDER=0";}
		if (ShowHeader == true)		{QueryString += "SHEADER=1"}	else	{QueryString += "SHEADER=0"}
		if (ShowButtons == true)	{QueryString += "SBUTTONS=1"}	else	{QueryString += "SBUTTONS=0"}
		if (HasTab == true)			{QueryString += "STAB=1"}		else	{QueryString += "STAB=0"}
		
		//alert(QueryString);
		return QueryString;
	}

	function  GetObjectHeight(obj)
	{
		var iHeight;
		iHeight = 0;
		try
		{
			iHeight = obj.clientHeight;
			
		}
		catch(Ex)
		{
		
		}
		
		return iHeight;
	}
	
	function  GetElementHeight(Ename)
	{
		var iHeight;
		if(document.getElementById(Ename))
		{
			try
			{
				iHeight = GetObjectHeight(document.getElementById(Ename))
			}
			catch(Ex)
			{
			}
		} 
		return iHeight;
	}
	
	function objectOver(x){ 
x.style.color="black"; 
} 

function objectOut(x)
{ 
	try
	{
		x.style.color="black"; 
	}
	catch(ex)
	{
		alert("Object Out " + ex.description);
	}
} 

function collapse(x)
{ 
	try
	{
		var sElementID;
		sElementID  = "text_"	+	x;
		//alert(sElementID);
		var oElement;
		oElement = document.getElementById(sElementID);
		
		
		//var oTemp=eval("document.all.text_"+x); 
		var oClick=eval("document.all.click_"+x); 
	    
	    //alert(oTemp.style);
	    
		if(oElement.style.display=="block")
		{ 
			oElement.style.display="none"; 
			oClick.innerHTML="+"; 
		} 
		else
		{ 
			oElement.style.display="block"; 
			oClick.innerHTML="-"; 
		} 
	}
	catch(ex)
	{
		alert(ex.description);
	}

} 


	//Changed by Arun on 12/10/2007 for changing the color after user has visited document BUGID #929 
	function ChangeColor(obj)
	{
		try
		{
			var index = parseInt(obj.getProperty("selection/index"));
			obj.getTemplate("row",index).refresh();
			obj.getTemplate("row",index).setStyle("background", "white"); // to change background color
			obj.getTemplate("row",index).setStyle("color", "red"); // to change font color
		}catch(ex)
		{
				// alert(ex.Description);
		}
	} 	
