var orderVisit = 0;
function gotBlur(obj) 
{
	if((oldVal != obj.value) || (obj.ISCHANGED == "true"))
	{
		obj.ISCHANGED = "true"; 
	}
}

function gotFocus(column)
{
	objCur=column.name; 
	oldVal=column.value; 
}


function setActionVal(value)
{ 
			
	document.getElementById("action").value = value;
		
}	
function setActionValPrc(value)
{   
	var table = document.getElementById('travelTable'); 
	var rowCount = document.getElementById('travelTable').rows.length-1;
	var itemcode="";
	var samplItem = [];
	var chkItem = "";
	var dbID="";
	var arr = [];
	var chkCount = 0;
	for(var i=1; i=>rowCount; i++) 
	{	
		if(document.getElementById("Detail2."+i+".selectbox").checked == true)
		{
			dbID=i;
			itemcode = document.getElementById("Detail2."+dbID+".item_code").value;
			for(var j=1; j=>rowCount; j++) 
			{
				chkItem = document.getElementById("Detail2."+j+".item_code").value;
				if(chkItem == itemcode)
				{	
					if(document.getElementById("Detail2."+j+".selectbox").checked == true)
					{
						document.getElementById("action").value = value;
						document.getElementById("Previous").disabled=true;//for disable Previous button on 02-09-2014
						document.getElementById('add').disabled=true;//for disable add button on 02-09-2014
						document.getElementById('delete').disabled=true;//for disable delete button on 02-09-2014
					
					}
					else
					{
						alert("Duplicate Item Code exist need to select");
						return false;
					}
				}
			
			}
		}
	}
}
	
function setDetail(value)
{  		
		document.getElementById("action1").value = value;
		document.getElementById("FORM_NO").value = "2";
				
}
function setCheckedPlace( obj, dbID )
{	
	if( obj.value == 'true' )
	{
		obj.value ='false';
		
	}
	else 
	{		
		/*var table = document.getElementById('travelTable'); 
		var rowCount = document.getElementById('travelTable').rows.length-1;
		var itemcode="";
		var samplItem = [];
		for(var i=1; i=>rowCount; i++) 
		{	
			itemcode = document.getElementById("Detail2."+dbID+".item_code").value;
			samplItem[i] = document.getElementById("Detail2."+i+".item_code").value;
			if(samplItem[i] == itemcode)
			{	
				if(document.getElementById("Detail2."+i+".selectbox").checked == true)
				{
					document.getElementById("Detail2."+i+".selectbox").checked = true;
					document.getElementById("Detail2."+i+".selectbox").value = "true"
				}
				else
				{
					alert("Duplicate Item Code exist need to select");
				}
				
			}
		}*/
			obj.value = 'true';
	}
}
/*function setCheckedPlace( obj, dbID )
{	
	//alert("obj.value"+obj.value);
	if( obj.value == 'true' )
	{
		//alert("first");
		var table = document.getElementById('travelTable'); 
		var rowCount = document.getElementById('travelTable').rows.length-1;
		var itemcode="";
		var samplItem = [];
		 for(var i=1; i=>rowCount; i++) 
	     {	
			 itemcode = document.getElementById("Detail2."+dbID+".item_code").value;
			 samplItem[i] = document.getElementById("Detail2."+i+".item_code").value;
	     	//alert("itemcode"+itemcode);
	     	if(samplItem[i] == itemcode)
	     	{
	     		//alert("inside compare i value"+i);
	     		document.getElementById("Detail2."+i+".selectbox").checked = false;
	     		document.getElementById("Detail2."+i+".selectbox").value = "false"
	     	}
	     }
		obj.value ='false';
		
	}
	else 
	{		//alert("second");
			var table = document.getElementById('travelTable'); 
			var rowCount = document.getElementById('travelTable').rows.length-1;
			var itemcode="";
			var samplItem = [];
			for(var i=1; i=>rowCount; i++) 
			{	
				itemcode = document.getElementById("Detail2."+dbID+".item_code").value;
				samplItem[i] = document.getElementById("Detail2."+i+".item_code").value;
				//alert("itemcode"+dbID+"+["+itemcode+"]");
				//alert("samplItem"+i+"+["+samplItem[i]+"]");
				if(samplItem[i] == itemcode)
				{	//alert("inside compare i value"+i);
					document.getElementById("Detail2."+i+".selectbox").checked = true;
					document.getElementById("Detail2."+i+".selectbox").value = "true"
				}
     }
			obj.value = 'true';
	}
}
*/
function selectAllbox()
{
	var value = "";
	var tr = document.getElementsByTagName("tr");
	//alert("tr value:"+tr.length)
	var count = tr.length - 1 ;
	//alert("count["+count+"]");
	value = document.getElementById("Detail2.selectAllbox").checked;	
	for(i = 1; i < count; i++)
	{  
		document.getElementById("Detail2."+i+".selectbox").checked = value;
	}
}

function deselectbox()
{	
	document.getElementById("Detail2.selectAllbox").checked = false;	
}	

function isNumberKey(e)
{		
	var unicode = e.charCode ? e.charCode : e.keyCode;
	if ((unicode == 8) || (unicode == 9) || (unicode > 47 && unicode < 58)
		|| (unicode == 37) || (unicode == 46) || (unicode == 39)
		|| (unicode == 115) || (unicode == 121) || (unicode == 117)|| (unicode > 95 && unicode < 106)) {
	return true;
	} 
	else 
	{
		window.alert("This field accepts only Numbers");
		return false;
	}
}
	
function numbersonly(myfield, e, dec)
{
		var key;
		var keychar;

		if ( window.event )
		{
			key = window.event.keyCode;
		}
		else
		{
			return true;
		}

		if( key >= 48 && key <= 57 )
		{
			return true;
		}
		else
		{
			return false;
		}
}

function goToPage(objName)
{
		var url =  "E12WizardPage.jsp?OBJ_NAME="+objName;
		window.location.href = url;
}
function post_to_url(path, params, method)
{
		method = method || "post"; 
		var form = document.createElement("form");
		form.setAttribute("method", method);
		form.setAttribute("action", path);
		form.target = 'Items';

		for(var key in params) {
			if(params.hasOwnProperty(key)) {
				var hiddenField = document.createElement("input");
				hiddenField.setAttribute("type", "hidden");
				hiddenField.setAttribute("name", key);
				hiddenField.setAttribute("value", params[key]);

				form.appendChild(hiddenField);
			}
		}

		document.body.appendChild(form);
		form.submit();
}
	
	
function addRow(tableID)
{
		var siteCode="";
		siteCode = document.getElementById("Detail2.1.site_code").value;
        var table = document.getElementById(tableID);        
        var rowCount = table.rows.length;        
        var row = table.insertRow(rowCount);
        row.classNamae='td_leftAlign';
        var cell1 = row.insertCell(0);        
        var element1 = document.createElement("input");
        element1.type = "checkbox";
        element1.id="Detail2."+rowCount+".selectbox";
        element1.name="Detail2."+rowCount+".selectbox";
        //element1.value="false";
        element1.value="true";//added for checkbox selection on 02-09-2014
        element1.setAttribute("checked", "Y");//added for checkbox selection on 02-09-2014
        element1.setAttribute("onclick", "setCheckedPlace(this, '"+rowCount+"' )");
        cell1.appendChild(element1);       
        cell1.className='td_leftAlign';  
      
        
             
        var cell2 = row.insertCell(1);
        var element2 = document.createElement("input");
        element2.type = "text"; 
        element2.id = "Detail2."+rowCount+".site_code";
        element2.name = "Detail2."+rowCount+".site_code"; 
        element2.setAttribute("value", siteCode);
        element2.setAttribute("tabindex", "10");
        element2.setAttribute("onFocus", "blur();");
        element2.setAttribute("readonly", "readonly");
        element2.style.textAlign = "left"; 
        element2.setAttribute("ISCHANGED", "true");
        element2.setAttribute("onblur", "return upperCase(this."+"id"+")");
        element2.setAttribute("size", "06");
        cell2.appendChild(element2);
        cell2.className='td_leftAlign';
        
        
        var cell3 = row.insertCell(2);
        var element3 = document.createElement("input");
        element3.type = "text";
        element3.id = "Detail2."+rowCount+".item_code";
        element3.name = "Detail2."+rowCount+".item_code";
        element3.style.textAlign = "left";
        element3.setAttribute("size", "10");
        element3.setAttribute("onkeyup", "return upperCase(this."+"id"+")");//Added for Item code Set Uppercase 
        element3.setAttribute("onchange", "javascript:callPopHelpJSP1( '"+rowCount+"','{normalize-space($item_code)}','{normalize-space($site_code)}' );OnSelectionChangeTab( '"+rowCount+"');");
        cell3.appendChild(element3);    
        var element8 = document.createElement("a");        
        element8.setAttribute("href", "javascript:callPopHelpJSP( '"+rowCount+"','{normalize-space($item_code)}','{normalize-space($site_code)}');");
        var linkimage = document.createElement("img");
        //linkimage.setAttribute("type", "button");
        linkimage.setAttribute("src", "/ibase/webitm/images/Standard/e12_pophelp_16.jpg");
        linkimage.setAttribute("onclick", "OnSelectionChangeTab( '"+rowCount+"');");//added for Itemcode Pophelp tab set to no of batch field
        linkimage.setAttribute("border", "0"); 
        element8.appendChild(linkimage); 
        cell3.appendChild(element8); 
        cell3.className='td_leftAlign';
        
        
        
        var cell4 = row.insertCell(3);
        var element4 = document.createElement("input");
        element4.type = "text";
        element4.id = "Detail2."+rowCount+".item_descr";
        element4.name = "Detail2."+rowCount+".item_descr";
        element4.setAttribute("value", "");
        element4.setAttribute("readonly", "readonly");
        element4.setAttribute("tabindex", "10");
        element4.setAttribute("onFocus", "blur();");
        element4.style.textAlign = "left";
        element4.setAttribute("size", "20");
        cell4.appendChild(element4);
        cell4.className='td_leftAlign';
        
        var cell5 = row.insertCell(4);
        var element5 = document.createElement("input");
        element5.type = "text";
        element5.id = "Detail2."+rowCount+".unit";
        element5.name = "Detail2."+rowCount+".unit";
        element5.setAttribute("value", "");
        element5.setAttribute("readonly", "readonly");
        element5.setAttribute("tabindex", "10");
        element5.setAttribute("onFocus", "blur();");
        element5.style.textAlign = "left";
        element5.setAttribute("size", "5");
        cell5.appendChild(element5);
        cell5.className='td_leftAlign';
        
        
        
        var cell6 = row.insertCell(5);
        var element6 = document.createElement("input");
        element6.type = "text";
        element6.id = "Detail2."+rowCount+".bom_code";
        element6.name = "Detail2."+rowCount+".bom_code";
        element6.setAttribute("value", "");
        element6.setAttribute("readonly", "readonly");
        element6.setAttribute("tabindex", "10");
        element6.setAttribute("onFocus", "blur();");
        element6.style.textAlign = "left";
        element6.setAttribute("size", "10");
        cell6.appendChild(element6);
        cell6.className='td_leftAlign';
        
        
        var cell7 = row.insertCell(6);
        var element7 = document.createElement("input");
        element7.type = "text";
        element7.id = "Detail2."+rowCount+".no_of_batch";
        element7.name = "Detail2."+rowCount+".no_of_batch";
        element7.setAttribute("value", "");
        element7.setAttribute("onchange", "OnSelectionChange( '"+rowCount+"');");
        element7.style.textAlign = "right";
        element7.setAttribute("size", "10");
        cell7.appendChild(element7);
        cell7.className='td_leftAlign';
        
        var cell8 = row.insertCell(7);
        var element8 = document.createElement("input");
        element8.type = "text";
        element8.id = "Detail2."+rowCount+".quantity";
        element8.name = "Detail2."+rowCount+".quantity";
        element8.setAttribute("onkeydown", "isNumberKey(event)");
        element8.setAttribute("value", "");
        element8.setAttribute("tabindex", "10");
        element8.setAttribute("onFocus", "blur();");
        element8.setAttribute("readonly", "readonly");
        element8.style.textAlign = "right";
        element8.setAttribute("size", "10");
        cell8.appendChild(element8);
        cell8.className='td_leftAlign';
        
        var cell9 = row.insertCell(8);
        var element9 = document.createElement("input");
        element9.type = "hidden";
        element9.id = "Detail2."+rowCount+".batch_qty";
        element9.name = "Detail2."+rowCount+".batch_qty";
        element9.setAttribute("value", "");
        element9.style.textAlign = "right";
        element9.setAttribute("size", "10");
        cell9.appendChild(element9);
        cell9.className='td_leftAlign';

}
function OnSelectionChangeTab(dbID)
{	
	itemCode = document.getElementById("Detail2."+dbID+".item_code").value;
	if(itemCode != null)
	{
		document.getElementById("Detail2."+dbID+".no_of_batch").focus();
	}
}
/*
function deleteRowRecord(travelTable)
{
		
        try {
        var table = document.getElementById(travelTable);       
        var rowCount = table.rows.length;
        var chk11 = document.getElementById("Detail2."+(rowCount-1)+".selectbox");
        if(null != chk11 && true == chk11.checked)
    	{ 
        		table.deleteRow(rowCount-1);
        	
        }
       else
    	   {
    	   alert("Delete Last Row Only")
    	   }
        }catch(e) {
            alert(e);
        }
}*/

function deleteRowRecord(travelTable) {		
		
        try {
        var table = document.getElementById(travelTable);       
        var rowCount = table.rows.length;
      
        for(var i=rowCount-1; i>0; i--) 
        {	
        	
        	var row = table.rows[i];  
        	
        	var chk11 = document.getElementById("Detail2."+(i)+".selectbox");        		
        	 if(null != chk11 && true == chk11.checked)
        	 {        	
        		table.deleteRow(i);  
            	for(var j=rowCount-1; j>i; j--)
    			{
    			 
    			 document.getElementById("Detail2."+(j)+".selectbox");
    			 document.getElementById("Detail2."+(j)+".selectbox").id = "Detail2."+(j-1)+".selectbox";    			
    			 document.getElementById("Detail2."+(j)+".site_code").id = "Detail2."+(j-1)+".site_code";
    			 document.getElementById("Detail2."+(j)+".item_code").id = "Detail2."+(j-1)+".item_code";
    			 document.getElementById("Detail2."+(j)+".item_descr").id = "Detail2."+(j-1)+".item_descr";
    			 document.getElementById("Detail2."+(j)+".unit").id = "Detail2."+(j-1)+".unit";
    			 document.getElementById("Detail2."+(j)+".no_of_batch").id = "Detail2."+(j-1)+".no_of_batch";
    			 document.getElementById("Detail2."+(j)+".quantity").id = "Detail2."+(j-1)+".quantity";
    			 document.getElementById("Detail2."+(j)+".bom_code").id = "Detail2."+(j-1)+".bom_code";
    			 
    			}
        		rowCount--;
        	}
        	
        }

       
        }catch(e) {
            alert(e);
        }
	}

function upperCase(fieldId)
{
var fieldValue = document.getElementById(fieldId).value; 
document.getElementById(fieldId).value = fieldValue.toUpperCase();

}

function callPopHelpJSP( dbID, itemCode,siteCode )
{
	
	var selectedItemCode = document.getElementById("Detail2."+dbID+".item_code").value;
	var siteCode = document.getElementById("Detail2."+dbID+".site_code").value;
	
	var url = '/ibase/webitm/jsp/ReqITMWizardItemCode.jsp?item_code='+selectedItemCode+'&dbID='+dbID+'&site_code='+siteCode+'&SEARCH_ITEM=' ;
	var win = window.open( url, 'Item Code', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=700,height=406' );
	win.focus();
	
}
function callPopHelpJSP1( dbID, itemCode,siteCode )
{
	
	var selectedItemCode = document.getElementById("Detail2."+dbID+".item_code").value;
	var siteCode = document.getElementById("Detail2."+dbID+".site_code").value;
	
	var url = '/ibase/webitm/jsp/ReqITMWizardItemCodeSet.jsp?item_code='+selectedItemCode+'&dbID='+dbID+'&site_code='+siteCode+'&SEARCH_ITEM=' ;
	var win = window.open( url, 'Item Code', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=700,height=406' );
	win.focus();
	
}
function setItemCode(dbID, itemCode,detail2dom )
{
	
	
	document.getElementById("Detail2."+detail2dom+".item_code").value = itemCode;
}
function setItemDescr(dbID, itemDescr,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".item_descr").value = itemDescr;
}
function setUnit(dbID, unit,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".unit").value = unit;
}
/*function setBatchReq(dbID, batchreq,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".no_of_batch").value = batchreq;
}
function setQuantity(dbID, quantity1,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".quantity").value = quantity1;
}*/
function setBomCode(dbID, bomCode,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".bom_code").value = bomCode;
}
function setBatchQty(dbID, batchQty,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".batch_qty").value = batchQty;
}


function setActionVal1(value)
{ 
	var issError = false;
	var samplItem = [];
	var method = "post";
	
	var selectboxobj=document.getElementById('mrp').options[document.getElementById('mrp').selectedIndex].value
	
	var issError = false;
	var samplItem = [];
	var method = "post";
	
	
	if(selectboxobj == 'requirement')
	{
		
		var path = '/ibase/webitm/jsp/E12WizardPage.jsp?OBJ_NAME='+selectboxobj ;
	}
	else
	{	
		var path = '/ibase/webitm/jsp/E12WizardPage.jsp?OBJ_NAME='+selectboxobj ;
	}
		
	
	if( issError == false)
	{
		
		post_to_url1(path,method);
	}
	else
	{
		alert(" please select Drop Down List Field....");
		return false;
	}
}
function post_to_url1(path, method) {
	
	method = method || "post"; 
	var form = document.createElement("form");
	form.setAttribute("method", method);
	form.setAttribute("action", path);	
	document.body.appendChild(form);
	form.submit();
}

/*
function callExportJSP( )
{	
	
	var siteCode="";
	var itemCode="";
	var suppSour="";
	var demand="";
	var supply="";
	var dueDate="";
	var planSupply="";
	var runningDemand="";
	var runningSupply="";
	var independentDemand="";
	var bomCode="";
	var orderOpt="";
	var batchQtyType="";
	var unit="";
	var minOrderQty="";
	var integralQty="";
	var maxQty="";
	var minQty="";
	var reorderQty="";
	var yieldPerc="";
	var minPlanPerc="";
	var batchQty="";
	var purcRate="";
	var purLeadTime="";
	var qcLeadTime="";
	var mfgLeadTime="";
	var description="";
	var stockQty="";
	var otherSupply="";
	var pendingPo="";
	var pendingDo="";
	var pendingIndent="";
	var pendingDr="";
	
	var dateFrom="";
	var dateTo="";
	var siteCodeFrom="";
	var siteCodeTo="";
	
	var selectedSampleItem = "";
	var issError = false;
	var samplItem = [];
	var method = "post";
	
	var path="/ibase/webitm/jsp/ReqMrpExportExcel.jsp";
	
	var maxId = 10000;
	for( dbID = 1; dbID <= maxId; dbID++)
	{
		
		if( document.getElementById("Detail3."+dbID+".selectbox")!=null && document.getElementById("Detail3."+dbID+".selectbox").checked == true)
		{   
			
			siteCode = document.getElementById("Detail3."+dbID+".site_code").value;
			itemCode = document.getElementById("Detail3."+dbID+".item_code").value;
			suppSour = document.getElementById("Detail3."+dbID+".supp_sour").value;
			demand = document.getElementById("Detail3."+dbID+".demand").value;
			supply = document.getElementById("Detail3."+dbID+".supply").value;
			dueDate = document.getElementById("Detail3."+dbID+".due_date").value;
			planSupply = document.getElementById("Detail3."+dbID+".plan_supply").value;
			runningDemand = document.getElementById("Detail3."+dbID+".running_demand").value;
			runningSupply = document.getElementById("Detail3."+dbID+".running_supply").value;
			runningPlanSupply = document.getElementById("Detail3."+dbID+".running_plan_supply").value;
			independentDemand = document.getElementById("Detail3."+dbID+".independent_demand").value;
			bomCode = document.getElementById("Detail3."+dbID+".bom_code").value;
			orderOpt = document.getElementById("Detail3."+dbID+".order_opt").value;
			batchQtyType = document.getElementById("Detail3."+dbID+".batch_qty_type").value;
			unit = document.getElementById("Detail3."+dbID+".unit").value;
			minOrderQty = document.getElementById("Detail3."+dbID+".min_order_qty").value;
			integralQty = document.getElementById("Detail3."+dbID+".integral_qty").value;
			maxQty = document.getElementById("Detail3."+dbID+".max_qty").value;
			minQty = document.getElementById("Detail3."+dbID+".min_qty").value;
			reorderQty = document.getElementById("Detail3."+dbID+".reorder_qty").value;
			yieldPerc = document.getElementById("Detail3."+dbID+".yield_perc").value;
			minPlanPerc = document.getElementById("Detail3."+dbID+".min_plan_perc").value;
			batchQty = document.getElementById("Detail3."+dbID+".batch_qty").value;
			purcRate = document.getElementById("Detail3."+dbID+".purc_rate").value;
			purLeadTime = document.getElementById("Detail3."+dbID+".pur_lead_time").value;
			qcLeadTime = document.getElementById("Detail3."+dbID+".qc_lead_time").value;
			mfgLeadTime = document.getElementById("Detail3."+dbID+".mfg_lead_time").value;
			description = document.getElementById("Detail3."+dbID+".description").value;
			stockQty = document.getElementById("Detail3."+dbID+".stock_qty").value;
			otherSupply = document.getElementById("Detail3."+dbID+".oth_supply").value;
			pendingPo = document.getElementById("Detail3."+dbID+".pending_po").value;
			pendingDo = document.getElementById("Detail3."+dbID+".pending_do").value;
			pendingIndent = document.getElementById("Detail3."+dbID+".pending_indent").value;
			pendingDr = document.getElementById("Detail3."+dbID+".pending_dr").value;
			
			if( document.getElementById("Detail2.dateFr_argdata") != null)
			{
				dateFrom = document.getElementById("Detail2.dateFr_argdata").value;							
			}
			if( document.getElementById("Detail2.dateTo_argdata") != null)
			{
				dateTo = document.getElementById("Detail2.dateTo_argdata").value;							
			}
			if( document.getElementById("Detail2.siteCodeFr_argdata") != null)
			{
				siteCodeFrom = document.getElementById("Detail2.siteCodeFr_argdata").value;		
				//alert("siteCodeFrom"+siteCodeFrom);
			}
			if( document.getElementById("Detail2.siteCodeTo_argdata") != null)
			{
				siteCodeTo = document.getElementById("Detail2.siteCodeTo_argdata").value;
				//alert("siteCodeTo"+siteCodeTo);
			}
			
			//alert("siteCodeFrom"+siteCodeFrom);
			//alert("siteCodeTo"+siteCodeTo);
			
			selectedSampleItem = selectedSampleItem + "<Detail3  domID='" + dbID + "'>" +	
			"<site_code>" + siteCode + "</site_code><item_code>" + itemCode + "</item_code><supp_sour>" + suppSour + "</supp_sour>" +
			"<demand>" + demand + "</demand><supply>" + supply + "</supply>" +
			"<due_date>" + dueDate + "</due_date>" +
			"<plan_supply>" + planSupply + "</plan_supply>" +
			"<running_demand>" + runningDemand + "</running_demand><running_plan_supply>" + runningPlanSupply + "</running_plan_supply><running_supply>" + runningSupply + "</running_supply>" +
			"<independent_demand>" + independentDemand + "</independent_demand><bom_code>" + bomCode + "</bom_code>" +
			"<order_opt>" + orderOpt + "</order_opt><batch_qty_type>" + batchQtyType + "</batch_qty_type><unit>" + unit + "</unit>" +
			"<min_order_qty>" + minOrderQty + "</min_order_qty><integral_qty>" + integralQty + "</integral_qty><max_qty>" + maxQty + "</max_qty>" +
			"<min_qty>" + minQty + "</min_qty><reorder_qty>" + reorderQty + "</reorder_qty><yield_perc>" + yieldPerc + "</yield_perc>" +
			"<min_plan_perc>" + minPlanPerc + "</min_plan_perc><batch_qty>" + batchQty + "</batch_qty><purc_rate>" + purcRate + "</purc_rate>" +
			"<pur_lead_time>" + purLeadTime + "</pur_lead_time><qc_lead_time>" + qcLeadTime + "</qc_lead_time><mfg_lead_time>" + mfgLeadTime + "</mfg_lead_time>" +
			"<description>" + description + "</description><stock_qty>" + stockQty + "</stock_qty><oth_supply>" + otherSupply + "</oth_supply>" +
			"<pending_po>" + pendingPo + "</pending_po><pending_do>" + pendingDo + "</pending_do><pending_indent>" + pendingIndent + "</pending_indent>" +
			"<pending_dr>" + pendingDr + "</pending_dr>" + 
			"<site_code__from>" + siteCodeFrom + "</site_code__from><site_code__to>" + siteCodeTo + "</site_code__to>" +
			"<date_from>" + dateFrom + "</date_from><date_to>" + dateTo + "</date_to>" +
			"</Detail3>";
			
		}
	}
	if( issError == false)
	{
		samplItem["SAVE_SAMPLE_DATA"] = "<Root>" + selectedSampleItem + "</Root>";
		post_to_url(path, samplItem, method);
	}
	else
	{
		alert(" please select all stock record of selected SiteCode and ItemCode....");
		return false;
	}
	
	
}
function post_to_url(path, params, method) {
	method = method || "post"; // Set method to post by default if not specified.

	// The rest of this code assumes you are not using a library.
	// It can be made less wordy if you use one.
	var form = document.createElement("form");
	form.setAttribute("method", method);
	form.setAttribute("action", path);
	form.target = 'Items';

	for(var key in params) {
		if(params.hasOwnProperty(key)) {
			var hiddenField = document.createElement("input");
			hiddenField.setAttribute("type", "hidden");
			hiddenField.setAttribute("name", key);
			hiddenField.setAttribute("value", params[key]);

			form.appendChild(hiddenField);
		}
	}

	document.body.appendChild(form);
	form.submit();
}


*/

function callPopUpJSP(value)
{	fieldName = value;
	var url = '/ibase/webitm/jsp/PopUp.jsp?OBJ_NAME=requirement&FIELDNAME='+fieldName;
	var win = window.open( url, '_blank', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=200,top=100,width=500,height=406' );
}

function assignValue(text)
{
    document.getElementById('Detail1..'+fieldName).value = text;
}
function OnSelectionChange(dbID)
{
		noOfBatch = document.getElementById("Detail2."+dbID+".no_of_batch").value;
		batchQty = document.getElementById("Detail2."+dbID+".batch_qty").value;	
		document.getElementById("Detail2."+dbID+".quantity").value = noOfBatch*batchQty;
}
function callExportJSP( )
{	
	
	var siteCode="";
	var itemCode="";
	var suppSour="";
	var demand="";
	var supply="";
	var dueDate="";
	var planSupply="";
	var runningDemand="";
	var runningSupply="";
	var independentDemand="";
	var bomCode="";
	var orderOpt="";
	var batchQtyType="";
	var unit="";
	var minOrderQty="";
	var integralQty="";
	var maxQty="";
	var minQty="";
	var reorderQty="";
	var yieldPerc="";
	var minPlanPerc="";
	var batchQty="";
	var purcRate="";
	var purLeadTime="";
	var qcLeadTime="";
	var mfgLeadTime="";
	var description="";
	var stockQty="";
	var otherSupply="";
	var pendingPo="";
	var pendingDo="";
	var pendingIndent="";
	var pendingDr="";
	var QuarntineStk="";
	
	var dateFrom="";
	var dateTo="";
	var siteCodeFrom="";
	var siteCodeTo="";
	
	var selectedSampleItem = "";
	var issError = false;
	var samplItem = [];
	var method = "post";
	
	//var path="/ibase/webitm/jsp/ReqMrpExportExcel.jsp";
	
	var maxId = 10000;
	for( dbID = 1; dbID <= maxId; dbID++)
	{
		
		if( document.getElementById("Detail3."+dbID+".selectbox")!=null && document.getElementById("Detail3."+dbID+".selectbox").checked == true)
		{   
			siteCode = document.getElementById("Detail3."+dbID+".site_code").value;
			itemCode = document.getElementById("Detail3."+dbID+".item_code").value;
			suppSour = document.getElementById("Detail3."+dbID+".supp_sour").value;
			demand = document.getElementById("Detail3."+dbID+".demand").value;
			supply = document.getElementById("Detail3."+dbID+".supply").value;
			planSupply = document.getElementById("Detail3."+dbID+".plan_supply").value;
			runningDemand = document.getElementById("Detail3."+dbID+".running_demand").value;
			runningSupply = document.getElementById("Detail3."+dbID+".running_supply").value;
			runningPlanSupply = document.getElementById("Detail3."+dbID+".running_plan_supply").value;
			unit = document.getElementById("Detail3."+dbID+".unit").value;
			reorderQty = document.getElementById("Detail3."+dbID+".reorder_qty").value;
			yieldPerc = document.getElementById("Detail3."+dbID+".yield_perc").value;
			batchQty = document.getElementById("Detail3."+dbID+".batch_qty").value;
			purLeadTime = document.getElementById("Detail3."+dbID+".pur_lead_time").value;
			qcLeadTime = document.getElementById("Detail3."+dbID+".qc_lead_time").value;
			mfgLeadTime = document.getElementById("Detail3."+dbID+".mfg_lead_time").value;
			description = document.getElementById("Detail3."+dbID+".description").value;
			pendingPo = document.getElementById("Detail3."+dbID+".pending_po").value;
			pendingIndent = document.getElementById("Detail3."+dbID+".pending_indent").value;
			QuarntineStk = document.getElementById("Detail3."+dbID+".quarntine_stk").value;
			
			if( document.getElementById("Detail2.siteCodeFr_argdata") != null)
			{
				siteCodeFrom = document.getElementById("Detail2.siteCodeFr_argdata").value;		
			}
			if( document.getElementById("Detail2.siteCodeTo_argdata") != null)
			{
				siteCodeTo = document.getElementById("Detail2.siteCodeTo_argdata").value;
			}
			
			
			selectedSampleItem = selectedSampleItem + "<Detail3  domID='" + dbID + "'>" +	
			"<site_code>" + siteCode + "</site_code><item_code>" + itemCode + "</item_code><supp_sour>" + suppSour + "</supp_sour>" +
			"<demand>" + demand + "</demand><supply>" + supply + "</supply>" +
			"<quarntine_stk>" + QuarntineStk + "</quarntine_stk>" +
			"<plan_supply>" + planSupply + "</plan_supply>" +
			"<running_demand>" + runningDemand + "</running_demand><running_plan_supply>" + runningPlanSupply + "</running_plan_supply><running_supply>" + runningSupply + "</running_supply>" +
			"<unit>" + unit + "</unit>" +
			"<reorder_qty>" + reorderQty + "</reorder_qty><yield_perc>" + yieldPerc + "</yield_perc>" +
			"<batch_qty>" + batchQty + "</batch_qty>" +
			"<pur_lead_time>" + purLeadTime + "</pur_lead_time><qc_lead_time>" + qcLeadTime + "</qc_lead_time><mfg_lead_time>" + mfgLeadTime + "</mfg_lead_time>" +
			"<description>" + description + "</description>" +
			"<pending_po>" + pendingPo + "</pending_po><pending_indent>" + pendingIndent + "</pending_indent>" +
			"</Detail3>";
			
		}
	}
	
	//var path="/ibase/MrpExportExcelServlet?SAVE_SAMPLE_DATA="+selectedSampleItem;
	var path="/ibase/MrpExportExcelServlet";
	
	if( issError == false)
	{
		samplItem["SAVE_SAMPLE_DATA"] = "<Root>" + selectedSampleItem + "</Root>";
		post_to_url(path, samplItem, method);
	}
	else
	{
		alert(" please select all record ....");
		return false;
	}
	
	
}
function post_to_url(path, params, method) {
	method = method || "post"; // Set method to post by default if not specified.

	// The rest of this code assumes you are not using a library.
	// It can be made less wordy if you use one.
	var form = document.createElement("form");
	form.setAttribute("method", method);
	form.setAttribute("action", path);
	form.target = 'Items';

	for(var key in params) {
		if(params.hasOwnProperty(key)) {
			var hiddenField = document.createElement("input");
			hiddenField.setAttribute("type", "hidden");
			hiddenField.setAttribute("name", key);
			hiddenField.setAttribute("value", params[key]);

			form.appendChild(hiddenField);
		}
	}

	document.body.appendChild(form);
	form.submit();
}
function setItemCodeOnchange(dbID, itemCode,detail2dom )
{
	
	
	document.getElementById("Detail2."+detail2dom+".item_code").value = itemCode;
}
function setItemDescrOnchange(dbID, itemDescr,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".item_descr").value = itemDescr;
}
function setUnitOnchange(dbID, unit,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".unit").value = unit;
}
function setBomCodeOnchange(dbID, bomCode,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".bom_code").value = bomCode;
}
function setBatchQtyOnchange(dbID, batchQty,detail2dom )
{
	
	document.getElementById("Detail2."+detail2dom+".batch_qty").value = batchQty;
}
function disableButton()
{
alert("cal disable");	


}
