﻿// JScript File
//
var gv_newInvAC=new Array();
var gv_newInvName=new Array();
var gv_newInvIndex=0; // 0-based currently selected customer index.
var gv_newInvFocusIndex=0; //Currently focused customer
var gv_newInvNumPerPage=0;
var gv_newInvCurPage=0; //0-base current page number
var gv_newInvTotPage=0;
var gv_newInvEditingData=0;
var gv_newInvDataCategory=null;
var gv_newInvEditedName=null;  // Stores edited customer item name(name=cat_name, eg. 1_AC Ref
var gv_newInvEditedValue=null; // Edited values
var gv_tempTable;
var gv_newInvRowH=20;
var gv_scrollCurPage=0;
var gv_scrollTotPage=0;
var addNewInvDropDownValue = "";
var NewInvPartCode = "";
var NewInviPage = 1;
var NewInvTotalPage = 1;
var NewInvListPD = 0;//pan duan showNewInvList(1);
function doNewInvList()
{
    if(document.getElementById('NewInvCustomer_ACRef')){ NewInvPartCode = document.getElementById('NewInvCustomer_ACRef').value;}
	var url = gv_rooturl+"?cmd=NewInvList"+"&NewInvPartCode="+NewInvPartCode+"&NewInviPage="+NewInviPage;
	var xmlhttp = newHttpRequest(url,true);
	if( xmlhttp==null ) return;
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 ) {
			if( xmlhttp.status!=200 ) alert("Connection error");
			else
			{
			    var newinvtotalpages=xmlhttp.responseXML.getElementsByTagName("NewInvTotalPage");
                NewInvTotalPage = parseInt(newinvtotalpages[0].firstChild.nodeValue);
			    renewNewInvList(xmlhttp.responseXML);
			}
			document.getElementById('idloading').style.visibility='hidden';
			
		}
	}
	xmlhttp.send(null);
	document.getElementById('idloading').style.visibility='visible';
}


function renewNewInvList(xmldoc)
{
	var newinvs=xmldoc.getElementsByTagName("NewInv");
	gv_newInvAC.length=gv_newInvName.length=0;
	gv_newInvIndex=0;
	
    for(var i=0; i<newinvs.length; i++) {
		var curNode=newinvs[i].firstChild;
		gv_newInvAC[i]=gv_newInvName[i]="";
		while( curNode ) 
		{
			switch(curNode.nodeName){
			   	case "AC" :  gv_newInvAC[i]=curNode.firstChild.nodeValue; break;
				case "Name" : gv_newInvName[i]=curNode.firstChild.nodeValue;  break;
			}
			curNode=curNode.nextSibling;
		}
    }
    if(newinvs.length==0) alert("No newinvs found!");
    else {
		gv_newInvTotPage=0;
		showNewInvList(0);
	}
}



function showNewInvList(NewInvStatus)
{
    if(NewInvStatus == 0)
    {
       gv_newInvTotPage=0;
       gv_newInvCurPage=0;
    }
    else if(NewInvStatus == 1)
    {}
    if(NewInvListPD == 1)
    {
        gv_newInvCurPage = NewInvListCurPage;
        gv_newInvTotPage = NewInvListTotPage;
    }
    NewInvListPD = 0;
	if(gv_newInvAC.length==0) return;
    gv_tempTable = document.getElementById('tempTable');
	var ycur=gv_tempTable.style.pixelTop=gv_device==Nokia ? 28:26;
	var tdstr="<td height='"+gv_newInvRowH+"px'>";
	var tabstr="<table border='1' cellpadding='1' cellspacing='0' style='position:absolute;width:"+(gv_winw-4)+"px;left:2px;'>"; 
	//var ixs=gv_newInvCurPage*gv_newInvNumPerPage;
	var idx=0;
    for(var i=0; i<gv_newInvAC.length; i++) {
		var imgName=idx==gv_newInvIndex ? 'radon.png':'radoff.png';
		var trColor=idx==gv_newInvIndex ? '#ffcc00':'#add8e6';
		var radstr="<td width='22px' height='"+gv_newInvRowH+"px'><input type='image' src='img/"+imgName+
			"' id='cus_img"+idx+"' onclick='newInvoiceRowClicked(event);'";
		if(gv_device==Nokia) radstr+="onfocus='overNewInvItem(event);' onblur='leavNewInvItem(event);'></td>";
		else radstr+="onmouseover='overNewInvItem(event);' onmouseleave='leavNewInvItem(event);'></td>";
		tabstr+="<tr id='cus_row"+idx+"' onclick='newInvoiceRowClicked(event);' style='background-color:"+
			trColor+";'>"+radstr + tdstr+gv_newInvAC[i]+"</td>"+tdstr+gv_newInvName[i]+"</td></tr>";
		//ycur+=gv_newInvRowH;
		//if(ycur+45>gv_winh) break; else 
		idx++;
    }
//    if(gv_newInvTotPage==0) {
//		gv_scrollCurPage=gv_newInvCurPage=0;
//		gv_newInvNumPerPage=i;
//		var ntt=gv_newInvAC.length;
//		gv_newInvTotPage=0;
//		while(ntt>0) {gv_newInvTotPage++; ntt-=gv_newInvNumPerPage; }
		gv_scrollTotPage=NewInvTotalPage;
		if(gv_device!=Nokia) {
			var mleft=document.getElementById('img_mleft3');
			mleft.onclick=newInvPageLeft;
			mleft.style.cursor='hand';
			var mright=document.getElementById('img_mright3');
			mright.onclick=newInvPageRight;
			mright.style.cursor='hand';
		}
   // }
    gv_tempTable.innerHTML=tabstr+"</table>";
    gv_tempTable.style.left='0px';
    gv_tempTable.style.visibility='visible';
    if(gv_device!=Nokia) {
		var btnBack=document.getElementById("back2submenu");
		btnBack.style.pixelTop=gv_winh-28;
		btnBack.style.visibility = "hidden";
	}
	gv_newInvFocusIndex=gv_newInvIndex;
	
    var newinvcmd = document.getElementById('sopCmds');
	newinvcmd.style.pixelLeft=gv_winw-newinvcmd.style.pixelWidth-1;
	newinvcmd.style.pixelTop = gv_winh-29;
    newinvcmd.style.visibility='visible';
    if(gv_device!=Nokia) {
		var btn1=document.getElementById('btnNewInvDetail');
		if(btn1==null) setNewInvPageScrollCommands(
			"<input type='button' id='btnNewInvDetail' value='OK' onclick='editNewInvDetail();' />",
			"<input type='button' id='btnNewSopOK' value='OK' onclick='editNewInvDetail();' />");
			document.getElementById('btnNewSopOK').style.visibility="hidden";
			//document.getElementById('btnCusDetail').style.visibility="visible";
	     }
	setNewInvPageScroll();
	doNokiaMenuNewInvList();    
}

//function newPopRowClicked(ee)
//{
//	var srcele=getEventObject(ee);
//	if(srcele.id.length<8) return;
//	var newIndex=parseInt(srcele.id.substring(7));
//	if(gv_newPopIndex==newIndex) return;
//	document.getElementById('sup_row'+gv_newPopIndex).style.backgroundColor='#add8e6';
//	document.getElementById('sup_img'+gv_newPopIndex).src='img/radoff.png';
//	document.getElementById('sup_row'+newIndex).style.backgroundColor='#ffcc00';
//	document.getElementById('sup_img'+newIndex).src='img/radon.png';
//	gv_newPopIndex=newIndex;
//}
//function overNewPopItem(e_event)
//{
//	var srcobj=getEventObject(e_event);
//	if(srcobj.id=='sup_img'+gv_newPopIndex) return; // Entering the current selection
//	srcobj.src="img/radover.png";
//}
//function leavNewPopItem(e_event)
//{
//	var srcobj=getEventObject(e_event);
//	if(srcobj.id=='sup_img'+gv_newPopIndex) return; // Leaving the current selection
//	srcobj.src="img/radoff.png";
//}
function newInvoiceRowClicked(ee)
{
	var srcele=getEventObject(ee);
	if(srcele.id.length<8) return;
	var newIndex=parseInt(srcele.id.substring(7));
	if(gv_newInvIndex==newIndex) return;
	document.getElementById('cus_row'+gv_newInvIndex).style.backgroundColor='#add8e6';
	document.getElementById('cus_img'+gv_newInvIndex).src='img/radoff.png';
	document.getElementById('cus_row'+newIndex).style.backgroundColor='#ffcc00';
	document.getElementById('cus_img'+newIndex).src='img/radon.png';
	gv_newInvIndex=newIndex;
}
function overNewInvItem(e_event)
{
	var srcobj=getEventObject(e_event);
	if(srcobj.id=='cus_img'+gv_newInvIndex) return; // Entering the current selection
	srcobj.src="img/radover.png";
}
function leavNewInvItem(e_event)
{
	var srcobj=getEventObject(e_event);
	if(srcobj.id=='cus_img'+gv_newInvIndex) return; // Leaving the current selection
	srcobj.src="img/radoff.png";
}

function doNokiaMenuNewInvList()
{
	if(window.widget) {
		window.menu.clear();
		var mEdit = new MenuItem('OK',2102);
		mEdit.onSelect=editNewInvDetail;
		window.menu.append(mEdit);
//		var mBack = new MenuItem('Back',2103);
//		mBack.onSelect=backSops;
//		window.menu.append(mBack);
	}
}


function getNewInvDetail()
{
	var ACIndex=gv_newInvCurPage*gv_newInvNumPerPage+gv_newInvIndex;
	
	var url = gv_rooturl+"?cmd=NewInvDetail&AC="+gv_newInvAC[ACIndex]+"&index="+ACIndex;
		var xmlhttp = newHttpRequest(url,true);
	if( xmlhttp==null ) return;
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 ) {
			if( xmlhttp.status!=200 ) alert("Connection error");
			else {
				gv_newInvDataCategory=xmlhttp.responseXML.getElementsByTagName("DataCategory");
				if(gv_newInvDataCategory.length==0) alert("Cannot load details!");
				else {
					gv_scrollCurPage=0;
					gv_scrollTotPage=gv_newInvDataCategory.length;
					//document.getElementById('cusCmds').style.visibility='hidden';
					setNewInvPageScrollCommands("<input type='button' id='savenewinvdata' value='Save' onclick='saveNewInvData();' />","");
					showNewInvDataPage("Load");
				}
			}
			document.getElementById('idloading').style.visibility='hidden';
		}
	}
	xmlhttp.send(null);
	document.getElementById('idloading').style.visibility='visible';
	gv_newInvEditedName=null;
	gv_newInvEditedValue=null;
}
function showNewInvDetail(cmdid)
{
	gv_newInvEditingData=0;
	getNewInvDetail();

}
function editNewInvDetail(cmdid)
{
	gv_newInvEditingData=1;
	getNewInvDetail();
}




function  doNewInvoice()
{
    var url = gv_rooturl+"?cmd=NewInvDetail";
    var xmlhttp = newHttpRequest(url,true);
	if( xmlhttp==null ) return;
	xmlhttp.onreadystatechange=function() { 
		if (xmlhttp.readyState==4 ) {
			if( xmlhttp.status!=200 ) alert("Connection error");
			else 
			{
			gv_newInvDataCategory=xmlhttp.responseXML.getElementsByTagName("DataCategory"); 
				if(gv_newInvDataCategory.length==0) alert("Cannot load details!");
				else {
				    
					gv_scrollCurPage=0;
					gv_scrollTotPage=gv_newInvDataCategory.length;
					gv_newInvEditingData=1;
					setNewInvPageScrollCommands("<input type='button' id='savenewinvdata' value='Save' onclick='saveNewInvData();' />","");
					showNewInvDataPage("FirstLoad"); 
				}
			}
			document.getElementById('idloading').style.visibility='hidden';		
		}
			    
	}
	  
	xmlhttp.send(null);
	document.getElementById('idloading').style.visibility='visible';
	
}


function getNewInvSysTime()
{
  var myDate,s = "";
  myDate = new Date();
  var Day = (myDate.getDate() > 9) ? myDate.getDate() : "0" + myDate.getDate();
  var Month = (myDate.getMonth() + 1) > 9 ? (myDate.getMonth() + 1) : "0" + (myDate.getMonth() + 1);
  s += Day + "/" + Month + "/" + myDate.getFullYear();
  return s;
}


var NewInvOrder_Date = getNewInvSysTime();
var NewInvCustomer_ACRef="",NewInvDelivery="", NewInvOrder_Type='',NewInvFormat='',NewInvCustomer_Order_Number='',NewInvOrder_Number='<AutoNumber>',NewInvTotal_GBP='',NewInvTotal_VAT='',NewInvCarriage_GBP='',NewInvCarriage_VAT='',NewInvGross_GBP='',NewInvCustomer_Tel_No='',NewInvCustomer_Contact='',NewInvNet_GBP='',NewInvTax_Code='',NewInvVAT_GBP='',NewInvNC='',NewInvDepartment='',NewInvConsign_Number='',NewInvCourier='',NewInvDays='',NewInvDiscount='',NewInvAmount_GBP='',NewInvTotal_GBP='',NewInvDetails='',NewInvPayment_Ref='',NewInvBank_Account='';
var NewInvPayment_Amount_GBP='',NewInvAddress1="",NewInvAddress2="",NewInvAddress3="",NewInvAddress4="",NewInvAddress5="",NewInvName="",NewInvDelivery_Street1='',NewInvDelivery_Street2='',NewInvDelivery_Town='',NewInvDelivery_County='',NewInvDelivery_Post_Code="",NewInvSet_Gross_GBP = '',NewInvSet_Total_GBP='';
var NewInvGlobal_Tax_Code = "";NewInvGlobal_Department = "";NewInvGlobal_NC = "";


function showNewInvDataPage(HasNewInvStatus)
{	  
     
 //if(gv_newsopAC.length==0) return;
    gv_tempTable = document.getElementById('tempTable');
	var ycur=gv_tempTable.style.pixelTop=gv_device==Nokia ? 28:26;	
	var tdh="height='"+gv_newInvRowH+"px'";  //height='24px'
   	if(gv_device!=Nokia) {
			var mleft=document.getElementById('img_mleft3');
			mleft.onclick=newInvPageLeft;
			mleft.style.cursor='hand';
			var mright=document.getElementById('img_mright3');
			mright.onclick=newInvPageRight;
			mright.style.cursor='hand';
		}
    gv_tempTable.style.left='0px';
    gv_tempTable.style.visibility='visible';
    if(gv_device!=Nokia) {
		var btnBack=document.getElementById("back2submenu");
		btnBack.style.pixelTop=gv_winh-28;
		btnBack.style.visibility = "visible";
	}
	gv_newInvFocusIndex=gv_newInvIndex;
    var newinvcmd = document.getElementById('sopCmds');
	newinvcmd.style.pixelLeft=gv_winw-newinvcmd.style.pixelWidth-1;
	newinvcmd.style.pixelTop = gv_winh-29;
    newinvcmd.style.visibility='visible';

 // gv_tempTable = document.getElementById('tempTable');
 	var widstyle="style='width:"+Math.round(gv_winw/2).toString()+"px' ";
	var tabstr="<table cellpadding='1' cellspacing='0' style='position:absolute;background-color:#98F898;width:"+(gv_winw-4)+"px;left:2px;'>"; 
	var rowJump="<tr><td align=right "+tdh+">Jump to Page</td><td><select class='edtxt' "+widstyle+" id='selnewinvcat' onchange='jumpToNewInvCat();'>";
    for(var ic=0; ic<gv_newInvDataCategory.length; ic++) {
		var attName0=gv_newInvDataCategory[ic].attributes.getNamedItem("title");
		if(attName0) {
			var tname=attName0.value.replace('_',' ');
			rowJump+="<option label='"+tname+"'";
			if(ic==gv_scrollCurPage) rowJump+=" selected=true";
			rowJump+=">"+tname+"</option>";
		}
	}	
	rowJump+="</select></td></tr>";	       
 for(var ic=gv_scrollCurPage; ic<gv_newInvDataCategory.length; ic++) {
		var attName=gv_newInvDataCategory[ic].attributes.getNamedItem("title");	
		if(attName==null) continue;
		var rowtxt=ic==gv_scrollCurPage ? rowJump:'';
		rowtxt += "<tr><td colspan=2 align=center "+tdh+" style='color:blue;font-weight:bold;text-decoration:underline;'>"
			+attName.value+"</td></tr>";	                   
			ycur+=gv_newInvRowH;
	var curNode=gv_newInvDataCategory[ic].firstChild;
		var end_tdr = gv_newInvEditingData==1 ? "></td></tr>":" ReadOnly></td></tr>";	
    while( curNode ) 
		{
			var itemName=curNode.nodeName;
			var itemId=ic.toString()+"_"+itemName;	
			var ndv=curNode.firstChild;
	        var itemVal=getEditedNewInvData(itemId);
		   	if(itemVal==null) itemVal=ndv?ndv.nodeValue:'';
		   if(HasNewInvStatus == "FirstLoad")
		   {
			if(curNode.nodeName=='Customer_ACRef')	
  			 {
  		     NewInvCustomer_ACRef="";         
	        rowtxt+="<tr><td align=right "+tdh+">Customer A/C &nbsp<br>Ref <span style='color:red'>*</span></td>";
			rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:125px;height:20px;'value='"+NewInvCustomer_ACRef+"' id='NewInvCustomer_ACRef'><input type='Button'  Value='Get' id='newInvGetCustomer_ACRef' onclick='newInvGetCustomer_ACRef()'    Runat='server' style='color:blue;font-weight:bold;width:35px;height:20px;text-decoration:underline;'/></td></tr>";//<input type='Button' value='Get' onclick='getSupplierACRef();' runat='server' style='color: blue; width: 35px;height: 20px; font-weight: bold; text-decoration: underline;' /></td>";
			//NewInvCustomer_ACRef=itemVal;
	                   
	               
  		 }
      
	
			 else if(itemName=="Order_Type")
             {
                 var rowJumpOrder_Type="<tr><td align='right'"+tdh+">Order Type &nbsp</td><td><select class='edtxt'  id='NewInvOrder_Type' "+widstyle+"  onchange='NewInvTaxCode();'>"
                 rowJumpOrder_Type+="<option value='Invoice'"
                 if(NewInvOrder_Type == '') {rowJumpOrder_Type += "selected = 'true'";}
                 rowJumpOrder_Type +=">Invoice</option><option value='Pro-forma'";
                 if(NewInvOrder_Type =='Pro-forma') {rowJumpOrder_Type += "selected = 'true'";}
                 rowJumpOrder_Type +=">Pro-forma</option><option value='Credit'";
                 if(NewInvOrder_Type =='Credit') {rowJumpOrder_Type += "selected = 'true'";}
                  rowJumpOrder_Type +=">Credit</option>";
                 rowtxt+=rowJumpOrder_Type+"</select></td></tr>";
	          }
	          
			 else if(itemName=="Format")
             {
                 var rowJumpFormat="<tr><td align='right'"+tdh+">Format &nbsp</td><td><select class='edtxt'  id='NewInvFormat' "+widstyle+"  onchange='NewInvTaxCode();'>"
                 rowJumpFormat+="<option value='Product'>Product</option><option value='Service'"
                 if(NewInvFormat == 'Service'){ rowJumpFormat+="selected = 'true'";}
                rowJumpFormat+=">Service</option>";
                 rowtxt+=rowJumpFormat+"</select></td></tr>";
	          }
			else if(itemName=="Order_Date")
			{
			   
               rowtxt+="<tr><td align=right "+tdh+">Order Date &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvOrder_Date+"' id='NewInvOrder_Date'>";	  

			}
//			else if(itemName=="Order_Number")
//			{
//               rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"</td>";
//               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;'value='"+gv_supName[gv_supIndex]+"' id='"+itemId+"'>";	  

//			}
			
			
			else if(itemName=="Customer_Order_Number")
			{
			   NewInvCustomer_Order_Number = "";
               rowtxt+="<tr><td align=right "+tdh+">Customer Order &nbsp<br>Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Order_Number+"' id='NewInvCustomer_Order_Number'>";	  

			}
			else if(itemName=="Order_Number")
			{
			   Order_Number = "<AutoNumber>";
               rowtxt+="<tr><td align=right "+tdh+">Order Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvOrder_Number+"' id='NewInvOrder_Number' ReadOnly>";	  
			}
			
            else if(itemName=="Total_GBP")
			{
			   NewInvTotal_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Total GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvTotal_GBP+"' id='NewInvTotal_GBP' ReadOnly>";	  
			}
			else if(itemName=="Total_VAT")
			{
			   NewInvTotal_VAT = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Total VAT &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvTotal_VAT+"' id='NewInvTotal_VAT' ReadOnly>";	  

			}
			else if(itemName=="Carriage_GBP")
			{
			   NewInvCarriage_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Carriage GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCarriage_GBP+"' id='NewInvCarriage_GBP' ReadOnly>";	  
			}
			else if(itemName=="Carriage_VAT")
			{
			   NewInvCarriage_VAT = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Carriage VAT &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCarriage_VAT+"' id='NewInvCarriage_VAT' ReadOnly>";	  
			}
			else if(itemName=="Gross_GBP")
			{
			   NewInvGross_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Gross GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvGross_GBP+"' id='NewInvGross_GBP' ReadOnly>";	  
			}
			else if(itemName=="Delivery")
			{
			   NewInvDelivery="";
               rowtxt+="<tr><td align=right "+tdh+">Delivery &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery+"' id='NewInvDelivery'>";	  
			}
			else if(itemName=="Address1")
			{
			   NewInvAddress1="";
               rowtxt+="<tr><td align=right "+tdh+">Address1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress1+"' id='NewInvAddress1'>";	  
			}
			else if(itemName=="Address2")
			{
			   NewInvAddress2="";
               rowtxt+="<tr><td align=right "+tdh+">Address2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress2+"' id='NewInvAddress2'>";	  
			}
			else if(itemName=="Address3")
			{
			   NewInvAddress3="";
               rowtxt+="<tr><td align=right "+tdh+">Address3 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress3+"' id='NewInvAddress3'>";	  
			}
			else if(itemName=="Address4")
			{
			   NewInvAddress4="";
               rowtxt+="<tr><td align=right "+tdh+">Address4 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress4+"' id='NewInvAddress4'>";	  
			}
			else if(itemName=="Address5")
			{
			   NewInvAddress5="";
               rowtxt+="<tr><td align=right "+tdh+">Address5 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress5+"' id='NewInvAddress5'>";	  
			}
			else if(itemName=="Name")
			{
			   NewInvName="";
               rowtxt+="<tr><td align=right "+tdh+">Name <span style='color:red'>*</span></td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvName+"' id='NewInvName'>";	  
			}
	       else if(itemName=="Delivery_Street1")
			{
               NewInvDelivery_Street1="";
               rowtxt+="<tr><td align=right "+tdh+">Delivery Street1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Street1+"' id='NewInvDelivery_Street1'>";	  
			}
			else if(itemName=="Delivery_Street2")
			{
               NewInvDelivery_Street2="";
               rowtxt+="<tr><td align=right "+tdh+">Delivery Street2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Street2+"' id='NewInvDelivery_Street2'>";	  
			}
			else if(itemName=="Delivery_Town")
			{
               NewInvDelivery_Town="";
               rowtxt+="<tr><td align=right "+tdh+">Delivery Town &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Town+"' id='NewInvDelivery_Town'>";	  
			}
			else if(itemName=="Delivery_County")
			{
               NewInvDelivery_County="";
               rowtxt+="<tr><td align=right "+tdh+">Delivery County &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_County+"' id='NewInvDelivery_County'>";	  
			}
			else if(itemName=="Delivery_Post_Code")
			{
			   NewInvDelivery_Post_Code="";
               rowtxt+="<tr><td align=right "+tdh+">Delivery Post Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Post_Code+"' id='NewInvDelivery_Post_Code'>";	  
			}
			
			else if(itemName=="Customer_Tel_No")
			{
               NewInvCustomer_Tel_No="";
               rowtxt+="<tr><td align=right "+tdh+">Customer Tel No &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Tel_No+"' id='NewInvCustomer_Tel_No'>";	  
			}
			else if(itemName=="Customer_Contact")
			{
               NewInvCustomer_Contact="";
               rowtxt+="<tr><td align=right "+tdh+">Customer Contact &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Contact+"' id='NewInvCustomer_Contact'>";	  
			}
			else if(itemName=="Net_GBP")
			{
			   NewInvNet_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Net GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvNet_GBP+"' id='NewInvNet_GBP'>";	  

			}
//			else if(itemName=="Tax_Code")
//			{
//               rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"</td>";
//               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewSopDataButton();' value='"+NewSopTax_Code+"' id='Tax_Code'>";	  

//			}
              else if(itemName=="Tax_Code")
             {
                 var rowJumpTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select class='edtxt'  id='NewInvTax_Code'  "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attTaxCodeName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attTaxCodeName) 
                   {
                    rowJumpTaxCode+="<option value='"+attTaxCodeName+"'";
                    
                    if(attTaxCodeName==NewInvTax_Code) {rowJumpTaxCode+="selected=true";}
                    if(NewInvTax_Code =="" && i == 1) 
                    { 
                       rowJumpTaxCode+="selected=true";
                       NewInvTax_Code = attTaxCodeName;
                    }
                    rowJumpTaxCode+=">"+attTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpTaxCode+"</select></td></tr>";
	          }

			else if(itemName=="VAT_GBP")
			{
			   NewInvVAT_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">V.A.T GBP</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvVAT_GBP+"' id='NewInvVAT_GBP'>";	  

			}
			else if(itemName=="NC")
			{
			   NewInvNC = "";
               rowtxt+="<tr><td align=right "+tdh+">N/C</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvNC+"' id='NewInvNC'>";	  

			}
			
            else if(itemName=="Department")
             {
                 var rowJumpDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewInvDepartment' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attDepartmentName=curNode.childNodes[i].childNodes[0].data;                         
                   if(attDepartmentName) 
                   {
                    rowJumpDepartment+="<option value='"+attDepartmentName+"'";
                    if(attDepartmentName==NewInvDepartment) {rowJumpDepartment+="selected=true";}
                    if(NewInvDepartment == "" && i ==0)  {rowJumpDepartment+="selected=true";NewInvDepartment =attDepartmentName; }
                    rowJumpDepartment+=">"+attDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpDepartment+"</select></td></tr>";
	          }

			else if(itemName=="Consign_Number")
			{
			   NewInvConsign_Number = "";
               rowtxt+="<tr><td align=right "+tdh+">Consign. Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvConsign_Number+"' id='NewInvConsign_Number'>";	  

			}

            else if(itemName=="Courier")
             {
                 var rowJumpCourier="<tr><td align='right'"+tdh+">Courier &nbsp</td><td><select class='edtxt'   id='NewInvCourier' "+widstyle+" onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attCourierName=curNode.childNodes[i].childNodes[0].data;                         
                   if(attCourierName) 
                   {
                    rowJumpCourier+="<option value='"+attCourierName+"'";
                    if(attCourierName==NewInvCourier) {rowJumpCourier+="selected=true";}
                    if(NewInvCourier == "" && i == 0)  {rowJumpCourier+="selected=true"; NewInvCourier = attCourierName;}
                    rowJumpCourier+=">"+attCourierName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpCourier+"</select></td></tr>";
	          }

			else if(itemName=="Days")
			{
               NewInvDays="0.00";
               rowtxt+="<tr><td align=right "+tdh+">Days &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDays+"' id='NewInvDays'>";	  
			}
			else if(itemName=="Discount")
			{
               NewInvDiscount="0.00";
               rowtxt+="<tr><td align=right "+tdh+">Discount% &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDiscount+"' id='NewInvDiscount'>";	  
			}
			else if(itemName=="Amount_GBP")
			{
			   NewInvAmount_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Amount GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAmount_GBP+"' id='NewInvAmount_GBP' ReadOnly>";	  

			}
			else if(itemName=="Set_Total_GBP")
			{
			   NewInvSet_Total_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Total GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvSet_Total_GBP+"' id='NewInvSet_Total_GBP' ReadOnly>";	  

			}  
			else if(itemName=="Set_Gross_GBP")
			{
			   NewInvSet_Gross_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Gross GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvSet_Gross_GBP+"' id='NewInvSet_Gross_GBP' ReadOnly>";	  
			}
			 else if(itemName=="G_NC")
			{
			   NewInvGlobal_NC = "";
               rowtxt+="<tr><td align=right "+tdh+">N/C &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvGlobal_NC+"' id='NewInvGlobal_NC'>";	  

			}  
			else if(itemName=="Details")
			{
               NewInvDetails="";
               rowtxt+="<tr><td align=right "+tdh+">Details &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDetails+"' id='NewInvDetails'>";	  
			}  

             else if(itemName=="G_Tax_Code")
             {
                 var rowJumpGTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select class='edtxt'  id='NewInvG_Tax_Code'  "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attGTaxCodeName=curNode.childNodes[i].childNodes[0].data;                        
                   if(attGTaxCodeName) 
                   {
                    rowJumpGTaxCode+="<option value='"+attGTaxCodeName+"'";
                    if(attGTaxCodeName==NewInvGlobal_Tax_Code)  {rowJumpGTaxCode+="selected=true";}
                    if(NewInvGlobal_Tax_Code == "" && i == 1)  {rowJumpGTaxCode+="selected=true";}
                    rowJumpGTaxCode+=">"+attGTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpGTaxCode+"</select></td></tr>";
                   
	          }
			 else if(itemName=="G_Department")
             {
                 var rowJumpDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewInvG_Department' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attDepartmentName=curNode.childNodes[i].childNodes[0].data;                        
                   if(attDepartmentName) 
                   {
                    rowJumpDepartment+="<option value='"+attDepartmentName+"'";
                    if(attDepartmentName==NewInvGlobal_Department) {rowJumpDepartment+="selected=true";}
                    if(NewInvGlobal_Department == "" && i == 0)   {rowJumpDepartment+="selected=true";}
                    rowJumpDepartment+=">"+attDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpDepartment+"</select></td></tr>";
	          }
			else if(itemName=="Payment_Ref")
			{
               NewInvPayment_Ref="";
               rowtxt+="<tr><td align=right "+tdh+">Payment Ref &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvPayment_Ref+"' id='NewInvPayment_Ref'>";	  
			} 
			else if(itemName=="Bank_Account")
             {
                 var rowJumpBank_Account="<tr><td align='right'"+tdh+">Bank Account &nbsp</td><td><select class='edtxt'  id='NewInvBank_Account' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attBank_AccountName=curNode.childNodes[i].childNodes[0].data;                       
                   if(attBank_AccountName) 
                   {
                    rowJumpBank_Account+="<option value='"+attBank_AccountName+"'";
                    if(attBank_AccountName==NewInvBank_Account) { rowJumpBank_Account+="selected=true";}
                    if(NewInvBank_Account == "" && i == 0)  { rowJumpBank_Account+="selected=true";}
                    rowJumpBank_Account+=">"+attBank_AccountName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpBank_Account+"</select></td></tr>";
	          }

			else if(itemName=="Payment_Amount_GBP")
			{
			   NewInvPayment_Amount_GBP = "0.00";
               rowtxt+="<tr><td align=right "+tdh+">Payment Amount &nbsp<br>GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvPayment_Amount_GBP+"' id='NewInvPayment_Amount_GBP'>";	  

			}  
         else 	if(curNode.nodeName=='Item_No')	
			 {
			 var rowJump1="<tr><td align=right "+tdh+">Item No &nbsp</td><td><select class='edtxt' "+widstyle+" id='selnewinvitempagecat'>";
                  
                     var invItems = curNode.firstChild;	 
                  for(var i=0; i<curNode.childNodes.length;i++)   
	           {
	           var attName1=curNode.childNodes[i].childNodes[0].data;                   
	             	if(attName1) 
	             	{
			            var tname1=attName1.replace('_',' ');
		                  rowJump1+="<option label='"+tname1+"'";
		                   	if(i==gv_scrollCurPage) rowJump1+=" selected=true";
		                       rowJump1+=">"+tname1+"</option>";		   
		             }
            	}	 
                  
                  
	                 rowJump1+="<tr><td colspan=2 align=center "+tdh+" style='color:blue;font-weight:bold;><input type='Button'  Value='AddItem' id='addnewinvitemturnbtn'  onclick='getNewInvItemPage()' Runat='server' style='color:blue;font-weight:bold;width:65px;height:20px;text-decoration:underline;'/>";
	                 rowJump1+="&nbsp&nbsp&nbsp&nbsp&nbsp<input type='Button'  Value='EditItem' id='editnewinvitemturnbtn'  onclick='getEditNewInvItemPage()' Runat='server' style='color:blue;font-weight:bold;width:65px;height:20px;text-decoration:underline;'  disabled='true';/></td></tr>";
	                  rowtxt+=rowJump1;
	               
	          
	           }
	      else
			{ 	
		       rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"&nbsp&nbsp"+"</td>";
		            	rowtxt+="<td "+tdh+"><input type='text' class='edtxt' onchange='showSaveNewInvDataButton();' "+widstyle+
			        	"value='"+itemVal+"' id='"+itemId+"'"+end_tdr;
            }
            }
            if(HasNewInvStatus == "Load")
            {
              if(curNode.nodeName=='Customer_ACRef')	
  			 {
  		       //if(NewInvCustomer_ACRef == "") { NewInvCustomer_ACRef=itemVal; }     
  		        NewInvCustomer_ACRef=itemVal;    
	           rowtxt+="<tr><td align=right "+tdh+">Customer A/C &nbsp<br>Ref <span style='color:red'>*</span></td>";
			   rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:125px;height:20px;'value='"+NewInvCustomer_ACRef+"' id='NewInvCustomer_ACRef'><input type='Button'  Value='Get' id='newInvGetCustomer_ACRef' onclick='newInvGetCustomer_ACRef()'    Runat='server' style='color:blue;font-weight:bold;width:35px;height:20px;text-decoration:underline;'/></td></tr>";//<input type='Button' value='Get' onclick='getSupplierACRef();' runat='server' style='color: blue; width: 35px;height: 20px; font-weight: bold; text-decoration: underline;' /></td>";
			   //NewInvCustomer_ACRef=itemVal;
  		    }
      
	
			 else if(itemName=="Order_Type")
             {
                 var rowJumpOrder_Type="<tr><td align='right'"+tdh+">Order Type &nbsp</td><td><select class='edtxt'  id='NewInvOrder_Type' "+widstyle+"  onchange='NewInvTaxCode();'>"
                 rowJumpOrder_Type+="<option value='Invoice'"
                 if(NewInvOrder_Type == '') {rowJumpOrder_Type += "selected = 'true'";}
                 rowJumpOrder_Type +=">Invoice</option><option value='Pro-forma'";
                 if(NewInvOrder_Type =='Pro-forma') {rowJumpOrder_Type += "selected = 'true'";}
                 rowJumpOrder_Type +=">Pro-forma</option><option value='Credit'";
                 if(NewInvOrder_Type =='Credit') {rowJumpOrder_Type += "selected = 'true'";}
                  rowJumpOrder_Type +=">Credit</option>";
                 rowtxt+=rowJumpOrder_Type+"</select></td></tr>";
	          }
	          
			 else if(itemName=="Format")
             {
                 var rowJumpFormat="<tr><td align='right'"+tdh+">Format &nbsp</td><td><select id='NewInvFormat' class='edtxt'  "+widstyle+"  onchange='NewInvTaxCode();'>"
                 rowJumpFormat+="<option value='Product'>Product</option><option value='Service'"
                 if(NewInvFormat == 'Service'){ rowJumpFormat+="selected = 'true'";}
                rowJumpFormat+=">Service</option>";
                 rowtxt+=rowJumpFormat+"</select></td></tr>";
	          }
			else if(itemName=="Order_Date")
			{
               rowtxt+="<tr><td align=right "+tdh+">Order Date &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvOrder_Date+"' id='NewInvOrder_Date'>";	  

			}
//			else if(itemName=="Order_Number")
//			{
//               rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"</td>";
//               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;'value='"+gv_supName[gv_supIndex]+"' id='"+itemId+"'>";	  

//			}
			
			
			else if(itemName=="Customer_Order_Number")
			{
			   NewInvCustomer_Order_Number = itemVal; 
               rowtxt+="<tr><td align=right "+tdh+">Customer Order &nbsp<br>Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Order_Number+"' id='NewInvCustomer_Order_Number'>";	  

			}
			else if(itemName=="Order_Number")
			{
			   NewInvOrder_Number = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Order Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvOrder_Number+"' id='NewInvOrder_Number' ReadOnly>";	  

			}
			
            else if(itemName=="Total_GBP")
			{
			    NewInvTotal_GBP = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Total GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvTotal_GBP+"' id='NewInvTotal_GBP' ReadOnly>";	  

			}
			else if(itemName=="Total_VAT")
			{
			    NewInvTotal_VAT = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Total VAT &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvTotal_VAT+"' id='NewInvTotal_VAT' ReadOnly>";	  

			}
			else if(itemName=="Carriage_GBP")
			{
			    NewInvCarriage_GBP = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Carriage GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCarriage_GBP+"' id='NewInvCarriage_GBP' ReadOnly>";	  

			}
			else if(itemName=="Carriage_VAT")
			{
			    NewInvCarriage_VAT = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Carriage VAT &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCarriage_VAT+"' id='NewInvCarriage_VAT' ReadOnly>";	  
			}
			else if(itemName=="Gross_GBP")
			{
			    NewInvGross_GBP = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Gross GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvGross_GBP+"' id='NewInvGross_GBP' ReadOnly>";	  
			}
			else if(itemName=="Delivery")
			{
			   NewInvDelivery=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Delivery &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery+"' id='NewInvDelivery'>";	  
			}
			else if(itemName=="Address1")
			{
			   NewInvAddress1=itemVal; 
               rowtxt+="<tr><td align=right "+tdh+">Address1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress1+"' id='NewInvAddress1'>";	  
			}
			else if(itemName=="Address2")
			{
			   NewInvAddress2=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Address2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress2+"' id='NewInvAddress2'>";	  
			}
			else if(itemName=="Address3")
			{
			   NewInvAddress3=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Address3 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress3+"' id='NewInvAddress3'>";	  
			}
			else if(itemName=="Address4")
			{
			   NewInvAddress4=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Address4 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress4+"' id='NewInvAddress4'>";	  
			}
			else if(itemName=="Address5")
			{
			   NewInvAddress5=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Address5 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress5+"' id='NewInvAddress5'>";	  
			}
			else if(itemName=="Name")
			{
			   NewInvName=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Name <span style='color:red'>*</span></td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvName+"' id='NewInvName'>";	  
			}
	       else if(itemName=="Delivery_Street1")
			{
               NewInvDelivery_Street1=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Delivery Street1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Street1+"' id='NewInvDelivery_Street1'>";	  
			}
			else if(itemName=="Delivery_Street2")
			{
               NewInvDelivery_Street2=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Delivery Street2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Street2+"' id='NewInvDelivery_Street2'>";	  
			}
			else if(itemName=="Delivery_Town")
			{
               NewInvDelivery_Town=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Delivery Town &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Town+"' id='NewInvDelivery_Town'>";	  
			}
			else if(itemName=="Delivery_County")
			{
               NewInvDelivery_County=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Delivery County &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_County+"' id='NewInvDelivery_County'>";	  
			}
			else if(itemName=="Delivery_Post_Code")
			{
			   NewInvDelivery_Post_Code=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Delivery Post Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Post_Code+"' id='NewInvDelivery_Post_Code'>";	  
			}
			
			else if(itemName=="Customer_Tel_No")
			{
               NewInvCustomer_Tel_No=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Customer Tel No &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Tel_No+"' id='NewInvCustomer_Tel_No'>";	  
			}
			else if(itemName=="Customer_Contact")
			{
               NewInvCustomer_Contact=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Customer Contact &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Contact+"' id='NewInvCustomer_Contact'>";	  
			}
			else if(itemName=="Net_GBP")
			{
			   NewInvNet_GBP = itemVal; 
               rowtxt+="<tr><td align=right "+tdh+">Net GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvNet_GBP+"' id='NewInvNet_GBP'>";	  

			}
//			else if(itemName=="Tax_Code")
//			{
//               rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"</td>";
//               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewSopDataButton();' value='"+NewSopTax_Code+"' id='Tax_Code'>";	  

//			}
              else if(itemName=="Tax_Code")
             {
                 var rowJumpTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select id='NewInvTax_Code'  class='edtxt'  "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attTaxCodeName=curNode.childNodes[i].childNodes[0].data;                         
                   if(attTaxCodeName) 
                   {
                    rowJumpTaxCode+="<option value='"+attTaxCodeName+"'";
                    
                    if(attTaxCodeName==NewInvTax_Code) {rowJumpTaxCode+="selected=true";}
                    if(NewInvTax_Code =="" && i == 1) 
                    { 
                       rowJumpTaxCode+="selected=true";
                       NewInvTax_Code = attTaxCodeName;
                    }
                    rowJumpTaxCode+=">"+attTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpTaxCode+"</select></td></tr>";
	          }

			else if(itemName=="VAT_GBP")
			{
			    NewInvVAT_GBP = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">V.A.T GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvVAT_GBP+"' id='NewInvVAT_GBP'>";	  

			}
			else if(itemName=="NC")
			{
			   NewInvNC = itemVal; 
               rowtxt+="<tr><td align=right "+tdh+">N/C &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvNC+"' id='NewInvNC'>";	  

			}
			
            else if(itemName=="Department")
            {
                 var rowJumpDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewInvDepartment' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attDepartmentName=curNode.childNodes[i].childNodes[0].data;                         
                   if(attDepartmentName) 
                   {
                    rowJumpDepartment+="<option value='"+attDepartmentName+"'";
                    if(attDepartmentName==NewInvDepartment) {rowJumpDepartment+="selected=true";}
                    if(NewInvDepartment == "" && i ==0)  {rowJumpDepartment+="selected=true";NewInvDepartment =attDepartmentName; }
                    rowJumpDepartment+=">"+attDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpDepartment+"</select></td></tr>";
	          }

			else if(itemName=="Consign_Number")
			{
			    NewInvConsign_Number = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Consign. Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvConsign_Number+"' id='NewInvConsign_Number'>";	  

			}

            else if(itemName=="Courier")
             {
                 var rowJumpCourier="<tr><td align='right'"+tdh+">Courier &nbsp</td><td><select class='edtxt'   id='NewInvCourier' "+widstyle+" onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attCourierName=curNode.childNodes[i].childNodes[0].data;                        
                   if(attCourierName) 
                   {
                    rowJumpCourier+="<option value='"+attCourierName+"'";
                    if(attCourierName==NewInvCourier) {rowJumpCourier+="selected=true";}
                    if(NewInvCourier == "" && i == 0)  {rowJumpCourier+="selected=true"; NewInvCourier = attCourierName;}
                    rowJumpCourier+=">"+attCourierName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpCourier+"</select></td></tr>";
	          }

			else if(itemName=="Days")
			{
               NewInvDays=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Days &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDays+"' id='NewInvDays'>";	  
			}
			else if(itemName=="Discount")
			{
               NewInvDiscount=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Discount% &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDiscount+"' id='NewInvDiscount'>";	  
			}
			else if(itemName=="Amount_GBP")
			{
			   if(NewInvTotal_GBP != "" && NewInvDiscount != "") { NewInvAmount_GBP = NewInvTotal_GBP * NewInvDiscount / 100;}
               rowtxt+="<tr><td align=right "+tdh+">Amount GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAmount_GBP+"' id='NewInvAmount_GBP' ReadOnly>";	  

			}
			else if(itemName=="Set_Total_GBP")
			{
			   if(NewInvGross_GBP != '' && NewInvAmount_GBP != '') { NewInvSet_Total_GBP = NewInvGross_GBP - NewInvAmount_GBP;}
               rowtxt+="<tr><td align=right "+tdh+">Total GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvSet_Total_GBP+"' id='NewInvSet_Total_GBP' ReadOnly>";	  

			}
			else if(itemName=="Set_Gross_GBP")
			{
			   	if(NewInvCarriage_GBP != "" && NewInvCarriage_VAT != "") 
			    {NewInvSet_Gross_GBP=parseFloat(NewInvCarriage_GBP) + parseFloat(NewInvCarriage_VAT);}
               rowtxt+="<tr><td align=right "+tdh+">Gross GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvSet_Gross_GBP+"' id='NewInvSet_Gross_GBP' ReadOnly>";	  
			}  
			 else if(itemName=="G_NC")
			{
			   NewInvGlobal_NC = itemVal; 
               rowtxt+="<tr><td align=right "+tdh+">N/C &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvGlobal_NC+"' id='NewInvGlobal_NC'>";	  
			}  
			else if(itemName=="Details")
			{
               NewInvDetails=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Details &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDetails+"' id='NewInvDetails'>";	  
			}  

             else if(itemName=="G_Tax_Code")
             {
                 var rowJumpGTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select class='edtxt'  id='NewInvG_Tax_Code'  "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attGTaxCodeName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attGTaxCodeName) 
                   {
                    rowJumpGTaxCode+="<option value='"+attGTaxCodeName+"'";
                    if(attGTaxCodeName==NewInvGlobal_Tax_Code)  {rowJumpGTaxCode+="selected=true";}
                    if(NewInvGlobal_Tax_Code == "" && i == 1)  {rowJumpGTaxCode+="selected=true";}
                    rowJumpGTaxCode+=">"+attGTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpGTaxCode+"</select></td></tr>";
                   
	          }
			 else if(itemName=="G_Department")
             {
                 var rowJumpDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewInvG_Department' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attDepartmentName=curNode.childNodes[i].childNodes[0].data;                       
                   if(attDepartmentName) 
                   {
                    rowJumpDepartment+="<option value='"+attDepartmentName+"'";
                    if(attDepartmentName==NewInvGlobal_Department) {rowJumpDepartment+="selected=true";}
                    if(NewInvGlobal_Department == "" && i == 0)   {rowJumpDepartment+="selected=true";}
                    rowJumpDepartment+=">"+attDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpDepartment+"</select></td></tr>";
	          }
			else if(itemName=="Payment_Ref")
			{
               NewInvPayment_Ref=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Payment Ref &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvPayment_Ref+"' id='NewInvPayment_Ref'>";	  
			} 
			else if(itemName=="Bank_Account")
             {
                 var rowJumpBank_Account="<tr><td align='right'"+tdh+">Bank Account &nbsp</td><td><select class='edtxt' id='NewInvBank_Account' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attBank_AccountName=curNode.childNodes[i].childNodes[0].data;                        
                   if(attBank_AccountName) 
                   {
                    rowJumpBank_Account+="<option value='"+attBank_AccountName+"'";
                    if(attBank_AccountName==NewInvBank_Account) { rowJumpBank_Account+="selected=true";}
                    if(NewInvBank_Account == "" && i == 0)  { rowJumpBank_Account+="selected=true";}
                    rowJumpBank_Account+=">"+attBank_AccountName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpBank_Account+"</select></td></tr>";
	          }

			else if(itemName=="Payment_Amount_GBP")
			{
			   NewInvPayment_Amount_GBP = itemVal; 
               rowtxt+="<tr><td align=right "+tdh+">Payment Amount &nbsp<br>GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvPayment_Amount_GBP+"' id='NewInvPayment_Amount_GBP'>";	  

			}  
             else if(curNode.nodeName=='Item_No')	
			 {
			    var rowJumpNewInv="<tr><td align=right "+tdh+">Item No &nbsp</td><td><select class='edtxt' "+widstyle+" id='selnewinvitempagecat'>";
                 rowJumpNewInv += addNewInvDropDownValue;
                 rowJumpNewInv += "</select></td></tr>";
	             rowJumpNewInv+="<tr><td colspan=2 align=center "+tdh+" style='color:blue;font-weight:bold;'><input type='Button'  Value='AddItem' id='addnewinvitemturnbtn'  onclick='getNewInvItemPage()' Runat='server' style='color:blue;font-weight:bold;width:65px;height:20px;text-decoration:underline;'/>";
	             rowJumpNewInv+="&nbsp&nbsp&nbsp&nbsp&nbsp<input type='Button'  Value='EditItem' id='editnewinvitemturnbtn'  onclick='getEditNewInvItemPage()' Runat='server' style='color:blue;font-weight:bold;width:65px;height:20px;text-decoration:underline;' disabled='true';/></td></tr>";
	             rowtxt+=rowJumpNewInv;
	               
	          
	           }
	      else
			{ 	
		       rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"&nbsp&nbsp"+"</td>";
		       rowtxt+="<td "+tdh+"><input type='text' class='edtxt' onchange='showSaveNewInvDataButton();' "+widstyle+"value='"+itemVal+"' id='"+itemId+"'"+end_tdr;
            }
            }
            if(HasNewInvStatus == "OtherLoad")
            {
              if(curNode.nodeName=='Customer_ACRef')	
  			 {
  		       //if(NewInvCustomer_ACRef == "") { NewInvCustomer_ACRef=itemVal; }     
  		        NewInvCustomer_ACRef=itemVal;    
	           rowtxt+="<tr><td align=right "+tdh+">Customer A/C &nbsp<br>Ref <span style='color:red'>*</span></td>";
			   rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:125px;height:20px;'value='"+NewInvCustomer_ACRef+"' id='NewInvCustomer_ACRef'><input type='Button'  Value='Get' id='newInvGetCustomer_ACRef' onclick='newInvGetCustomer_ACRef()'    Runat='server' style='color:blue;font-weight:bold;width:35px;height:20px;text-decoration:underline;'/></td></tr>";//<input type='Button' value='Get' onclick='getSupplierACRef();' runat='server' style='color: blue; width: 35px;height: 20px; font-weight: bold; text-decoration: underline;' /></td>";
			   //NewInvCustomer_ACRef=itemVal;
  		    }
      
	
			 else if(itemName=="Order_Type")
             {
                 var rowJumpOrder_Type="<tr><td align='right'"+tdh+">Order Type &nbsp</td><td><select class='edtxt'  id='NewInvOrder_Type' "+widstyle+"  onchange='NewInvTaxCode();'>"
                 rowJumpOrder_Type+="<option value='Invoice'"
                 if(NewInvOrder_Type == '') {rowJumpOrder_Type += "selected = 'true'";}
                 rowJumpOrder_Type +=">Invoice</option><option value='Pro-forma'";
                 if(NewInvOrder_Type =='Pro-forma') {rowJumpOrder_Type += "selected = 'true'";}
                 rowJumpOrder_Type +=">Pro-forma</option><option value='Credit'";
                 if(NewInvOrder_Type =='Credit') {rowJumpOrder_Type += "selected = 'true'";}
                  rowJumpOrder_Type +=">Credit</option>";
                 rowtxt+=rowJumpOrder_Type+"</select></td></tr>";
	          }
	          
			 else if(itemName=="Format")
             {
                 var rowJumpFormat="<tr><td align='right'"+tdh+">Format &nbsp</td><td><select id='NewInvFormat' class='edtxt'  "+widstyle+"  onchange='NewInvTaxCode();'>"
                 rowJumpFormat+="<option value='Product'>Product</option><option value='Service'"
                 if(NewInvFormat == 'Service'){ rowJumpFormat+="selected = 'true'";}
                rowJumpFormat+=">Service</option>";
                 rowtxt+=rowJumpFormat+"</select></td></tr>";
	          }
			else if(itemName=="Order_Date")
			{
               rowtxt+="<tr><td align=right "+tdh+">Order Date &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvOrder_Date+"' id='NewInvOrder_Date'>";	  

			}
//			else if(itemName=="Order_Number")
//			{
//               rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"</td>";
//               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;'value='"+gv_supName[gv_supIndex]+"' id='"+itemId+"'>";	  

//			}
			
			
			else if(itemName=="Customer_Order_Number")
			{
               rowtxt+="<tr><td align=right "+tdh+">Customer Order &nbsp<br>Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Order_Number+"' id='NewInvCustomer_Order_Number'>";	  

			}
			else if(itemName=="Order_Number")
			{
               rowtxt+="<tr><td align=right "+tdh+">Order Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvOrder_Number+"' id='NewInvOrder_Number' ReadOnly>";	  

			}
			
            else if(itemName=="Total_GBP")
			{
               rowtxt+="<tr><td align=right "+tdh+">Total GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvTotal_GBP+"' id='NewInvTotal_GBP' ReadOnly>";	  

			}
			else if(itemName=="Total_VAT")
			{
               rowtxt+="<tr><td align=right "+tdh+">Total VAT &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvTotal_VAT+"' id='NewInvTotal_VAT' ReadOnly>";	  

			}
			else if(itemName=="Carriage_GBP")
			{
               rowtxt+="<tr><td align=right "+tdh+">Carriage GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCarriage_GBP+"' id='NewInvCarriage_GBP' ReadOnly>";	  

			}
			else if(itemName=="Carriage_VAT")
			{
               rowtxt+="<tr><td align=right "+tdh+">Carriage VAT &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCarriage_VAT+"' id='NewInvCarriage_VAT' ReadOnly>";	  

			}
			else if(itemName=="Gross_GBP")
			{
               rowtxt+="<tr><td align=right "+tdh+">Gross GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvGross_GBP+"' id='NewInvGross_GBP' ReadOnly>";	  
			}
			else if(itemName=="Delivery")
			{
			   //if(NewInvDelivery == "") { NewInvDelivery=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Delivery &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery+"' id='NewInvDelivery'>";	  
			}
			else if(itemName=="Address1")
			{
			   //if(NewInvAddress1 == "") { NewInvAddress1=itemVal; }
               rowtxt+="<tr><td align=right "+tdh+">Address1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress1+"' id='NewInvAddress1'>";	  
			}
			else if(itemName=="Address2")
			{
			   //if(NewInvAddress2 == "") { NewInvAddress2=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Address2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress2+"' id='NewInvAddress2'>";	  
			}
			else if(itemName=="Address3")
			{
			   //if(NewInvAddress3 == "") { NewInvAddress3=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Address3 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress3+"' id='NewInvAddress3'>";	  
			}
			else if(itemName=="Address4")
			{
			   //if(NewInvAddress4 == "") { NewInvAddress4=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Address4 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress4+"' id='NewInvAddress4'>";	  
			}
			else if(itemName=="Address5")
			{
			   //if(NewInvAddress5 == "") { NewInvAddress5=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Address5 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAddress5+"' id='NewInvAddress5'>";	  
			}
			else if(itemName=="Name")
			{
			   //if(NewInvName == "") { NewInvName=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Name <span style='color:red'>*</span></td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvName+"' id='NewInvName'>";	  
			}
	       else if(itemName=="Delivery_Street1")
			{
               //if(NewInvDelivery_Street1 == "") { NewInvDelivery_Street1=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Delivery Street1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Street1+"' id='NewInvDelivery_Street1'>";	  
			}
			else if(itemName=="Delivery_Street2")
			{
               //if(NewInvDelivery_Street2 == "") { NewInvDelivery_Street2=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Delivery Street2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Street2+"' id='NewInvDelivery_Street2'>";	  
			}
			else if(itemName=="Delivery_Town")
			{
               //if(NewInvDelivery_Town == "") { NewInvDelivery_Town=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Delivery Town &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Town+"' id='NewInvDelivery_Town'>";	  
			}
			else if(itemName=="Delivery_County")
			{
               //if(NewInvDelivery_County == "") { NewInvDelivery_County=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Delivery County &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_County+"' id='NewInvDelivery_County'>";	  
			}
			else if(itemName=="Delivery_Post_Code")
			{
			   //if(NewInvDelivery_Post_Code == "") { NewInvDelivery_Post_Code=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Delivery Post Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDelivery_Post_Code+"' id='NewInvDelivery_Post_Code'>";	  
			}
			
			else if(itemName=="Customer_Tel_No")
			{
               //if(NewInvCustomer_Tel_No == "") { NewInvCustomer_Tel_No=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Customer Tel No &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Tel_No+"' id='NewInvCustomer_Tel_No'>";	  
			}
			else if(itemName=="Customer_Contact")
			{
               //if(NewInvCustomer_Contact == "") { NewInvCustomer_Contact=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Customer Contact &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvCustomer_Contact+"' id='NewInvCustomer_Contact'>";	  
			}
			else if(itemName=="Net_GBP")
			{
               rowtxt+="<tr><td align=right "+tdh+">Net GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvNet_GBP+"' id='NewInvNet_GBP'>";	  

			}
//			else if(itemName=="Tax_Code")
//			{
//               rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"</td>";
//               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewSopDataButton();' value='"+NewSopTax_Code+"' id='Tax_Code'>";	  

//			}
              else if(itemName=="Tax_Code")
             {
                 var rowJumpTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select id='NewInvTax_Code'  class='edtxt'  "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attTaxCodeName=curNode.childNodes[i].childNodes[0].data;                         
                   if(attTaxCodeName) 
                   {
                    rowJumpTaxCode+="<option value='"+attTaxCodeName+"'";
                    
                    if(attTaxCodeName==NewInvTax_Code) {rowJumpTaxCode+="selected=true";}
                    if(NewInvTax_Code =="" && i == 1) 
                    { 
                       rowJumpTaxCode+="selected=true";
                       NewInvTax_Code = attTaxCodeName;
                    }
                    rowJumpTaxCode+=">"+attTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpTaxCode+"</select></td></tr>";
	          }

			else if(itemName=="VAT_GBP")
			{
               rowtxt+="<tr><td align=right "+tdh+">V.A.T GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvVAT_GBP+"' id='NewInvVAT_GBP'>";	  

			}
			else if(itemName=="NC")
			{
               rowtxt+="<tr><td align=right "+tdh+">N/C &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvNC+"' id='NewInvNC'>";	  

			}
			
            else if(itemName=="Department")
             {
                 var rowJumpDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewInvDepartment' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attDepartmentName=curNode.childNodes[i].childNodes[0].data;                         
                   if(attDepartmentName) 
                   {
                    rowJumpDepartment+="<option value='"+attDepartmentName+"'";
                    if(attDepartmentName==NewInvDepartment) {rowJumpDepartment+="selected=true";}
                    if(NewInvDepartment == "" && i ==0)  {rowJumpDepartment+="selected=true";NewInvDepartment =attDepartmentName; }
                    rowJumpDepartment+=">"+attDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpDepartment+"</select></td></tr>";
	          }

			else if(itemName=="Consign_Number")
			{
               rowtxt+="<tr><td align=right "+tdh+">Consign. Number &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvConsign_Number+"' id='NewInvConsign_Number'>";	  

			}

            else if(itemName=="Courier")
             {
                 var rowJumpCourier="<tr><td align='right'"+tdh+">Courier &nbsp</td><td><select class='edtxt'   id='NewInvCourier' "+widstyle+" onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attCourierName=curNode.childNodes[i].childNodes[0].data;                        
                   if(attCourierName) 
                   {
                    rowJumpCourier+="<option value='"+attCourierName+"'";
                    if(attCourierName==NewInvCourier) {rowJumpCourier+="selected=true";}
                    if(NewInvCourier == "" && i == 0)  {rowJumpCourier+="selected=true"; NewInvCourier = attCourierName;}
                    rowJumpCourier+=">"+attCourierName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpCourier+"</select></td></tr>";
	          }

			else if(itemName=="Days")
			{
               //if(NewInvDays == "") { NewInvDays=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Days &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDays+"' id='NewInvDays'>";	  
			}
			else if(itemName=="Discount")
			{
               //if(NewInvDiscount == "") { NewInvDiscount=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Discount% &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDiscount+"' id='NewInvDiscount'>";	  
			}
			else if(itemName=="Amount_GBP")
			{
			   if(NewInvTotal_GBP != "" && NewInvDiscount != "") { NewInvAmount_GBP = NewInvTotal_GBP * NewInvDiscount / 100;}
               rowtxt+="<tr><td align=right "+tdh+">Amount GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvAmount_GBP+"' id='NewInvAmount_GBP' ReadOnly>";	  

			}
			else if(itemName=="Set_Total_GBP")
			{
			   if(NewInvGross_GBP != '' && NewInvAmount_GBP != '') { NewInvSet_Total_GBP = NewInvGross_GBP - NewInvAmount_GBP;}

               rowtxt+="<tr><td align=right "+tdh+">Total GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvSet_Total_GBP+"' id='NewInvSet_Total_GBP' ReadOnly>";	  

			}
			else if(itemName=="Set_Gross_GBP")
			{
			   	if(NewInvCarriage_GBP != "" && NewInvCarriage_VAT != "") 
			    {NewInvSet_Gross_GBP=parseFloat(NewInvCarriage_GBP) + parseFloat(NewInvCarriage_VAT);}
               rowtxt+="<tr><td align=right "+tdh+">Gross GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvSet_Gross_GBP+"' id='NewInvSet_Gross_GBP' ReadOnly>";	  
			}  
			 else if(itemName=="G_NC")
			{
               rowtxt+="<tr><td align=right "+tdh+">N/C &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvGlobal_NC+"' id='NewInvGlobal_NC'>";	  

			}  
			else if(itemName=="Details")
			{
               //if(NewInvDetails == "") { NewInvDetails=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Details &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvDetails+"' id='NewInvDetails'>";	  
			}  

             else if(itemName=="G_Tax_Code")
             {
                 var rowJumpGTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select class='edtxt'  id='NewInvG_Tax_Code'  "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attGTaxCodeName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attGTaxCodeName) 
                   {
                    rowJumpGTaxCode+="<option value='"+attGTaxCodeName+"'";
                    if(attGTaxCodeName==NewInvGlobal_Tax_Code)  {rowJumpGTaxCode+="selected=true";}
                    if(NewInvGlobal_Tax_Code == "" && i == 1)  {rowJumpGTaxCode+="selected=true";}
                    rowJumpGTaxCode+=">"+attGTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpGTaxCode+"</select></td></tr>";
                   
	          }
			 else if(itemName=="G_Department")
             {
                 var rowJumpDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewInvG_Department' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attDepartmentName=curNode.childNodes[i].childNodes[0].data;                       
                   if(attDepartmentName) 
                   {
                    rowJumpDepartment+="<option value='"+attDepartmentName+"'";
                    if(attDepartmentName==NewInvGlobal_Department) {rowJumpDepartment+="selected=true";}
                    if(NewInvGlobal_Department == "" && i == 0)   {rowJumpDepartment+="selected=true";}
                    rowJumpDepartment+=">"+attDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpDepartment+"</select></td></tr>";
	          }
			else if(itemName=="Payment_Ref")
			{
               //if(NewInvPayment_Ref == "") { NewInvPayment_Ref=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Payment Ref &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvPayment_Ref+"' id='NewInvPayment_Ref'>";	  
			} 
			else if(itemName=="Bank_Account")
             {
                 var rowJumpBank_Account="<tr><td align='right'"+tdh+">Bank Account &nbsp</td><td><select class='edtxt' id='NewInvBank_Account' "+widstyle+"  onchange='NewInvTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attBank_AccountName=curNode.childNodes[i].childNodes[0].data;                        
                   if(attBank_AccountName) 
                   {
                    rowJumpBank_Account+="<option value='"+attBank_AccountName+"'";
                    if(attBank_AccountName==NewInvBank_Account) { rowJumpBank_Account+="selected=true";}
                    if(NewInvBank_Account == "" && i == 0)  { rowJumpBank_Account+="selected=true";}
                    rowJumpBank_Account+=">"+attBank_AccountName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpBank_Account+"</select></td></tr>";
	          }

			else if(itemName=="Payment_Amount_GBP")
			{
               rowtxt+="<tr><td align=right "+tdh+">Payment Amount &nbsp<br>GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewInvDataButton();' value='"+NewInvPayment_Amount_GBP+"' id='NewInvPayment_Amount_GBP'>";	  

			}  
             else if(curNode.nodeName=='Item_No')	
			 {
			    var rowJumpNewInv="<tr><td align=right "+tdh+">Item No &nbsp</td><td><select class='edtxt' "+widstyle+" id='selnewinvitempagecat'>";
                 rowJumpNewInv += addNewInvDropDownValue;
                 rowJumpNewInv += "</select></td></tr>";
	             rowJumpNewInv+="<tr><td colspan=2 align=center "+tdh+" style='color:blue;font-weight:bold;'><input type='Button'  Value='AddItem' id='addnewinvitemturnbtn'  onclick='getNewInvItemPage()' Runat='server' style='color:blue;font-weight:bold;width:65px;height:20px;text-decoration:underline;'/>";
	             rowJumpNewInv+="&nbsp&nbsp&nbsp&nbsp&nbsp<input type='Button'  Value='EditItem' id='editnewinvitemturnbtn'  onclick='getEditNewInvItemPage()' Runat='server' style='color:blue;font-weight:bold;width:65px;height:20px;text-decoration:underline;' disabled='true';/></td></tr>";
	             rowtxt+=rowJumpNewInv;
	               
	          
	           }
	      else
			{ 	
		       rowtxt+="<tr><td align=right "+tdh+">"+itemName.replace('_',' ')+"&nbsp&nbsp"+"</td>";
		       rowtxt+="<td "+tdh+"><input type='text' class='edtxt' onchange='showSaveNewInvDataButton();' "+widstyle+"value='"+itemVal+"' id='"+itemId+"'"+end_tdr;
            }
            }
			curNode=curNode.nextSibling;
			           ycur+=gv_newInvRowH;
		}
          //if(ic==gv_scrollCurPage || ycur+45<gv_winh) tabstr+=rowtxt; else break;
          if(ic==gv_scrollCurPage) tabstr+=rowtxt; 
   }
    tabstr += "</table>";   
    gv_tempTable.innerHTML = tabstr;
    if(NewInvItemDDVal != "")
    {
        if(document.getElementById("editnewinvitemturnbtn")) { document.getElementById("editnewinvitemturnbtn").disabled = false; }
    }
     	if(document.getElementById('savenewinvdata')==null) setNewInvPageScrollCommands('','');
          setNewInvPageScroll();
   setTopTitle('Sop -> New Inv ');
   doNokiaMenuNewInvPage();
}

function getNewInvItemPage()
{
    NewInvItemTurnPage = 1;
    document.getElementById('savenewinvdata').style.visibility = "hidden";
    doAddInvItem();
}

function getEditNewInvItemPage()
{
    EditNewInvItemStrRun = 1;
    NewInvItemTurnPage = 2;
    doEditNewInvItem();
}

function doNokiaMenuNewInvPage()
{
	if(window.widget) {
		window.menu.clear();
		var mBack = new MenuItem('Back',2102);
		mBack.onSelect=backSops;
		window.menu.append(mBack);
	}
}

function NewInvTaxCode()
{
var NewInvType=document.getElementById('NewInvOrder_Type');
var NewInvFor=document.getElementById('NewInvFormat');
var NewInvTax=document.getElementById('NewInvTax_Code');
var NewInvDep=document.getElementById('NewInvDepartment');
var NewInvCou=document.getElementById('NewInvCourier');
var NewInvGTax=document.getElementById('NewInvG_Tax_Code');
var NewInvG_Dep=document.getElementById('NewInvG_Department');
var NewInvBank=document.getElementById('NewInvBank_Account');
 if(NewInvType)
 {
      NewInvOrder_Type=NewInvType.options[NewInvType.selectedIndex].value;

 }
 if(NewInvFor)
 {
      NewInvFormat=NewInvFor.options[NewInvFor.selectedIndex].value;

 }
  if(NewInvTax)
  {

  NewInvTax_Code=NewInvTax.options[NewInvTax.selectedIndex].value;

  }
  if(NewInvDep)
  {

   NewInvDepartment = NewInvDep.options[NewInvDep.selectedIndex].value; 
  }
  if(NewInvCou)
  {
   NewInvCourier=NewInvCou.options[NewInvCou.selectedIndex].value; 
  }
  if(NewInvGTax)
  {
  NewInvGlobal_Tax_Code=NewInvGTax.options[NewInvGTax.selectedIndex].value; 
  }
  if(NewInvG_Dep)
  {
   NewInvGlobal_Department=NewInvG_Dep.options[NewInvG_Dep.selectedIndex].value; 
  }
  
  if(NewInvBank)
  {
  NewInvBank_Account=NewInvBank.options[NewInvBank.selectedIndex].value; 
  }
}



function newInvGetCustomer_ACRef()
{
   document.getElementById('savenewinvdata').style.visibility = "hidden";
   NewInviPage = 1;
   doNewInvList();
// document.getElementById('sopCmds').style.visibility='hidden';
}

function setNewInvPageScroll()

{   var pncur=document.getElementById('pn_cur3');
    pncur.innerHTML='Page '+(gv_scrollCurPage+1)+' of '+gv_scrollTotPage;
    var pnleft=document.getElementById('pn_left3');
    pnleft.innerHTML=gv_scrollCurPage>0 ? gv_scrollCurPage.toString():'';
    var pnright=document.getElementById('pn_right3');
    pnright.innerHTML=gv_scrollCurPage<gv_scrollTotPage-1 ? (gv_scrollCurPage+2).toString():'';  
}

function  jumpToNewInvCat()
{
var selcat = document.getElementById('selnewinvcat');
//	if(gv_newInvEditingData==1) checkNewInvPageEdited(gv_scrollCurPage); //Save any edited data to memory
	gv_scrollCurPage=selcat.selectedIndex;
    if(document.getElementById("NewInvCustomer_ACRef")){NewInvCustomer_ACRef = document.getElementById("NewInvCustomer_ACRef").value;}
	if(document.getElementById("NewInvOrder_Type")){NewInvOrder_Type=document.getElementById('NewInvOrder_Type').options[document.getElementById('NewInvOrder_Type').selectedIndex].value; }
	if(document.getElementById("NewInvFormat")){NewInvFormat=document.getElementById('NewInvFormat').options[document.getElementById('NewInvFormat').selectedIndex].value; }
    if(document.getElementById("NewInvOrder_Date")){NewInvOrder_Date = document.getElementById("NewInvOrder_Date").value;}
	if(document.getElementById("NewInvCustomer_Order_Number")){NewInvCustomer_Order_Number = document.getElementById("NewInvCustomer_Order_Number").value;}
	if(document.getElementById("NewInvOrder_Number")){NewInvOrder_Number = document.getElementById("NewInvOrder_Number").value;}
	if(document.getElementById("NewInvTotal_GBP")){NewInvTotal_GBP = document.getElementById("NewInvTotal_GBP").value;}
	if(document.getElementById("NewInvTotal_VAT")){NewInvTotal_VAT = document.getElementById("NewInvTotal_VAT").value;}
	if(document.getElementById("NewInvCarriage_GBP")){NewInvCarriage_GBP = document.getElementById("NewInvCarriage_GBP").value;}
	if(document.getElementById("NewInvCarriage_VAT")){NewInvCarriage_VAT = document.getElementById("NewInvCarriage_VAT").value;}
	if(document.getElementById("NewInvDelivery")){NewInvDelivery = document.getElementById("NewInvDelivery").value;}
	if(document.getElementById("NewInvAddress1")){NewInvAddress1 = document.getElementById("NewInvAddress1").value;}
	if(document.getElementById("NewInvAddress2")){NewInvAddress2 = document.getElementById("NewInvAddress2").value;}
	if(document.getElementById("NewInvAddress3")){NewInvAddress3 = document.getElementById("NewInvAddress3").value;}
	if(document.getElementById("NewInvAddress4")){NewInvAddress4 = document.getElementById("NewInvAddress4").value;}
	if(document.getElementById("NewInvAddress5")){NewInvAddress5 = document.getElementById("NewInvAddress5").value;}
	if(document.getElementById("NewInvName")){NewInvName = document.getElementById("NewInvName").value;}
	if(document.getElementById("NewInvDelivery_Street1")){NewInvDelivery_Street1 = document.getElementById("NewInvDelivery_Street1").value;}
	if(document.getElementById("NewInvDelivery_Street2")){NewInvDelivery_Street2 = document.getElementById("NewInvDelivery_Street2").value;}
	if(document.getElementById("NewInvDelivery_Town")){NewInvDelivery_Town = document.getElementById("NewInvDelivery_Town").value;}
	if(document.getElementById("NewInvDelivery_County")){NewInvDelivery_County = document.getElementById("NewInvDelivery_County").value;}
	if(document.getElementById("NewInvDelivery_Post_Code")){NewInvDelivery_Post_Code = document.getElementById("NewInvDelivery_Post_Code").value;}			
	if(document.getElementById("NewInvCustomer_Tel_No")){NewInvCustomer_Tel_No = document.getElementById("NewInvCustomer_Tel_No").value;}
	if(document.getElementById("NewInvCustomer_Contact")){NewInvCustomer_Contact = document.getElementById("NewInvCustomer_Contact").value;}
	if(document.getElementById("NewInvNet_GBP")){NewInvNet_GBP = document.getElementById("NewInvNet_GBP").value;}
	if(document.getElementById("NewInvTax_Code")){NewInvTax_Code=document.getElementById('NewInvTax_Code').options[document.getElementById('NewInvTax_Code').selectedIndex].value; }
	if(document.getElementById("NewInvVAT_GBP")){NewInvVAT_GBP = document.getElementById("NewInvVAT_GBP").value;}
	if(document.getElementById("NewInvNC")){NewInvNC = document.getElementById("NewInvNC").value;}
	if(document.getElementById("NewInvGlobal_NC")){NewInvGlobal_NC = document.getElementById("NewInvGlobal_NC").value;}
	if(document.getElementById("NewInvGross_GBP")){NewInvGross_GBP = document.getElementById("NewInvGross_GBP").value;}
	if(document.getElementById("NewInvSet_Gross_GBP")){NewInvSet_Gross_GBP = document.getElementById("NewInvSet_Gross_GBP").value;}
	if(document.getElementById("NewInvDepartment")){NewInvDepartment = document.getElementById("NewInvDepartment").value;}
	if(document.getElementById("NewInvConsign_Number")){NewInvConsign_Number = document.getElementById("NewInvConsign_Number").value;}
	if(document.getElementById("NewInvCourier")){NewInvCourier = document.getElementById("NewInvCourier").value;}
	if(document.getElementById("NewInvDays")){NewInvDays = document.getElementById("NewInvDays").value;}
	if(document.getElementById("NewInvDiscount")){NewInvDiscount = document.getElementById("NewInvDiscount").value;}
	if(document.getElementById("NewInvAmount_GBP")){NewInvAmount_GBP = document.getElementById("NewInvAmount_GBP").value;}
	if(document.getElementById("NewInvSet_Total_GBP")){NewInvSet_Total_GBP = document.getElementById("NewInvSet_Total_GBP").value;}
	if(document.getElementById("NewInvDetails")){NewInvDetails = document.getElementById("NewInvDetails").value;}
	if(document.getElementById("NewInvPayment_Ref")){NewInvPayment_Ref = document.getElementById("NewInvPayment_Ref").value;}
	if(document.getElementById("NewInvBank_Account")){NewInvBank_Account = document.getElementById("NewInvBank_Account").value;}
	if(document.getElementById("NewInvPayment_Amount_GBP")){NewInvPayment_Amount_GBP = document.getElementById("NewInvPayment_Amount_GBP").value;}	
	showNewInvDataPage("OtherLoad");

}

function checkNewInvPageEdited(pagenum)
{
	var itemEle=null;
    for(var ic=pagenum; ic<gv_newInvDataCategory.length; ic++) {
		var attName=gv_newInvDataCategory[ic].attributes.getNamedItem("title");	
		if(attName==null) continue;
		var curNode=gv_newInvDataCategory[ic].firstChild;
		while( curNode ) 
		{
			var ndv=curNode.firstChild;
			var oldv=ndv?ndv.nodeValue:''
			var itemId=ic.toString()+"_"+curNode.nodeName;
			itemEle=document.getElementById(itemId);
			if(itemEle==null) break;
			var newv=itemEle.value;
			if(oldv!=newv) setEditNewInvData(itemId,newv);
			curNode=curNode.nextSibling;
		}
		if(itemEle==null) break;
    }
}
function setEditNewInvData(itemName,edValue)
{
	if(!gv_newInvEditedName) {
		gv_newInvEditedName=new Array();
		gv_newInvEditedValue=new Array();
	}
	for(var i=0; i<gv_newInvEditedName.length; i++){
		if(gv_newInvEditedName[i]==itemName) {	gv_newInvEditedValue[i]=edValue; return; }
	}
	gv_newInvEditedValue[gv_newInvEditedName.length]=edValue;	
	gv_newInvEditedName[gv_newInvEditedName.length]=itemName;
}
//return: edited string value, null if not edited
function getEditedNewInvData(itemName)
{
	if(!gv_newInvEditedName) return null;	
	for(var i=0; i<gv_newInvEditedName.length; i++) {
		if(gv_newInvEditedName[i]==itemName) return gv_newInvEditedValue[i];
	}
}

function newInvPageLeft()
{
	if(gv_scrollCurPage<=0) return;
    
   
	var selcat=document.getElementById('selnewinvcat');
	var selitemcat=document.getElementById('selnewinvitemcat');
	var divtab=document.getElementById('tempTable');
	var tleft=divtab.style.pixelLeft;

	if(tleft>=gv_winw-30) {	
		gv_scrollCurPage--;
		divtab.style.pixelLeft=0;
		if(selcat) { //Customer data
			if(gv_newInvEditingData==1) checkNewInvPageEdited(gv_scrollCurPage+1); //Save any edited data to memory
			selcat.selectedIndex=gv_scrollCurPage;
			if(document.getElementById("NewInvCustomer_ACRef")){NewInvCustomer_ACRef = document.getElementById("NewInvCustomer_ACRef").value;}
			if(document.getElementById("NewInvOrder_Type")){NewInvOrder_Type=document.getElementById('NewInvOrder_Type').options[document.getElementById('NewInvOrder_Type').selectedIndex].value; }
			if(document.getElementById("NewInvFormat")){NewInvFormat=document.getElementById('NewInvFormat').options[document.getElementById('NewInvFormat').selectedIndex].value; }
    		if(document.getElementById("NewInvOrder_Date")){NewInvOrder_Date = document.getElementById("NewInvOrder_Date").value;}
			if(document.getElementById("NewInvCustomer_Order_Number")){NewInvCustomer_Order_Number = document.getElementById("NewInvCustomer_Order_Number").value;}
			if(document.getElementById("NewInvOrder_Number")){NewInvOrder_Number = document.getElementById("NewInvOrder_Number").value;}
			if(document.getElementById("NewInvTotal_GBP")){NewInvTotal_GBP = document.getElementById("NewInvTotal_GBP").value;}
			if(document.getElementById("NewInvTotal_VAT")){NewInvTotal_VAT = document.getElementById("NewInvTotal_VAT").value;}
			if(document.getElementById("NewInvCarriage_GBP")){NewInvCarriage_GBP = document.getElementById("NewInvCarriage_GBP").value;}
			if(document.getElementById("NewInvCarriage_VAT")){NewInvCarriage_VAT = document.getElementById("NewInvCarriage_VAT").value;}
			if(document.getElementById("NewInvDelivery")){NewInvDelivery = document.getElementById("NewInvDelivery").value;}
						if(document.getElementById("NewInvAddress1")){NewInvAddress1 = document.getElementById("NewInvAddress1").value;}
			if(document.getElementById("NewInvAddress2")){NewInvAddress2 = document.getElementById("NewInvAddress2").value;}
			if(document.getElementById("NewInvAddress3")){NewInvAddress3 = document.getElementById("NewInvAddress3").value;}
			if(document.getElementById("NewInvAddress4")){NewInvAddress4 = document.getElementById("NewInvAddress4").value;}
			if(document.getElementById("NewInvAddress5")){NewInvAddress5 = document.getElementById("NewInvAddress5").value;}
			if(document.getElementById("NewInvName")){NewInvName = document.getElementById("NewInvName").value;}
			if(document.getElementById("NewInvDelivery_Street1")){NewInvDelivery_Street1 = document.getElementById("NewInvDelivery_Street1").value;}
			if(document.getElementById("NewInvDelivery_Street2")){NewInvDelivery_Street2 = document.getElementById("NewInvDelivery_Street2").value;}
			if(document.getElementById("NewInvDelivery_Town")){NewInvDelivery_Town = document.getElementById("NewInvDelivery_Town").value;}
			if(document.getElementById("NewInvDelivery_County")){NewInvDelivery_County = document.getElementById("NewInvDelivery_County").value;}
			if(document.getElementById("NewInvDelivery_Post_Code")){NewInvDelivery_Post_Code = document.getElementById("NewInvDelivery_Post_Code").value;}
			if(document.getElementById("NewInvCustomer_Tel_No")){NewInvCustomer_Tel_No = document.getElementById("NewInvCustomer_Tel_No").value;}
			if(document.getElementById("NewInvCustomer_Contact")){NewInvCustomer_Contact = document.getElementById("NewInvCustomer_Contact").value;}
			if(document.getElementById("NewInvNet_GBP")){NewInvNet_GBP = document.getElementById("NewInvNet_GBP").value;}
			if(document.getElementById("NewInvTax_Code")){NewInvTax_Code=document.getElementById('NewInvTax_Code').options[document.getElementById('NewInvTax_Code').selectedIndex].value; }
			if(document.getElementById("NewInvVAT_GBP")){NewInvVAT_GBP = document.getElementById("NewInvVAT_GBP").value;}
			if(document.getElementById("NewInvNC")){NewInvNC = document.getElementById("NewInvNC").value;}
			if(document.getElementById("NewInvGlobal_NC")){NewInvGlobal_NC = document.getElementById("NewInvGlobal_NC").value;}
			if(document.getElementById("NewInvGross_GBP")){NewInvGross_GBP = document.getElementById("NewInvGross_GBP").value;}
			if(document.getElementById("NewInvSet_Gross_GBP")){NewInvSet_Gross_GBP = document.getElementById("NewInvSet_Gross_GBP").value;}
			if(document.getElementById("NewInvDepartment")){NewInvDepartment = document.getElementById("NewInvDepartment").value;}
			if(document.getElementById("NewInvConsign_Number")){NewInvConsign_Number = document.getElementById("NewInvConsign_Number").value;}
			if(document.getElementById("NewInvCourier")){NewInvCourier = document.getElementById("NewInvCourier").value;}
			if(document.getElementById("NewInvDays")){NewInvDays = document.getElementById("NewInvDays").value;}
			if(document.getElementById("NewInvDiscount")){NewInvDiscount = document.getElementById("NewInvDiscount").value;}
			if(document.getElementById("NewInvAmount_GBP")){NewInvAmount_GBP = document.getElementById("NewInvAmount_GBP").value;}
			if(document.getElementById("NewInvSet_Total_GBP")){NewInvSet_Total_GBP = document.getElementById("NewInvSet_Total_GBP").value;}
			if(document.getElementById("NewInvDetails")){NewInvDetails = document.getElementById("NewInvDetails").value;}
			if(document.getElementById("NewInvPayment_Ref")){NewInvPayment_Ref = document.getElementById("NewInvPayment_Ref").value;}
			if(document.getElementById("NewInvBank_Account")){NewInvBank_Account = document.getElementById("NewInvBank_Account").value;}
			if(document.getElementById("NewInvPayment_Amount_GBP")){NewInvPayment_Amount_GBP = document.getElementById("NewInvPayment_Amount_GBP").value;}

			showNewInvDataPage("OtherLoad");
		}
		else if(selitemcat)
		{
		 if(gv_newInvItemEditingData==1) checkNewInvItemPageEdited(gv_scrollCurPage+1); //Save any edited data to memory
			selitemcat.selectedIndex=gv_scrollCurPage;
			showNewInvItemDataPage("NewInvItemOtherLoad");
		}
		else
		 { //customer list
			gv_newInvCurPage=gv_scrollCurPage;		
			gv_newInvIndex=0;
			NewInviPage--;
			if(NewInviPage < 1)
			{
			    NewInviPage = 1;
			    return;
			}
			NewInvListPD = 1;
			NewInvListCurPage = gv_newInvCurPage;
            NewInvListTotPage = gv_newInvTotPage;
			doNewInvList();
		}
	}
	else {
		divtab.style.pixelLeft=tleft+30;
		setTimeout("newInvPageLeft();",75);
	}
}
 
function newInvPageRight()
{
         

	if(gv_scrollCurPage>=gv_scrollTotPage-1) return;

	var selcat=document.getElementById('selnewinvcat'); //If null, then in Customer List.
	var selitemcat=document.getElementById('selnewinvitemcat');
	var divtab=document.getElementById('tempTable');
	var tleft=divtab.style.pixelLeft;
	if(tleft<30-gv_winw) {	
		gv_scrollCurPage++;
		divtab.style.pixelLeft=0;
		if(selcat) { //Customer data
			selcat.selectedIndex=gv_scrollCurPage;
			if(document.getElementById("NewInvCustomer_ACRef")){NewInvCustomer_ACRef = document.getElementById("NewInvCustomer_ACRef").value;}
			if(document.getElementById("NewInvOrder_Type")){NewInvOrder_Type=document.getElementById('NewInvOrder_Type').options[document.getElementById('NewInvOrder_Type').selectedIndex].value; }
			if(document.getElementById("NewInvFormat")){NewInvFormat=document.getElementById('NewInvFormat').options[document.getElementById('NewInvFormat').selectedIndex].value; }
    		if(document.getElementById("NewInvOrder_Date")){NewInvOrder_Date = document.getElementById("NewInvOrder_Date").value;}
			if(document.getElementById("NewInvCustomer_Order_Number")){NewInvCustomer_Order_Number = document.getElementById("NewInvCustomer_Order_Number").value;}
			if(document.getElementById("NewInvOrder_Number")){NewInvOrder_Number = document.getElementById("NewInvOrder_Number").value;}
			if(document.getElementById("NewInvTotal_GBP")){NewInvTotal_GBP = document.getElementById("NewInvTotal_GBP").value;}
			if(document.getElementById("NewInvTotal_VAT")){NewInvTotal_VAT = document.getElementById("NewInvTotal_VAT").value;}
			if(document.getElementById("NewInvCarriage_GBP")){NewInvCarriage_GBP = document.getElementById("NewInvCarriage_GBP").value;}
			if(document.getElementById("NewInvCarriage_VAT")){NewInvCarriage_VAT = document.getElementById("NewInvCarriage_VAT").value;}
			if(document.getElementById("NewInvDelivery")){NewInvDelivery = document.getElementById("NewInvDelivery").value;}
						if(document.getElementById("NewInvAddress1")){NewInvAddress1 = document.getElementById("NewInvAddress1").value;}
			if(document.getElementById("NewInvAddress2")){NewInvAddress2 = document.getElementById("NewInvAddress2").value;}
			if(document.getElementById("NewInvAddress3")){NewInvAddress3 = document.getElementById("NewInvAddress3").value;}
			if(document.getElementById("NewInvAddress4")){NewInvAddress4 = document.getElementById("NewInvAddress4").value;}
			if(document.getElementById("NewInvAddress5")){NewInvAddress5 = document.getElementById("NewInvAddress5").value;}
			if(document.getElementById("NewInvName")){NewInvName = document.getElementById("NewInvName").value;}
			if(document.getElementById("NewInvDelivery_Street1")){NewInvDelivery_Street1 = document.getElementById("NewInvDelivery_Street1").value;}
			if(document.getElementById("NewInvDelivery_Street2")){NewInvDelivery_Street2 = document.getElementById("NewInvDelivery_Street2").value;}
			if(document.getElementById("NewInvDelivery_Town")){NewInvDelivery_Town = document.getElementById("NewInvDelivery_Town").value;}
			if(document.getElementById("NewInvDelivery_County")){NewInvDelivery_County = document.getElementById("NewInvDelivery_County").value;}
			if(document.getElementById("NewInvDelivery_Post_Code")){NewInvDelivery_Post_Code = document.getElementById("NewInvDelivery_Post_Code").value;}			
			if(document.getElementById("NewInvCustomer_Tel_No")){NewInvCustomer_Tel_No = document.getElementById("NewInvCustomer_Tel_No").value;}
			if(document.getElementById("NewInvCustomer_Contact")){NewInvCustomer_Contact = document.getElementById("NewInvCustomer_Contact").value;}
			if(document.getElementById("NewInvNet_GBP")){NewInvNet_GBP = document.getElementById("NewInvNet_GBP").value;}
			if(document.getElementById("NewInvTax_Code")){NewInvTax_Code=document.getElementById('NewInvTax_Code').options[document.getElementById('NewInvTax_Code').selectedIndex].value; }
			if(document.getElementById("NewInvVAT_GBP")){NewInvVAT_GBP = document.getElementById("NewInvVAT_GBP").value;}
			if(document.getElementById("NewInvNC")){NewInvNC = document.getElementById("NewInvNC").value;}
			if(document.getElementById("NewInvGlobal_NC")){NewInvGlobal_NC = document.getElementById("NewInvGlobal_NC").value;}
			if(document.getElementById("NewInvGross_GBP")){NewInvGross_GBP = document.getElementById("NewInvGross_GBP").value;}
			if(document.getElementById("NewInvSet_Gross_GBP")){NewInvSet_Gross_GBP = document.getElementById("NewInvSet_Gross_GBP").value;}
			if(document.getElementById("NewInvDepartment")){NewInvDepartment = document.getElementById("NewInvDepartment").value;}
			if(document.getElementById("NewInvConsign_Number")){NewInvConsign_Number = document.getElementById("NewInvConsign_Number").value;}
			if(document.getElementById("NewInvCourier")){NewInvCourier = document.getElementById("NewInvCourier").value;}
			if(document.getElementById("NewInvDays")){NewInvDays = document.getElementById("NewInvDays").value;}
			if(document.getElementById("NewInvDiscount")){NewInvDiscount = document.getElementById("NewInvDiscount").value;}
			if(document.getElementById("NewInvAmount_GBP")){NewInvAmount_GBP = document.getElementById("NewInvAmount_GBP").value;}
			if(document.getElementById("NewInvSet_Total_GBP")){NewInvSet_Total_GBP = document.getElementById("NewInvSet_Total_GBP").value;}
			if(document.getElementById("NewInvDetails")){NewInvDetails = document.getElementById("NewInvDetails").value;}
			if(document.getElementById("NewInvPayment_Ref")){NewInvPayment_Ref = document.getElementById("NewInvPayment_Ref").value;}
			if(document.getElementById("NewInvBank_Account")){NewInvBank_Account = document.getElementById("NewInvBank_Account").value;}
			if(document.getElementById("NewInvPayment_Amount_GBP")){NewInvPayment_Amount_GBP = document.getElementById("NewInvPayment_Amount_GBP").value;}
			showNewInvDataPage("OtherLoad");			
		}
		else if(selitemcat)
		{
		 if(gv_newInvItemEditingData==1) checkNewInvItemPageEdited(gv_scrollCurPage+1); //Save any edited data to memory
			selitemcat.selectedIndex=gv_scrollCurPage;
			showNewInvItemDataPage("NewInvItemOtherLoad");
		}
		
		
		else { //customer list
		gv_newInvCurPage=gv_scrollCurPage;		
			gv_newInvIndex=0;
	        NewInviPage++;
			if(NewInviPage > NewInvTotalPage)
			{
			    NewInviPage = NewInvTotalPage;
			    return;
			}
			NewInvListPD = 1;
			NewInvListCurPage = gv_newInvCurPage;
            NewInvListTotPage = gv_newInvTotPage;
			doNewInvList();
		}
	}
	else
	 {
		divtab.style.pixelLeft=tleft-30;
	
		  setTimeout("newInvPageRight();",75);
	 }
}


function setNewInvPageScrollCommands(Cmd1,Cmd2)
{
	document.getElementById('sopbtn1').innerHTML=Cmd1;
	document.getElementById('sopbtn2').innerHTML=Cmd2;
	var newinvcmd=document.getElementById('sopCmds').style;
	var ncmds=Cmd1.length<5 ? 0:1;
	if(Cmd2.length>5) ncmds++;
	newinvcmd.pixelWidth=150+50*ncmds;
	newinvcmd.pixelLeft=gv_winw-newinvcmd.pixelWidth-1;
}

function showSaveNewInvDataButton()
{
	if(document.getElementById('savenewinvdata')) return;

	setNewInvPageScrollCommands("<input type='button' id='savenewinvdata' value='Save' onclick='saveNewInvData();' />","");
}

var strNewInvItem = "";
var InvHiddenField="<input type='hidden' name='InvHiddenField' id='InvHiddenField' value=''>";

function ButtonNewInvItem_onclick()
{
  var charSplitChar = ",";
  strNewInvItem += NewInvItemProduct_Code +charSplitChar;
  strNewInvItem += NewInvItemDescription +charSplitChar;
  strNewInvItem += NewInvItemUnits +charSplitChar;
  strNewInvItem += NewInvItemComment1 +charSplitChar;
  strNewInvItem += NewInvItemComment2 +charSplitChar;
  strNewInvItem += NewInvItemOrder_Reference +charSplitChar;
  strNewInvItem += NewInvItemOrder_Line_Reference +charSplitChar;
  strNewInvItem += NewInvItemQuantity +charSplitChar;
  strNewInvItem += NewInvItemUnit_Price_GBP +charSplitChar;
  strNewInvItem += NewInvItemDiscount +charSplitChar;
  strNewInvItem += NewInvItemDiscount_GBP +charSplitChar;
  strNewInvItem += NewInvItemNet_GBP +charSplitChar;
  strNewInvItem += NewInvItemVAT_GBP +charSplitChar;
  strNewInvItem += NewInvItemNominal_Code +charSplitChar;
  strNewInvItem += NewInvItemTax_Code +charSplitChar;
  strNewInvItem += NewInvItemDepartment +charSplitChar;
  strNewInvItem += NewInvItemLine_Information +charSplitChar;
  strNewInvItem += NewInvItemAllocated +charSplitChar;
  strNewInvItem += NewInvItemDespatched +charSplitChar;
  strNewInvItem += NewInvItemTo_Deliver +charSplitChar;
  strNewInvItem += NewInvItemIntrastat +charSplitChar;
  strNewInvItem += NewInvItemDue_Date;
  strNewInvItem += "|,|";
 document.getElementById('InvHiddenField').value =strNewInvItem;
}
          var ItemInvProduct_Code, ItemInvDescription, ItemInvUnits, ItemInvComment1, ItemInvComment2, ItemInvOrder_Reference, ItemInvOrder_Line_Reference;
         var ItemInvQuantity, ItemInvUnit_Price_GBP, ItemInvDiscount, ItemInvDiscount_GBP, ItemInvNet_GBP, ItemInvVAT_GBP, ItemInvNominal_Code, ItemInvTax_Code; 
         var ItemInvDepartment,ItemInvLineInformation, ItemInvAllocated, ItemInvDespatched, ItemInvTo_Deliver, ItemInvIntrastat, ItemInvDue_Date;
    
    function ContactsNewInvItemData(strData)
    {
        
        var arrTemp = strData.split(",");
        ItemInvProduct_Code = arrTemp[0];
        ItemInvDescription = arrTemp[1];
        ItemInvUnits = arrTemp[2];
        ItemInvComment1 = arrTemp[3];
        ItemInvComment2 = arrTemp[4];
        ItemInvOrder_Reference = arrTemp[5];
        ItemInvOrder_Line_Reference = arrTemp[6];
        ItemInvQuantity = arrTemp[7];
        ItemInvUnit_Price_GBP = arrTemp[8];
        ItemInvDiscount = arrTemp[9];
        ItemInvDiscount_GBP = arrTemp[10];
        ItemInvNet_GBP = arrTemp[11];
        ItemInvVAT_GBP = arrTemp[12];
        ItemInvNominal_Code = arrTemp[13];
        ItemInvTax_Code = arrTemp[14];
        ItemInvDepartment = arrTemp[15];
        ItemInvLineInformation = arrTemp[16];
        ItemInvAllocated = arrTemp[17];
        ItemInvDespatched = arrTemp[18];
        ItemInvTo_Deliver = arrTemp[19];
        ItemInvIntrastat = arrTemp[20];
        ItemInvDue_Date = arrTemp[21];
    }
   var NewInvItemDDVal = "";
     function showNewInvCount()
    {
        var  strItems = document.getElementById('InvHiddenField').value;
        var arrItems = strItems.split("|,|");
        var SInvNet_GBP = 0, SInvVAT_GBP= 0;
        addNewInvDropDownValue = "";
        for (var i = 0; i < arrItems.length - 1; i++)
        {  
         ContactsNewInvItemData(arrItems[i]);
         var num = arrItems.length - 1;
         var j = i + 1;
         NewInvItemDDVal = j + ' ' + 'of' + ' '+ num;
         addNewInvDropDownValue += "<option>"+NewInvItemDDVal+"</option>";
         if(ItemInvNet_GBP == "") {ItemInvNet_GBP= "0";}
         if(ItemInvVAT_GBP == "") {ItemInvVAT_GBP = "0";}
         SInvNet_GBP += parseFloat(ItemInvNet_GBP);
         SInvVAT_GBP += parseFloat(ItemInvVAT_GBP);
        }
         NewInvTotal_GBP = SInvNet_GBP;
         NewInvTotal_VAT = SInvVAT_GBP;
         NewInvGross_GBP = SInvNet_GBP + SInvVAT_GBP;
        
    }

 
function saveNewInvData()
{
	//checkNewInvPageEdited(gv_scrollCurPage);
	if(document.getElementById("NewInvCustomer_ACRef")){NewInvCustomer_ACRef = document.getElementById("NewInvCustomer_ACRef").value;}
	if(document.getElementById("NewInvOrder_Type")){NewInvOrder_Type=document.getElementById('NewInvOrder_Type').options[document.getElementById('NewInvOrder_Type').selectedIndex].value; }
	if(document.getElementById("NewInvFormat")){NewInvFormat=document.getElementById('NewInvFormat').options[document.getElementById('NewInvFormat').selectedIndex].value; }
    if(document.getElementById("NewInvOrder_Date")){NewInvOrder_Date = document.getElementById("NewInvOrder_Date").value;}
	if(document.getElementById("NewInvCustomer_Order_Number")){NewInvCustomer_Order_Number = document.getElementById("NewInvCustomer_Order_Number").value;}
	if(document.getElementById("NewInvOrder_Number")){NewInvOrder_Number = document.getElementById("NewInvOrder_Number").value;}
	if(document.getElementById("NewInvTotal_GBP")){NewInvTotal_GBP = document.getElementById("NewInvTotal_GBP").value;}
	if(document.getElementById("NewInvTotal_VAT")){NewInvTotal_VAT = document.getElementById("NewInvTotal_VAT").value;}
	if(document.getElementById("NewInvCarriage_GBP")){NewInvCarriage_GBP = document.getElementById("NewInvCarriage_GBP").value;}
	if(document.getElementById("NewInvCarriage_VAT")){NewInvCarriage_VAT = document.getElementById("NewInvCarriage_VAT").value;}
	if(document.getElementById("NewInvDelivery")){NewInvDelivery = document.getElementById("NewInvDelivery").value;}
	if(document.getElementById("NewInvAddress1")){NewInvAddress1 = document.getElementById("NewInvAddress1").value;}
	if(document.getElementById("NewInvAddress2")){NewInvAddress2 = document.getElementById("NewInvAddress2").value;}
	if(document.getElementById("NewInvAddress3")){NewInvAddress3 = document.getElementById("NewInvAddress3").value;}
	if(document.getElementById("NewInvAddress4")){NewInvAddress4 = document.getElementById("NewInvAddress4").value;}
	if(document.getElementById("NewInvAddress5")){NewInvAddress5 = document.getElementById("NewInvAddress5").value;}
	if(document.getElementById("NewInvName")){NewInvName = document.getElementById("NewInvName").value;}
	if(document.getElementById("NewInvDelivery_Street1")){NewInvDelivery_Street1 = document.getElementById("NewInvDelivery_Street1").value;}
	if(document.getElementById("NewInvDelivery_Street2")){NewInvDelivery_Street2 = document.getElementById("NewInvDelivery_Street2").value;}
	if(document.getElementById("NewInvDelivery_Town")){NewInvDelivery_Town = document.getElementById("NewInvDelivery_Town").value;}
	if(document.getElementById("NewInvDelivery_County")){NewInvDelivery_County = document.getElementById("NewInvDelivery_County").value;}
	if(document.getElementById("NewInvDelivery_Post_Code")){NewInvDelivery_Post_Code = document.getElementById("NewInvDelivery_Post_Code").value;}
	if(document.getElementById("NewInvCustomer_Tel_No")){NewInvCustomer_Tel_No = document.getElementById("NewInvCustomer_Tel_No").value;}
	if(document.getElementById("NewInvCustomer_Contact")){NewInvCustomer_Contact = document.getElementById("NewInvCustomer_Contact").value;}
	if(document.getElementById("NewInvNet_GBP")){NewInvNet_GBP = document.getElementById("NewInvNet_GBP").value;}
	if(document.getElementById("NewInvTax_Code")){NewInvTax_Code=document.getElementById('NewInvTax_Code').options[document.getElementById('NewInvTax_Code').selectedIndex].value; }
	if(document.getElementById("NewInvVAT_GBP")){NewInvVAT_GBP = document.getElementById("NewInvVAT_GBP").value;}
	if(document.getElementById("NewInvNC")){NewInvNC = document.getElementById("NewInvNC").value;}
	if(document.getElementById("NewInvGlobal_NC")){NewInvGlobal_NC = document.getElementById("NewInvGlobal_NC").value;}
	if(document.getElementById("NewInvGross_GBP")){NewInvGross_GBP = document.getElementById("NewInvGross_GBP").value;}
	if(document.getElementById("NewInvSet_Gross_GBP")){NewInvSet_Gross_GBP = document.getElementById("NewInvSet_Gross_GBP").value;}
	if(document.getElementById("NewInvDepartment")){NewInvDepartment = document.getElementById("NewInvDepartment").value;}
	if(document.getElementById("NewInvConsign_Number")){NewInvConsign_Number = document.getElementById("NewInvConsign_Number").value;}
	if(document.getElementById("NewInvCourier")){NewInvCourier = document.getElementById("NewInvCourier").value;}
	if(document.getElementById("NewInvDays")){NewInvDays = document.getElementById("NewInvDays").value;}
	if(document.getElementById("NewInvDiscount")){NewInvDiscount = document.getElementById("NewInvDiscount").value;}
	if(document.getElementById("NewInvAmount_GBP")){NewInvAmount_GBP = document.getElementById("NewInvAmount_GBP").value;}
	if(document.getElementById("NewInvSet_Total_GBP")){NewInvSet_Total_GBP = document.getElementById("NewInvSet_Total_GBP").value;}
	if(document.getElementById("NewInvDetails")){NewInvDetails = document.getElementById("NewInvDetails").value;}
	if(document.getElementById("NewInvPayment_Ref")){NewInvPayment_Ref = document.getElementById("NewInvPayment_Ref").value;}
	if(document.getElementById("NewInvBank_Account")){NewInvBank_Account = document.getElementById("NewInvBank_Account").value;}
	if(document.getElementById("NewInvPayment_Amount_GBP")){NewInvPayment_Amount_GBP = document.getElementById("NewInvPayment_Amount_GBP").value;}
    NewInvTax_Code = NewInvTax_Code.slice(1,3).replace(/(\s*$)/g,"");
    NewInvDepartment = NewInvDepartment.slice(0,2).replace(/(\s*$)/g,"");
    NewInvGlobal_Tax_Code = NewInvGlobal_Tax_Code.slice(1,3).replace(/(\s*$)/g,"");
    NewInvGlobal_Department = NewInvGlobal_Department.slice(0,2).replace(/(\s*$)/g,"");
    NewInvCourier = NewInvCourier.slice(0,2).replace(/(\s*$)/g,"");
//    NewSopBank_Account = NewSopTax_Code.slice(1,3).replace(/(\s*$)/g,"");
    if(NewInvCustomer_ACRef == "" && NewInvItemDDVal != "")
    {
        alert("Please select account reference of customer!");
        //showNewInvDataPage("OtherLoad");
        return;
    }
    if(NewInvCustomer_ACRef != "" && NewInvItemDDVal == "")
    {
        alert("Please Add Item For Sales Order!");
        //showNewInvDataPage("OtherLoad");
        return;
    }
    if(NewInvCustomer_ACRef == "" && NewInvItemDDVal == "")
    {
        alert("Please select account reference of customer and add item for sales order! ");
        //showNewInvDataPage("OtherLoad");
        return;
    }
    var InvHiddenValue = document.getElementById("InvHiddenField").value;
    var ACIndex=gv_newInvCurPage*10+gv_newInvIndex;

	var url=gv_rooturl+"?cmd=SaveNewInvData&AC="+gv_newInvAC[gv_newInvIndex]+"&index="+ACIndex;

         url+="&NewInvHiddenValue="+InvHiddenValue+"&0_Customer_ACRef="+NewInvCustomer_ACRef+"&0_Order_Type="+NewInvOrder_Type+"&0_Format="+NewInvFormat+"&0_Order_Date="+NewInvOrder_Date+"&0_Customer_Order_Number="+NewInvCustomer_Order_Number+"&0_Order_Number="+NewInvOrder_Number+"&1_Total_GBP="+NewInvTotal_GBP+"&1_Total_VAT="+NewInvTotal_VAT+"&1_Carriage_GBP="+NewInvCarriage_GBP+"&1_Carriage_VAT="+NewInvCarriage_VAT+"&1_Gross_GBP="+NewInvGross_GBP+"&2_Delivery="+NewInvDelivery+"&2_Address1="+NewInvAddress1+"&2_Address2="+NewInvAddress2+"&2_Address3="+NewInvAddress3+"&2_Address4="+NewInvAddress4+"&2_Address5="+NewInvAddress5+"&2_Name="+NewInvName+"&2_Delivery_Street1="+NewInvDelivery_Street1+"&2_Delivery_Street2="+NewInvDelivery_Street2+"&2_Delivery_Town="+NewInvDelivery_Town+"&2_Delivery_County="+NewInvDelivery_County+"&2_Delivery_Post_Code="+NewInvDelivery_Post_Code+"&2_Customer_Tel_No="+NewInvCustomer_Tel_No+"&2_Customer_Contact="+NewInvCustomer_Contact+"&3_Net_GBP="+NewInvNet_GBP+"&3_Tax_Code="+NewInvTax_Code+"&3_VAT_GBP="+NewInvVAT_GBP+"&3_NC="+NewInvNC+"&3_Gross_GBP="+NewInvGross_GBP+"&3_Department="+NewInvDepartment+"&3_Consign_Number="+NewInvConsign_Number+"&3_Courier="+NewInvCourier+"&4_Days="+NewInvDays+"&4_Discount="+NewInvDiscount+"&4_Amount_GBP="+NewInvAmount_GBP+"&4_Total_GBP="+NewInvTotal_GBP+"&5_NC="+NewInvGlobal_NC+"&5_Details="+NewInvDetails+"&5_Tax_Code="+NewInvGlobal_Tax_Code+"&5_Department="+NewInvGlobal_Department+"&6_Payment_Ref="+NewInvPayment_Ref+"&6_Bank_Account="+NewInvBank_Account+"&6_Payment_Amount_GBP="+NewInvPayment_Amount_GBP;
var xmlhttp = newHttpRequest(url,true);
	if( xmlhttp==null ) return;
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4 ) {
			if( xmlhttp.status!=200 ) alert("Connection error");
			else if(xmlhttp.responseText=='1') {
				alert("Data saved OK.");
				gv_newInvEditedName=null;
		        gv_newInvEditedValue=null;
		        document.getElementById('savenewinvdata').style.visibility = "hidden";
                NewInvOrder_Date = getNewInvSysTime();
                NewInvCustomer_ACRef="",NewInvDelivery="", NewInvOrder_Type='',NewInvFormat='',NewInvCustomer_Order_Number='',NewInvOrder_Number='<AutoNumber>',NewInvTotal_GBP='',NewInvTotal_VAT='',NewInvCarriage_GBP='';
                NewInvCarriage_VAT='',NewInvGross_GBP='',NewInvCustomer_Tel_No='',NewInvCustomer_Contact='',NewInvNet_GBP='',NewInvTax_Code='',NewInvVAT_GBP='',NewInvNC='',NewInvDepartment='',NewInvConsign_Number='';
                NewInvCourier='',NewInvDays='',NewInvDiscount='',NewInvAmount_GBP='',NewInvTotal_GBP='',NewInvDetails='',NewInvPayment_Ref='',NewInvBank_Account='';
                NewInvPayment_Amount_GBP='',NewInvAddress1="",NewInvAddress2="",NewInvAddress3="",NewInvAddress4="",NewInvAddress5="",NewInvName="",NewInvDelivery_Street1='',NewInvDelivery_Street2='';
                NewInvDelivery_Town='',NewInvDelivery_County='',NewInvDelivery_Post_Code="",NewInvSet_Gross_GBP = '',NewInvSet_Total_GBP='';
                NewInvGlobal_Tax_Code = "";NewInvGlobal_Department = "";NewInvGlobal_NC = "";
		    	backSops();
		    	//strNewInvItem = "";  
		    	//addNewInvDropDownValue = "";   
			}
			else alert("Server error!");
			document.getElementById('idloading').style.visibility='hidden';
			document.getElementById('idSaving').style.visibility='hidden';
		}
	}
	xmlhttp.send(null);
	document.getElementById('idloading').style.visibility='visible';
	document.getElementById('idSaving').style.visibility='visible';	
	
}



