function openRow(openrowobject)
{
	var object=openrowobject;
	if (document.all) {
		var temp=object.parentElement; 
		var table=temp.parentElement;
	}
	else {
		var temp=object.parentNode; 
		var table=temp.parentNode;
	}
	var id = parseInt(object.id.substring(1, object.id.indexOf("_")));
 	
 	var xxrow;
 	for (var i=0;i<table.rows.length;i++) 
 	{
 		xxrow = parseInt(table.rows[i].id.substring(table.rows[i].id.indexOf("_") + 1));
 		if (xxrow) 
 		if (xxrow == id) 
 		if (table.rows[i].style.display == "none") 
 		{
 			if (document.all) {table.rows[i].style.display = "inline";}
 			else {table.rows[i].style.display = 'table-row';}
 		} 
 		else 
 		{
 			if (document.all) {table.rows[i].style.display = "none";}
 			else {table.rows[i].setAttribute( 'style', 'display:none' );}
 		}
 	}
}

function myfunction(txt)
{
alert('adf6' + txt + 'sdf');
}

function passcustdlvr(var1, var2, var3, var4, var5, var6) {
InsertHidden(document.LANSA, 'DMWHID', var1);
InsertHidden(document.LANSA, 'DMACID', var2);
InsertHidden(document.LANSA, 'DMOTYP', var3);
InsertHidden(document.LANSA, 'DMSEQN', var4);
InsertHidden(document.LANSA, 'DMSEQh', var5);
InsertHidden(document.LANSA, 'DMDLCD', var6);
//alert('DONWeE')
//alert(var2)

return true;
}

function addOrderSPCLFields(part, partky, lnecde, lline, ordqtyFld, brnlidFld, avlqty, prddsc, lstprc, cusprc, corprc, selpck, code01) {

var rowQty = stdGetFromDocumentByNameOrId(document, ordqtyFld).value;
//var elBranch = stdGetFromDocumentByNameOrId(document, brnlidFld);
//var rowBranch = elBranch.value;
var rowBranch = brnlidFld;

InsertHidden(document.LANSA, 'PART', part);
InsertHidden(document.LANSA, 'PARTKY', partky);
InsertHidden(document.LANSA, 'LNECDE',lnecde);
InsertHidden(document.LANSA, 'LLINE', lline);
InsertHidden(document.LANSA, 'ORDQTY', rowQty);
InsertHidden(document.LANSA, 'BRNLID', rowBranch);
//InsertHidden(document.LANSA, 'AVLQTY', avlqty);
InsertHidden(document.LANSA, 'AVLQTY', rowQty);
InsertHidden(document.LANSA, 'PRDDSC', prddsc);
InsertHidden(document.LANSA, 'LSTPRC', lstprc);
InsertHidden(document.LANSA, 'CUSPRC', cusprc);
InsertHidden(document.LANSA, 'CORPRC', corprc);
InsertHidden(document.LANSA, 'SELPCK', selpck);
InsertHidden(document.LANSA, 'CODE01', code01);
// showToolWindow(true);
//alert(rowQty);
//alert(rowBranch);
return true;
}

function addOrderFields(part, partky, lnecde, lline, ordqtyFld, brnlidFld, avlqty, prddsc, lstprc, cusprc, corprc, selpck) {

var rowQty = stdGetFromDocumentByNameOrId(document, ordqtyFld).value;
var elBranch = stdGetFromDocumentByNameOrId(document, brnlidFld);
var rowBranch = elBranch.value;
var rowAvlQty = elBranch.options[elBranch.selectedIndex].getAttribute('tag_AVLQTYBR');

InsertHidden(document.LANSA, 'PART', part);
InsertHidden(document.LANSA,'PARTKY', partky);
InsertHidden(document.LANSA, 'LNECDE',lnecde);
InsertHidden(document.LANSA, 'LLINE', lline);
InsertHidden(document.LANSA, 'ORDQTY', rowQty);
InsertHidden(document.LANSA, 'BRNLID', rowBranch);
InsertHidden(document.LANSA, 'AVLQTY', rowAvlQty);
InsertHidden(document.LANSA, 'PRDDSC', prddsc);
InsertHidden(document.LANSA, 'LSTPRC', lstprc);
InsertHidden(document.LANSA, 'CUSPRC', cusprc);
InsertHidden(document.LANSA, 'CORPRC', corprc);
InsertHidden(document.LANSA, 'SELPCK', selpck);
// showToolWindow(true);
//alert(rowQty);
return true;
}
function orderDetailFields(dctordnum, dctordsts, dctbrnlid, dctinvnum) {
InsertHidden(document.LANSA, 'DCTORDNUM', dctordnum);
InsertHidden(document.LANSA,'DCTORDSTS', dctordsts);
InsertHidden(document.LANSA, 'DCTBRNLID',dctbrnlid);
InsertHidden(document.LANSA, 'DCTINVNUM', dctinvnum);
return true;
}
function toggleDisplay(elName) {
rows=getElementsByName(elName);
  for (i = 0; rows.length; i++)
  {
    el= rows[i];

    if (el.style.display) {

      switch(el.style.display) {
      case "none":
      el.style.display = 'block'
      break;
      case "block":
      el.style.display = 'none'
      break;
      }

    }
    else {return true;}
  }
return true;
}
function orderDetailFields_Rev2(dctordnum, dctordsts, dctbrnlid, dctinvnum, dctorddat, dctdlvdat, dctshpto, dctshpdsc, dctcstpoh, dctdlvfrm) {
InsertHidden(document.LANSA, 'DCTORDNUM', dctordnum);
InsertHidden(document.LANSA,'DCTORDSTS', dctordsts);
InsertHidden(document.LANSA, 'DCTBRNLID',dctbrnlid);
InsertHidden(document.LANSA, 'DCTINVNUM', dctinvnum);
InsertHidden(document.LANSA, 'DCTORDDAT', dctorddat);
InsertHidden(document.LANSA, 'DCTDLVDAT', dctdlvdat);
InsertHidden(document.LANSA, 'DCTSHPTO', dctshpto);
InsertHidden(document.LANSA, 'DCTSHPDSC', dctshpdsc);
InsertHidden(document.LANSA, 'DCTCSTPO#', dctcstpoh);
InsertHidden(document.LANSA, 'DCTDLVFRM', dctdlvfrm);
return true;
}
function addOrderSPCLFields2(part, partky, lnecde, lline, ordqtyFld, brnlidFld, avlqty, prddsc, lstprc, cusprc, corprc, selpck, i, code01) {

var divName = "d_" + i;
var rowQty = stdGetFromDocumentByNameOrId(document, ordqtyFld).value;
//var elBranch = stdGetFromDocumentByNameOrId(document, brnlidFld);
//var rowBranch = elBranch.value;
var rowBranch = brnlidFld;

InsertHidden(document.LANSA, 'PART', part);
InsertHidden(document.LANSA, 'PARTKY', partky);
InsertHidden(document.LANSA, 'LNECDE',lnecde);
InsertHidden(document.LANSA, 'LLINE', lline);
InsertHidden(document.LANSA, 'ORDQTY', rowQty);
InsertHidden(document.LANSA, 'BRNLID', rowBranch);
//InsertHidden(document.LANSA, 'AVLQTY', avlqty);
InsertHidden(document.LANSA, 'AVLQTY', rowQty);
InsertHidden(document.LANSA, 'PRDDSC', prddsc);
InsertHidden(document.LANSA, 'LSTPRC', lstprc);
InsertHidden(document.LANSA, 'CUSPRC', cusprc);
InsertHidden(document.LANSA, 'CORPRC', corprc);
InsertHidden(document.LANSA, 'SELPCK', selpck);
InsertHidden(document.LANSA, 'CODE01', code01);
// showToolWindow(true);
//alert(rowQty);
//alert(rowBranch);
if (document.getElementById(divName))
{
	if (document.getElementById(divName).style.display == 'none')
   	{
   	   	document.getElementById(divName).style.display = 'inline';
		if (window.name == 'SpcDtl')
		{
			//Resize the height of the window to accomodate messages if coming from Specials Design 2	
	  		var h = 0;
	  		var w = 0;
	  		if( typeof( window.innerWidth ) == 'number' ) 
	  		{
	   			//Non-IE
	   			h = window.innerHeight + 40;
	   			w = window.innerWidth;
	  		} 
	  		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	  		{
	    			//IE 6+ in 'standards compliant mode'
	   			h = document.documentElement.clientHeight + 40;
	   			w = document.documentElement.clientWidth;
	  		} 
	  		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	  		{
	    			//IE 4 compatible
	   			h = document.body.clientHeight + 40;
	   			w = document.body.clientWidth;
	  		}
	    		window.resizeTo(w, h);
	    	}
   	}
}
return true;
}

function addOrderFields2(part, partky, lnecde, lline, ordqtyFld, brnlidFld, avlqty, prddsc, lstprc, cusprc, corprc, selpck, i) 
{
	try
	{
		var divName = "n_" + i;
		var rowQty = stdGetFromDocumentByNameOrId(document, ordqtyFld).value;
		var elBranch = stdGetFromDocumentByNameOrId(document, brnlidFld);
		var rowBranch = elBranch.value;
		var rowAvlQty = elBranch.options[elBranch.selectedIndex].getAttribute('tag_AVLQTYBR');
	
		InsertHidden(document.LANSA, 'PART', part);
		InsertHidden(document.LANSA,'PARTKY', partky);
		InsertHidden(document.LANSA, 'LNECDE',lnecde);
		InsertHidden(document.LANSA, 'LLINE', lline);
		InsertHidden(document.LANSA, 'ORDQTY', rowQty);
		InsertHidden(document.LANSA, 'BRNLID', rowBranch);
		InsertHidden(document.LANSA, 'AVLQTY', rowAvlQty);
		InsertHidden(document.LANSA, 'PRDDSC', prddsc);
		InsertHidden(document.LANSA, 'LSTPRC', lstprc);
		InsertHidden(document.LANSA, 'CUSPRC', cusprc);
		InsertHidden(document.LANSA, 'CORPRC', corprc);
		InsertHidden(document.LANSA, 'SELPCK', selpck);
		// showToolWindow(true);
		//alert(rowQty);
		if (document.getElementById(divName))
		{
			if (document.getElementById(divName).style.display == 'none')
		   	{
		      		document.getElementById(divName).style.display = 'inline';
		   	}
		}
		
		//Resize the frame to accomodate for the added message
	  	var h1 = document.body.scrollHeight;
	  	var h2 = parent.document.body.scrollHeight;
	  	var thisFrame = parent.document.getElementById('_w_PAlist');
	  	var parentFrame = parent.parent.document.getElementById('_w_PartsCatalog');
	  	
	  	//parentFrame.style.height = parseInt(h2) + 80 + "px";
	  	thisFrame.style.height = parseInt(h1) + 40 + "px";
		return true;
	}
	catch(e)
	{
		alert(e.message);
	}
}

function LoadFile(fileType){
	var FSO;
	var nForReading=1;
	var validExt;
	var qty;
	var partNo;

	var strFileName = document.getElementById('oFile1').value;
	var splitter = '\n';
	var delimitter;
	var partsList = '';
	
	if (strFileName == null || strFileName == '')
	{
		alert('You need to specify what file to use for the import.');
		return false;		
	}

	if (fileType != 'EPC')
	{
		var rownum = parseInt(document.getElementById('Z2ROWNO').value);
		var partColNo = parseInt(document.getElementById('Z2PCOLNO').value);
		var qtyColNo = parseInt(document.getElementById('Z2QCOLNO').value);
		var preview = document.getElementById('Z1PREVIEW').value;
		
		
		var fileTypes = document.forms[0].elements['Z2FLETYP'];
		for (var i=0; i < fileTypes.length; i++)
		{
			if (fileTypes[i].checked)
		      	{
		      		fileType = fileTypes[i].value;
		      	}
		}
	
		if (fileType == null)
		{
			alert('You need to select a file type.');
			return false;
		}
	}
	
	switch (fileType)
	{
		case "EPC":
			validExt = 'XFR';
			delimitter = '|';
			break;
		case "XLS":
			validExt = 'XLS';
			break;
		case "CSV":
			validExt = '';		
			delimitter = ',';
			break;
		case "TAB":
			validExt = '';		
			delimitter = '\t';
			break;
		default:
			validExt = '';		
			delimitter = document.getElementById('Z1DELIM').value;
			if (delimitter == null || delimitter == '')
			{
				alert('No Delimiter was specified. Blank Space is assumed as the delimiter.');
				delimitter = ' ';
				//return false;
			}
	}

	switch (fileType)
	{
		case "XLS":
			try
			{
				var oEx = new ActiveXObject("Excel.Application");
				try
				{
					var oBo = oEx.Workbooks.Open(strFileName);
					var oSh = oBo.Worksheets(1);
	
    					i = rownum;
    					while ((oSh.Cells(i, partColNo).text != '') && (oSh.Cells(i, partColNo).text != null) && (i < rownum + 500))
    					{
    						partNo = oSh.Cells(i, partColNo).text;
						// Strip off Quotations from the part number
						partNo = partNo.replace(/"/g, '');
						partNo = partNo.replace(/\*/g, '');
						partNo = partNo.replace(/\./g, '');
						partNo = partNo.replace(/\s+/g, '');
    						if (isNaN(qtyColNo))
    						{
    							qty = '';
							partsList = partsList + partNo + splitter;
    						}
    						else
    						{
    							qty = oSh.Cells(i, qtyColNo);    					
							partsList = partsList + qty + ',' + partNo + splitter;
    						}
						i = i + 1;
    					}
   				
   					if (preview == 'Y')
   					{
						document.getElementById('oText1').value = partsList;
						document.getElementById('oText1').fireEvent('onChange');
						alert('Please review the Quantity/Parts Pair in the text area and click on Copy Into Order to see prices.');
					}
					else
					{
						document.getElementById('oText2').value = partsList;
						document.getElementById('oText2').fireEvent('onChange');				
					}
					partNo = null;
					qty = null;
					partsList = null;
					oSh = null;
					oBo.Close(false);
					oBo = null;
					oEx.Quit();
					oEx = null;			

   					if (preview != 'Y')
   					{
						document.getElementById('copyToOrder').fireEvent('onClick');
					}				
					return true;
				}
				catch(e)
				{
					e = 'Cannot process the file specified.';
					alert(e);
					partNo = null;
					qty = null;
					partsList = null;
					oSh = null;
					oBo.Close(false);
					oBo = null;
					oEx.Quit();
					oEx = null;					
				}					
			}
			catch(e)
			{
				//e = 'ActiveX is not enabled in your browser. To enable ActiveX:\n';
				//e = e + 'At the top of your browser, click on Tools, then Internet Options.\n';
				//e = e + 'Go to the Security Tab and then click on the Custom Level Button.\n';
				//e = e + 'Scroll down until you find the item \"Initialize and script ActiveX controls not marked as safe\"\n';
				//e = e + 'and make sure it is set to \"Prompt\" and not "\Disable\".\n';
				//e = e + 'Click on OK to exit out of Internet Options and try importing your file again.';
				//alert(e);
				e = 'ActiveX is not enabled in your browser. To enable ActiveX, click OK and follow the instructions on the next page.\n';
				var input_box=confirm(e);
				if (input_box==true)
				{
					window.open("/images/help/EnablingActiveX.htm");
				}
				partNo = null;
				qty = null;
				partsList = null;
				oSh = null;
				oBo.Close(false);
				oBo = null;
				oEx.Quit();
				oEx = null;					
			}
			break;
		default:	
			try
			{
				FSO = new ActiveXObject("Scripting.FileSystemObject");
				
				if (validExt != '')
				{
					if (strFileName.substr(strFileName.length - 3).toUpperCase() != validExt)
					{
						e = 'The file chosen is not a valid shopping list file. Please choose another file.';
						throw e;	
					}
				}
				
				var oFileObj = FSO.OpenTextFile(strFileName,nForReading, false);
				
				try
				{	
					var sFileContents=oFileObj.ReadAll();
				}
				catch(e)
				{
					e = 'The file can not be read. The file might be empty or not a text file.';
					throw e;
				}
				
				oFileObj.Close();
			
				var cartLines = sFileContents.split(splitter);
				if ((cartLines.length == 1) && (fileType == "EPC"))
				{
					e = 'The file only has one line. The first line should be reserved for header information.';
					throw e;
				}
			
				var lineItems = new Array();
				partsList = '';

				switch (fileType)
				{
					case "EPC":
						for (var i=1; i < cartLines.length - 1; i++)
						{
							lineItems = cartLines[i].split(delimitter);
							qty = parseInt(lineItems[2]);
							if (isNaN(qty))
							{
								qty = 1;
							}
							if (lineItems[0].substr(0, 1) == 'N' || lineItems[0].substr(0, 1) == 'A' || lineItems[0].substr(0, 1) == 'B')
							{
								partNo = lineItems[0].substr(1);
							}else
							{
								partNo = lineItems[0];
							}
							
							// Strip off Quotations from the part number
							partNo = partNo.replace(/"/g, '');
							partNo = partNo.replace(/\*/g, '');
							partNo = partNo.replace(/\./g, '');
							partNo = partNo.replace(/\s+/g, '');
							partsList = partsList + qty + ',' + partNo + splitter;
						}
						break;
					default:
						for (var i=rownum - 1; i < cartLines.length - 1; i++)
						{
							if (cartLines[i].indexOf(delimitter) > 0)
							{
								if (delimitter == ' ')
								{
									while (cartLines[i].indexOf('  ') > 0)
									{
										cartLines[i] = cartLines[i].replace('  ', ' ');
									}
								}
								lineItems = cartLines[i].split(delimitter);
								if (isNaN(qtyColNo))
								{
									qty = 1;							
								}
								else
								{
									qty = parseInt(lineItems[qtyColNo - 1]);							
								}
								partNo = lineItems[partColNo - 1];
								
								// Strip off Quotations from the part number
								partNo = partNo.replace(/"/g, '');
								partNo = partNo.replace(/\*/g, '');
								partNo = partNo.replace(/\./g, '');
								partNo = partNo.replace(/\s+/g, '');
								partsList = partsList + qty + ',' + partNo + splitter;
							}
							else
							{
								alert('The delimiter you specified does not exist in the file.');
								return false;
							}
						}
						break;
				}
				
   				if (preview == 'Y' || fileType == 'EPC')
   				{
					document.getElementById('oText1').value = partsList;
					document.getElementById('oText1').fireEvent('onChange');
					alert('Please review the Quantity/Parts Pair in the text area and click on Copy Into Order to see prices.');
				}
				else
				{
					document.getElementById('oText2').value = partsList;
					document.getElementById('oText2').fireEvent('onChange');				
					document.getElementById('copyToOrder').fireEvent('onClick');
				}
				return true;
			}
			catch(e)
			{
				//e = 'ActiveX is not enabled in your browser. To enable ActiveX:\n';
				//e = e + 'At the top of your browser, click on Tools, then Internet Options.\n';
				//e = e + 'Go to the Security Tab and then click on the Custom Level Button.\n';
				//e = e + 'Scroll down until you find the item \"Initialize and script ActiveX controls not marked as safe\"\n';
				//e = e + 'and make sure it is set to \"Prompt\" and not "\Disable\".\n';
				//e = e + 'Click on OK to exit out of Internet Options and try importing your file again.';
				//alert(e);
				e = 'ActiveX is not enabled in your browser. To enable ActiveX, click OK and follow the instructions on the next page.\n';
				var input_box=confirm(e);
				if (input_box==true)
				{
					window.open("/images/help/EnablingActiveX.htm");
				}
			}							
	}
}

function fireClickEvent(control) 
{
    if (document.all) 
    {
        control.fireEvent('onclick'); 
    } 
    else 
    {
        var clickEvent = document.createEvent('MouseEvents'); 
        clickEvent.initEvent('click', false, true); 
        control.dispatchEvent(clickEvent); 
    } 
} 

function getWindowHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
	return myHeight;
}
function getTZDate()
{
	var myDate = new Date();
	var myYear = myDate.getFullYear();
	var myMonth = myDate.getMonth();
	var myDay = myDate.getDay();
	var isDST = false; /* whether we are in Daylight Saving Time or not */
	var timeZoneOffset = myDate.getTimezoneOffset() / 60;
	var TZ;
	var TZDate;

	switch (myYear)
	{
		case 2007:
		{
			if (Date.parse(myDate) < Date.parse("March 11, 2007") || Date.parse(myDate) > Date.parse("November 4, 2007")){isDST = false;}
			else {isDST = true;}
			break;
		}
		case 2008:
		{
			if (Date.parse(myDate) < Date.parse("March 9, 2008") || Date.parse(myDate) > Date.parse("November 2, 2008")){isDST = false;}
			else {isDST = true;}
			break;
		}
		case 2009:
		{
			if (Date.parse(myDate) < Date.parse("March 8, 2009") || Date.parse(myDate) > Date.parse("November 1, 2009")){isDST = false;}
			else {isDST = true;}
			break;
		}
		case 2010:
		{
			if (Date.parse(myDate) < Date.parse("March 14, 2010") || Date.parse(myDate) > Date.parse("November 7, 2010")){isDST = false;}
			else {isDST = true;}
			break;
		}
		case 2011:
		{
			if (Date.parse(myDate) < Date.parse("March 13, 2011") || Date.parse(myDate) > Date.parse("November 6, 2011")){isDST = false;}
			else {isDST = true;}
			break;
		}
		case 2012:
		{
			if (Date.parse(myDate) < Date.parse("March 11, 2012") || Date.parse(myDate) > Date.parse("November 4, 2012")){isDST = false;}
			else {isDST = true;}
			break;
		}
	}

	if (isDST)
	{
		switch (timeZoneOffset)
		{
			case 4:{TZ = "AST or EDT";break;}
			case 5:{TZ = "CDT";break;}
			case 6:{TZ = "MDT";break;}
			case 7:{TZ = "PDT";break;}
		}
	}
	else
	{
		switch (timeZoneOffset)
		{
			case 4:{TZ = "AST";break;}
			case 5:{TZ = "EST";break;}
			case 6:{TZ = "CST";break;}
			case 7:{TZ = "MST";break;}
			case 8:{TZ = "PST";break;}
		}
	}
	// Do not add the time zone unless they ask for it
	// TZDate = myDate.toLocaleString() + " (" + TZ + ")";
	TZDate = myDate.toLocaleString();
	return TZDate;
}

function setHeights()
{
	var mainRowH = 0;
	var catalogH = 0;
	var orderprH = 0;
	var savedorH = 0;
	var orderhiH = 0;
	var orderrvH = 0;
	var specialH = 0;
	
	//Check for MC2 footer
	//Ahmadou on 03/25/2010
	
	if(document.getElementById('mc2footer'))
	{	
		if( typeof( window.innerWidth ) == 'number' ) 
		{
			//Non-IE
			mainRowH = window.innerHeight - 150;
			catalogH = mainRowH - 46;
			orderprH = mainRowH - 46;
			savedorH = mainRowH - 46;
			orderhiH = mainRowH - 46;
			orderrvH = mainRowH - 46;
			specialH = mainRowH - 46;		
		} 
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{
			//IE 6+ in 'standards compliant mode'
			mainRowH = document.documentElement.clientHeight - 170;
			catalogH = mainRowH - 30;
			orderprH = mainRowH - 30;
			savedorH = mainRowH - 30;
			orderhiH = mainRowH - 30;
			orderrvH = mainRowH - 30;
			specialH = mainRowH - 30;		
		} 
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
		{
			//IE 4 compatible
			mainRowH = document.body.clientHeight - 170;
			catalogH = mainRowH - 30;
			orderprH = mainRowH - 30;
			savedorH = mainRowH - 30;
			orderhiH = mainRowH - 30;
			orderrvH = mainRowH - 30;
			specialH = mainRowH - 30;		
		}
	}
	else
	{
		if( typeof( window.innerWidth ) == 'number' ) 
		{
			//Non-IE
			mainRowH = window.innerHeight - 145;
			catalogH = mainRowH - 46;
			orderprH = mainRowH - 46;
			savedorH = mainRowH - 46;
			orderhiH = mainRowH - 46;
			orderrvH = mainRowH - 46;
			specialH = mainRowH - 46;		
		}
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{
			//IE 6+ in 'standards compliant mode'
			mainRowH = document.documentElement.clientHeight - 165;
			catalogH = mainRowH - 30;
			orderprH = mainRowH - 30;
			savedorH = mainRowH - 30;
			orderhiH = mainRowH - 30;
			orderrvH = mainRowH - 30;
			specialH = mainRowH - 30;		
		} 
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
		{
			//IE 4 compatible
			mainRowH = document.body.clientHeight - 165;
			catalogH = mainRowH - 30;
			orderprH = mainRowH - 30;
			savedorH = mainRowH - 30;
			orderhiH = mainRowH - 30;
			orderrvH = mainRowH - 30;
			specialH = mainRowH - 30;		
		}
	}

	document.getElementById('mainRow').style.height = mainRowH;
	document.getElementById('catalog_f').style.height = catalogH;
	document.getElementById('order_f').style.height = orderprH;
	document.getElementById('special_f').style.height = specialH;
	document.getElementById('savedord_f').style.height = savedorH;
	document.getElementById('orderh_f').style.height = orderhiH;
	document.getElementById('orderr_f').style.height = orderrvH;
	
	// Set the height of the tab divs
	document.getElementById('DstTabPage_content_1').style.height = specialH;
	document.getElementById('DstTabPage_content_2').style.height = orderprH;
	document.getElementById('DstTabPage_content_3').style.height = catalogH;
	document.getElementById('DstTabPage_content_4').style.height = savedorH;
	document.getElementById('DstTabPage_content_5').style.height = catalogH;
	document.getElementById('DstTabPage_content_6').style.height = catalogH;
	
}

function preSubmit1()
{	
	var elOrdNav=window.parent.parent.frames["w_OrderParts"];
	elOrdNav.document.write("<html><head>"
				+ "</head><body style=" 
				+ "\"" + "background-color:transparent; text-align: center;" + "\"" + ">" 
				+ "<div id=" + "\"" + "waitDiv" + "\"" + ">"
				+ "<img src=" + "\"" + "/images/wam/plzwait.gif" + "\""
				+ " width=" + "\"" + "50" + "\""
				+ " height=" + "\"" + "50" + "\""
				+ " alt=" + "\"" + "Please wait while your request is being processed ..." + "\""
				+ "></img></div>"
				+ "</body></html>"); 
	elOrdNav.document.close();
	
	//fireClickEvent(window.parent.parent.document.getElementById("tabs_Main_tab2"));
	parent.parent.stdTabPagesSelectTab("DstTabPage", 2);
}
function tempResize()
{
	if( typeof( window.innerWidth ) == 'number' ) {
        // Non-IE
		if (parent.parent.document.getElementById('_w_PAlist'))
		{
			var hDiv = parent.parent.document.getElementById('_w_PAlist');
		}
		else
		{
			var hDiv = parent.parent.document.getElementById('_w_InterchangeList');		
		}		
        	//hDiv.scrolling = 'YES';
        }
}

function disableSpclPrice()
{
	var ind = document.getElementById('GRPNUM').selectedIndex;
	var isDisabled;
	var grptyp = document.getElementById('GRPNUM').options[ind].tag_GRPTYP;
	
	if (grptyp == 'P') 
	{
		isDisabled = true;
		document.getElementById('validation').style.display = 'inline';
	}
	else 
	{
		isDisabled = false;
		document.getElementById('validation').style.display = 'none';
	}
	
	var elm = document.getElementById('SPCLST');
	elm.disabled = isDisabled;
	elm = document.getElementById('SPCPRC');
	elm.disabled = isDisabled;
	elm = document.getElementById('SPCCOR');
	elm.disabled = isDisabled;
	//elm = document.getElementById('SPCSPK');
	//elm.disabled = isDisabled;
	elm = document.getElementById('SPCBRN');
	elm.disabled = isDisabled;

	return true;
}

function selectAllChkbx()
{
	var status;
	var val;
	var hiddenPart;
	if (document.getElementById('slctAll').checked)
	{
		status = true;
		val = 'Y';
	}
	else
	{
		status = false;
		val = 'N';
	}

	for(var i=0; i<document.forms[0].elements.length; i++)
	{
		hiddenPart = '';
	   	try
	   	{
	   	   	if (document.forms[0].elements[i].type + "" == 'checkbox')
	   	   	{
	   	   		hiddenPart = document.forms[0].elements[i].name;
	   	   		hiddenPart = hiddenPart.substring(2, hiddenPart.length - 6);
	   	   		document.forms[0].elements[i].checked = status;	   	   			
	   	   		document.forms[0].elements[i].value = val;
	   	   		document.forms[0].elements[hiddenPart].value = val;
	   	   	}
	   	}
	   	catch(e)
	   	{}
	}
}

function jumpTo(frameName, tabNumber)
{
	var elOrdNav=window.parent.parent.frames[frameName];
	//var elmName = 'tabs_Main_tab' + tabNumber;
	//window.parent.parent.document.getElementsByName(elmName)[0].fireEvent("onclick");
	parent.parent.stdTabPagesSelectTab("DstTabPage", tabNumber);
	elOrdNav.document.write("<html><head></head><body style=" + "\"" + "background-color:transparent" + "\"" + ">" + stdNavPanelGetWaitHTML(elOrdNav, "/images/wam/loading_animation.gif", "", "", "", "") + "</body></html>");
	elOrdNav.document.close();
}

function is_invalideInput_SPCL(elmNumber)
{
	var inputName;
	var qty;
	var sellPack;
	var d1;
	var d2;
	var counter = "0000";
	if (elmNumber == 'a')
	{
		// Validate All Input Fields	
		try
		{
		 	var table = stdGetFromDocumentByNameOrId(document, 'specials');
		 	for (var i=0;i<table.rows.length;i++) 
		 	{
				counter = counter.substr(1, 4 - i.toString().length) + i.toString();
				inputName = '__SPCL.' + counter + '.STDSELECT_PROXY';
				
				if (stdGetFromDocumentByNameOrId(document, inputName))
				{
					if (stdGetFromDocumentByNameOrId(document, inputName).checked == true)
					{
						inputName = 'SPCL.' + counter + '.ORDQTY';
						qty = parseInt(stdGetFromDocumentByNameOrId(document, inputName).value);
						inputName = 'SPCL.' + counter + '.SPCSPK';
						sellPack = parseInt(stdGetFromDocumentByNameOrId(document, inputName).value);
						d1 = parseInt(qty/sellPack);
						d2 = parseFloat(qty/sellPack);
						if (d1 != d2)
						{
							alert('Quantities should be a multiple of their respective Sell Pack.');
							return true;
						}
					}
				}
				counter = "0000";
		 	}
		 	return false;
		}
		catch(e)
		{
			alert(e);
			return true;
		}
	}
	else
	{
		try
		{
			counter = counter.substr(1, 4 - elmNumber.toString().length) + elmNumber.toString();
			inputName = 'SPCL.' + counter + '.ORDQTY';
			qty = parseInt(stdGetFromDocumentByNameOrId(document, inputName).value);
			inputName = 'SPCL.' + counter + '.SPCSPK';
			sellPack = parseInt(stdGetFromDocumentByNameOrId(document, inputName).value);
			d1 = parseInt(qty/sellPack);
			d2 = parseFloat(qty/sellPack);
			if (d1 != d2)
			{
				alert('Quantity should be a multiple of the Sell Pack.');
				return true;
			}
		 	return false;
		}
		catch(e)
		{
			alert(e);
			return true;
		}
	}
}

function is_invalideInput_Login()
{
	var inputName;
	// Validate All Input Fields 
	try
	{
		inputName = 'WUSPRF';
		if (document.getElementById(inputName).value == null || document.getElementById(inputName).value == '')
		{
			alert('User Profile cannot be blank.');
			return true;
		}
		
		inputName = 'WUSPWD';
		if (document.getElementById(inputName).value == null || document.getElementById(inputName).value == '')
		{
			alert('Password cannot be blank.');
			return true;
		}
		
		// Make sure the screen size flag is sent with a correct value
		if ((screen.width>=1024) && (screen.height>=768))
		{
		 	stdGetFromDocumentByNameOrId(document, "ZZSCRSIZE").value = 'L';
		}
		else
		{
		 	stdGetFromDocumentByNameOrId(document, "ZZSCRSIZE").value = 'S';
		}
		
		return false;
	}
	catch(e)
	{
		alert(e);
		return true;
	}
}


function disableAnchor_Ordrvw(obj, disable)
{
	if(disable)
	{
		var href = obj.getAttribute("href");
		if(href && href != "" && href != null)
		{
			obj.setAttribute('href_bak', href);
		}
		obj.removeAttribute('href');
		obj.style.color="gray";
	}
	else
	{
		obj.setAttribute('href', obj.attributes['href_bak'].nodeValue);
		obj.style.color="blue";
	}
}

function disableButtons_Ordrvw()
{
	for(var i=0; i<document.forms[0].elements.length; i++)
	{
		try
		{
			if (document.forms[0].elements[i].type + "" == 'button' ||  document.forms[0].elements[i].type == 'submit') 
				document.forms[0].elements[i].disabled = true;
		}
		catch(e)
		{}
	}

	for(var i=0; i<document.anchors.length; i++)
	{
		try
		{
			disableAnchor_Ordrvw(document.anchors[i], 1);
		}
		catch(e)
		{}
	}
}

function is_invalidInput_ORVW(stdrentry)
{
	var inputName;
	var qty;
	var sellPack;
	var avlQty;
	var d1;
	var d2;
	var counter = "0000";
	var thisRow;
	var rowClass;
	var avlFlag;

	// Validate All Input Fields	
	try
	{
	 	var table = document.getElementById('orderLines');
	 	for (var i=0;i<table.rows.length;i++) 
	 	{
	 		thisRow = table.getElementsByTagName("tr")[i];
	 		rowClass = thisRow.className;
			counter = counter.substr(1, 4 - i.toString().length) + i.toString();
			
			if (rowClass == "ReviewV")
			{
				inputName = 'BLRDPNORD.' + counter + '.DCTORDQTY';
				
				if (document.getElementById(inputName))
				{
					qty = parseInt(document.getElementById(inputName).value);
					inputName = 'BLRDPNORD.' + counter + '.DCTPKGQTY';
					sellPack = parseInt(document.getElementById(inputName).value);
					
					// Check for quantity to be less than 9999
					if (qty > 9999)
					{
						alert('Order Quantity CANNOT be more than 9999. Please adjust the quantity and try again.');
						return true;
					}
					
					if (sellPack > 0)
					{
						d1 = parseInt(qty/sellPack);
						d2 = parseFloat(qty/sellPack);
					
						// Check to see if the qty requested is multiply of sell pack
						if (d1 != d2)
						{
							alert('Quantities should be a multiple of their respective Sell Pack.');
							return true;
						}
					}
					
					// Check to see if the qty requested is more than available quantity
					avlFlag = document.getElementById('Z1ALLOWFL').value;
					if (avlFlag == "2")
					{
						inputName = 'BLRDPNORD.' + counter + '.DCTAVLQTY';
						avlQty = parseInt(document.getElementById(inputName).value);
						if (qty > avlQty)
						{
							alert('Requested Quantity cannot be more than available quantity for a line item.');
							return true;				
						}
					}
				}
			}
			counter = "0000";
	 	}
	 	// Check for Warranty (RO) Number is this is a warranty order before placing the order
		var frghtFlag = document.getElementById('Z1FRALWFL').value;
		if (frghtFlag == 'Y')
		{
			if (stdrentry == 'P')
			{
				var rad = document.getElementsByName('Z2RADVAL');
       				if (rad != null)
       				{
      					if (rad[0].checked)
       					{
       						var roNum = document.getElementById('WARNUM').value;
       						if (roNum == null || roNum == '')
            					{
            						alert('You have specified this order as a Warranty Order but have not entered the Warranty Number.');
            						return true;
            					}
            				}
            			}
            		}
	            	// Update the free freight usage
	            	updateUsedAllw();
            	}
	 	disableButtons_Ordrvw();
	 	return false;
	}
	catch(e)
	{
		alert(e);
		return true;
	}
}


function Set_Cookie( name, value, expires, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	// if the expires variable is set, make the correct expires time, the
	// current script below will set it for x number of days, to make it
	// for hours, delete * 24, for minutes, delete * 60 * 24
	if ( expires )
	{
		expires = expires * 1000 * 60 * 60 * 24;
	}
	//alert( 'today ' + today.toGMTString() );// this is for testing purpose only
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());// this is for testing purposes only

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

function initRVWPage()
{
	var table = document.getElementById('orderLines');
	var divTag = '';
	var dropdown = null;
	var id = '0000';
	var rowNum = null;
	try
	{
		var frghtFlag = null;
		frghtFlag = document.getElementById('Z1FRALWFL').value;
		// Check if Warranty Question is rendered on the page (meaning the warehouse is using the Freight Allowance Program
		if (frghtFlag == 'Y')
		{
			// alert('Initializing ...');
			// show/hide freight allowance question based on the value of Delivery Codes
			for (var i=0;i<table.rows.length;i++)
			{
				id = '0000';
				rowNum = i + '';
				id = 'BLRDPNORD.' + id.substr(1, 4 - rowNum.length) + rowNum + '.DCTSHPCOD';
				dropdown = stdGetFromDocumentByNameOrId(document, id);
				if (dropdown && dropdown.type == 'select-one')
				{
					showFrghtQ(id);			
				}
			}
			var frghtAllwnce = parseInt(document.getElementById('DXALLO').value);
			var d = document.getElementById('roNum');
			var d2 = document.getElementById('frtQ');
			var rad = document.getElementsByName('Z2RADVAL');
			if (rad[0].checked)
			{
				d.style.display = 'inline';
				d2.style.display = 'none';
			}
			else
			{
				d.style.display = 'none';
				if (frghtAllwnce == -99)
				{
					d2.style.display = 'none';
				}
				else
				{
					d2.style.display = 'inline';			
				}
			}
		}
	}
	catch (e)
	{
		alert(e.message);
	}
}

function showFrghtQ(id)
{
	try
	{
		var frghtFlag = null;
		frghtFlag = document.getElementById('Z1FRALWFL').value;
		if (frghtFlag == 'Y')
		{
			var dropdown = document.getElementById(id);
			var frghtAllwnce = parseInt(document.getElementById('DXALLO').value);
			var isEligible = false;
			var relCode = '';
			if (dropdown)
			{
				for (var i=0;i<dropdown.options.length;i++)
				{
					if (dropdown.options[i].selected == true || i == dropdown.selectedIndex)
					{
						relCode = dropdown.options[i].text.substr(0, 2);
						//frghtAllwnce = parseInt(dropdown.options[i].getAttribute('tag_DXALLO'));
						break;
					}
				}			
			}
			var isWarranty = document.getElementsByName('Z2RADVAL');
			var rowNum = parseInt(id.substr(id.indexOf('.') + 1, 4), 10);
			var divTag = document.getElementById('div_' + rowNum);
			if (isWarranty[0].checked == false)
			{
				if (frghtAllwnce > 0 && relCode == '$-')
				{
					divTag.style.display = 'inline';
				}
				else
				{
					divTag.style.display = 'none';
				}
			}
			else
			{
				divTag.style.display = 'none';
			}
		}
	}
	catch (e)
	{
		alert(e);
	}
}

function showRO()
{
	try
	{
		var frghtAllwnce = parseInt(document.getElementById('DXALLO').value); 
		var d = document.getElementById('roNum');
		var d2 = document.getElementById('frtQ');
		var rad = document.getElementsByName('Z2RADVAL');
		if (rad[0].checked)
		{
			d.style.display = 'inline';
			d2.style.display = 'none';
		}
		else
		{
			d.style.display = 'none';
			if (frghtAllwnce == -99)
			{
				d2.style.display = 'none';
			}
			else
			{
				d2.style.display = 'inline';			
			}
			document.getElementById('WARNUM').value = '';
		}
		initRVWPage();
	}
	catch (e)
	{
		alert(e);
	}
}

function updateUsedAllw()
{
	try
	{
		var table = document.getElementById('orderLines');
		var rad = null;
		var id = null;
		var currUsage = 0;
		for (var i=0;i<table.rows.length;i++)
		{
			id = '0000';
			rowNum = i + '';
			id = 'BLRDPNORD.' + id.substr(1, 4 - rowNum.length) + rowNum + '.FRALFL';
			rad = document.getElementsByName(id);
			if (rad[0])
			{
				if (rad[0].checked)
				{
					currUsage++;
				}
			}
		}
		document.getElementById('Z2DXALLO').value = currUsage + '';
	}
	catch (e)
	{
		alert(e);
	}
}

function dummy()
{
	return 0;
	//;
}

function doHandCursor()
{
	document.body.style.cursor = 'pointer';
	document.body.style.cursor = 'hand';
}         

function resetCursor()
{
	document.body.style.cursor = 'default';
}

function betaAlert()
{
	alert('Our Spanish version is in Beta testing. Please report any misspelling or mistranslation to dstservice@dstinc.com and make sure you include your User ID in the email. Thank you for your business.');
}

function toggleSearch(msgFlag)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var divName = "searchParms";
		var sts = stdGetFromDocumentByNameOrId(document, "DCTORDSTS_options");
		var searchFlag = sts.options[sts.selectedIndex].getAttribute('tag_TSSRCH');
		var ordSts = sts.options[sts.selectedIndex].value;
		if (searchFlag == 0)
		{
			document.getElementById(divName).style.display = 'none';
		}
		else
		{
			document.getElementById(divName).style.display = 'inline';
		}
		
		if (msgFlag)
		{
			sendAJAXRequest('w_SearchHelp', 'ZZRENTRY', 1, 'TPORDHIST', 'SearchHelp', 'DCTORDSTS', ordSts, 'ZZRENTRY', 1, true, lang, portNo);
		}
		return true;
	}
	catch(e)
	{
		alert(e.message);
	}
}

function searchDocs(searchType)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var sts = stdGetFromDocumentByNameOrId(document, "DCTORDSTS_options");
		var ordSts = sts.options[sts.selectedIndex].value;
		var postData = "";
		postData += "&" + "DCTORDSTS" + "=" + escape(ordSts);
		
		switch (searchType)
		{
			case "A":
				var ordNum = stdGetFromDocumentByNameOrId(document, "DCTORDNUM_s").value;
				var brnchNum = stdGetFromDocumentByNameOrId(document, "DCTBRNLID_s").value;
				postData += "&" + "DCTBRNLID" + "=" + escape(brnchNum);
				sendAJAXRequestWithPostData('w_HistoryList', 'TPORDHIST', 'Search', 'ZZRENTRY', searchType, 'DCTORDNUM', ordNum, postData, true, lang, portNo);
				break;
			case "B":
				var invNum = stdGetFromDocumentByNameOrId(document, "DCTINVNUM_s").value;
				var brnchNum = stdGetFromDocumentByNameOrId(document, "DCTBRNLID_s").value;
				postData += "&" + "DCTBRNLID" + "=" + escape(brnchNum);
				sendAJAXRequestWithPostData('w_HistoryList', 'TPORDHIST', 'Search', 'ZZRENTRY', searchType, 'DCTINVNUM', invNum, postData, true, lang, portNo);
				break;
			case "P":
				var poNum = stdGetFromDocumentByNameOrId(document, "DCTCUSTPO_s").value;
				sendAJAXRequestWithPostData('w_HistoryList', 'TPORDHIST', 'Search', 'ZZRENTRY', searchType, 'DCTCUSTPO', poNum, postData, true, lang, portNo);
				break;
		}
		return true;
	}
	catch(e)
	{
		alert(e);
		return true;
	}
}

function getAnotherDocPage(nextPageFlag)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var stdrentry = stdGetFromDocumentByNameOrId(document, "ZZRENTRY").value;
		var postData = "";
		postData += "&" + "NXDATE" + "=" + escape(stdGetFromDocumentByNameOrId(document, "NXDATE").value);
		postData += "&" + "NXBRNCH" + "=" + escape(stdGetFromDocumentByNameOrId(document, "NXBRNCH").value);
		postData += "&" + "NXINVOICE" + "=" + escape(stdGetFromDocumentByNameOrId(document, "NXINVOICE").value);
		postData += "&" + "NXORDER" + "=" + escape(stdGetFromDocumentByNameOrId(document, "NXORDER").value);
		postData += "&" + "DCTORDSTS" + "=" + escape(stdGetFromDocumentByNameOrId(document, "DCTORDSTS").value);
		postData += "&" + "DCTINVNUM" + "=" + escape(stdGetFromDocumentByNameOrId(document, "DCTINVNUM").value);
		postData += "&" + "DCTBRNLID" + "=" + escape(stdGetFromDocumentByNameOrId(document, "DCTBRNLID").value);
		postData += "&" + "DCTCUSTPO" + "=" + escape(stdGetFromDocumentByNameOrId(document, "DCTCUSTPO").value);
		postData += "&" + "DCTORDNUM" + "=" + escape(stdGetFromDocumentByNameOrId(document, "DCTORDNUM").value);
		postData += "&" + "ZZCPGENO" + "=" + escape(stdGetFromDocumentByNameOrId(document, "ZZCPGENO").value);

		var elmName;
		var counter = "0000";
		var j = 1;
		for (var i= 0; i < document.forms[0].elements.length; i++)
		{
			elmName = document.forms[0].elements[i].name;
			if (elmName.indexOf("ZZINDEX") >= 0)
			{
				counter = counter.substr(1, 4 - j.toString().length) + j.toString();
				if (elmName.indexOf("ZZPDATE") >= 0)
				{
					elmName = "ZZINDEX" + "." + counter + "." + "ZZPDATE";
					postData += "&" + elmName + "=" + escape(document.forms[0].elements[i].value);
				}
				if (elmName.indexOf("ZZPBRNCH") >= 0)
				{
					elmName = "ZZINDEX" + "." + counter + "." + "ZZPBRNCH";
					postData += "&" + elmName + "=" + escape(document.forms[0].elements[i].value);
				}
				if (elmName.indexOf("ZZPINVCE") >= 0)
				{
					elmName = "ZZINDEX" + "." + counter + "." + "ZZPINVCE";
					postData += "&" + elmName + "=" + escape(document.forms[0].elements[i].value);
				}
				if (elmName.indexOf("ZZPORDER") >= 0)
				{
					elmName = "ZZINDEX" + "." + counter + "." + "ZZPORDER";
					postData += "&" + elmName + "=" + escape(document.forms[0].elements[i].value);
				}
				if (elmName.indexOf("ZZPGENO") >= 0)
				{
					elmName = "ZZINDEX" + "." + counter + "." + "ZZPGENO";
					postData += "&" + elmName + "=" + escape(document.forms[0].elements[i].value);
					j++;
				}
				counter = "0000";
			}
		}
		j = j - 1;
		postData = "&ZZINDEX..=" + j + postData;
		sendAJAXRequestWithPostData('w_HistoryList', 'TPORDHIST', 'Search', 'STDNEXT', nextPageFlag, 'ZZRENTRY', stdrentry, postData, true, lang, portNo);

		return true;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function getDocDetail(dctordnum, dctordsts, dctbrnlid, dctinvnum, dctorddat, dctdlvdat, dctshpto, dctshpdsc, dctcstpoh, dctdlvfrm)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var postData = "";
		postData += "&" + "DCTORDNUM" + "=" + escape(dctordnum);
		postData += "&" + "DCTORDSTS" + "=" + escape(dctordsts);
		postData += "&" + "DCTBRNLID" + "=" + escape(dctbrnlid);
		postData += "&" + "DCTINVNUM" + "=" + escape(dctinvnum);
		postData += "&" + "DCTORDDAT" + "=" + escape(dctorddat);
		postData += "&" + "DCTDLVDAT" + "=" + escape(dctdlvdat);
		postData += "&" + "DCTSHPTO" + "=" + escape(dctshpto);
		postData += "&" + "DCTSHPDSC" + "=" + escape(dctshpdsc);
		postData += "&" + "DCTCSTPO#" + "=" + escape(dctcstpoh);
		postData += "&" + "DCTDLVFRM" + "=" + escape(dctdlvfrm);

		window.scroll(0,0);
		sendAJAXRequestWithPostData('w_OderDetail1', 'TPORDER', 'orderDetail', 'STDRENTRY', 1, 'STDRENTRY', 1, postData, true, lang, portNo);

		return true;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function getStatementDetail(docNum, docDate)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		sendAJAXRequest('w_OderDetail1', 'ZZRENTRY', 'D', 'TPORDHIST', 'STMDetail', 'Z1DOCNUM', docNum, 'Z1DOCDATE', docDate, true, lang, portNo);

		return true;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function viewDocList()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var sts = stdGetFromDocumentByNameOrId(document, "DCTORDSTS_options");
		var ordSts = sts.options[sts.selectedIndex].value;
		switch (ordSts)
		{
			case "S":
				sendAJAXRequest('w_HistoryList', 'ZZRENTRY', 'D', 'TPORDHIST', 'GetStatements', 'DCTORDSTS', ordSts, 'ZZRENTRY', 'D', true, lang, portNo);
				break;
			default:
				sendAJAXRequest('w_HistoryList', 'ZZRENTRY', 'D', 'TPORDHIST', 'Search', 'DCTORDSTS', ordSts, 'ZZRENTRY', 'D', true, lang, portNo);
				break;
		}
		return true;
	}
	catch(e)
	{
		alert(e);
		return true;
	}
}

function validateRegForm()
{
	try
	{
		var errMsg = '';
		var inputName = 'DXCONT';
		var newPwd1;
		var newPw21;
		var inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([a-zA-Z]|[0-9])([-a-zA-Z0-9\s]*)$/)) {errMsg += '- Contact Name is required and should only include letters or numbers. <br/>';}
		
		inputName = 'DXADD1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([a-zA-Z]|[0-9])([-a-zA-Z0-9\s@_\.#]*)$/)) {errMsg += '- Address Line 1 is required and should only include letters, numbers or @, _, # or . <br/>';}
		
		inputName = 'DXCITY';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([a-zA-Z])([-a-zA-Z\s]*)$/)) {errMsg += '- City is required and should only include letters. <br/>';}
		
		inputName = 'DXSTAT';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([a-zA-Z]){2}$/)) {errMsg += '- State is required and should only be 2 letters. <br/>';}
		
		inputName = 'DXZIP';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([a-zA-Z]|[0-9])([-a-zA-Z0-9]*)$/)) {errMsg += '- Zip Code is required and should only include letters and numbers. <br/>';}
		
		inputName = 'DXCTRY';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([a-zA-Z])([-a-zA-Z\s]*)$/)) {errMsg += '- Country is required and should only include letters. <br/>';}
		
		inputName = 'DXEML1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([0-9a-zA-Z]+[-._+&amp;])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/)) {errMsg += '- Email Address is required and should be in the correct format. <br/>';}
		inputName = 'ZZDXEML1';
		if (stdGetFromDocumentByNameOrId(document, inputName) != null) 
		{
			email2 = stdGetFromDocumentByNameOrId(document, inputName).value;
			if (inputValue != email2) {errMsg += '- Email Address and Confirm Email Address should match. <br/>';}
		}		
		
		inputName = 'DXTEL1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		// if (!inputValue.match(/((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}/)) {errMsg += '- Phone Number is required and should be in the correct format ((xxx)xxx-xxxx or xxx-xxx-xxxx). <br/>';}
		if (!inputValue.match(/\d{10}/)) {errMsg += '- Phone Number is required and should only be numbers (no parentheses or dashes). <br/>';}
		
		inputName = 'DXTPCT';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (parseInt(inputValue, 10) <= 0) {errMsg += '- Please select a Business Type. <br/>';}
		
		inputName = 'ZZNWPWD1';
		if (stdGetFromDocumentByNameOrId(document, inputName) != null)
		{
			newPwd1 = stdGetFromDocumentByNameOrId(document, inputName).value;
			if ((newPwd1 != '') && (newPwd1 != null))
			{
				if (!newPwd1.match(/^([a-zA-Z]|[0-9])([-a-zA-Z0-9@_\.#]*)$/)) {errMsg += '- The new password should only include letters, numbers or @, _, # or . <br/>';}
				
				inputName = 'ZZNWPWD2';
				newPwd2 = stdGetFromDocumentByNameOrId(document, inputName).value;
				if (newPwd1 != newPwd2) {errMsg += '- The new password and the confirm password should be exactly the same. <br/>';}		
			}
		}
		
		// If password Hint Question Number is not present, the form is being viewed from Admin Console so Don't check the password answer
		inputName = 'DXPASH';
		if (stdGetFromDocumentByNameOrId(document, inputName) != null)
		{
			inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
			if (parseInt(inputValue, 10) <= 0) {errMsg += '- Please select a Password Hint Question. <br/>';}
			
			inputName = 'DXPASA';
			if (stdGetFromDocumentByNameOrId(document, inputName) != null)
			{
				inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
				if (!inputValue.match(/^([a-zA-Z]|[0-9])([-a-zA-Z0-9\s]*)$/)) {errMsg += '- Password Hint Answer is required and should only include letters or numbers. <br/>';}
			}
		}
		
		inputName = 'DXBSYC';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (parseInt(inputValue, 10) <= 0) {errMsg += '- Please select a Business System. <br/>';}

		if (errMsg != '')
		{
			errMsg = '<b>Errors listed below were found in your registration form. Please correct them and click continue.</b><br/>' + errMsg; 
			document.getElementById('errMsgs').style.display = 'block';
			document.getElementById('errMsgs').innerHTML = errMsg;
			return true;
		}
		else
		{
			return false;
		}
	}
	catch(e)
	{
		alert(e);
		return true;
	}
}

function getLanguage()
{
	try
	{
		var query = location.search.substring(1); 
		var pairs = query.split("+"); 
		for (var i = 0; i < pairs.length; i++) 
		{ 
			var pos = pairs[i].indexOf('='); 
			if (pos == -1) continue; 
			var argname = pairs[i].substring(0,pos);
			if (argname.toLowerCase() == 'language' || argname.toLowerCase() == 'lang' || argname.toLowerCase() == 'l')
			{
				var lang = pairs[i].substring(pos+1);
				break;
			}
		} 
		return lang;
	}
	catch(e)
	{
		alert(e);
		return 'ENG';
	}
}

function getPort()
{
	try
	{
		return location.port;
	}
	catch(e)
	{
		alert(e);
		return null;
	}
}


function getOsiData(partnm, partky, lnecde, prddsc, lstprc, cusprc)
{
	try
	{
		InsertHidden(document.LANSA, 'PARTNM', partnm);
		InsertHidden(document.LANSA, 'PARTKY', partky);
		InsertHidden(document.LANSA, 'ZZLNECDE', lnecde);
		InsertHidden(document.LANSA, 'ZZPRDDSC', prddsc);
		InsertHidden(document.LANSA, 'ZZLSTPRC', lstprc);
		InsertHidden(document.LANSA, 'ZZCUSPRC', cusprc);
		
		return true;
	}
	catch(e)
	{
		alert(e.message);
	}

}

function addOsiToCart(part, partky, lnecde, ordqtyFld, brnlidFld, prddsc, lstprc, cusprc, corprc, selpck, i, code01) 
{
	try
	{
		var divName = "d_" + i;
		var rowQty = stdGetFromDocumentByNameOrId(document, ordqtyFld).value;
		var elBranch = stdGetFromDocumentByNameOrId(document, brnlidFld);
		var rowBranch = elBranch.value;
		var rowAvlQty = elBranch.options[elBranch.selectedIndex].getAttribute('tag_AVLQTYBR');
		var lline = 0; /*Since the line number is not know yet*/
		
		InsertHidden(document.LANSA, 'PART', part);
		InsertHidden(document.LANSA, 'PARTKY', partky);
		InsertHidden(document.LANSA, 'LNECDE',lnecde);
		InsertHidden(document.LANSA, 'LLINE', lline);
		InsertHidden(document.LANSA, 'ORDQTY', rowQty);
		InsertHidden(document.LANSA, 'BRNLID', rowBranch);
		InsertHidden(document.LANSA, 'AVLQTY', rowAvlQty);
		InsertHidden(document.LANSA, 'PRDDSC', prddsc);
		InsertHidden(document.LANSA, 'LSTPRC', lstprc);
		InsertHidden(document.LANSA, 'CUSPRC', cusprc);
		InsertHidden(document.LANSA, 'CORPRC', corprc);
		InsertHidden(document.LANSA, 'SELPCK', selpck);
		InsertHidden(document.LANSA, 'CODE01', code01);
	
		if (document.getElementById(divName))
		{
			if (document.getElementById(divName).style.display == 'none')
		   	{
		   	   	document.getElementById(divName).style.display = 'inline';
		   	}
		}
		return true;
	}
	catch(e)
	{
		alert(e.message);
	}
}

function toggleOEColmns(module)
{
	try
	{
		var winWidth;
		if (typeof(window.innerWidth) == 'number') 
		{
		//Non-IE
			winWidth = window.innerWidth;
		} 
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
		{
		//IE 6+ in 'standards compliant mode'
			winWidth = document.documentElement.clientWidth;
		} 
		else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
		{
		//IE 4 compatible
			winWidth = document.body.clientWidth;
		}

		var normalDisp;
		var oeDisp;
		var partsTbl = document.getElementById('partsTbl');
		var rows = partsTbl.getElementsByTagName('tr');
		var col_h = document.getElementById('oecatgrp_h');
		var toggleAnch = document.getElementById('toggleOE');
		if (col_h.style.display == 'none')
		{
			oeDisp = '';
			normalDisp = 'none';
			toggleAnch.innerHTML = 'Hide OE Information';
			if (module == "catalog" && winWidth < 1024)
			{
				var prddscH = partsTbl.rows[0].getElementsByTagName('th')[6];
				prddscH.style.width = 110 + 'px';			
			}
		}
		else
		{
			oeDisp = 'none';
			normalDisp = '';
			toggleAnch.innerHTML = 'Show OE Information';
		}
		
		for (var row = 0; row < rows.length; row++)
		{
			switch (module)
			{
				case "orderparts":
					if (row == 0)
					{
						var cells_h = rows[row].getElementsByTagName('th');
						
						cells_h[5].style.display = oeDisp;
						cells_h[6].style.display = normalDisp;
						cells_h[7].style.display = oeDisp;
						cells_h[9].style.display = oeDisp;
					}
					else
					{
						var cells = rows[row].getElementsByTagName('td');

						cells[8].style.display = oeDisp;
						cells[9].style.display = normalDisp;
						cells[10].style.display = oeDisp;
						cells[12].style.display = oeDisp;
					}
					break;
				case "catalog":
					var rowid = rows[row].id;
					if (rowid.toUpperCase().search('P') > 0 || row == 0)
					{
						if (row == 0)
						{
							var cells_h = rows[row].getElementsByTagName('th');
							cells_h[4].style.display = normalDisp;
							cells_h[5].style.display = oeDisp;
							cells_h[7].style.display = oeDisp;
							cells_h[8].style.display = normalDisp;
							cells_h[9].style.display = oeDisp;
							cells_h[11].style.display = oeDisp;
							if (winWidth < 1024)
							{
								cells_h[16].style.display = normalDisp;
								cells_h[17].style.display = normalDisp;
							}
						}
						else
						{
							var cells = rows[row].getElementsByTagName('td');
							cells[4].style.display = normalDisp;
							cells[5].style.display = oeDisp;
							cells[7].style.display = oeDisp;
							cells[8].style.display = normalDisp;
							cells[9].style.display = oeDisp;
							cells[11].style.display = oeDisp;
							if (winWidth < 1024)
							{
								cells[15].style.display = normalDisp;
								cells[16].style.display = normalDisp;
							}
						}
					}
					else if (rowid.toUpperCase().search('S') > 0 || rowid.toUpperCase().search('H') > 0 || rowid.toUpperCase().search('D') > 0 || rowid.toUpperCase().search('G') > 0 || rowid.toUpperCase().search('U') > 0)
					{
						var cells = rows[row].getElementsByTagName('td');
						if (oeDisp == '')
						{
							if (rowid.toUpperCase().search('H') > 0)
							{
								if (cells[1].colSpan == "9")
								{
									cells[1].colSpan = "11";
								}
								else
								{
									cells[1].colSpan = "15";
								}
							}
							else
							{
								cells[1].colSpan = "15";
							}
						}
						else
						{
							if (rowid.toUpperCase().search('H') > 0)
							{
								if (cells[1].colSpan == "11")
								{
									cells[1].colSpan = "9";
								}
								else
								{
									cells[1].colSpan = "13";
								}
							}
							else
							{
								cells[1].colSpan = "13";
							}
						}						
					}
					else if (rowid.toUpperCase().search('cmt') > 0)
					{
						var cells = rows[row].getElementsByTagName('td');
						if (oeDisp == '')
						{
							cells[3].colSpan = "7";
						}
						else
						{
							cells[3].colSpan = "5";
						}						
					}
					else if (rowid.toUpperCase().search('msg') > 0)
					{
						var cells = rows[row].getElementsByTagName('td');
						if (oeDisp == '')
						{
							cells[1].colSpan = "15";
						}
						else
						{
							cells[1].colSpan = "13";
						}						
					}					
					break;
			}
		}
	}
	catch(e)
	{
		alert(e.message);
	}
}

function postStockOrder()
{
	try
	{
		// Validate the input before uploading the file
		var errMsg = '';
		var fileType = '';
		var fileName = '';
		var fileExt = '';
		var inputName = '';
		var inputValue = '';
		var fileTypes = document.LANSA2.Z2FLETYP;
		
		if (fileTypes.type == "hidden")
		{
			//EPC Import
			fileType = "EPC";
		}
		else
		{
			for (var i=0; i < document.LANSA2.Z2FLETYP.length; i++)
			{
				if (fileTypes[i].checked) {fileType = fileTypes[i].value;}
			}
		}
		
		if (fileType == '')
		{
			errMsg += '- No File Type was chosen. <br/>';
		}
		else
		{
			inputName = 'W_FILE';
			fileName = stdGetFromDocumentByNameOrId(document, inputName).value;
			fileName = fileName.substring(fileName.lastIndexOf('\\') + 1);
			fileExt = fileName.substring(fileName.lastIndexOf('.') + 1);
			
			switch (fileType)
			{
				case "XLS":
					if (fileExt.toUpperCase() != 'XLS')
					{
						errMsg += '- File Chosen is not a supported excel file. Supported versions of Excel files are 2003 or older. <br/>';
					}
					else
					{
						inputName = 'Z2SHTNME';
						inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
						if (!inputValue.match(/^([a-zA-Z]|[0-9]|[-_])([-a-zA-Z0-9\s_-]*)$/)) {errMsg += '- Sheet Name is required and should only include letters or numbers. <br/>';}
					}
					break;
				case "CSV":
					if (fileExt.toUpperCase() != 'CSV')
					{
						errMsg += '- File Chosen is not a comma delimited file. <br/>';
					}
					break;
				case "ODF":
					inputName = 'Z1DELIM';
					inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
					if (inputValue == null || inputValue == '') {errMsg += '- No Delimiter was selected for the Delimited file. <br/>';}
					break;
				case "EPC":
					if (fileExt.toUpperCase() != 'XFR')
					{
						errMsg += '- File Chosen is not a valid EPC Shopping list file. <br/>';
					}
					break;
				default:
					break;
			}						

			if (fileName == '')
			{
				errMsg += '- Please select a file to upload. File Name cannot be blank. <br/>';
			}
			
			var partCol = stdGetFromDocumentByNameOrId(document, 'Z2PCOLNO').value;
			var qtyCol = stdGetFromDocumentByNameOrId(document, 'Z2QCOLNO').value;

			if (partCol == qtyCol)
			{
				errMsg += '- Parts Column Number Cannot be the same as Quantity Column Number. <br/>';
			}
		}
		
		if (errMsg != '')
		{
			errMsg = '<b>Errors listed below were found on the page. Please correct them and try again.</b><br/>' + errMsg; 
			document.getElementById('errMsgs').style.display = 'block';
			document.getElementById('errMsgs').innerHTML = errMsg;
			window.scrollTo(0,0);
			return false;
		}

		var selectedOperation;
		if (fileType == "EPC")
		{
		   	selectedOperation = 'PREVIEW';
		}
		else
		{
			if (stdGetFromDocumentByNameOrId(document, '__Z1PREVIEW_PROXY').checked)
			{
			   	selectedOperation = 'PREVIEW';
			}
			else
			{
			   	selectedOperation = 'UPLOAD';                     
			}
		}
		document.LANSA2.W_ACTION.value  = selectedOperation;
		
		// Add wait div
		plzWait();

		document.LANSA2.submit();
		return false;
	}
	catch(e)
	{
		alert(e.message);
		return false;
	}
}

function plzWait()
{
	try
	{
	  	var h = 0;
	  	var w = 0;
	  	if( typeof( window.innerWidth ) == 'number' ) 
	  	{
	   		//Non-IE
	   		h = window.innerHeight;
	   		w = window.innerWidth;
	  	} 
	  	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	  	{
	    		//IE 6+ in 'standards compliant mode'
	   		h = document.documentElement.clientHeight;
	   		w = document.documentElement.clientWidth;
	  	} 
	  	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	  	{
	    		//IE 4 compatible
	   		h = document.body.clientHeight;
	   		w = document.body.clientWidth;
	  	}
	  	
		var waitDiv = document.getElementById('waitDiv');
		waitDiv.style.display = 'block';
		waitDiv.style.top = (h / 2) - 35;
		waitDiv.style.left = (w / 2) - 165;

		return false;
	}
	catch(e)
	{
		alert(e.message);
		return false;
	}
}

function checkBranch(module, slctid, position)
{
	try
	{
		var id = slctid.substr(slctid.indexOf('.') + 1, 4);
		var msgDiv = '';
		var brDropdown = '';
		var buttonDisabled = true;
		var addbuttontop = '';
		var addbuttonbottom = '';
		switch (module)
		{
			case "orderparts":
				id = 'PARTS.' + id + '.BRNLID';
				msgDiv = stdGetFromDocumentByNameOrId(document, 'msg_' + position);
				brDropdown = stdGetFromDocumentByNameOrId(document, id);
				var chkbox = stdGetFromDocumentByNameOrId(document, slctid);
				var chkboxproxy = stdGetFromDocumentByNameOrId(document, '__' + slctid + '_PROXY');
				if (brDropdown[brDropdown.selectedIndex].className.toUpperCase() == 'VIEWONLY')
				{
					msgDiv.innerHTML = 'This is a view only branch. <br/> Please select your primary branch to order this part.';
					msgDiv.style.display = 'inline';
					chkboxproxy.disabled = true;
					chkboxproxy.checked = false;
					chkboxproxy.value = 'N';
					chkbox.value = 'N';
				}
				else
				{
				
					msgDiv.style.display = 'none';		
					chkboxproxy.disabled = false;
					chkboxproxy.checked = true;
					chkboxproxy.value = 'Y';
					chkbox.value = 'Y';
					
				}
				
				// If no part is elligible to be added to order, disable add to order button
				addbuttontop = stdGetFromDocumentByNameOrId(document, 'addtoorder_top');
				addbuttonbottom = stdGetFromDocumentByNameOrId(document, 'addtoorder_bottom');
				for (var i=0; i < document.forms['LANSA'].elements.length; i++)
				{
					if (document.forms['LANSA'].elements[i].type == "checkbox" && document.forms['LANSA'].elements[i].checked)
					{
						buttonDisabled = false;
						break;
					}
				}
				addbuttontop.disabled = buttonDisabled;
				addbuttonbottom.disabled = buttonDisabled;
				break;
			case "osidata":
				id = 'OSIPARTS.' + id + '.BRNLID';
				msgDiv = stdGetFromDocumentByNameOrId(document, 'msg_' + position);
				brDropdown = stdGetFromDocumentByNameOrId(document, id);
				var addLink = stdGetFromDocumentByNameOrId(document, 'addlink_' + position);
				break;
			case "alternates":
				id = 'PART2.' + id + '.BRNLID';
				msgDiv = stdGetFromDocumentByNameOrId(document, 'msg_' + position);
				brDropdown = stdGetFromDocumentByNameOrId(document, id);
				var addLink = stdGetFromDocumentByNameOrId(document, slctid);
				break;
			case "catalog":
				id = 'PARTS.' + id + '.BRNLID';
				msgDiv = stdGetFromDocumentByNameOrId(document, 'msg_' + position);
				brDropdown = stdGetFromDocumentByNameOrId(document, id);
				var addLink = stdGetFromDocumentByNameOrId(document, 'addlink_' + position);
				break;
			case "related_r":
				id = 'PARTS_R.' + id + '.BRNLID';
				msgDiv = stdGetFromDocumentByNameOrId(document, 'msg_r_' + position);
				brDropdown = stdGetFromDocumentByNameOrId(document, id);
				var addLink = stdGetFromDocumentByNameOrId(document, 'parts_r_addlink_' + position);
				break;
			case "related_o":
				id = 'PARTS_O.' + id + '.BRNLID';
				msgDiv = stdGetFromDocumentByNameOrId(document, 'msg_o_' + position);
				brDropdown = stdGetFromDocumentByNameOrId(document, id);
				var addLink = stdGetFromDocumentByNameOrId(document, 'parts_o_addlink_' + position);
				break;
			case "related_v":
				id = 'PARTS_V.' + id + '.BRNLID';
				msgDiv = stdGetFromDocumentByNameOrId(document, 'msg_v_' + position);
				brDropdown = stdGetFromDocumentByNameOrId(document, id);
				var addLink = stdGetFromDocumentByNameOrId(document, 'parts_v_addlink_' + position);
				break;
		}
		
		if (module != "orderparts")
		{
		
			if (brDropdown[brDropdown.selectedIndex].className.toUpperCase() == 'VIEWONLY')
			{
				msgDiv.innerHTML = 'This is a view only branch. <br/> Please select your primary branch to order this part.';
				msgDiv.style.display = 'inline';
				if (addLink != null)
				{
					var href = addLink.getAttribute("href");	
					var onclick = addLink.getAttribute("onclick");
			
					addLink.setAttribute('href_bak', href);
					addLink.setAttribute('onclick_bak', onclick);
					addLink.setAttribute('onclick', "return false;");
					addLink.removeAttribute('href');
					
					addLink.disabled = true;
				}
			}
			else
			{
			
				msgDiv.style.display = 'none';
				if (addLink != null)
				{
					var hrefBack = addLink.getAttribute("href_bak");	
					var onclickBack = addLink.getAttribute("onclick_bak");
				
					if (onclickBack != null)
					{
						addLink.setAttribute('onclick', onclickBack);
					}
					if (hrefBack != null)
					{
						addLink.setAttribute('href', hrefBack);					
					}
				
					addLink.disabled = false;
				}
			}
			if (module == "catalog")
			{
				//Resize the frame to accomodate for the added message
			  	var h1 = document.body.scrollHeight;
			  	var h2 = parent.document.body.scrollHeight;
			  	var thisFrame = parent.document.getElementById('_w_PAlist');
			  	if (thisFrame == null)
			  	{
			  		// Interchange Page
			  		thisFrame = parent.document.getElementById('_w_InterchangeList');
			  	}				
				thisFrame.style.height = parseInt(h1) + "px";			  	
			}
		}
		return false;
	}
	catch(e)
	{
	
		alert(e.message);
		return false;
	}
	
}

function addAlternate(id, rowid)
{
	try
	{
		InsertHidden(document.LANSA, 'BRNLIDBR', '0');
		document.LANSA.BRNLIDBR.value = stdGetFromDocumentByNameOrId(document, id).value;
		InsertHidden(document.LANSA, 'STDROWNUM', rowid);
		document.LANSA.STDROWNUM.value = rowid;
		closeWin();

		return false;
	}
	catch(e)
	{
		alert(e.message);
		return false;
	}
}

function closeWin()
{
	try
	{
		if (document.all) {window.close();}
		else {setTimeout("self.close()", 1000);}
	}
	catch(e)
	{
		alert(e.message);
	}
}

function resetMargin()
{
	try
	{
		var w = document.getElementById('hist_wrapper').scrollWidth;
		var histNav = document.getElementById('hist_navigation');
		histNav.style.marginLeft = -1 * w + 'px';

		return true;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function changeOrderType()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var orderTypes = stdGetFromDocumentByNameOrId(document, "dd_ORTCOD");
		var newOrderType = orderTypes.options[orderTypes.selectedIndex].value;
		
		sendAJAXRequest('orderSpan', 'STDRENTRY', 1, 'TPUTIL', 'setOrderType', 'ORTCOD', newOrderType, 'STDRENTRY', 1, true, lang, portNo);
		return true;
	}
	catch(e)
	{
		alert(e.message);
	}
}

function changeDfltBranch()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var branches = stdGetFromDocumentByNameOrId(document, "dd_DTBRCH");
		var newBranch = branches.options[branches.selectedIndex].value;
		
		sendAJAXRequest('branchSpan', 'STDRENTRY', 1, 'TPUTIL', 'setBranch', 'DTBRCH', newBranch, 'STDRENTRY', 1, true, lang, portNo);
		return true;
	}
	catch(e)
	{
		alert(e.message);
	}
}

function sendTZDate()
{
	try
	{
		var tzd = stdGetFromDocumentByNameOrId(document, "currTime").innerHTML;
		var i = tzd.toUpperCase().lastIndexOf('</SCRIPT>');
		if (i > 0)
		{
			tzd = tzd.substr(i + 9);
		}
		InsertHidden(document.LANSA, 'ZZTZD', tzd);

		return false;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function printConfirmation()
{
	try
	{
		window.print();
		if (confirm('Please click OK to close this window and continue shopping with Turboparts.'))
		{
			window.close();
		}

		return false;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function toggleFields_OrderParts()
{
	try
	{
		var i= 1;
		var divName = "d_" + i;
		var flag;
		
		while (document.getElementById(divName))
		{
			if (document.getElementById(divName).style.display == '' || document.getElementById(divName).style.display == 'block')
			{
				document.getElementById(divName).style.display = 'none';
				flag = 'H';
			}
			else
			{
				document.getElementById(divName).style.display = 'block';
				flag = 'S';
			}
			i = i + 1;
			divName = "d_" + i;
		}
		
		var currCaption = document.getElementById('show_hide_caption').value;
		var altCaption = document.getElementById('show_hide_caption').getAttribute('altcaption');
		var temp = '';
		
		// Switch the captions
		temp = currCaption;
		currCaption = altCaption;
		altCaption = temp;

		document.getElementById('show_hide_caption').value = currCaption;
		document.getElementById('show_hide_caption').setAttribute('altcaption', altCaption);
		document.getElementById('show_hide_button').value = currCaption;
		
		setToggleVar_OrderParts(flag);
		
		return false;
	}
	catch(e)
	{
		alert(e.message);
	}
}
function setToggleVar_OrderParts(t)
{
	try
	{
		InsertHidden(document.LANSA, 'ZZTOGGLE', t);
		document.LANSA.ZZTOGGLE.value = t;
		Set_Cookie('C_TOGGLE', t, 90, '/', '', '' ); 
	}
	catch(e)
	{
		alert(e.message);
	}
}
function toggleDesc()
{
	try
	{
		var descSpan = document.getElementById('partDesc');
		var longSpan = document.getElementById('longPart');
		var descHead = document.getElementById('dscHeading');
		var numrows = parseInt(document.getElementById('partsTbl').rows.length, 10);
		if (descSpan.style.display == 'inline' || descSpan.style.display == '')
		{
			descSpan.style.display = 'none';
			longSpan.style.display = 'inline';
			var i= 1;
			var divName1 = "l_" + i;
			var divName2 = "p_" + i;
			while (document.getElementById(divName1) || parseInt(i, 10) < numrows)
			{
				if (document.getElementById(divName1) != null)
				{
					document.getElementById(divName1).style.display = 'block';
				}
				if (document.getElementById(divName2) != null)
				{
					document.getElementById(divName2).style.display = 'none';
				}
				i = i + 1;
				divName1 = "l_" + i;
				divName2 = "p_" + i;
			}
		}
		else
		{
			descSpan.style.display = 'inline';
			longSpan.style.display = 'none';
			var i= 1;
			var divName1 = "l_" + i;
			var divName2 = "p_" + i;
			while (document.getElementById(divName1) || parseInt(i, 10) < numrows)
			{
				if (document.getElementById(divName1) != null)
				{
					document.getElementById(divName1).style.display = 'none';
				}
				if (document.getElementById(divName2) != null)
				{
					document.getElementById(divName2).style.display = 'block';
				}
				i = i + 1;
				divName1 = "l_" + i;
				divName2 = "p_" + i;
			}
		}

		return false;
	}
	catch(e)
	{
		alert(e.message);
	}
}

function setToggleVar_Catalog(t)
{
	try
	{
		InsertHidden(document.LANSA, 'ZZTOGGLE', t);
		document.LANSA.ZZTOGGLE.value = t;
		Set_Cookie('C_TOGGLE', t, 90, '/', '', '' ); 
	}
	catch(e)
	{
		alert(e.message);
	}
}
function toggleFields_Catalog()
{
	try
	{
		var numrows = 0;
		var i= 1;
		var divName = "d_" + i;
		var flag;

		if (document.getElementById('partsTbl'))
		{
			// This is catalog or interchange
			numrows = parseInt(document.getElementById('partsTbl').rows.length, 10);
			while (document.getElementById(divName) || parseInt(i, 10) < numrows)
			{
				if (document.getElementById(divName) != null)
				{
					if (document.getElementById(divName).style.display != 'none')
					{
						document.getElementById(divName).style.display = 'none';
						flag = 'H';
					}
					else
					{
						document.getElementById(divName).style.display = 'inline';
						flag = 'S';
					}
				}
				i = i + 1;
				divName = "d_" + i;
			}
		}
		else
		{
			// This is Related Parts Page
			i= 1;
			divName = "d_r_" + i;
			numrows = parseInt(document.getElementById('parts_r').rows.length, 10);
			while (document.getElementById(divName) || parseInt(i, 10) < numrows)
			{
				if (document.getElementById(divName) != null)
				{
					if (document.getElementById(divName).style.display != 'none')
					{
						document.getElementById(divName).style.display = 'none';
						flag = 'H';
					}
					else
					{
						document.getElementById(divName).style.display = 'inline';
						flag = 'S';
					}
				}
				i = i + 1;
				divName = "d_" + i;
			}

			i= 1;
			divName = "d_o_" + i;
			numrows = parseInt(document.getElementById('parts_o').rows.length, 10);
			while (document.getElementById(divName) || parseInt(i, 10) < numrows)
			{
				if (document.getElementById(divName) != null)
				{
					if (document.getElementById(divName).style.display != 'none')
					{
						document.getElementById(divName).style.display = 'none';
						flag = 'H';
					}
					else
					{
						document.getElementById(divName).style.display = 'inline';
						flag = 'S';
					}
				}
				i = i + 1;
				divName = "d_" + i;
			}

			i= 1;
			divName = "d_v_" + i;
			numrows = parseInt(document.getElementById('parts_v').rows.length, 10);
			while (document.getElementById(divName) || parseInt(i, 10) < numrows)
			{
				if (document.getElementById(divName) != null)
				{
					if (document.getElementById(divName).style.display != 'none')
					{
						document.getElementById(divName).style.display = 'none';
						flag = 'H';
					}
					else
					{
						document.getElementById(divName).style.display = 'inline';
						flag = 'S';
					}
				}
				i = i + 1;
				divName = "d_" + i;
			}
		}
		
		var currCaption = document.getElementById('show_hide_caption').value;
		var altCaption = document.getElementById('show_hide_caption').getAttribute('altcaption');
		var temp = '';
		
		// Switch the captions
		temp = currCaption;
		currCaption = altCaption;
		altCaption = temp;

		document.getElementById('show_hide_caption').value = currCaption;
		document.getElementById('show_hide_caption').setAttribute('altcaption', altCaption);
		document.getElementById('show_hide_button').value = currCaption;
		
		setToggleVar_Catalog(flag);
		
		return false;
	}
	catch(e)
	{
		alert(e.message);
	}
}

function sendPartNo(t)
{
	InsertHidden(document.LANSA, 'PART', t);
	document.LANSA.PART.value = t;
}

function resetPage()
{
	InsertHidden(document.LANSA, 'NXTMFGSEQ', '');
	document.LANSA.NXTMFGSEQ.value = '';
}

function sendRelPart(t)
{
	InsertHidden(document.LANSA, 'ZZPRTTYP', t);
	document.LANSA.ZZPRTTYP.value = t;
}

function popupHelp() 
{
	try
	{
		newwindow2=window.open('/images/wam/legend1.htm','Legend','width=400,height=300,status=no');
	}
	catch(e)
	{
		alert(e.message)
	}
}

function setFocusOnElement(id)
{
	try
	{
		var elem = document.getElementById(id);
		elem.focus();	
	}
	catch(e)
	{
		alert(e.message);
	}
	return false;
}

function forgotPwd_sendEmail()
{
	try
	{
		var errMsg = '';
		var inputName = '';
		var inputValue = '';
		
		inputName = 'DXEML1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([0-9a-zA-Z]+[-._+&amp;])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/)) {errMsg += '- Email Address is required and should be in the correct format. <br/>';}
		
		if (errMsg != '')
		{
			errMsg = '<b>Errors listed below were found on the page. Please correct them and try again.</b><br/>' + errMsg; 
			document.getElementById('errMsgs').style.display = 'block';
			document.getElementById('errMsgs').innerHTML = errMsg;
			window.scrollTo(0,0);
			return true;
		}
		else
		{
			document.getElementById('errMsgs').innerHTML = '';
		}
		
		var lang = getLanguage();
		var portNo = getPort();
		var email = stdGetFromDocumentByNameOrId(document, 'DXEML1').value;
		
		sendAJAXRequest('logonForgotPwdSecQ', 'DXEML1', email, 'TPLOGON', 'forgotpwd2', 'STDRENTRY', 1, 'STDRENTRY', 1, true, lang, portNo);		
	}
	catch(e)
	{
		alert(e.message);
	}
	return true;
}

function forgotPwd_sendUserID()
{
	try
	{
		var errMsg = '';
		var inputName = '';
		var inputValue = '';
		
		inputName = 'DXEML1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([0-9a-zA-Z]+[-._+&amp;])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/)) {errMsg += '- Email Address is required and should be in the correct format. <br/>';}

		inputName = 'DXUSER';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue == '' || inputValue == null) {errMsg += '- The Turboparts User ID is required to be able to retrieve your password. <br/>';}
		
		if (errMsg != '')
		{
			errMsg = '<b>Errors listed below were found on the page. Please correct them and try again.</b><br/>' + errMsg; 
			document.getElementById('errMsgs').style.display = 'block';
			document.getElementById('errMsgs').innerHTML = errMsg;
			window.scrollTo(0,0);
			return true;
		}
		else
		{
			document.getElementById('errMsgs').innerHTML = '';
		}
		
		var lang = getLanguage();
		var portNo = getPort();
		var email = stdGetFromDocumentByNameOrId(document, 'DXEML1').value;
		var userId = stdGetFromDocumentByNameOrId(document, 'DXUSER').value;
		
		sendAJAXRequest('logonForgotPwdSecQ', 'DXEML1', email, 'TPLOGON', 'forgotpwd2', 'DXUSER', userId, 'STDRENTRY', 'U', true, lang, portNo);		
	}
	catch(e)
	{
		alert(e.message);
	}
	return true;
}

function forgotPwd_submit()
{
	try
	{
		var errMsg = '';
		var inputName = '';
		var inputValue = '';
		
		inputName = 'DXEML1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (!inputValue.match(/^([0-9a-zA-Z]+[-._+&amp;])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/)) {errMsg += '- Email Address is required and should be in the correct format. <br/>';}

		inputName = 'DXPASA';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue == '' || inputValue == null) {errMsg += '- The Security Answer is required to be able to retrieve your password. <br/>';}
		
		if (errMsg != '')
		{
			errMsg = '<b>Errors listed below were found on the page. Please correct them and try again.</b><br/>' + errMsg; 
			document.getElementById('errMsgs').style.display = 'block';
			document.getElementById('errMsgs').innerHTML = errMsg;
			window.scrollTo(0,0);
			return true;
		}
		else
		{
			document.getElementById('errMsgs').innerHTML = '';
		}
		
		var lang = getLanguage();
		var portNo = getPort();
		var email = stdGetFromDocumentByNameOrId(document, 'DXEML1').value;
		var userId = stdGetFromDocumentByNameOrId(document, 'DXUSER').value;		
		var secAnswer = stdGetFromDocumentByNameOrId(document, 'DXPASA').value;

		var postData = "";
		postData += "&" + "DXUSER" + "=" + escape(userId);
		postData += "&" + "DXPASA" + "=" + escape(secAnswer);
		sendAJAXRequestWithPostData('logonForgotPwdSecQ', 'TPLOGON', 'forgotpwd2', 'STDRENTRY', 'S', 'DXEML1', email, postData, true, lang, portNo);
	}
	catch(e)
	{
		alert(e.message);
	}
	return true;
}

function addToOrder(part, partky, lnecde, lline, ordqtyFld, brnlidFld, avlqty, prddsc, lstprc, cusprc, corprc, selpck, i, code01) 
{
	try
	{
		var divName = "";
		if (code01 == null || code01 == '' || code01 == 'S' || code01 == 'Q')
		{
			divName = "n_" + i;
		}
		else if (code01.length == 3)
		{
			divName = "n_" + code01.substr(2) + "_" + i;
		}
		var rowQty = stdGetFromDocumentByNameOrId(document, ordqtyFld).value;
		var elBranch = stdGetFromDocumentByNameOrId(document, brnlidFld);
		var rowBranch = 0;
		var rowAvlQty = 0;
		if (code01 == 'S')
		{
			rowBranch = brnlidFld;
			rowAvlQty = rowQty;
		}
		else
		{
			rowBranch = elBranch.value;
			rowAvlQty = elBranch.options[elBranch.selectedIndex].getAttribute('tag_AVLQTYBR');
		}

		if (document.getElementById(divName))
		{
			if (document.getElementById(divName).style.display == 'none')
		   	{
		      		document.getElementById(divName).style.display = 'inline';
		      		document.getElementById(divName).innerHTML = '<br/><br/><br/>';
		   	}
		}
	
		var lang = getLanguage();
		var portNo = getPort();
		var postData = "";
		postData += "&" + "LNECDE" + "=" + escape(lnecde);
		postData += "&" + "LLINE" + "=" + escape(lline);
		postData += "&" + "ORDQTY" + "=" + escape(rowQty);
		postData += "&" + "BRNLID" + "=" + escape(rowBranch);
		postData += "&" + "AVLQTY" + "=" + escape(rowAvlQty);
		postData += "&" + "PRDDSC" + "=" + escape(prddsc);
		postData += "&" + "LSTPRC" + "=" + escape(lstprc);
		postData += "&" + "CUSPRC" + "=" + escape(cusprc);
		postData += "&" + "CORPRC" + "=" + escape(corprc);
		postData += "&" + "SELPCK" + "=" + escape(selpck);
		if (code01 != null && code01 != '')
		{
			postData += "&" + "CODE01" + "=" + escape(code01);
		}

		//Resize the frame to accomodate for the added message
		if (code01 != 'R' && code01 != 'Q')
		{
			var h1 = document.body.scrollHeight;
			var h2 = parent.document.body.scrollHeight;
			var thisFrame = parent.document.getElementById('_w_PAlist');
			if (thisFrame == null)
			{
				// Interchange Page
				thisFrame = parent.document.getElementById('_w_InterchangeList');
				if (thisFrame == null)
				{
					// Specials Page - Tree View desgin
					thisFrame = parent.document.getElementById('_SpcDtl');				
				}
			}
			if (thisFrame != null)
			{
				thisFrame.style.height = parseInt(h1) + "px";			  	
			}
		}
		sendAJAXRequestWithPostData(divName, 'TPCATALOG', 'addOrderLine', 'PART', part, 'PARTKY', partky, postData, true, lang, portNo);
	}
	catch(e)
	{
		alert(e.message);
	}
	return true;
}

function refreshCartTotals_Cat(code01)
{
	try
	{
		var d_total_window_parent = window;
		if (code01 == 'R' || code01 == 'Q')
		{
			d_total_window_parent = d_total_window_parent.opener;
		}
		while((d_total_window_parent.frames["w_OrderTotals"] == null) && (d_total_window_parent.name != d_total_window_parent.parent.name))
		{
			d_total_window_parent = d_total_window_parent.parent;
		}
		if (d_total_window_parent.frames["w_OrderTotals"].document.forms["totalsForm"] != null) 
		{
			HandleEvent('TPUTIL', 'OrderTotals', d_total_window_parent.frames["w_OrderTotals"].document.forms["totalsForm"], null);
		}
	}
	catch(e)
	{
		alert(e.message);
	}
}

function addToOrderOrLost(part, partky, lnecde, lline, ordqtyFld, brnlidFld, avlqty, prddsc, lstprc, cusprc, corprc, selpck, i, code01, lostSaleFlag) 
{
	try
	{
		var divName = "";
		if (code01 == null || code01 == '' || code01 == 'S' || code01 == 'Q')
		{
			divName = "n_" + i;
		}
		else if (code01.length == 3)
		{
			divName = "n_" + code01.substr(2) + "_" + i;
		}
		var rowQty = stdGetFromDocumentByNameOrId(document, ordqtyFld).value;
		var elBranch = stdGetFromDocumentByNameOrId(document, brnlidFld);
		var rowBranch = 0;
		var rowAvlQty = 0;
		if (code01 == 'S')
		{
			rowBranch = brnlidFld;
			rowAvlQty = rowQty;
		}
		else
		{
			rowBranch = elBranch.value;
			rowAvlQty = elBranch.options[elBranch.selectedIndex].getAttribute('tag_AVLQTYBR');
		}

		if (document.getElementById(divName))
		{
			if (document.getElementById(divName).style.display == 'none')
		   	{
		      		document.getElementById(divName).style.display = 'inline';
		      		document.getElementById(divName).innerHTML = '<br/><br/><br/>';
		   	}
		}
	
		var lang = getLanguage();
		var portNo = getPort();
		var ctgyid = stdGetFromDocumentByNameOrId(document, 'CTGYID').value;
		var prgrid = stdGetFromDocumentByNameOrId(document, 'PRGRID').value;
		var z1prvkey = stdGetFromDocumentByNameOrId(document, 'Z1PRVKEY').value;
		var zzvinnum = stdGetFromDocumentByNameOrId(document, 'ZZVINNUM').value;
		var postData = "";
		postData += "&" + "LNECDE" + "=" + escape(lnecde);
		postData += "&" + "LLINE" + "=" + escape(lline);
		postData += "&" + "ORDQTY" + "=" + escape(rowQty);
		postData += "&" + "BRNLID" + "=" + escape(rowBranch);
		postData += "&" + "AVLQTY" + "=" + escape(rowAvlQty);
		postData += "&" + "PRDDSC" + "=" + escape(prddsc);
		postData += "&" + "LSTPRC" + "=" + escape(lstprc);
		postData += "&" + "CUSPRC" + "=" + escape(cusprc);
		postData += "&" + "CORPRC" + "=" + escape(corprc);
		postData += "&" + "SELPCK" + "=" + escape(selpck);
		if (code01 != null && code01 != '')
		{
			postData += "&" + "CODE01" + "=" + escape(code01);
		}
		postData += "&" + "CTGYID" + "=" + escape(ctgyid);
		postData += "&" + "PRGRID" + "=" + escape(prgrid);
		postData += "&" + "Z1PRVKEY" + "=" + escape(z1prvkey);
		postData += "&" + "ZZVINNUM" + "=" + escape(zzvinnum);

		//Resize the frame to accomodate for the added message
		if (code01 != 'R' && code01 != 'Q')
		{
			var h1 = document.body.scrollHeight;
			var h2 = parent.document.body.scrollHeight;
			var thisFrame = parent.document.getElementById('_w_PAlist');
			if (thisFrame == null)
			{
				// Interchange Page
				thisFrame = parent.document.getElementById('_w_InterchangeList');
				if (thisFrame == null)
				{
					// Specials Page - Tree View desgin
					thisFrame = parent.document.getElementById('_SpcDtl');				
				}
			}
			if (thisFrame != null)
			{
				thisFrame.style.height = parseInt(h1) + "px";			  	
			}
		}
		
		if (lostSaleFlag == '1')
		{
			sendAJAXRequestWithPostData(divName, 'TPCATALOG', 'markAsLost', 'PART', part, 'PARTKY', partky, postData, true, lang, portNo);
		}
		else
		{
			sendAJAXRequestWithPostData(divName, 'TPCATALOG', 'addOrderLine', 'PART', part, 'PARTKY', partky, postData, true, lang, portNo);
		}
	}
	catch(e)
	{
		alert(e.message);
	}
	return true;
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function loadFlash(targetElm, fileName, w, h)
{
	try
	{
		targetDiv = document.getElementById(targetElm);
		targetDiv.innerHTML = '<object data=\"' + fileName 
			+ '\" width=\"' + w 
			+ '\" height=\"' + h 
			+ '\" type=\"application/x-shockwave-flash\">'
			+ '<param name=\"movie\" value=\"' + fileName + '\" />'
			+ '<param name=\"FlashVars\" value=\"spak=sv\" />'
			+ '<param name=\"bgcolor\" value=\"#ffffff\" />'
			+ '<param name=\"menu\" value=\"false\" />'
			+ '<param name=\"quality\" value=\"high\" />'
			+ '<h3>No Flash</h3><br />Please Install <a href=\"http://www.macromedia.com/go/getflashplayer\" target=\"_blank\">FLASH plugin</a>.'
			+ '</object>';
	}
	catch(e)
	{
		alert(e.message);
	}
}
/* ******************************************************************************************** */
/* Admin Console Functions */
/* ******************************************************************************************** */
function togglecols1()
{
	try
	{
		var i;
		var th1;
		var td1;
		
		for (var j= 1; j < 9; j++)
		{
			i = 1;
			td1 = "c" + j + "_" + i;
			th1 = "c" + j;
			if (document.getElementById(th1).style.display == 'none' || document.getElementById(th1).style.display == '' )
			{
				document.getElementById(th1).style.display = 'block';
				document.getElementById('tbl').style.width = "100%";
			}
			else
			{
				document.getElementById(th1).style.display = 'none';
				document.getElementById('tbl').style.width = "550px";
			}
			while (document.getElementById(td1))
			{
				if (document.getElementById(td1).style.display == 'none' || document.getElementById(td1).style.display == '')
				{
					document.getElementById(td1).style.display = 'block';
				}
				else
				{
					document.getElementById(td1).style.display = 'none';
				}
				i = i + 1;
				td1= "c" + j + "_" + i;
			}               
		}
	}
	catch(e)
	{
		alert(e);
	}
}
function trim(str, chars) 
{
	return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) 
{
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) 
{
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function ExportToExcel1()
{
	try
	{
		var oEx = new ActiveXObject("Excel.Application");
		var oBo = oEx.Workbooks.Add;
		var oSh = oBo.Worksheets(1);
		var i;
		var txt;
		for (i=1; i < salesTbl.rows(0).cells.length; i++)
		{
			if (salesTbl.rows(0).cells(i).style.display == 'block' || (salesTbl.rows(0).cells(i).style.display == '' && salesTbl.rows(0).cells(i).className != 'addcol1'))
			{
				oSh.Cells(1, i) = trim(salesTbl.rows(0).cells(i).innerText);
			}
		}
		for (i=1; i < salesTbl.rows.length; i++)
		{
			txt = trim(salesTbl.rows(i).cells(1).innerText);
			if (txt.toLowerCase() != "totals")
			{
				for (var j=1;j < salesTbl.rows(i).cells.length; j++)
				{
					if (salesTbl.rows(i).cells(j).style.display == 'block' || (salesTbl.rows(i).cells(j).style.display == '' && salesTbl.rows(i).cells(j).className != 'addcol1'))
					{
						oSh.Cells(i + 1, j) = salesTbl.rows(i).cells(j).innerText;
					}
				}			
			}
		}
		oEx.Visible = true;
		oEx.UserControl = true;
	}
	catch(e)
	{
		alert(e.message);
		oSh = null;
		oBo.Close(false);
		oBo = null;
		oEx.Quit();
		oEx = null;
	}
}
function togglecols2()
{
	try
	{
		var i;
		var th1;
		var td1;
		var td2;
		
		for (var j= 1; j < 9; j++)
		{
			i = 1;
			td1 = "c" + j + "_" + i;
			th1 = "c" + j;
			td2 = "c" + j + "_f";
			if (document.getElementById(th1).style.display == 'none' || document.getElementById(th1).style.display == '' )
			{
				document.getElementById(th1).style.display = 'block';
				document.getElementById('tbl').style.width = "100%";
				document.getElementById(td2).style.display = 'block';
			}
			else
			{
				document.getElementById(th1).style.display = 'none';
				document.getElementById('tbl').style.width = "700px";
				document.getElementById(td2).style.display = 'none';
			}
			while (document.getElementById(td1))
			{
				if (document.getElementById(td1).style.display == 'none' || document.getElementById(td1).style.display == '')
				{
					document.getElementById(td1).style.display = 'block';
				}
				else
				{
					document.getElementById(td1).style.display = 'none';
				}
				i = i + 1;
				td1= "c" + j + "_" + i;
			}               
		}
	}
	catch(e)
	{
		alert(e);
	}
}
function togglecols3()
{
	try
	{
		var i;
		var th1;
		var td1;
		var td2;
		
		for (var j= 1; j < 9; j++)
		{
			i = 1;
			td1 = "c" + j + "_" + i;
			th1 = "c" + j;
			td2 = "c" + j + "_f";
			if (document.getElementById(th1).style.display == 'none' || document.getElementById(th1).style.display == '' )
			{
				document.getElementById(th1).style.display = 'block';
				document.getElementById('tbl').style.width = "100%";
				document.getElementById(td2).style.display = 'block';
			}
			else
			{
				document.getElementById(th1).style.display = 'none';
				document.getElementById('tbl').style.width = "900px";
				document.getElementById(td2).style.display = 'none';
			}
			while (document.getElementById(td1))
			{
				if (document.getElementById(td1).style.display == 'none' || document.getElementById(td1).style.display == '')
				{
					document.getElementById(td1).style.display = 'block';
				}
				else
				{
					document.getElementById(td1).style.display = 'none';
				}
				i = i + 1;
				td1= "c" + j + "_" + i;
			}               
		}
	}
	catch(e)
	{
		alert(e);
	}
}
function togglestats()
{
	try
	{
		var d = document.getElementById('salesstats');
		if (d.style.display == 'block')
		{
			d.style.display = 'none';
		}
		else
		{
			d.style.display = 'block';
		}
	}
	catch(e)
	{
		alert(e);
	}
}

function refreshUsrAuth1()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var userId = document.getElementById('DCUSER').value;
		var userWd = document.getElementById('DCWHID').value;
		sendAJAXRequest('UsrAuth1', 'STDRENTRY', 'D', 'TPADMIN', 'UsrAuth1', 'DCWHID', userWd, 'DCUSER', userId, true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function updateUsrAuth1()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var userId = document.getElementById('DCUSER').value;
		var userWd = document.getElementById('DCWHID').value;
		var postData = "";
		var elmName;
		var counter = "0000";
		var j = 1;
		for (var i= 0; i < document.forms[0].elements.length; i++)
		{
			elmName = document.forms[0].elements[i].name;
			if (elmName.indexOf("DOCS") >= 0)
			{
				counter = counter.substr(1, 4 - j.toString().length) + j.toString();
				if (elmName.indexOf("TCALLW_PROXY") >= 0)
				{
					elmName = "DOCS" + "." + counter + "." + "TCALLW";
					if (document.getElementById("__DOCS." + counter + ".TCALLW_PROXY").checked == true)
					{
						postData += "&" + elmName + "=Y";
					}
					else
					{
						postData += "&" + elmName + "=N";
					}
				}
				if (elmName.indexOf("TSCODE") >= 0)
				{
					elmName = "DOCS" + "." + counter + "." + "TSCODE";
					postData += "&" + elmName + "=" + escape(document.forms[0].elements[i].value);
				}
				if (elmName.indexOf("TSDESC") >= 0)
				{
					elmName = "DOCS" + "." + counter + "." + "TSDESC";
					postData += "&" + elmName + "=" + escape(document.forms[0].elements[i].value);
					j++;
				}
				counter = "0000";
			}
		}
		j = j - 1;
		postData = "&DOCS..=" + j + postData;
		postData += "&" + "DCWHID" + "=" + escape(userWd);
		sendAJAXRequestWithPostData('UsrAuth1', 'TPADMIN', 'UsrAuth1', 'STDRENTRY', 'U', 'DCUSER', userId, postData, true, lang, portNo);
		return true;	
	}
	catch(e)
	{
		alert(e);
		return true;
	}
}

function validateProfileInput()
{
	try
	{
		var errMsg = '';
		var inputName = 'DXCONT';
		var inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue != null && inputValue != '')
		{
			if (!inputValue.match(/^([a-zA-Z]|[0-9])([-a-zA-Z0-9\s]*)$/)) {errMsg += '- Contact Name is required and should only include letters or numbers. <br/>';}
		}
		
		inputName = 'DXADD1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue != null && inputValue != '')
		{
			if (!inputValue.match(/^([a-zA-Z]|[0-9])([-a-zA-Z0-9\s@_\.#]*)$/)) {errMsg += '- Address Line 1 is required and should only include letters, numbers or @, _, # or . <br/>';}
		}
		
		inputName = 'DXCITY';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue != null && inputValue != '')
		{
			if (!inputValue.match(/^([a-zA-Z])([-a-zA-Z\s]*)$/)) {errMsg += '- City is required and should only include letters. <br/>';}
		}
		
		inputName = 'DXSTAT';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue != null && inputValue != '')
		{
			if (!inputValue.match(/^([a-zA-Z]){2}$/)) {errMsg += '- State is required and should only be 2 letters. <br/>';}
		}
		
		inputName = 'DXZIP';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue != null && inputValue != '')
		{
			if (!inputValue.match(/^([a-zA-Z]|[0-9])([-a-zA-Z0-9]*)$/)) {errMsg += '- Zip Code is required and should only include letters and numbers. <br/>';}
		}
		
		inputName = 'DXCTRY';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue != null && inputValue != '')
		{
			if (!inputValue.match(/^([a-zA-Z])([-a-zA-Z\s]*)$/)) {errMsg += '- Country is required and should only include letters. <br/>';}
		}
		
		inputName = 'DXEML1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		if (inputValue != null && inputValue != '')
		{
			if (!inputValue.match(/^([0-9a-zA-Z]+[-._+&amp;])*[0-9a-zA-Z]+@([-0-9a-zA-Z]+[.])+[a-zA-Z]{2,6}$/)) {errMsg += '- Email Address is required and should be in the correct format. <br/>';}
		}
		
		inputName = 'DXTEL1';
		inputValue = stdGetFromDocumentByNameOrId(document, inputName).value;
		// if (!inputValue.match(/((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}/)) {errMsg += '- Phone Number is required and should be in the correct format ((xxx)xxx-xxxx or xxx-xxx-xxxx). <br/>';}
		if (inputValue != null && inputValue != '')
		{
			if (!inputValue.match(/\d{10}/)) {errMsg += '- Phone Number is required and should only be numbers (no parentheses or dashes). <br/>';}
		}
						
		if (errMsg != '')
		{
			errMsg = '<b>Errors listed below were found in your registration form. Please correct them and click continue.</b><br/>' + errMsg; 
			document.getElementById('errMsgs').style.display = 'block';
			document.getElementById('errMsgs').innerHTML = errMsg;
			return true;
		}
		else
		{
			return false;
		}	
	}
	catch(e)
	{
		alert(e);
		return true;
	}	
}

function addNewCustType()
{
	try
	{
		stdGetFromDocumentByNameOrId(document, 'newtype').style.display = 'block';
	}
	catch(e)
	{
		alert(e);
	}		
	return false;
}

function showCustomers(wtwdct, wdid)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var divName = 'c_' + wtwdct;
		var targetDiv = stdGetFromDocumentByNameOrId(document, divName);
		var disp = targetDiv.style.display;
		
		if (disp == 'none' || disp == '')
		{
			// Show Customers
			targetDiv.style.display = 'block';
			targetDiv.innerText = 'Showing Customers...';
			
			// Call the getPartTypes webroutine using Ajax Handlers
			sendAJAXRequest(divName, 'STDRENTRY', 1, 'TPADMIN2', 'custsForType', 'WTWDCT', wtwdct, 'DWWHID', wdid, true, lang, portNo);
			return true;
		}
		else
		{
			// Collapse Sub Types
			targetDiv.style.display = 'none';
			return true;
		}				
	}
	catch(e)
	{
		alert(e);
		return true;
	}
}

function refreshSet1()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = stdGetFromDocumentByNameOrId(document, 'DWWHID').value;
		sendAJAXRequest('set1', 'STDRENTRY', 'D', 'TPADMIN2', 'setWebSite', 'DWWHID', wdid, 'STDRENTRY', 'D', true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function updateWebSite()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		var website = stdGetFromDocumentByNameOrId(document, 'DWWEBA').value;
		sendAJAXRequest('set1', 'STDRENTRY', 'B', 'TPADMIN2', 'setWebSite', 'DWWHID', wdid, 'DWWEBA', website, true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function refreshSet2()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = stdGetFromDocumentByNameOrId(document, 'DWWHID').value;
		sendAJAXRequest('set2', 'STDRENTRY', 'D', 'TPADMIN2', 'setLandPage', 'DWWHID', wdid, 'STDRENTRY', 'D', true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function updateLandPage()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		var landPageElm = stdGetFromDocumentByNameOrId(document, 'DWINIPAGE');
		var landPage = landPageElm.options[landPageElm.selectedIndex].value;
		sendAJAXRequest('set2', 'STDRENTRY', 'A', 'TPADMIN2', 'setLandPage', 'DWWHID', wdid, 'DWINIPAGE', landPage, true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function refreshSet3()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = stdGetFromDocumentByNameOrId(document, 'DWWHID').value;
		sendAJAXRequest('set3', 'STDRENTRY', 'D', 'TPADMIN2', 'setSpclView', 'DWWHID', wdid, 'STDRENTRY', 'D', true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function updateSpclView()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		var spcViewElm = stdGetFromDocumentByNameOrId(document, 'Z1SPCVNO');
		var spcView = 0;
		for (i = 0; i < 2; i++)
		{
			if (spcViewElm[i].checked == true) {spcView = i + 1;}
		}
		sendAJAXRequest('set3', 'STDRENTRY', 'C', 'TPADMIN2', 'setSpclView', 'DWWHID', wdid, 'Z1SPCVNO', spcView, true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function refreshSet4()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = stdGetFromDocumentByNameOrId(document, 'DWWHID').value;
		sendAJAXRequest('set4', 'STDRENTRY', 'D', 'TPADMIN2', 'setCustomFlds', 'DWWHID', wdid, 'STDRENTRY', 'D', true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function updateCustomFlds()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		var postData = "";
		var elmName;
		var counter1 = "0000";
		var c1 = 0
		var counter2 = "0000";
		var c2 = 0
		var counter3 = "0000";
		var c3 = 0
		var j1 = 1;
		var j2 = 1;
		var j3 = 1;
		for (var i= 0; i < document.forms['LANSA'].elements.length; i++)
		{
			elmName = document.forms['LANSA'].elements[i].name;
			if (elmName != null)
			{
				if (elmName.indexOf("CFLDS2") >= 0)
				{
					counter1 = counter1.substr(1, 4 - j1.toString().length) + j1.toString();
					if (elmName.indexOf("RFFLID") >= 0)
					{
						elmName = "CFLDS2" + "." + counter1 + "." + "RFFLID";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c1++;
					}
					if (elmName.indexOf("RFFLTY") >= 0)
					{
						elmName = "CFLDS2" + "." + counter1 + "." + "RFFLTY";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c1++;					
					}
					if (elmName.indexOf("RFFLHD") >= 0)
					{
						elmName = "CFLDS2" + "." + counter1 + "." + "RFFLHD";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c1++;
					}
					if (elmName.indexOf("Z1FLDTYP") >= 0)
					{
						elmName = "CFLDS2" + "." + counter1 + "." + "Z1FLDTYP";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c1++;
					}
					if (c1 == 4)
					{
						j1++;
						c1 = 0;				
					}
					counter1 = "0000";
				}
				if (elmName.indexOf("CFLDVS_D2") >= 0)
				{
					counter2 = counter2.substr(1, 4 - j2.toString().length) + j2.toString();
					if (elmName.indexOf("RVFLID") >= 0)
					{
						elmName = "CFLDVS_D2" + "." + counter2 + "." + "RVFLID";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c2++;
					}
					if (elmName.indexOf("RVFLSQ") >= 0)
					{
						if (elmName.indexOf("ZZRVFLSQ") >= 0)
						{
							elmName = "CFLDVS_D2" + "." + counter2 + "." + "ZZRVFLSQ";
							postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
							c2++;
						}
						else
						{
							elmName = "CFLDVS_D2" + "." + counter2 + "." + "RVFLSQ";
							postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
							c2++;
						}
					}
					if (elmName.indexOf("RVFLVL") >= 0)
					{
						elmName = "CFLDVS_D2" + "." + counter2 + "." + "RVFLVL";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c2++;
					}
					if (c2 == 4)
					{
						j2++;
						c2 = 0;				
					}
					counter2 = "0000";
				}
				if (elmName.indexOf("CFLDVS_C2") >= 0)
				{
					counter3 = counter3.substr(1, 4 - j3.toString().length) + j3.toString();
					if (elmName.indexOf("RVFLID") >= 0)
					{
						elmName = "CFLDVS_C2" + "." + counter3 + "." + "RVFLID";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c3++;
					}
					if (elmName.indexOf("RVFLSQ") >= 0)
					{
						if (elmName.indexOf("ZZRVFLSQ") >= 0)
						{
							elmName = "CFLDVS_C2" + "." + counter3 + "." + "ZZRVFLSQ";
							postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
							c3++;
						}
						else
						{
							elmName = "CFLDVS_C2" + "." + counter3 + "." + "RVFLSQ";
							postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
							c3++;
						}
					}
					if (elmName.indexOf("RVFLVL") >= 0)
					{
						elmName = "CFLDVS_C2" + "." + counter3 + "." + "RVFLVL";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c3++;
					}
					if (c3 == 4)
					{
						j3++;
						c3 = 0;				
					}
					counter3 = "0000";
				}
			}
		}
		j1 = j1 - 1;
		j2 = j2 - 1;
		j3 = j3 - 1;
		postData = "&CFLDS2..=" + j1 + postData;
		postData = "&CFLDVS_D2..=" + j2 + postData;
		postData = "&CFLDVS_C2..=" + j3 + postData;
		sendAJAXRequestWithPostData('set4', 'TPADMIN2', 'setCustomFlds', 'STDRENTRY', 'U', 'DWWHID', wdid, postData, true, lang, portNo);
		return true;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function refreshSet5()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = stdGetFromDocumentByNameOrId(document, 'DWWHID').value;
		sendAJAXRequest('set5', 'STDRENTRY', 'D', 'TPADMIN2', 'setAvailY', 'DWWHID', wdid, 'STDRENTRY', 'D', true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function updateWebSite5()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		var available = stdGetFromDocumentByNameOrId(document, 'WXAVLY').value;
		sendAJAXRequest('set5', 'STDRENTRY', 'Y', 'TPADMIN2', 'setAvailY', 'DWWHID', wdid, 'WXAVLY', available, true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function refreshSet6()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = stdGetFromDocumentByNameOrId(document, 'DWWHID').value;
		sendAJAXRequest('set6', 'STDRENTRY', 'D', 'TPADMIN2', 'setAvailN', 'DWWHID', wdid, 'STDRENTRY', 'D', true, lang, portNo);
	}
	catch(e)
	{
		alert(e);
	}
}

function updateWebSite6()
{
	try
	{ 
		var postData = "";
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		var notavailable = stdGetFromDocumentByNameOrId(document, 'WXAVLN').value;
		var available = stdGetFromDocumentByNameOrId(document, 'WXAVLY').value;
		postData += "&" + "WXAVLY" + "=" + escape(available);
		postData += "&" + "WXAVLN" + "=" + escape(notavailable);
		//alert("Post: " + postData);
		sendAJAXRequestWithPostData('set6', 'TPADMIN2', 'setAvailN', 'STDRENTRY', 'N', 'DWWHID', wdid, postData, true, lang, portNo);
		//sendAJAXRequest('set6', 'STDRENTRY', 'N', 'TPADMIN2', 'setAvailN', 'DWWHID', wdid, 'WXAVLY', available, true, lang, portNo);
		//sendAJAXRequest('set6', 'STDRENTRY', 'N', 'TPADMIN2', 'setAvailN', 'DWWHID', wdid, 'WXAVLN', notavailable, true, lang, portNo);
	//sendAJAXRequestWithPostData('w_HistoryList', 'TPORDHIST', 'Search', 'ZZRENTRY', searchType, 'DCTCUSTPO', poNum, postData, true, lang, portNo);

	}
	catch(e)
	{
		alert(e);
	}
}

function addNewFldValue(fldid, type)
{
	try
	{
		var c = 0;
		var counter = "0000";
		var listName;
		var spanId;
		switch (type)
		{
			case "L":
				listName = "CFLDVS_D2";
				spanId = 'l_' + fldid;				
				break;
			case "M":
				listName = "CFLDVS_C2";
				spanId = 'm_' + fldid;
				break;
		}
		
		for (var i= 0; i < document.forms['LANSA'].elements.length; i++)
		{
			elmName = document.forms['LANSA'].elements[i].name;
			if (elmName != null && elmName.indexOf(listName) >= 0 && elmName.indexOf("RVFLID") >= 0) {c++;}
		}
		c++;
		counter = counter.substr(1, 4 - c.toString().length) + c.toString();

		var newID = document.createElement('input');
		newID.setAttribute('id', listName + '.' + counter + '.RVFLID');
		newID.setAttribute('name', listName + '.' + counter + '.RVFLID');
		newID.setAttribute('class', 'utext');
		newID.setAttribute('type', 'hidden');
		newID.setAttribute('value', fldid);
		document.getElementById(spanId).appendChild(newID);

		var newSeq = document.createElement('input');
		newSeq.setAttribute('id', listName + '.' + counter + '.RVFLSQ');
		newSeq.setAttribute('name', listName + '.' + counter + '.RVFLSQ');
		newSeq.setAttribute('class', 'number');
		newSeq.style.width = '30px';
		newSeq.setAttribute('value', '000');
		document.getElementById(spanId).appendChild(newSeq);

		var newVal = document.createElement('input');
		newVal.setAttribute('id', listName + '.' + counter + '.RVFLVL');
		newVal.setAttribute('name', listName + '.' + counter + '.RVFLVL');
		newVal.setAttribute('class', 'utext');
		newVal.style.width = '180px';
		newVal.setAttribute('value', 'Enter a value');
		document.getElementById(spanId).appendChild(newVal);

		var newSeq2 = document.createElement('input');
		newSeq2.setAttribute('id', listName + '.' + counter + '.ZZRVFLSQ');
		newSeq2.setAttribute('name', listName + '.' + counter + '.ZZRVFLSQ');
		newSeq2.setAttribute('class', 'number');
		newSeq2.setAttribute('type', 'hidden');
		newSeq2.setAttribute('value', '000');
		document.getElementById(spanId).appendChild(newSeq2);

		var br = document.createElement('br');
		document.getElementById(spanId).appendChild(br);

		document.getElementById(spanId).style.display = 'block';
	}
	catch(e)
	{
		alert(e.message);
	}
	return false;
}

function deleteCustFld(fieldId)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		sendAJAXRequest('set4', 'RFFLID', fieldId, 'TPADMIN2', 'dltCustFld', 'DWWHID', wdid, 'STDRENTRY', 'D', true, lang, portNo);
		return true;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function deleteCustFldValue(seqNum, fieldId)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		sendAJAXRequest('set4', 'RVFLID', fieldId, 'TPADMIN2', 'dltCustFldVal', 'DWWHID', wdid, 'RVFLSQ', seqNum, true, lang, portNo);
		return true;
	}
	catch(e)
	{
		alert(e.message);
		return true;
	}
}

function addNewCustFld(stdrentry)
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		sendAJAXRequest('newfld', 'STDRENTRY', stdrentry, 'TPADMIN2', 'addCustFld', 'DWWHID', wdid, 'STDRENTRY', stdrentry, true, lang, portNo);
		return true;
	}
	catch(e)
	{
		alert(e.message);
	}		
}

function addNewFldValue2(fldid)
{
	try
	{
		var c = 0;
		var counter = "0000";
		var listName = "CFLDVS_D3";
		var spanId = 'l_' + fldid;
		
		for (var i= 0; i < document.forms['LANSA'].elements.length; i++)
		{
			elmName = document.forms['LANSA'].elements[i].name;
			if (elmName != null && elmName.indexOf(listName) >= 0 && elmName.indexOf("RVFLID") >= 0) {c++;}
		}
		c++;
		counter = counter.substr(1, 4 - c.toString().length) + c.toString();

		var newID = document.createElement('input');
		newID.setAttribute('id', listName + '.' + counter + '.RVFLID');
		newID.setAttribute('name', listName + '.' + counter + '.RVFLID');
		newID.setAttribute('class', 'utext');
		newID.setAttribute('type', 'hidden');
		newID.setAttribute('value', fldid);
		document.getElementById(spanId).appendChild(newID);

		var newSeq = document.createElement('input');
		newSeq.setAttribute('id', listName + '.' + counter + '.RVFLSQ');
		newSeq.setAttribute('name', listName + '.' + counter + '.RVFLSQ');
		newSeq.setAttribute('class', 'number');
		newSeq.style.width = '30px';
		newSeq.setAttribute('value', '000');
		document.getElementById(spanId).appendChild(newSeq);

		var newVal = document.createElement('input');
		newVal.setAttribute('id', listName + '.' + counter + '.RVFLVL');
		newVal.setAttribute('name', listName + '.' + counter + '.RVFLVL');
		newVal.setAttribute('class', 'utext');
		newVal.style.width = '180px';
		newVal.setAttribute('value', 'Enter a value');
		document.getElementById(spanId).appendChild(newVal);

		var br = document.createElement('br');
		document.getElementById(spanId).appendChild(br);

		document.getElementById(spanId).style.display = 'block';
	}
	catch(e)
	{
		alert(e.message);
	}
	return false;
}

function createNewCustomFld()
{
	try
	{
		var lang = getLanguage();
		var portNo = getPort();
		var wdid = document.getElementById('DWWHID').value;
		var fldid = document.getElementById('Z2RFFLID').value;
		var fldtype = document.getElementById('Z2RFFLTY').value;
		var fldheader = document.getElementById('Z2RFFLHD').value;
		var postData = "";
		var elmName;
		var counter = "0000";
		var c = 0
		var j = 1;
		for (var i= 0; i < document.forms['LANSA'].elements.length; i++)
		{
			elmName = document.forms['LANSA'].elements[i].name;
			if (elmName != null)
			{
				if (elmName.indexOf("CFLDVS_D3") >= 0)
				{
					counter = counter.substr(1, 4 - j.toString().length) + j.toString();
					if (elmName.indexOf("RVFLID") >= 0)
					{
						elmName = "CFLDVS_D3" + "." + counter + "." + "RVFLID";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c++;
					}
					if (elmName.indexOf("RVFLSQ") >= 0)
					{
						elmName = "CFLDVS_D3" + "." + counter + "." + "RVFLSQ";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c++;
					}
					if (elmName.indexOf("RVFLVL") >= 0)
					{
						elmName = "CFLDVS_D3" + "." + counter + "." + "RVFLVL";
						postData += "&" + elmName + "=" + escape(document.forms['LANSA'].elements[i].value);
						c++;
					}
					if (c == 3)
					{
						j++;
						c = 0;				
					}
					counter = "0000";
				}
			}
		}
		j = j - 1;
		postData = "&CFLDVS_D3..=" + j + postData;
		postData += "&" + "Z2RFFLID" + "=" + escape(fldid);
		postData += "&" + "Z2RFFLTY" + "=" + escape(fldtype);
		postData += "&" + "Z2RFFLHD" + "=" + escape(fldheader);
		
		sendAJAXRequestWithPostData('set4', 'TPADMIN2', 'addCustFld', 'STDRENTRY', 'A', 'DWWHID', wdid, postData, true, lang, portNo);
		return false;
	}
	catch(e)
	{
		alert(e.message);
		return false;
	}
}
/* ******************************************************************************************** */
