	//var OriginalJobsList;	
function setSelected(GridName)
{
	var i;
	var idxl;
	for(i=0;i<document.Form1.Counter.value;i++)
	{
		idx = i + 2;
		if (document.Form1.Counter.value != 1 )
		{
			if (  document.Form1.item( GridName + ":_ctl" + idx + ":chkSelect").checked) 
			{	
				document.Form1.isSelected[i].value = 1;
			}	
			else
			{
				document.Form1.isSelected[i].value = 0;    
			}
		}	
		else
		{
			if (  document.Form1.item( GridName + ":_ctl" + idx + ":chkSelect").checked) 
			{	
				document.Form1.isSelected.value = 1;
			}	
			else
			{
				document.Form1.isSelected.value = 0;    
			}
		}	
	} 
	//alert()
}		


function ToggleDisplay(TableID, Caption)
{
	var oTable=document.getElementById('Table' + TableID);
	var oDisplayText = document.getElementById(TableID);
	if(oTable == null)
	{
		alert("ToggleDisplay failed. Can't locate element : " + TableID);
		return;
	}

	if(oTable.style.display == '')
	{
		if(oDisplayText != null)oDisplayText.innerText = Caption + '  ^^';
		oTable.style.display = 'none';
	}
	else
	{
		if(oDisplayText != null)oDisplayText.innerText = Caption + ' >>';
		oTable.style.display = '';
	}
}

		function move(fbox, tbox,mode) 
		{
			var arrFbox = new Array();
			var arrTbox = new Array();
			var arrLookup = new Array();
			var Operation = 1 ;
			var i;
				for (i = 0; i < tbox.options.length; i++) {
					arrLookup[tbox.options[i].text] = tbox.options[i].value;
					arrTbox[i] = tbox.options[i].text;
				}
				var fLength = 0;
				var tLength = arrTbox.length;
				for(i = 0; i < fbox.options.length; i++) {
					arrLookup[fbox.options[i].text] = fbox.options[i].value;
					if (fbox.options[i].selected && fbox.options[i].value != "") {
						arrTbox[tLength] = fbox.options[i].text;
						tLength++;
					}
					else {
						arrFbox[fLength] = fbox.options[i].text;
						fLength++;
					}
				}
				//arrFbox.sort();
				//arrTbox.sort();
				fbox.length = 0;
				tbox.length = 0;
				var c;
				var strTemp='';
				for(c = 0; c < arrFbox.length; c++) 
				{
					var no = new Option();
					no.value = arrLookup[arrFbox[c]];
					no.text = arrFbox[c];
					strTemp=strTemp + no.value+ '~'  				
					fbox[c] = no;
				}
				
				if(mode==1) 
				{
					document.Form1.hdnUnSelEntries.value =strTemp
				}
				else
				{
					document.Form1.hdnSelEntries.value =strTemp
				}
				
				strTemp='';
				for(c = 0; c < arrTbox.length; c++) 
				{
					var no = new Option();
					no.value = arrLookup[arrTbox[c]];
					no.text = arrTbox[c];
					strTemp=strTemp + no.value+ '~'  					
					tbox[c] = no;
				}
				
				if(mode==1) 
				{
					document.Form1.hdnSelEntries.value =strTemp
				} 
				else 
				{
					document.Form1.hdnUnSelEntries.value =strTemp
				}
					document.Form1.hdnOperation.value = Operation
				}	
	function move2(fbox, tbox,mode) 
		{
			var arrFbox = new Array();
			var arrTbox = new Array();
			var arrLookup = new Array();
			var Operation2 = 1 ;
			var i;
				for (i = 0; i < tbox.options.length; i++) {
					arrLookup[tbox.options[i].text] = tbox.options[i].value;
					arrTbox[i] = tbox.options[i].text;
				}
				var fLength = 0;
				var tLength = arrTbox.length;
				for(i = 0; i < fbox.options.length; i++) {
					arrLookup[fbox.options[i].text] = fbox.options[i].value;
					if (fbox.options[i].selected && fbox.options[i].value != "") {
						arrTbox[tLength] = fbox.options[i].text;
						tLength++;
					}
					else {
						arrFbox[fLength] = fbox.options[i].text;
						fLength++;
					}
				}
				//arrFbox.sort();
				//arrTbox.sort();
				fbox.length = 0;
				tbox.length = 0;
				var c;
				var strTemp='';
				for(c = 0; c < arrFbox.length; c++) 
				{
					var no = new Option();
					no.value = arrLookup[arrFbox[c]];
					no.text = arrFbox[c];
					strTemp=strTemp + no.value+ '~'  				
					fbox[c] = no;
				}
				
				if(mode==1) 
				{
					document.Form1.hdnUnSelEntries2.value =strTemp
				}
				else
				{
					document.Form1.hdnSelEntries2.value =strTemp
				}
				
				strTemp='';
				for(c = 0; c < arrTbox.length; c++) 
				{
					var no = new Option();
					no.value = arrLookup[arrTbox[c]];
					no.text = arrTbox[c];
					strTemp=strTemp + no.value+ '~'  					
					tbox[c] = no;
				}
				
				if(mode==1) 
				{
					document.Form1.hdnSelEntries2.value =strTemp
				} 
				else 
				{
					document.Form1.hdnUnSelEntries2.value =strTemp
				}
					document.Form1.hdnOperation2.value = Operation2
				}	
		
		



function onSelectDT(Txt)
{
	//alert('calling captureMousePosition')
	captureMousePosition(Txt)
	  
}

 // Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
/*if (document.layers) { // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
    document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
    document.onmousemove = captureMousePosition;
}*/
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(Txt) {
    if (document.layers) {
        // When the page scrolls in Netscape, the event's mouse position
        // reflects the absolute position on the screen. innerHight/Width
        // is the position from the top/left of the screen that the user is
        // looking at. pageX/YOffset is the amount that the user has 
        // scrolled into the page. So the values will be in relation to
        // each other as the total offsets into the page, no matter if
        // the user has scrolled or not.
        xMousePos = e.pageX;
        yMousePos = e.pageY;
        xMousePosMax = window.innerWidth+window.pageXOffset-15;
        yMousePosMax = window.innerHeight+window.pageYOffset+90;
    } else if (document.all) {
        // When the page scrolls in IE, the event's mouse position 
        // reflects the position from the top/left of the screen the 
        // user is looking at. scrollLeft/Top is the amount the user
        // has scrolled into the page. clientWidth/Height is the height/
        // width of the current page the user is looking at. So, to be
        // consistent with Netscape (above), add the scroll offsets to
        // both so we end up with an absolute value on the page, no 
        // matter if the user has scrolled or not.
        xMousePos = window.event.x+document.body.scrollLeft-15;
        yMousePos = window.event.y+document.body.scrollTop+90;
        xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
        yMousePosMax = document.body.clientHeight+document.body.scrollTop;
    } else if (document.getElementById) {
        // Netscape 6 behaves the same as Netscape 4 in this regard 
        xMousePos = e.pageX  ;
        yMousePos = e.pageY ;
        xMousePosMax = window.innerWidth+window.pageXOffset-15;
        yMousePosMax = window.innerHeight+window.pageYOffset+90;
    }
      //alert("xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax + '')
     var retval=""
      //retval = window.showModalDialog('Calendardialogbox.htm', window, "dialogWidth:197px;dialogHeight:238px;dialogLeft:" +  xMousePos + ";dialogTop:" + yMousePos + ";status:no;help:no;unadorned:no")
      retval = window.showModalDialog('Calendardialogbox.htm', window, "dialogWidth:210px;dialogHeight:258px;dialogLeft:" +  xMousePos + ";dialogTop:" + yMousePos + ";status:no;help:no;unadorned:no")
      if(retval !="" && retval !=null)
      {
	        document.getElementById(Txt).value=retval
      }
    //window.status = "xMousePos=" + xMousePos + ", yMousePos=" + yMousePos + ", xMousePosMax=" + xMousePosMax + ", yMousePosMax=" + yMousePosMax;
}


function WindowOpenBox(URL)
{
      //retval = window.showModalDialog(URL, window, "dialogWidth:834px;dialogHeight:600px;dialogLeft:200;dialogTop:100;status:no;help:no;unadorned:no")
      window.open(URL, 'window', 'left=10,top=10,width=800,height=600,toolbar=0,resizable=1,menubar=0,scrollbars=1')
}

function WindowDialogBox(URL)
{
	retval = window.showModalDialog(URL, window, "dialogWidth:680px;dialogHeight:480px;dialogLeft:130;dialogTop:150;status:no;help:no;unadorned:no")
}

function CCWindowDialogBox(URL)
{
	retval = window.showModalDialog(URL, window, "dialogWidth:520px;dialogHeight:440px;dialogLeft:130;dialogTop:150;status:no;help:no;unadorned:no")
}


function LoadSheetWindowDialogBox(URL)
{
	retval = window.showModalDialog(URL, window, "dialogWidth:640px;dialogHeight:600px;dialogLeft:130;dialogTop:150;status:no;help:no;unadorned:no")
}

function RPTWindowDialogBox(URL)
{
	retval = window.showModalDialog(URL, window, "dialogWidth:900px;dialogHeight:600px;dialogLeft:130;dialogTop:150;status:no;help:no;unadorned:no")
}

function BalanceDueCalc(mode,level)
{
	//alert(mode + '--' + level + '' );
	var QPrice;
	var Deposit;
	var Due;
	if (mode == 1)
	{
		//alert('Balnace not Locked');
		QPrice = document.Form1.QuoteValue.value;
		Deposit = document.Form1.DepositAmt.value;
		Due = RoundTo2dp(parseFloat(QPrice) + parseFloat(Deposit));
		//if (isNan(Due) == true)
		document.Form1.BalanceDue.value = Due;
	}	
	else
	{
		if (document.Form1.chkLock.checked == true)
		{
			//alert("Checked");
			QPrice = parseFloat(document.Form1.QuoteValue.value);
			Deposit = parseFloat(document.Form1.DepositAmt.value);
			Due = parseFloat(document.Form1.BalanceDue.value);
			//alert(level);
			if (level==1)
			{
				//alert(QPrice + '--' + Deposit + '' );
				if (QPrice > Due )
				{
					alert("Logistics can not be greater than Proce Quote.");
					QPrice = RoundTo2dp(parseFloat(Due) - parseFloat(Deposit));
					document.Form1.QuoteValue.value = QPrice;
				}
				else
				{
					Deposit = RoundTo2dp(parseFloat(Due) - parseFloat(QPrice));
					document.Form1.DepositAmt.value = Deposit;
				}	
			}
			else
			{	
				//alert(Deposit + '--' + Due + '' );
				if (Deposit > Due )
				{
					alert("Deposit can not be greater than Proce Quote.")
					Deposit = RoundTo2dp(parseFloat(Due) - parseFloat(QPrice));
					document.Form1.DepositAmt.value = Deposit;	
				}
				else
				{
					QPrice = RoundTo2dp(parseFloat(Due) - parseFloat(Deposit));
					document.Form1.QuoteValue.value = QPrice;
				}				
			}	
		}
		else
		{
			QPrice = document.Form1.QuoteValue.value;
			Deposit = document.Form1.DepositAmt.value;
			//alert('Not Checked : QPrice='  + QPrice  + 'Deposit=' + Deposit + ''  );
			Due = RoundTo2dp(parseFloat(QPrice) + parseFloat(Deposit));
			document.Form1.BalanceDue.value = Due;
		}
	}	
}

function RoundTo2dp(X) { return Math.round(X*100)/100 }
