﻿var gv_newPopItemAC=new Array();
var gv_newPopItemName=new Array();
var gv_scrollCurPage=0;
var gv_scrollTotPage=0;
var gv_newPopItemEditingData=0;
var gv_newPopItemRowH=20;
var gv_newPopItemEditedName=null;
var gv_newPopItemCurPage=0; 
var gv_newPopItemTotPage=0; 

var gv_newPopItemEditedValue=null;
var gv_newPopItemFocusIndex=0; 
var gv_newPopItemNumPerPage=0;
var gv_newPopItemIndex=0;
var NewPopItemPartCode = "";
var NewPopItemiPage = 1;
var NewPopItemTotalPage = 1;
var NewPopItemListPD = 0;//pan duan showNewPopItemList(1);
function doNewPopItemList()
{
    if(document.getElementById('NewPopItemProduct_Code')){ NewPopItemPartCode = document.getElementById('NewPopItemProduct_Code').value;}
	var url = gv_rooturl+"?cmd=NewPopItemList"+"&NewPopItemPartCode="+NewPopItemPartCode+"&NewPopItemiPage="+NewPopItemiPage;
	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 newpopitemtotalpages=xmlhttp.responseXML.getElementsByTagName("NewPopItemTotalPage");
                NewPopItemTotalPage = parseInt(newpopitemtotalpages[0].firstChild.nodeValue);			    
                renewNewPopItemList(xmlhttp.responseXML);
			}
			document.getElementById('idloading').style.visibility='hidden';
			
		}
	}
	xmlhttp.send(null);
	document.getElementById('idloading').style.visibility='visible';
}


function renewNewPopItemList(xmldoc)
{
	var products=xmldoc.getElementsByTagName("NewPopItem");
//	var hidden=document.getElementById('popCmds');
	gv_newPopItemAC.length=gv_newPopItemName.length=0;
	gv_newPopItemIndex=0;
	
    for(var i=0; i<products.length; i++) {
		var curNode=products[i].firstChild;
		gv_newPopItemAC[i]=gv_newPopItemName[i]="";
		while( curNode ) 
		{
			switch(curNode.nodeName){
				case "ProductCode" : gv_newPopItemAC[i]=curNode.firstChild.nodeValue;  break;
				case "Name" : gv_newPopItemName[i]=curNode.firstChild.nodeValue;  break;
			}
			curNode=curNode.nextSibling;
			
		}
    }
    if(products.length==0) alert("No New Pop Item found!");
    else {
		gv_newPopItemTotPage=0;
		showNewPopItemList(0);
//		hidden.style.visibility='hidden';
		
	}
}


function showNewPopItemList(NewPopItemStatus)
{
    if(NewPopItemStatus == 0)
    {
      gv_newPopItemCurPage=0; 
      gv_newPopItemTotPage=0; 
    }
    else if(NewPopItemStatus == 1)
    {}
    if(NewPopItemListPD == 1)
    {
        gv_newPopItemCurPage = NewPopItemListCurPage;
        gv_newPopItemTotPage = NewPopItemListTotPage;
    }
    NewPopItemListPD = 0;
	if(gv_newPopItemAC.length==0) return;
    gv_tempTable = document.getElementById('tempTable');
	var ycur=gv_tempTable.style.pixelTop=gv_device==Nokia ? 28:26;
	var tdstr="<td height='"+gv_newPopItemRowH+"px'>";
	var tabstr="<table border='1' cellpadding='1' cellspacing='0' style='position:absolute;width:"+(gv_winw-4)+"px;left:2px;'>"; 
	//var ixs=gv_newPopItemCurPage*gv_newPopItemNumPerPage;
	var idx=0;
    for(var i=0; i<gv_newPopItemAC.length; i++) {
		var imgName=idx==gv_newPopItemIndex ? 'radon.png':'radoff.png';
		var trColor=idx==gv_newPopItemIndex ? '#ffcc00':'#add8e6';
		var radstr="<td width='22px' height='"+gv_newPopItemRowH+"px'><input type='image' src='img/"+imgName+
			"' id='newpopitem_img"+idx+"' onclick='newPopItemRowClicked(event);'";
		if(gv_device==Nokia) radstr+="onfocus='overNewPopItemItem(event);' onblur='leavNewPopItemItem(event);'></td>";
		else radstr+="onmouseover='overNewPopItemItem(event);' onmouseleave='leavNewPopItemItem(event);'></td>";
		tabstr+="<tr id='newpopitem_row"+idx+"' onclick='newPopItemRowClicked(event);' style='background-color:"+
			trColor+";'>"+radstr + tdstr+gv_newPopItemAC[i]+"</td>"+tdstr+gv_newPopItemName[i]+"</td></tr>";
		//ycur+=gv_newPopItemRowH;
		//if(ycur+45>gv_winh) break; else 
		idx++;
    }
//    if(gv_newPopItemTotPage==0) {
//		gv_scrollCurPage=gv_newPopItemCurPage=0;
//		gv_newPopItemNumPerPage=i;
//		var ntt=gv_newPopItemAC.length;
//		gv_newPopItemTotPage=0;
//		while(ntt>0) {gv_newPopItemTotPage++; ntt-=gv_newPopItemNumPerPage; }
		gv_scrollTotPage=NewPopItemTotalPage;
		if(gv_device!=Nokia) {
			var mleft=document.getElementById('img_mleft4');
			mleft.onclick=newPopItemPageLeft;
			mleft.style.cursor='hand';
			var mright=document.getElementById('img_mright4');
			mright.onclick=newPopItemPageRight;
			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_newPopItemFocusIndex=gv_newPopItemIndex;
	
    var newpopitemcmd= document.getElementById('popCmds');
	newpopitemcmd .style.pixelLeft=gv_winw-newpopitemcmd .style.pixelWidth-1;
	newpopitemcmd.style.pixelTop = gv_winh-29;
    newpopitemcmd.style.visibility='visible';
    if(gv_device!=Nokia) {
		var btn1=document.getElementById('btnNewPopItemOk');
		if(btn1==null) setNewPopItemPageScrollCommands(
			"<input type='button' id='btnNewPopItemOk' value='OK' onclick='editNewPopItemDetail();'/>",
			"<input type='button' id='btnNewPopItemDetail' value='OK' onclick='editNewPopItemDetail();' />");
			document.getElementById('btnNewPopItemDetail').style.visibility='hidden';
	     }
	setNewPopItemPageScroll();
	doNokiaMenuNewPopItemList();    
}

//function setNewPopItemProPageScroll()
//{
//    var pncur=document.getElementById('pn_cur2');
//    pncur.innerHTML='Page '+(gv_scrollCurPage+1)+' of '+gv_scrollTotPage;
//    var pnleft=document.getElementById('pn_left2');
//    pnleft.innerHTML=gv_scrollCurPage>0 ? gv_scrollCurPage.toString():'';
//    var pnright=document.getElementById('pn_right2');
//    pnright.innerHTML=gv_scrollCurPage<gv_scrollTotPage-1 ? (gv_scrollCurPage+2).toString():'';    
//}


function newPopItemRowClicked(ee)
{
	var srcele=getEventObject(ee);
	if(srcele.id.length<8) return;
	var newIndex=parseInt(srcele.id.substring(14));
	if(gv_newPopItemIndex==newIndex) return;
	document.getElementById('newpopitem_row'+gv_newPopItemIndex).style.backgroundColor='#add8e6';
	document.getElementById('newpopitem_img'+gv_newPopItemIndex).src='img/radoff.png';
	document.getElementById('newpopitem_row'+newIndex).style.backgroundColor='#ffcc00';
	document.getElementById('newpopitem_img'+newIndex).src='img/radon.png';
	gv_newPopItemIndex=newIndex;
}
function overNewPopItemItem(e_event)
{
	var srcobj=getEventObject(e_event);
	if(srcobj.id=='newpopitem_img'+gv_newPopItemIndex) return; // Entering the current selection
	srcobj.src="img/radover.png";
}
function leavNewPopItemItem(e_event)
{
	var srcobj=getEventObject(e_event);
	if(srcobj.id=='newpopitem_img'+gv_newPopItemIndex) return; // Leaving the current selection
	srcobj.src="img/radoff.png";
}

function doNokiaMenuNewPopItemList()
{
	if(window.widget) {
		window.menu.clear();
		var mShow = new MenuItem('OK',2102);
		mShow.onSelect=editNewPopItemDetail;
		window.menu.append(mShow);

	}
}


function getNewPopItemDetail()
{
	var ACIndex=gv_newPopItemCurPage*gv_newPopItemNumPerPage+gv_newPopItemIndex;
	var url = gv_rooturl+"?cmd=NewPopItemDetail&ProductCode="+gv_newPopItemAC[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_newPopItemDataCategory=xmlhttp.responseXML.getElementsByTagName("DataCategory");
				if(gv_newPopItemDataCategory.length==0) alert("Cannot load details!");
				else {
					gv_scrollCurPage=0;
					gv_scrollTotPage=gv_newPopItemDataCategory.length;
//					document.getElementById('proCmds').style.visibility='hidden';
//                    document.getElementById('saveNewPopItemData').style.visibility = "visible";
                    setNewPopItemPageScrollCommands("<input type='button' id='saveNewPopItemData' value='Save' onclick='saveNewPopItemData();'/>","");//Show save before get stock list.
					showNewPopItemDataPage("Load");
				}
			}
			document.getElementById('idloading').style.visibility='hidden';
		}
	}
	xmlhttp.send(null);
	document.getElementById('idloading').style.visibility='visible';
	gv_newPopItemEditedName=null;
	gv_newPopItemEditedValue=null;
}

function showNewPopItemDetail(cmdid)
{
	gv_newPopItemEditingData=0;
	getNewPopItemDetail();
}

function editNewPopItemDetail()
{
	gv_newPopItemEditingData=1;
	getNewPopItemDetail();
}





function doNewPopItem()
{
   var url = gv_rooturl+"?cmd=NewPopItemDetail";
	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_newPopItemDataCategory=xmlhttp.responseXML.getElementsByTagName("DataCategory");
				if(gv_newPopItemDataCategory.length==0) alert("Cannot load details!");
				else {
					gv_scrollCurPage=0;
					gv_scrollTotPage=gv_newPopItemDataCategory.length;
					gv_newPopItemEditingData=1;
					setNewPopItemPageScrollCommands("<input type='button' id='saveNewPopItemData' value='Save' onclick='saveNewPopItemData();'/>","");
					showNewPopItemDataPage("FirstLoad");
				}
			}
			document.getElementById('idloading').style.visibility='hidden';
		}
	}
	xmlhttp.send(null);
	document.getElementById('idloading').style.visibility='visible';
}




function getNewPopItemSysTime()
{
  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 NewPopItemDue_Date=getNewPopItemSysTime();
var NewPopItemUnits='',NewPopItemComment1='',NewPopItemComment2='',NewPopItemProject_Ref='',NewPopItemQuantity='',NewPopItemUnit_Price_GBP='',NewPopItemDiscount_GBP='',NewPopItemNominal_Code='',NewPopItemAllocated='',NewPopItemDespatched='',NewPopItemTo_Deliver='',NewPopItemIntrastat='',NewPopItemProduct_Code='',NewPopItemDescription='',NewPopItemCost_Code='',NewPopItemDiscount='',NewPopItemNet_GBP='',NewPopItemVAT_GBP='',NewPopItemTax_Code='',NewPopItemDepartment='',NewPopItemLine_Information='';
function showNewPopItemDataPage(Status)
{
    gv_tempTable = document.getElementById('tempTable');
	var ycur=gv_tempTable.style.pixelTop=gv_device==Nokia ? 28:26;
	var tdh="height='"+gv_newPopItemRowH+"px'";  
	
	if(gv_device!=Nokia) {
			var mleft=document.getElementById('img_mleft4');
			mleft.onclick=newPopItemPageLeft;
			mleft.style.cursor='hand';
			var mright=document.getElementById('img_mright4');
			mright.onclick=newPopItemPageRight;
			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_newPopItemFocusIndex=gv_newPopItemIndex;
	var newpopitemcmd = document.getElementById('popCmds');
	newpopitemcmd.style.pixelLeft=gv_winw-newpopitemcmd.style.pixelWidth-1;
	newpopitemcmd.style.pixelTop = gv_winh-29;
	
    newpopitemcmd.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='selnewpopitemcat' onchange='jumpToNewPopItemCat();'>";
    for(var ic=0; ic<gv_newPopItemDataCategory.length; ic++) {
		var attName0=gv_newPopItemDataCategory[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_newPopItemDataCategory.length; ic++) {
		var attName=gv_newPopItemDataCategory[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_newPopItemRowH;

		var curNode=gv_newPopItemDataCategory[ic].firstChild;
		var end_tdr = gv_newPopItemEditingData==1 ? "></td></tr>":" ReadOnly></td></tr>";
		while( curNode ) 
		{
			var itemName=curNode.nodeName;
			var itemId=itemName;//ic.toString()+"_"+itemName;
			var ndv=curNode.firstChild;
			var itemVal=getEditedNewPopItemData(itemId);
			if(itemVal==null) itemVal=ndv?ndv.nodeValue:'';
	if(Status.toString()=="FirstLoad")
	{
      if(itemName=="Product_Code")
              {
               NewPopItemProduct_Code="";
               rowtxt+="<tr><td align=right "+tdh+">Product Code <span style='color:red'>*</span></td>";
			   rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:125px;height:20px;'value='"+NewPopItemProduct_Code+"' id='NewPopItemProduct_Code'><input type='Button' value='Get'  onclick='getProductCode()' runat='server' style='color: blue; width: 35px;height: 20px; font-weight: bold; text-decoration: underline;' /></td></tr>";
            
              }
            else if(itemName=="Description")
			{
			   NewPopItemDescription="";
               rowtxt+="<tr><td align=right "+tdh+">Description <span style='color:red'>*</span></td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;'value='"+NewPopItemDescription+"' id='NewPopItemDescription'>";	  

			}
			else if(itemName=="Units")
			{
			   NewPopItemUnits="";
               rowtxt+="<tr><td align=right "+tdh+">Units &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemUnits+"' id='NewPopItemUnits'>";	  

			}
			else if(itemName=="Comment1")
			{
			   NewPopItemComment1 = ""; 
               rowtxt+="<tr><td align=right "+tdh+">Comment 1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemComment1+"' id='NewPopItemComment1'>";	  

			}
			else if(itemName=="Comment2")
			{
			   NewPopItemComment2 = "";
               rowtxt+="<tr><td align=right "+tdh+">Comment 2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemComment2+"' id='NewPopItemComment2'>";	  

			}
			else if(itemName=="Project_Ref")
			{
			   NewPopItemProject_Ref = "";
               rowtxt+="<tr><td align=right "+tdh+">Project Ref &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemProject_Ref+"' id='NewPopItemProject_Ref' ReadOnly>";	  

			}
			else if(itemName=="Cost_Code")
			{
  			   NewPopItemCost_Code="";
               rowtxt+="<tr><td align=right "+tdh+">Cost Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemCost_Code+"' id='NewPopItemCost_Code' ReadOnly>";	  

			}
			else if(itemName=="Quantity")
			{
			   NewPopItemQuantity="1.00";
               rowtxt+="<tr><td align=right "+tdh+">Quantity &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemQuantity+"' id='NewPopItemQuantity'>";	  

			}
			else if(itemName=="Unit_Price_GBP")
			{
			   NewPopItemUnit_Price_GBP="";
               rowtxt+="<tr><td align=right "+tdh+">Unit Price GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemUnit_Price_GBP+"' id='NewPopItemUnit_Price_GBP'>";	  

			}
			else if(itemName=="Discount")
			{
			   NewPopItemDiscount = ""; 
               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='showSaveNewPopItemDataButton();' value='"+NewPopItemDiscount+"' id='NewPopItemDiscount'>";	  

			}
			else if(itemName=="Discount_GBP")
			{
			   NewPopItemDiscount_GBP = "";
               rowtxt+="<tr><td align=right "+tdh+">Discount GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDiscount_GBP+"' id='NewPopItemDiscount_GBP'>";	  

			}
			else if(itemName=="Net_GBP")
			{
			   NewPopItemNet_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='showSaveNewPopItemDataButton();' value='"+NewPopItemNet_GBP+"' id='NewPopItemNet_GBP' ReadOnly>";	  

			}
			else if(itemName=="VAT_GBP")
			{
			   NewPopItemVAT_GBP="";
               rowtxt+="<tr><td align=right "+tdh+">VAT GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemVAT_GBP+"' id='NewPopItemVAT_GBP'  ReadOnly>";	  

			}
			else if(itemName=="Nominal_Code")
			{
			   NewPopItemNominal_Code="";
               rowtxt+="<tr><td align=right "+tdh+">Nominal Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemNominal_Code+"' id='NewPopItemNominal_Code' ReadOnly>";	  

			}
	       else if(itemName=="Tax_Code")
             {
                NewPopItemTax_Code = "";
                 var rowJumpNewPopItemTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select class='edtxt'  id='NewPopItemTax_Code'  "+widstyle+"  onchange='showNewPopItemCount();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attNewPopItemTaxCodeName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attNewPopItemTaxCodeName) 
                   {
                    rowJumpNewPopItemTaxCode+="<option value='"+attNewPopItemTaxCodeName+"'";
                    if(attNewPopItemTaxCodeName==NewPopItemTax_Code) {rowJumpNewPopItemTaxCode+="selected=true";}
                    else if(i ==1) {rowJumpNewPopItemTaxCode+="selected=true";if(NewPopItemTax_Code == "") {NewPopItemTax_Code = attNewPopItemTaxCodeName; }}
                    rowJumpNewPopItemTaxCode+=">"+attNewPopItemTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpNewPopItemTaxCode+"</select></td></tr>";
                   
	          }
			  else if(itemName=="Department")
             {
                NewPopItemDepartment = "";
                 var rowJumpNewPopItemDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewPopItemDepartment' "+widstyle+"  onchange='NewPopItemTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attNewPopItemDepartmentName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attNewPopItemDepartmentName) 
                   {
                    rowJumpNewPopItemDepartment+="<option value='"+attNewPopItemDepartmentName+"'";
                    if(attNewPopItemDepartmentName==NewPopItemDepartment) {rowJumpNewPopItemDepartment+="selected=true";}
                    else if(NewPopItemDepartment =="" && i ==0)  {rowJumpNewPopItemDepartment+="selected=true";}
                    rowJumpNewPopItemDepartment+=">"+attNewPopItemDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpNewPopItemDepartment+"</select></td></tr>";
	          }
	        else if(itemName=="Line_Information")
			{
			   NewPopItemLine_Information="";
               rowtxt+="<tr><td align=right "+tdh+">Line Information &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemLine_Information+"' id='NewPopItemLine_Information'>";	  

			}

			else if(itemName=="Allocated")
			{
			   NewPopItemAllocated="";
               rowtxt+="<tr><td align=right "+tdh+">Allocated &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemAllocated+"' id='NewPopItemAllocated' ReadOnly>";	  

			}
			else if(itemName=="Despatched")
			{
			   NewPopItemDespatched="";
               rowtxt+="<tr><td align=right "+tdh+">Despatched &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDespatched+"' id='NewPopItemDespatched' ReadOnly>";	  

			}
			else if(itemName=="To_Deliver")
			
			{
			   To_Deliver="1.00";
               rowtxt+="<tr><td align=right "+tdh+">To Deliver &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemTo_Deliver+"' id='NewPopItemTo_Deliver' ReadOnly>";	  

			}
			else if(itemName=="Intrastat")
			{
			   NewPopItemIntrastat = "";
               rowtxt+="<tr><td align=right "+tdh+">Intrastat &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemIntrastat+"'' id='NewPopItemIntrastat' ReadOnly>";	  

			}
			else if(itemName=="Due_Date")
			{
               rowtxt+="<tr><td align=right "+tdh+">Due Date &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDue_Date+"' id='NewPopItemDue_Date'>";	  
			}
    }
        else if(Status.toString()=="Load")
      {
			 if(itemName=="Product_Code")
              {
               //if(NewPopItemProduct_Code == "") { NewPopItemProduct_Code=itemVal;}
               NewPopItemProduct_Code=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Product Code <span style='color:red'>*</span></td>";
			   rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt'  style='width:125px;height:20px;'value='"+NewPopItemProduct_Code+"' id='NewPopItemProduct_Code'><input type='Button' value='Get'  onclick='getProductCode();' runat='server' style='color: blue; width: 35px;height: 20px; font-weight: bold; text-decoration: underline;' /></td></tr>";
            
              }
            else if(itemName=="Description")
			{
			   NewPopItemDescription=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Description <span style='color:red'>*</span></td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;'value='"+NewPopItemDescription+"' id='NewPopItemDescription'>";	  

			}
			else if(itemName=="Units")
			{
			  NewPopItemUnits=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Units &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemUnits+"' id='NewPopItemUnits'>";	  

			}
			else if(itemName=="Comment1")
			{
			    NewPopItemComment1 = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Comment 1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemComment1+"' id='NewPopItemComment1'>";	  
			}
			else if(itemName=="Comment2")
			{
			    NewPopItemComment2 = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Comment 2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemComment2+"' id='NewPopItemComment2'>";	  
			}
			else if(itemName=="Project_Ref")
			{
			    NewPopItemProject_Ref = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Project Ref &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemProject_Ref+"' id='NewPopItemProject_Ref' ReadOnly>";	  
			}
			else if(itemName=="Cost_Code")
			{
			    NewPopItemCost_Code = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Cost Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemCost_Code+"' id='NewPopItemCost_Code' ReadOnly>";	  
			}
			else if(itemName=="Quantity")
			{
			    NewPopItemQuantity = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Quantity &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showNewPopItemCount();' value='"+NewPopItemQuantity+"' id='NewPopItemQuantity'>";	  
			}
			else if(itemName=="Unit_Price_GBP")
			{
			   NewPopItemUnit_Price_GBP = itemVal;
			//   if(NewPopItemUnit_Price_GBP == "0") { NewPopItemUnit_Price_GBP = itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Unit Price GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showNewPopItemCount();' value='"+NewPopItemUnit_Price_GBP+"' id='NewPopItemUnit_Price_GBP'>";	  

			}
			else if(itemName=="Discount")
			{
			    NewPopItemDiscount = 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='showSaveNewPopItemDataButton();' value='"+NewPopItemDiscount+"' id='NewPopItemDiscount'>";	  
			}
			else if(itemName=="Discount_GBP")
			{
			    NewPopItemDiscount_GBP = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Discount GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDiscount_GBP+"' id='NewPopItemDiscount_GBP'>";	  
			}
			else if(itemName=="Net_GBP")
			{
			   if(NewPopItemQuantity !="" && NewPopItemUnit_Price_GBP !="") { NewPopItemNet_GBP = NewPopItemQuantity * NewPopItemUnit_Price_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='showNewPopItemCount();' value='"+NewPopItemNet_GBP+"' id='NewPopItemNet_GBP' ReadOnly>";	  

			}
			else if(itemName=="VAT_GBP")
			{
			    if(NewPopItemNet_GBP != "" && NewPopItemTax_Code != "")
			   {
			     var   m=/^\d+$/;   
                 if(m.test(NewPopItemTax_Code))   
			     {
			       NewPopItemVAT_GBP = parseFloat(NewPopItemNet_GBP) * NewPopItemTax_Code / 100; 
			     }
			     else{
			      var TaxRateS = NewPopItemTax_Code.split("|$|");
	              var TaxRate =parseFloat(TaxRateS[1]);
	              NewPopItemVAT_GBP = parseFloat(NewPopItemNet_GBP) * TaxRate / 100;}
	              }
               rowtxt+="<tr><td align=right "+tdh+">VAT GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showNewPopItemCount();' value='"+NewPopItemVAT_GBP+"' id='NewPopItemVAT_GBP' ReadOnly>";	  
			}
			else if(itemName=="Nominal_Code")
			{
			   NewPopItemNominal_Code=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Nominal Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemNominal_Code+"' id='NewPopItemNominal_Code' ReadOnly>";	  

			}
//			
	       else if(itemName=="Tax_Code")
             {
                NewPopItemTax_Code = "";
                 var rowJumpNewPopItemTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select class='edtxt'  id='NewPopItemTax_Code'  "+widstyle+"  onchange='showNewPopItemCount();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attNewPopItemTaxCodeName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attNewPopItemTaxCodeName) 
                   {
                    rowJumpNewPopItemTaxCode+="<option value='"+attNewPopItemTaxCodeName+"'";
                    if(attNewPopItemTaxCodeName==NewPopItemTax_Code) {rowJumpNewPopItemTaxCode+="selected=true";}
                    else if(i ==1) {rowJumpNewPopItemTaxCode+="selected=true";if(NewPopItemTax_Code == "") {NewPopItemTax_Code = attNewPopItemTaxCodeName; }}
                    rowJumpNewPopItemTaxCode+=">"+attNewPopItemTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpNewPopItemTaxCode+"</select></td></tr>";
                   
	          }
//              else if(itemName=="Tax_Code")
//              {
//                                 
//                     var rowJumpNewPopItemTaxCode="<tr><td align='right' height='20px'>Tax Code &nbsp</td><td><select class='edtxt' id='NewPopItemTax_Code' style='width: 160px' onchange='showNewPopItemCount();'>";
//                     rowJumpNewPopItemTaxCode += "<option value='T0  Zero rated|$|0'>T0 Zero rated|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T1  Standard rate|$|17.5' selected=true>T1 Standard rate|$|17.5</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T2  Exempt transactions|$|0'>T2 Exempt transactions|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T4  Sales to customers in EC|$|0'>T4 Sales to customers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T5  Lower Rate|$|5'>T5 Lower Rate|$|5</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T7  Zero rated purchases from suppliers in EC|$|0'>T7 Zero rated purchases from suppliers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T8  Standard rated purchases from suppliers in EC|$|0'>T8 Standard rated purchases from suppliers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T9  Non-Vatable Tax Code|$|0'>T9 Non-Vatable Tax Code|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T20  Reverse Charges|$|0'>T20 Reverse Charges|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T22  Sales of services to VAT registered customers in EC|$|0'>T22 Sales of services to VAT registered customers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T23  Zero rated purchases of services from suppliers in EC|$|0'>T23 Zero rated purchases of services from suppliers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T24  Standard rated purchases of services from suppliers in EC|$|0'>T24 Standard rated purchases of services from suppliers in EC|$|0</option>";
//                     rowtxt+=rowJumpNewPopItemTaxCode+"</select></td></tr>";
//                                 
//              }
			  else if(itemName=="Department")
             {
                 NewPopItemDepartment = "";
                 var rowJumpNewPopItemDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewPopItemDepartment' "+widstyle+"  onchange='NewPopItemTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attNewPopItemDepartmentName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attNewPopItemDepartmentName) 
                   {
                    rowJumpNewPopItemDepartment+="<option value='"+attNewPopItemDepartmentName+"'";
                    if(attNewPopItemDepartmentName==NewPopItemDepartment) {rowJumpNewPopItemDepartment+="selected=true";}
                    if(NewPopItemDepartment =="" && i ==0)  {rowJumpNewPopItemDepartment+="selected=true";}
                    rowJumpNewPopItemDepartment+=">"+attNewPopItemDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpNewPopItemDepartment+"</select></td></tr>";
	          }
//            else if(itemName=="Department")
//            {
//                 var rowJumpNewPopItemDepartment="<tr><td align='right' height='20px'>Department &nbsp</td><td><select class='edtxt' id='NewPopItemDepartment' style='width: 160px' onchange='NewPopItemTaxCode();'>";
//                 rowJumpNewPopItemDepartment += "<option value='0  Default' selected=true>0 Default</option>"
//                 rowJumpNewPopItemDepartment += "<option value='1  Sales'>1 Sales</option>";
//                 rowJumpNewPopItemDepartment += "<option value='2  Purchasing'>2 Purchasing</option>";
//                 rowJumpNewPopItemDepartment += "<option value='3  Accounts'>3 Accounts</option>";
//                 rowJumpNewPopItemDepartment += "<option value='4  Admin'>4 Admin</option>";
//                 rowJumpNewPopItemDepartment += "<option value='5  Marketing'>5 Marketing</option>";
//                 rowJumpNewPopItemDepartment += "<option value='6  Installations'>6 Installations</option>";
//                 rowJumpNewPopItemDepartment += "<option value='7  Workshop'>7 Workshop</option>";
//                 rowtxt+=rowJumpNewPopItemDepartment+"</select></td></tr>";
//            }
	          else if(itemName=="Line_Information")
			{
			   NewPopItemLine_Information=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Line Information &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemLine_Information+"' id='NewPopItemLine_Information'>";	  

			}

			else if(itemName=="Allocated")
			{
			   NewPopItemAllocated=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Allocated &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemAllocated+"' id='NewPopItemAllocated' ReadOnly>";	  

			}
			else if(itemName=="Despatched")
			{
			   NewPopItemDespatched=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Despatched &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDespatched+"' id='NewPopItemDespatched' ReadOnly>";	  

			}
			else if(itemName=="To_Deliver")
			
			{
			   NewPopItemTo_Deliver="1.00";
               rowtxt+="<tr><td align=right "+tdh+">To Deliver &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemTo_Deliver+"' id='NewPopItemTo_Deliver' ReadOnly>";	  

			}
			else if(itemName=="Intrastat")
			{
			    NewPopItemIntrastat = itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Intrastat &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemIntrastat+"'' id='NewPopItemIntrastat' ReadOnly>";	  
			}
			else if(itemName=="Due_Date")
			{
			   NewPopItemDue_Date = getNewPopItemSysTime(); 
               rowtxt+="<tr><td align=right "+tdh+">Due Date &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDue_Date+"' id='NewPopItemDue_Date'>";	  
			}
      }
    else if(Status.toString()=="OtherLoad")
    {
			 if(itemName=="Product_Code")
              {
               //if(NewPopItemProduct_Code == "") { NewPopItemProduct_Code=itemVal;}
               NewPopItemProduct_Code=itemVal;
               rowtxt+="<tr><td align=right "+tdh+">Product Code <span style='color:red'>*</span></td>";
			   rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt'  style='width:125px;height:20px;'value='"+NewPopItemProduct_Code+"' id='NewPopItemProduct_Code'><input type='Button' value='Get'  onclick='getProductCode();' runat='server' style='color: blue; width: 35px;height: 20px; font-weight: bold; text-decoration: underline;' /></td></tr>";
            
              }
            else if(itemName=="Description")
			{
			   //if(NewPopItemDescription == "") { NewPopItemDescription=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Description <span style='color:red'>*</span></td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;'value='"+NewPopItemDescription+"' id='NewPopItemDescription'>";	  

			}
			else if(itemName=="Units")
			{
			  //if(NewPopItemUnits == "") { NewPopItemUnits=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Units &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemUnits+"' id='NewPopItemUnits'>";	  

			}
			else if(itemName=="Comment1")
			{
               rowtxt+="<tr><td align=right "+tdh+">Comment 1 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemComment1+"' id='NewPopItemComment1'>";	  

			}
			else if(itemName=="Comment2")
			{
               rowtxt+="<tr><td align=right "+tdh+">Comment 2 &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemComment2+"' id='NewPopItemComment2'>";	  

			}
			else if(itemName=="Project_Ref")
			{
               rowtxt+="<tr><td align=right "+tdh+">Project Ref &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemProject_Ref+"' id='NewPopItemProject_Ref' ReadOnly>";	  

			}
			else if(itemName=="Cost_Code")
			{
               rowtxt+="<tr><td align=right "+tdh+">Cost Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemCost_Code+"' id='NewPopItemCost_Code' ReadOnly>";	  

			}
			else if(itemName=="Quantity")
			{
               rowtxt+="<tr><td align=right "+tdh+">Quantity &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showNewPopItemCount();' value='"+NewPopItemQuantity+"' id='NewPopItemQuantity'>";	  

			}
			else if(itemName=="Unit_Price_GBP")
			{
			  // if(NewPopItemUnit_Price_GBP =="") {  NewPopItemUnit_Price_GBP = itemVal;}
			//   if(NewPopItemUnit_Price_GBP == "0") { NewPopItemUnit_Price_GBP = itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Unit Price GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showNewPopItemCount();' value='"+NewPopItemUnit_Price_GBP+"' id='NewPopItemUnit_Price_GBP'>";	  

			}
			else if(itemName=="Discount")
			{
               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='showSaveNewPopItemDataButton();' value='"+NewPopItemDiscount+"' id='NewPopItemDiscount'>";	  

			}
			else if(itemName=="Discount_GBP")
			{
               rowtxt+="<tr><td align=right "+tdh+">Discount GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDiscount_GBP+"' id='NewPopItemDiscount_GBP'>";	  

			}
			else if(itemName=="Net_GBP")
			{
			   if(NewPopItemQuantity !="" && NewPopItemUnit_Price_GBP !="") { NewPopItemNet_GBP = NewPopItemQuantity * NewPopItemUnit_Price_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='showNewPopItemCount();' value='"+NewPopItemNet_GBP+"' id='NewPopItemNet_GBP' ReadOnly>";	  

			}
			else if(itemName=="VAT_GBP")
			{
			    if(NewPopItemNet_GBP != "" && NewPopItemTax_Code != "")
			   {
			     var   m=/^\d+$/;   
                 if(m.test(NewPopItemTax_Code))   
			     {
			       NewPopItemVAT_GBP = parseFloat(NewPopItemNet_GBP) * NewPopItemTax_Code / 100; 
			     }
			     else{
			      var TaxRateS = NewPopItemTax_Code.split("|$|");
	              var TaxRate =parseFloat(TaxRateS[1]);
	              NewPopItemVAT_GBP = parseFloat(NewPopItemNet_GBP) * TaxRate / 100;}
	              }
               rowtxt+="<tr><td align=right "+tdh+">VAT GBP &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showNewPopItemCount();' value='"+NewPopItemVAT_GBP+"' id='NewPopItemVAT_GBP' ReadOnly>";	  
			}
			else if(itemName=="Nominal_Code")
			{
			  //if(NewPopItemNominal_Code == "") { NewPopItemNominal_Code=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Nominal Code &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemNominal_Code+"' id='NewPopItemNominal_Code' ReadOnly>";	  

			}
//			
	       else if(itemName=="Tax_Code")
             {
                 var rowJumpNewPopItemTaxCode="<tr><td align='right'"+tdh+">Tax Code &nbsp</td><td><select class='edtxt'  id='NewPopItemTax_Code'  "+widstyle+"  onchange='showNewPopItemCount();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attNewPopItemTaxCodeName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attNewPopItemTaxCodeName) 
                   {
                    rowJumpNewPopItemTaxCode+="<option value='"+attNewPopItemTaxCodeName+"'";
                    if(attNewPopItemTaxCodeName==NewPopItemTax_Code) {rowJumpNewPopItemTaxCode+="selected=true";}
                    else if(i ==1) {rowJumpNewPopItemTaxCode+="selected=true";if(NewPopItemTax_Code == "") {NewPopItemTax_Code = attNewPopItemTaxCodeName; }}
                    rowJumpNewPopItemTaxCode+=">"+attNewPopItemTaxCodeName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpNewPopItemTaxCode+"</select></td></tr>";
                   
	          }
//              else if(itemName=="Tax_Code")
//              {
//                                 
//                     var rowJumpNewPopItemTaxCode="<tr><td align='right' height='20px'>Tax Code &nbsp</td><td><select class='edtxt' id='NewPopItemTax_Code' style='width: 160px' onchange='showNewPopItemCount();'>";
//                     rowJumpNewPopItemTaxCode += "<option value='T0  Zero rated|$|0'>T0 Zero rated|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T1  Standard rate|$|17.5' selected=true>T1 Standard rate|$|17.5</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T2  Exempt transactions|$|0'>T2 Exempt transactions|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T4  Sales to customers in EC|$|0'>T4 Sales to customers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T5  Lower Rate|$|5'>T5 Lower Rate|$|5</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T7  Zero rated purchases from suppliers in EC|$|0'>T7 Zero rated purchases from suppliers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T8  Standard rated purchases from suppliers in EC|$|0'>T8 Standard rated purchases from suppliers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T9  Non-Vatable Tax Code|$|0'>T9 Non-Vatable Tax Code|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T20  Reverse Charges|$|0'>T20 Reverse Charges|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T22  Sales of services to VAT registered customers in EC|$|0'>T22 Sales of services to VAT registered customers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T23  Zero rated purchases of services from suppliers in EC|$|0'>T23 Zero rated purchases of services from suppliers in EC|$|0</option>";
//                     rowJumpNewPopItemTaxCode += "<option value='T24  Standard rated purchases of services from suppliers in EC|$|0'>T24 Standard rated purchases of services from suppliers in EC|$|0</option>";
//                     rowtxt+=rowJumpNewPopItemTaxCode+"</select></td></tr>";
//                                 
//              }
			  else if(itemName=="Department")
             {
                 var rowJumpNewPopItemDepartment="<tr><td align='right'"+tdh+">Department &nbsp</td><td><select class='edtxt'  id='NewPopItemDepartment' "+widstyle+"  onchange='NewPopItemTaxCode();'>";
                 for(var i=0; i< curNode.childNodes.length; i++) 
                 { 
                   var attNewPopItemDepartmentName=curNode.childNodes[i].childNodes[0].data;                      
                   if(attNewPopItemDepartmentName) 
                   {
                    rowJumpNewPopItemDepartment+="<option value='"+attNewPopItemDepartmentName+"'";
                    if(attNewPopItemDepartmentName==NewPopItemDepartment) {rowJumpNewPopItemDepartment+="selected=true";}
                    if(NewPopItemDepartment =="" && i ==0)  {rowJumpNewPopItemDepartment+="selected=true";}
                    rowJumpNewPopItemDepartment+=">"+attNewPopItemDepartmentName+"</option>"; 
                   }
                 }  
                     rowtxt+=rowJumpNewPopItemDepartment+"</select></td></tr>";
	          }
//            else if(itemName=="Department")
//            {
//                 var rowJumpNewPopItemDepartment="<tr><td align='right' height='20px'>Department &nbsp</td><td><select class='edtxt' id='NewPopItemDepartment' style='width: 160px' onchange='NewPopItemTaxCode();'>";
//                 rowJumpNewPopItemDepartment += "<option value='0  Default' selected=true>0 Default</option>"
//                 rowJumpNewPopItemDepartment += "<option value='1  Sales'>1 Sales</option>";
//                 rowJumpNewPopItemDepartment += "<option value='2  Purchasing'>2 Purchasing</option>";
//                 rowJumpNewPopItemDepartment += "<option value='3  Accounts'>3 Accounts</option>";
//                 rowJumpNewPopItemDepartment += "<option value='4  Admin'>4 Admin</option>";
//                 rowJumpNewPopItemDepartment += "<option value='5  Marketing'>5 Marketing</option>";
//                 rowJumpNewPopItemDepartment += "<option value='6  Installations'>6 Installations</option>";
//                 rowJumpNewPopItemDepartment += "<option value='7  Workshop'>7 Workshop</option>";
//                 rowtxt+=rowJumpNewPopItemDepartment+"</select></td></tr>";
//            }
	          else if(itemName=="Line_Information")
			{
			  //if(NewPopItemLine_Information == "") { NewPopItemLine_Information=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Line Information &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemLine_Information+"' id='NewPopItemLine_Information'>";	  

			}

			else if(itemName=="Allocated")
			{
			  // if(NewPopItemAllocated == "") { NewPopItemAllocated=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Allocated &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemAllocated+"' id='NewPopItemAllocated' ReadOnly>";	  

			}
			else if(itemName=="Despatched")
			{
			   //if(NewPopItemDespatched == "") { NewPopItemDespatched=itemVal;}
               rowtxt+="<tr><td align=right "+tdh+">Despatched &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDespatched+"' id='NewPopItemDespatched' ReadOnly>";	  

			}
			else if(itemName=="To_Deliver")
			
			{
			  //if(NewPopItemTo_Deliver) { NewPopItemTo_Deliver="1.00";}
               rowtxt+="<tr><td align=right "+tdh+">To Deliver &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemTo_Deliver+"' id='NewPopItemTo_Deliver' ReadOnly>";	  

			}
			else if(itemName=="Intrastat")
			{
               rowtxt+="<tr><td align=right "+tdh+">Intrastat &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemIntrastat+"'' id='NewPopItemIntrastat' ReadOnly>";	  

			}
			else if(itemName=="Due_Date")
			{
               rowtxt+="<tr><td align=right "+tdh+">Due Date &nbsp</td>";
               rowtxt+="<td align=center"+tdh+"><input type='text' class='edtxt' style='width:160px;height:20px;' onchange='showSaveNewPopItemDataButton();' value='"+NewPopItemDue_Date+"' id='NewPopItemDue_Date'>";	  

			}
      }
			curNode=curNode.nextSibling;
			ycur+=gv_newPopItemRowH;
		}
		//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(document.getElementById('saveNewPopItemData')==null) setNewPopItemPageScrollCommands('','');
	setNewPopItemPageScroll();
	setTopTitle('Pop -> New Pop Item');
	doNokiaMenuNewPopItemPage();
}
function doNokiaMenuNewPopItemPage()
{
	if(window.widget) {
		window.menu.clear();
		var mBack = new MenuItem('Back',2102);
		mBack.onSelect=backPops;
		window.menu.append(mBack);
	}
}
function NewPopItemTaxCode()
{
//var NewPopItemTax=document.getElementById('NewPopItemTax_Code');
var NewPopItemDep=document.getElementById('NewPopItemDepartment');
//  if(NewPopItemTax)
//  {
//  if(NewPopItemTax.options[NewPopItemTax.selectedIndex])
//  NewPopItemTax_Code=NewPopItemTax.options[NewPopItemTax.selectedIndex].value; 
//  }
  if(NewPopItemDep)
  {
   if(NewPopItemDep.options[NewPopItemDep.selectedIndex])
   NewPopItemDepartment=NewPopItemDep.options[NewPopItemDep.selectedIndex].value; 
  }
  
}

 function getProductCode()
 {
   document.getElementById('saveNewPopItemData').style.visibility = "hidden";
   NewPopItemiPage = 1;
   doNewPopItemList();
//   document.getElementById('popCmds').style.visibility='hidden';
 }


function setNewPopItemPageScroll()
{
    var pncur=document.getElementById('pn_cur4');
    pncur.innerHTML='Page '+(gv_scrollCurPage+1)+' of '+gv_scrollTotPage;
    var pnleft=document.getElementById('pn_left4');
    pnleft.innerHTML=gv_scrollCurPage>0 ? gv_scrollCurPage.toString():'';
    var pnright=document.getElementById('pn_right4');
    pnright.innerHTML=gv_scrollCurPage<gv_scrollTotPage-1 ? (gv_scrollCurPage+2).toString():'';    
}
function newPopItemPageLeft()
{
	if(gv_scrollCurPage<=0) return;

	var selcat=document.getElementById('selnewpopitemcat'); 
	var divtab=document.getElementById('tempTable');
	var tleft=divtab.style.pixelLeft;
	if(tleft>=gv_winw-30) {	
		gv_scrollCurPage--;
		divtab.style.pixelLeft=0;
		if(selcat) {
			if(gv_newPopItemEditingData==1) checkNewPopItemPageEdited(gv_scrollCurPage+1); 
			selcat.selectedIndex=gv_scrollCurPage;
			if(document.getElementById('NewPopItemProduct_Code')){NewPopItemProduct_Code=document.getElementById('NewPopItemProduct_Code').value;}
			if(document.getElementById('NewPopItemDescription')){NewPopItemDescription=document.getElementById('NewPopItemDescription').value;}
			if(document.getElementById('NewPopItemUnits')){NewPopItemUnits=document.getElementById('NewPopItemUnits').value;}
			if(document.getElementById('NewPopItemComment1')){NewPopItemComment1=document.getElementById('NewPopItemComment1').value;}
			if(document.getElementById('NewPopItemComment2')){NewPopItemComment2=document.getElementById('NewPopItemComment2').value;}
			if(document.getElementById('NewPopItemProject_Ref')){NewPopItemProject_Ref=document.getElementById('NewPopItemProject_Ref').value;}
			if(document.getElementById('NewPopItemCost_Code')){NewPopItemCost_Code=document.getElementById('NewPopItemCost_Code').value;}
			if(document.getElementById('NewPopItemQuantity')){NewPopItemQuantity=document.getElementById('NewPopItemQuantity').value;}
			if(document.getElementById('NewPopItemUnit_Price_GBP')){NewPopItemUnit_Price_GBP=document.getElementById('NewPopItemUnit_Price_GBP').value;}
			if(document.getElementById('NewPopItemDiscount')){NewPopItemDiscount=document.getElementById('NewPopItemDiscount').value;}
			if(document.getElementById('NewPopItemDiscount_GBP')){NewPopItemDiscount_GBP=document.getElementById('NewPopItemDiscount_GBP').value;}
			if(document.getElementById('NewPopItemNet_GBP')){NewPopItemNet_GBP=document.getElementById('NewPopItemNet_GBP').value;}
			if(document.getElementById('NewPopItemVAT_GBP')){NewPopItemVAT_GBP=document.getElementById('NewPopItemVAT_GBP').value;}
			if(document.getElementById('NewPopItemNominal_Code')){NewPopItemNominal_Code=document.getElementById('NewPopItemNominal_Code').value;}
			if(document.getElementById("NewPopItemTax_Code")){NewPopItemTax_Code=document.getElementById('NewPopItemTax_Code').options[document.getElementById('NewPopItemTax_Code').selectedIndex].value;}
			if(document.getElementById("NewPopItemDepartment")){NewPopItemDepartment=document.getElementById('NewPopItemDepartment').options[document.getElementById('NewPopItemDepartment').selectedIndex].value;}
			if(document.getElementById('NewPopItemLine_Information')){NewPopItemLine_Information=document.getElementById('NewPopItemLine_Information').value;}

			if(document.getElementById('NewPopItemAllocated')){NewPopItemAllocated=document.getElementById('NewPopItemAllocated').value;}
			if(document.getElementById('NewPopItemDespatched')){NewPopItemDespatched=document.getElementById('NewPopItemDespatched').value;}
			if(document.getElementById('NewPopItemTo_Deliver')){NewPopItemTo_Deliver=document.getElementById('NewPopItemTo_Deliver').value;}
			if(document.getElementById('NewPopItemIntrastat')){NewPopItemIntrastat=document.getElementById('NewPopItemIntrastat').value;}
			if(document.getElementById('NewPopItemDue_Date')){NewPopItemDue_Date=document.getElementById('NewPopItemDue_Date').value;}
//			
			showNewPopItemDataPage("OtherLoad");
		}
		else { 
			gv_newPopItemCurPage=gv_scrollCurPage;		
			gv_newPopItemIndex=0;
            NewPopItemiPage--;
			if(NewPopItemiPage < 1)
			{
			    NewPopItemiPage = 1;
			    return;
			}
			NewPopItemListPD = 1;
			NewPopItemListCurPage = gv_newPopItemCurPage;
            NewPopItemListTotPage = gv_newPopItemTotPage;
			doNewPopItemList();
		}
	}
	else {
		divtab.style.pixelLeft=tleft+30;
		setTimeout("newPopItemPageLeft();",75);
	}
}
function newPopItemPageRight()
{
	if(gv_scrollCurPage>=gv_scrollTotPage-1) return;
	
	var selcat=document.getElementById('selnewpopitemcat'); 
	var divtab=document.getElementById('tempTable');
	var tleft=divtab.style.pixelLeft;
	if(tleft<30-gv_winw) {	
		gv_scrollCurPage++;
		divtab.style.pixelLeft=0;
		if(selcat) { 
			selcat.selectedIndex=gv_scrollCurPage;
			if(document.getElementById('NewPopItemProduct_Code')){NewPopItemProduct_Code=document.getElementById('NewPopItemProduct_Code').value;}
			if(document.getElementById('NewPopItemDescription')){NewPopItemDescription=document.getElementById('NewPopItemDescription').value;}
			if(document.getElementById('NewPopItemUnits')){NewPopItemUnits=document.getElementById('NewPopItemUnits').value;}
			if(document.getElementById('NewPopItemComment1')){NewPopItemComment1=document.getElementById('NewPopItemComment1').value;}
			if(document.getElementById('NewPopItemComment2')){NewPopItemComment2=document.getElementById('NewPopItemComment2').value;}
			if(document.getElementById('NewPopItemProject_Ref')){NewPopItemProject_Ref=document.getElementById('NewPopItemProject_Ref').value;}
			if(document.getElementById('NewPopItemCost_Code')){NewPopItemCost_Code=document.getElementById('NewPopItemCost_Code').value;}
			if(document.getElementById('NewPopItemQuantity')){NewPopItemQuantity=document.getElementById('NewPopItemQuantity').value;}
			if(document.getElementById('NewPopItemUnit_Price_GBP')){NewPopItemUnit_Price_GBP=document.getElementById('NewPopItemUnit_Price_GBP').value;}
			if(document.getElementById('NewPopItemDiscount')){NewPopItemDiscount=document.getElementById('NewPopItemDiscount').value;}
			if(document.getElementById('NewPopItemDiscount_GBP')){NewPopItemDiscount_GBP=document.getElementById('NewPopItemDiscount_GBP').value;}
			if(document.getElementById('NewPopItemNet_GBP')){NewPopItemNet_GBP=document.getElementById('NewPopItemNet_GBP').value;}
			if(document.getElementById('NewPopItemVAT_GBP')){NewPopItemVAT_GBP=document.getElementById('NewPopItemVAT_GBP').value;}
			if(document.getElementById('NewPopItemNominal_Code')){NewPopItemNominal_Code=document.getElementById('NewPopItemNominal_Code').value;}
			if(document.getElementById("NewPopItemTax_Code")){NewPopItemTax_Code=document.getElementById('NewPopItemTax_Code').options[document.getElementById('NewPopItemTax_Code').selectedIndex].value;}
			if(document.getElementById("NewPopItemDepartment")){NewPopItemDepartment=document.getElementById('NewPopItemDepartment').options[document.getElementById('NewPopItemDepartment').selectedIndex].value;}
		
			if(document.getElementById('NewPopItemLine_Information')){NewPopItemLine_Information=document.getElementById('NewPopItemLine_Information').value;}
	          if(document.getElementById('NewPopItemAllocated')){NewPopItemAllocated=document.getElementById('NewPopItemAllocated').value;}
			if(document.getElementById('NewPopItemDespatched')){NewPopItemDespatched=document.getElementById('NewPopItemDespatched').value;}
			if(document.getElementById('NewPopItemTo_Deliver')){NewPopItemTo_Deliver=document.getElementById('NewPopItemTo_Deliver').value;}
			if(document.getElementById('NewPopItemIntrastat')){NewPopItemIntrastat=document.getElementById('NewPopItemIntrastat').value;}
			if(document.getElementById('NewPopItemDue_Date')){NewPopItemDue_Date=document.getElementById('NewPopItemDue_Date').value;}
			showNewPopItemDataPage("OtherLoad");			
		}
		else { 
			gv_newPopItemCurPage=gv_scrollCurPage;		
			gv_newPopItemIndex=0;
            NewPopItemiPage++;
			if(NewPopItemiPage > NewPopItemTotalPage)
			{
			    NewPopItemiPage = NewPopItemTotalPage;
			    return;
			}
			NewPopItemListPD = 1;
			NewPopItemListCurPage = gv_newPopItemCurPage;
            NewPopItemListTotPage = gv_newPopItemTotPage;
			doNewPopItemList();
		}
	}
	else {
		divtab.style.pixelLeft=tleft-30;
		setTimeout("newPopItemPageRight();",75);
	}
}
function jumpToNewPopItemCat()
{
  var selcat = document.getElementById('selnewpopitemcat');
	//if(gv_newPopItemEditingData==1) checkNewPopItemPageEdited(gv_scrollCurPage); 
	gv_scrollCurPage=selcat.selectedIndex;	
    if(document.getElementById('NewPopItemProduct_Code')){NewPopItemProduct_Code=document.getElementById('NewPopItemProduct_Code').value;}
    if(document.getElementById('NewPopItemDescription')){NewPopItemDescription=document.getElementById('NewPopItemDescription').value;}
    if(document.getElementById('NewPopItemUnits')){NewPopItemUnits=document.getElementById('NewPopItemUnits').value;}
    if(document.getElementById('NewPopItemComment1')){NewPopItemComment1=document.getElementById('NewPopItemComment1').value;}
    if(document.getElementById('NewPopItemComment2')){NewPopItemComment2=document.getElementById('NewPopItemComment2').value;}
    if(document.getElementById('NewPopItemProject_Ref')){NewPopItemProject_Ref=document.getElementById('NewPopItemProject_Ref').value;}
    if(document.getElementById('NewPopItemCost_Code')){NewPopItemCost_Code=document.getElementById('NewPopItemCost_Code').value;}
    if(document.getElementById('NewPopItemQuantity')){NewPopItemQuantity=document.getElementById('NewPopItemQuantity').value;}
    if(document.getElementById('NewPopItemUnit_Price_GBP')){NewPopItemUnit_Price_GBP=document.getElementById('NewPopItemUnit_Price_GBP').value;}
    if(document.getElementById('NewPopItemDiscount')){NewPopItemDiscount=document.getElementById('NewPopItemDiscount').value;}
    if(document.getElementById('NewPopItemDiscount_GBP')){NewPopItemDiscount_GBP=document.getElementById('NewPopItemDiscount_GBP').value;}
    if(document.getElementById('NewPopItemNet_GBP')){NewPopItemNet_GBP=document.getElementById('NewPopItemNet_GBP').value;}
    if(document.getElementById('NewPopItemVAT_GBP')){NewPopItemVAT_GBP=document.getElementById('NewPopItemVAT_GBP').value;}
    if(document.getElementById('NewPopItemNominal_Code')){NewPopItemNominal_Code=document.getElementById('NewPopItemNominal_Code').value;}
    if(document.getElementById("NewPopItemTax_Code")){NewPopItemTax_Code=document.getElementById('NewPopItemTax_Code').options[document.getElementById('NewPopItemTax_Code').selectedIndex].value;}
    if(document.getElementById("NewPopItemDepartment")){NewPopItemDepartment=document.getElementById('NewPopItemDepartment').options[document.getElementById('NewPopItemDepartment').selectedIndex].value;}
    if(document.getElementById('NewPopItemLine_Information')){NewPopItemLine_Information=document.getElementById('NewPopItemLine_Information').value;}
    if(document.getElementById('NewPopItemAllocated')){NewPopItemAllocated=document.getElementById('NewPopItemAllocated').value;}
    if(document.getElementById('NewPopItemDespatched')){NewPopItemDespatched=document.getElementById('NewPopItemDespatched').value;}
    if(document.getElementById('NewPopItemTo_Deliver')){NewPopItemTo_Deliver=document.getElementById('NewPopItemTo_Deliver').value;}
    if(document.getElementById('NewPopItemIntrastat')){NewPopItemIntrastat=document.getElementById('NewPopItemIntrastat').value;}
    if(document.getElementById('NewPopItemDue_Date')){NewPopItemDue_Date=document.getElementById('NewPopItemDue_Date').value;}	
	showNewPopItemDataPage("OtherLoad");
}

function checkNewPopItemPageEdited(pagenum)
{
	var itemEle=null;
    for(var ic=pagenum; ic<gv_newPopItemDataCategory.length; ic++) {
		var attName=gv_newPopItemDataCategory[ic].attributes.getNamedItem("title");	
		if(attName==null) continue;
		var curNode=gv_newPopItemDataCategory[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) setEditNewPopItemData(itemId,newv); 
			curNode=curNode.nextSibling;
		}
		if(itemEle==null) break;
    }
}
function setEditNewPopItemData(itemName,edValue)
{
	if(!gv_newPopItemEditedName) {
		gv_newPopItemEditedName=new Array();
		gv_newPopItemEditedValue=new Array();
	}
	for(var i=0; i<gv_newPopItemEditedName.length; i++){
		if(gv_newPopItemEditedName[i]==itemName) {	gv_newPopItemEditedValue[i]=edValue; return; }
	}
	gv_newPopItemEditedValue[gv_newPopItemEditedName.length]=edValue;	
	gv_newPopItemEditedName[gv_newPopItemEditedName.length]=itemName;
}

function getEditedNewPopItemData(itemName)
{
  if(!gv_newPopItemEditedName) return null;	
	for(var i=0; i<gv_newPopItemEditedName.length; i++) {
		if(gv_newPopItemEditedName[i]==itemName) return gv_newPopItemEditedValue[i];
	}

}
function setNewPopItemPageScrollCommands(Cmd1,Cmd2)
{
	document.getElementById('popbtn1').innerHTML=Cmd1;
	document.getElementById('popbtn2').innerHTML=Cmd2;
	var popcmd=document.getElementById('popCmds').style;
	var ncmds=Cmd1.length<5 ? 0:1;
	if(Cmd2.length>5) ncmds++;
	popcmd.pixelWidth=150+50*ncmds;
	popcmd.pixelLeft=gv_winw-popcmd.pixelWidth-1;
}
function showSaveNewPopItemDataButton()
{
	if(document.getElementById('saveNewPopItemData')) return;
	setNewPopItemPageScrollCommands("<input type='button' id='saveNewPopItemData' value='Save' onclick='saveNewPopItemData();'/>","");
}

function showNewPopItemCount()
{  
    var NewPopItemTax=document.getElementById('NewPopItemTax_Code');
    if(NewPopItemTax)
    {
        if(NewPopItemTax.options[NewPopItemTax.selectedIndex])
        NewPopItemTax_Code=NewPopItemTax.options[NewPopItemTax.selectedIndex].value; 
    }
    if(document.getElementById('NewPopItemQuantity')){NewPopItemQuantity=document.getElementById('NewPopItemQuantity').value;}
    if(NewPopItemQuantity == "") { NewPopItemQuantity = 1.00;}
    if(document.getElementById('NewPopItemUnit_Price_GBP')){NewPopItemUnit_Price_GBP=document.getElementById('NewPopItemUnit_Price_GBP').value;}
	 NewPopItemNet_GBP=NewPopItemQuantity * NewPopItemUnit_Price_GBP;
	// NewPopItemTax_Code=document.getElementById('NewPopItemTax_Code').options[document.getElementById('NewPopItemTax_Code').selectedIndex].value
	 var TaxRateS = NewPopItemTax_Code.split("|$|");
	 TaxRate =parseFloat(TaxRateS[1]);
	 NewPopItemVAT_GBP = parseFloat(NewPopItemNet_GBP) * TaxRate / 100;
  	showNewPopItemDataPage("OtherLoad");
	if(document.getElementById('saveNewPopItemData')) return;
	setNewPopItemPageScrollCommands("<input type='button' id='saveNewPopItemData' value='Save' onclick='saveNewPopItemData();'/>","");
}
function saveNewPopItemData()
{
    if(document.getElementById('NewPopItemProduct_Code')){NewPopItemProduct_Code=document.getElementById('NewPopItemProduct_Code').value;}
    if(document.getElementById('NewPopItemDescription')){NewPopItemDescription=document.getElementById('NewPopItemDescription').value;}
    if(document.getElementById('NewPopItemUnits')){NewPopItemUnits=document.getElementById('NewPopItemUnits').value;}
    if(document.getElementById('NewPopItemComment1')){NewPopItemComment1=document.getElementById('NewPopItemComment1').value;}
    if(document.getElementById('NewPopItemComment2')){NewPopItemComment2=document.getElementById('NewPopItemComment2').value;}
    if(document.getElementById('NewPopItemProject_Ref')){NewPopItemProject_Ref=document.getElementById('NewPopItemProject_Ref').value;}
    if(document.getElementById('NewPopItemCost_Code')){NewPopItemCost_Code=document.getElementById('NewPopItemCost_Code').value;}
    if(document.getElementById('NewPopItemQuantity')){NewPopItemQuantity=document.getElementById('NewPopItemQuantity').value;}
    if(document.getElementById('NewPopItemUnit_Price_GBP')){NewPopItemUnit_Price_GBP=document.getElementById('NewPopItemUnit_Price_GBP').value;}
    if(document.getElementById('NewPopItemDiscount')){NewPopItemDiscount=document.getElementById('NewPopItemDiscount').value;}
    if(document.getElementById('NewPopItemDiscount_GBP')){NewPopItemDiscount_GBP=document.getElementById('NewPopItemDiscount_GBP').value;}
    if(document.getElementById('NewPopItemNet_GBP')){NewPopItemNet_GBP=document.getElementById('NewPopItemNet_GBP').value;}
    if(document.getElementById('NewPopItemVAT_GBP')){NewPopItemVAT_GBP=document.getElementById('NewPopItemVAT_GBP').value;}
    if(document.getElementById('NewPopItemNominal_Code')){NewPopItemNominal_Code=document.getElementById('NewPopItemNominal_Code').value;}
    if(document.getElementById('NewPopItemTax_Code')){NewPopItemTax_Code=document.getElementById('NewPopItemTax_Code').value;}
    if(document.getElementById('NewPopItemDepartment')){NewPopItemDepartment=document.getElementById('NewPopItemDepartment').value;}
    if(document.getElementById('NewPopItemAllocated')){NewPopItemAllocated=document.getElementById('NewPopItemAllocated').value;}
    if(document.getElementById('NewPopItemDespatched')){NewPopItemDespatched=document.getElementById('NewPopItemDespatched').value;}
    if(document.getElementById('NewPopItemTo_Deliver')){NewPopItemTo_Deliver=document.getElementById('NewPopItemTo_Deliver').value;}
    if(document.getElementById('NewPopItemIntrastat')){NewPopItemIntrastat=document.getElementById('NewPopItemIntrastat').value;}
    if(document.getElementById('NewPopItemDue_Date')){NewPopItemDue_Date=document.getElementById('NewPopItemDue_Date').value;}
    if(document.getElementById('NewPopItemLine_Information')){NewPopItemLine_Information=document.getElementById('NewPopItemLine_Information').value;}
    NewPopItemTax_Code=NewPopItemTax_Code.substring(1,3).replace(/(\s*$)/g,"");
    NewPopItemDepartment=NewPopItemDepartment.substring(0,2).replace(/(\s*$)/g,"");
    if(NewPopItemProduct_Code == "" && NewPopItemDescription != "")
    {
        alert("Please Select A Product!");
        //showNewPopItemDataPage("OtherLoad");
        return;
    }
    if(NewPopItemProduct_Code != "" && NewPopItemDescription == "")
    {
        alert("Please enter the Description!");
        //showNewPopItemDataPage("OtherLoad");
        return;
    }
    if(NewPopItemProduct_Code == "" && NewPopItemDescription == "")
    {
        alert("Please Select A Product!");
        //showNewPopItemDataPage("OtherLoad");
        return;
    }
    Button_onclick();
    showNewPopCount();
    NewPopItemTurnPage = 0;
    document.getElementById('saveNewPopItemData').style.visibility = "hidden";
    setNewPopPageScrollCommands("<input type='button' id='savenewpopdata' value='Save' onclick='saveNewPopData();' />","");
    NewPopItemDue_Date=getNewPopItemSysTime();
    NewPopItemUnits='',NewPopItemComment1='',NewPopItemComment2='',NewPopItemProject_Ref='',NewPopItemQuantity='',NewPopItemUnit_Price_GBP='',NewPopItemDiscount_GBP='',NewPopItemNominal_Code='',NewPopItemAllocated='',NewPopItemDespatched='';
    NewPopItemTo_Deliver='',NewPopItemIntrastat='',NewPopItemProduct_Code='',NewPopItemDescription='',NewPopItemCost_Code='',NewPopItemDiscount='',NewPopItemNet_GBP='',NewPopItemVAT_GBP='',NewPopItemTax_Code='';
    NewPopItemDepartment='',NewPopItemLine_Information='';
    backPops();
}




