	function GetBrowserFrame(strFrameName,strURL)
	{
		opener.top.frames[strFrameName].document.location.href=strURL;
	}
	function GetToFrame(strFrameName,strURL)
	{
		top.frames[strFrameName].document.location.href=strURL;
	}
	function GetToMainFrame(strURL)
	{
		top.frames['MainFrame'].document.location.href=strURL;
	}
	function GetToMainPage(strURL)
	{
		document.location.href=strURL;
	}
	function RedirectUrl(strURL)
	{
		document.location.href=strURL;
	}
	function GetToParentPage(strURL)
	{
		opener.document.location.href=strURL;
		Close();
	}
	function GetToParentWindow(strURL)
	{
		window.parent.location.href=strURL;
	}
	function Back()
	{
		window.history.back(-1);
	}
	function Print()
	{
		window.print();
	}
	function OpenWindow(myLink,windowName, intWidth, intHeight)
	{
		if(! window.focus)return;
		var myWin=window.open("",windowName,"width="+intWidth+",height="+intHeight+", status=1, resizable=yes, dependent=yes,scrollbars=yes");
		myWin.focus();
		myLink.target=windowName;
	}
	function OpenWindowNoStatus(myLink,windowName, intWidth, intHeight)
	{
		if(! window.focus)return;
		var myWin=window.open("",windowName,"width="+intWidth+",height="+intHeight+", status=0, resizable=0, dependent=0,scrollbars=0,left=" + (window.event.screenX - 16) + ",top=" + (window.event.screenY - 100));
		myWin.focus();
		myLink.target=windowName;
	}
	function OpenWindowUrl(inURL,windowName, intWidth, intHeight)
	{
		if(! window.focus)return;
		var myWin=window.open(inURL,windowName,"width="+intWidth+",height="+intHeight+", status=1, resizable=yes, dependent=yes,scrollbars=yes");
		myWin.focus();
	}
	function OpenWindowUrlNoStatus(inURL,windowName, intWidth, intHeight)
	{
		if(! window.focus)return;
		var myWin=window.open(inURL,windowName,"width="+intWidth+",height="+intHeight+", status=0, resizable=0, dependent=0,scrollbars=0");
		myWin.focus();
	}
	function OpenWindowUrlMenu(inURL,windowName, intWidth, intHeight)
	{
		if(! window.focus)return;
		var myWin=window.open(inURL,windowName,"width="+intWidth+",height="+intHeight+", status=1, resizable=yes, dependent=yes,scrollbars=yes,menubar=yes");
		myWin.focus();
	}
	function OpenWindowUrlFull(inURL,windowName, intWidth, intHeight)
	{
		if(! window.focus)return;
		var myWin=window.open(inURL,windowName,"width="+intWidth+",height="+intHeight+", status=1, resizable=yes, dependent=no,scrollbars=yes,menubar=yes,location=yes");
		myWin.focus();
	}
	/*
	function OpenWindowImage(vLink, vHeight, vWidth)
	{
		var sLink = (typeof(vLink.href) == 'undefined') ? vLink : vLink.href;

		if (sLink == '')
		{
			return false;
		}

		winDef = 'status=no,resizable=no,scrollbars=no,toolbar=no,location=no,fullscreen=no,titlebar=yes,height='.concat(vHeight).concat(',').concat('width=').concat(vWidth).concat(',');
		winDef = winDef.concat('top=').concat((screen.height - vHeight)/2).concat(',');
		winDef = winDef.concat('left=').concat((screen.width - vWidth)/2);
		newwin = open('', '_blank', winDef);

		newwin.document.writeln('<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">');
		newwin.document.writeln('<a href="" onClick="window.close(); return false;"><img src="', sLink, '" alt="', (fBrw) ? '&#272;&#243;ng l&#7841;i' : 'Dong lai', '" border=0></a>');
		newwin.document.writeln('</body>');

		if (typeof(vLink.href) != 'undefined')
		{
			return false;
		}
	}
	*/
	function OpenWindowImage(strImagUrl,intImageWidth,intImageHeight) {
		var strTitle = "View Image - Click on image to close screen";
		var strBgColor="#FFFFFF";
		var adj=10
		var w = screen.width;
		var h = screen.height;
		var byFactor=1;

		if(w<740){
			var lift=0.90;
		}
		if(w>=740 & w<835){
			var lift=0.91;
		}
		if(w>=835){
			var lift=0.93;
		}
		if (intImageWidth>w){	
			byFactor = w / intImageWidth;			
			intImageWidth = w;
			intImageHeight = intImageHeight * byFactor;
		}
		if (intImageHeight>h-adj){
			byFactor = h / intImageHeight;
			intImageWidth = (intImageWidth * byFactor);
			intImageHeight = h; 
		}
			
		var scrWidth = w-adj;
		var scrHeight = (h*lift)-adj;

		if (intImageHeight>scrHeight){
		  	intImageHeight=intImageHeight*lift;
			intImageWidth=intImageWidth*lift;
		}

		var posLeft=0;
		var posTop=0;
		
		if (true){
			hugMargin = 0;
		
			var scrHeightTemp = intImageHeight - 0 + 2*hugMargin;
			if (scrHeightTemp < scrHeight) {
			scrHeight = scrHeightTemp;
			} 
			var scrWidthTemp = intImageWidth - 0 + 2*hugMargin;
			if (scrWidthTemp < scrWidth) {
			scrWidth = scrWidthTemp;
			}
			
			if (scrHeight<100){scrHeight=100;}
			if (scrWidth<100){scrWidth=100;}

			posTop =  ((h-(scrHeight/lift)-adj)/2);
			posLeft = ((w-(scrWidth)-adj)/2);
		}

		if (intImageHeight > (h*lift)-adj || intImageWidth > w-adj){
			intImageHeight=intImageHeight-adj;
			intImageWidth=intImageWidth-adj;
		}
		posTop = parseInt(posTop);
		posLeft = parseInt(posLeft);		
		scrWidth = parseInt(scrWidth); 
		scrHeight = parseInt(scrHeight);
		
		var agt=navigator.userAgent.toLowerCase();
		if (agt.indexOf("opera") != -1){
			var args= new Array();
			args[0]='parent';
			args[1]=strImagUrl;
			for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
		} else {
		newWindow = window.open("vwd_justso.htm","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
		newWindow.document.open();
		newWindow.document.write('<html><title>'+strTitle+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" strBgColor='+strBgColor+' onBlur="self.close()" onClick="self.close()">');  
		newWindow.document.write('<table width='+intImageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+' ><tr><td>');
		//newWindow.document.write('<img src="'+strImagUrl+'" width='+intImageWidth+' height='+intImageHeight+' alt="Click screen to close" title="Click screen to close">'); 
		newWindow.document.write('<img src="'+strImagUrl+'" alt="Click to close" title="Click to close">'); 
		newWindow.document.write('</td></tr></table></body></html>');
		newWindow.document.close();
		newWindow.focus();
		}
		return false;
	}
	function Close(pRefresh)
	{
		if (pRefresh)
		{
			opener.location.reload();
		}
		window.close();
	}
	function displayInlineError(sField, sErrMsg)
	{
		var itop, ileft, size, sName, oItem;
					
		oItem = sField;
		if(typeof(oItem)!="object")
			return;
					
		itop = 0;
		ileft = 0;
					
		itop = oItem.offsetHeight;
		while (oItem.tagName != "MADY" ){
				itop  += oItem.offsetTop;
				ileft += oItem.offsetLeft;
			oItem = oItem.offsetParent;
		}
					
		divError.style.left = ileft +"px";
		divError.style.top  = itop +"px"; 
		divError.innerText = sErrMsg;
				
		divError.style.display = "inline";
	}
	function ClearError()
	{
		divError.style.display = 'none';
		//if (event.keyCode == 13)
			//goNextPage();
	}	
	function SetBGColor_Yes(objPass)
	{
		objPass.style.backgroundColor="yellow";
	}
	function SetBGColor_No(objPass)
	{
		objPass.style.backgroundColor="";
	}
	function SetBGColor_Error(objPass)
	{
		objPass.style.backgroundColor="#FFCC66";
	}
	function NumericOnly(inObjectField)
	{
		var bOK = true;
		if(String(inObjectField.value).length != 0)
		{
			var NumericType = /^[0-9]+$/;
			if (!(NumericType.test(inObjectField.value)))
			{
				SetBGColor_Yes(inObjectField);
				alert('ERROR: \n\nPlease Input Numeric Only!');
				inObjectField.select();
				inObjectField.focus();
				bOK = false;
			}
		}
		else
		{
			bOK = false;
		}
		return bOK;
	}
	function ToInteger(inObjectField)
	{
		var strValue = inObjectField.value;
		var intValue = 0;
		if(strValue==null) {intValue=0;}
		else if(String(strValue).length == 0) {intValue=0;}
		else if(String(strValue).length != 0) {intValue = parseInt(strValue);}
		return intValue;
	}
	function HaveValue(inObjectField, inFieldName, bSetFocus)
	{
		if (String(inObjectField.value).length == 0)
		{
			alert("ERROR: \n\nPlease Provide Your "+inFieldName+"!");
			if (bSetFocus==false)
				return false;
			else
			{
				inObjectField.focus();
				return false;
			}
		}
		else
			return true;
	}
	function IsEmail(inObjectField)
	{
	    var reEmail = /^.+@.+\..+$/;
		if (!(reEmail.test(inObjectField.value)))
		{
			alert("Email address should be in the format xxx@yyy.zzz");
			inObjectField.focus()
			return false;
		}
		else
		{
			return true;
		}
	}
	function ConfirmVoid()
	{
		if (confirm('Are you sure you want to void the items?'))
			return true;
		else
			return false;
	}
	function ConfirmDelete()
	{
		if (confirm('Are you sure you want to delete?'))
			return true;
		else
			return false;
	}
	function ConfirmMessage(strMessage)
	{
		if (confirm(strMessage))
			return true;
		else
			return false;
	}
	function DisplayMessage(strMessage)
	{
		alert(strMessage);
	}
	function formatCurrency(num,bComma)
	{
		num = num.toString().replace(/\$|\,/g,'');
		if(isNaN(num))
		num = "0";
		sign = (num == (num = Math.abs(num)));
		num = Math.floor(num*100+0.50000000001);
		cents = num%100;
		num = Math.floor(num/100).toString();
		if(cents<10)
		cents = "0" + cents;
		if (bComma==false)
		{
			for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+num.substring(num.length-(4*i+3));
		}
		else
		{
			for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
			num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
		}
		return (((sign)?'':'-') + num + '.' + cents);
	}

	//BEGIN -- use to text append
	function pasteIcon(pObject, strValue)
	{
		pObject.focus();
		if (pObject.createTextRange && pObject.selected && pObject.selected.text.length == 0)
		{
			var selected = pObject.selected;
			selected.text = strValue;
		}
		else if ((strValue != null) && (strValue != ""))
		{
			pObject.value += strValue;
		}
		GetTextPosition(pObject);
	}
			
	function GetTextPosition(pObject)
	{
		if (pObject.createTextRange) 
		{
			pObject.selected = document.selection.createRange().duplicate();
		}
	}
	//END -- use to text append

	//BEGIN -- Use for check box highligh
	var objIE = document.all;

	function CheckOne(inMainForm, inObj)
	{
		if (inObj.checked)
		ChangeBGColor(inObj);
		else
		ResetBGColor(inObj);
		var intTotalCheckBox=intTotalUsedCheck=0;
		for (var i=0;i<inMainForm.elements.length;i++)
		{
			var objElement= inMainForm.elements[i];
			if ((objElement.name != 'ckhCheckAll') && (objElement.type=='checkbox'))
			{
				intTotalCheckBox++;
				if (objElement.checked)
					intTotalUsedCheck++;
			}
		}
		if (intTotalUsedCheck==intTotalCheckBox)
			inMainForm.ckhCheckAll.checked=true;
		else
			inMainForm.ckhCheckAll.checked=false;
	}

	function ChangeBGColor(inObj)
	{
		if (objIE)
		{
			while (inObj.tagName!="TR")
			{inObj=inObj.parentElement;}
		}
		else
		{
			while (inObj.tagName!="TR")
			{inObj=inObj.parentNode;}
		}
		if (inObj.className=="TDBG1" || inObj.className=="HIGHLIGHTROW1")
			inObj.className = "HIGHLIGHTROW1";
		else
			inObj.className = "HIGHLIGHTROW2";
	}

	function HighlighBGColor(inObj,inIsOn)
	{
		if (objIE)
		{
			while (inObj.tagName!="TR")
			{inObj=inObj.parentElement;}
		}
		else
		{
			while (inObj.tagName!="TR")
			{inObj=inObj.parentNode;}
		}
		//if (inObj.className=="TDBG1" || inObj.className=="HIGHLIGHTROW1")
		if(inIsOn)
			inObj.className = "HIGHLIGHTROW";
		else
			inObj.className = "";
	}

	function ResetBGColor(inObj)
	{
		if (objIE)
		{
			while (inObj.tagName!="TR")
			{inObj=inObj.parentElement;}
		}
		else
		{
			while (inObj.tagName!="TR")
			{inObj=inObj.parentNode;}
		}
		if (inObj.className=="TDBG1" || inObj.className=="HIGHLIGHTROW1")
			inObj.className = "TDBG1";
		else
			inObj.className = "TDBG2";
	}


	function CheckAll(inMainForm)
	{
		for (var i=0;i<inMainForm.elements.length;i++)
		{
			var objElement = inMainForm.elements[i];
			if ((objElement.name != 'ckhCheckAll') && (objElement.type=='checkbox'))
			{
				objElement.checked = inMainForm.ckhCheckAll.checked;
				//alert(substring(objElement.name,1,1));
				if (inMainForm.ckhCheckAll.checked && objElement.disabled==false)
				{
					ChangeBGColor(objElement);
				}
				else
				{
					objElement.checked=false;
					ResetBGColor(objElement);
				}
			}
		}
	}
	//END -- Use for check box highligh

