
//alert("PPPPPPPPPPPPP");
function finishAction( value )
{  
	//alert("call finishAction");

	document.getElementById("action").value = value;

	
	var samplItem = [];
	var method = "post";
	var path="/ibase/webitm/jsp/MilestonePayGen.jsp";


	var srNo = 1;
	var selectedSampleItem = "";
	//var maxId = 1000;
	var maxId = 10;
	var  purcOrder ="";
	var lineNo ="";
	var type ="";
	var relAgnst ="";
	var amtType ="";
	var relAmt ="";
	var relAfter ="";
	var vouchCreated ="";
	var taskCode ="";
	var dueDate ="";
	var adjMethod ="";
	var acctCode ="";
	var cctrCode ="";
	var taxClass ="";
	var taxChap ="";
	var taxEnv ="";
	var retentionPerc =""; 
	var siteCodeAdv ="";
	var adjPerc ="";
	var processDate="";
	var issError = true;
	//alert("maxId!^^^^^^^^^^^^^^^^^^@@@@@@!!!!! :"+maxId);	
	for( var dbIDOut = 1; dbIDOut <= maxId; dbIDOut++)
	{
		//alert("first for ckeck so------------");
		//alert("dbIDOut :"+dbIDOut);
		//alert("check null :"+document.getElementById("Detail2."+dbIDOut+".selectbox"));
		//alert("checked :"+document.getElementById("Detail2."+dbIDOut+".selectbox").checked);
		if(document.getElementById("Detail2."+dbIDOut+".selectbox")!=null && document.getElementById("Detail2."+dbIDOut+".selectbox").checked )
		{
			 issError = false;
			// alert("INSIDE IFFFFF");
			// alert(document.getElementById("Detail2."+dbIDOut+".purc_order"));
			if( document.getElementById("Detail2."+dbIDOut+".purc_order") != null)
			{
							purcOrder = document.getElementById("Detail2."+dbIDOut+".purc_order").value;
							//alert("purcOrder :"+purcOrder);
			}
			if( document.getElementById("Detail2."+dbIDOut+".line_no") != null)
			{
							lineNo = document.getElementById("Detail2."+dbIDOut+".line_no").value;
							//alert("lineNo :"+lineNo);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".type") != null)
			{
							type = document.getElementById("Detail2."+dbIDOut+".type").value;
							//alert("type :"+type);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".rel_agnst") != null)
			{
							relAgnst = document.getElementById("Detail2."+dbIDOut+".rel_agnst").value;
							//alert("relAgnst :"+relAgnst);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".amt_type") != null)
			{
							amtType = document.getElementById("Detail2."+dbIDOut+".amt_type").value;
							//alert("amtType :"+amtType);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".rel_amt") != null)
			{
							relAmt = document.getElementById("Detail2."+dbIDOut+".rel_amt").value;
							//alert("relAmt :"+relAmt);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".rel_after") != null)
			{
							relAfter = document.getElementById("Detail2."+dbIDOut+".rel_after").value;
							//alert("relAfter :"+relAfter);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".vouch_created") != null)
			{
							vouchCreated = document.getElementById("Detail2."+dbIDOut+".vouch_created").value;
							//alert("vouchCreated :"+vouchCreated);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".task_code") != null)
			{
							taskCode = document.getElementById("Detail2."+dbIDOut+".task_code").value;
							//alert("taskCode :"+taskCode);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".due_date") != null)
			{
							dueDate = document.getElementById("Detail2."+dbIDOut+".due_date").value;
							//alert("dueDate :"+dueDate);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".adj_method") != null)
			{
							adjMethod = document.getElementById("Detail2."+dbIDOut+".adj_method").value;
							//alert("adjMethod :"+adjMethod);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".acct_code") != null)
			{
							acctCode = document.getElementById("Detail2."+dbIDOut+".acct_code").value;
							//alert("acctCode :"+acctCode);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".cctr_code") != null)
			{
							cctrCode = document.getElementById("Detail2."+dbIDOut+".cctr_code").value;
							//alert("cctrCode :"+cctrCode);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".tax_class") != null)
			{
							taxClass = document.getElementById("Detail2."+dbIDOut+".tax_class").value;
							//alert("taxClass :"+taxClass);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".tax_chap") != null)
			{
							taxChap = document.getElementById("Detail2."+dbIDOut+".tax_chap").value;
							//alert("taxChap :"+taxChap);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".tax_env") != null)
			{
							taxEnv = document.getElementById("Detail2."+dbIDOut+".tax_env").value;
							//alert("taxEnv :"+taxEnv);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".retention_perc") != null)
			{
							retentionPerc = document.getElementById("Detail2."+dbIDOut+".retention_perc").value;
							//alert("retentionPerc :"+retentionPerc);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".site_code__adv") != null)
			{
							siteCodeAdv = document.getElementById("Detail2."+dbIDOut+".site_code__adv").value;
							//alert("siteCodeAdv :"+siteCodeAdv);
			}		
			if( document.getElementById("Detail2."+dbIDOut+".adj_perc") != null)
			{
							adjPerc = document.getElementById("Detail2."+dbIDOut+".adj_perc").value;
							//alert("adjPerc!!! :"+adjPerc);
			}	
			if( document.getElementById("Detail2."+dbIDOut+".process_date") != null)
			{
							processDate = document.getElementById("Detail2."+dbIDOut+".process_date").value;
							//alert("adjPerc!!! :"+adjPerc);
			}
	
			//alert("@@@@@@@@@@@@!!!!!!!!!!!@:");		
				selectedSampleItem = selectedSampleItem + "<Detail2  domID='" + dbIDOut + "'>" +	
								"<purc_order>" + purcOrder + "</purc_order><line_no>" + lineNo + "</line_no><type>" + type + "</type>" +
								"<rel_agnst>" + relAgnst + "</rel_agnst><amt_type>" + amtType + "</amt_type>" +
								"<rel_amt>" + relAmt + "</rel_amt>" +
								"<rel_after>" + relAfter + "</rel_after>" +
								"<vouch_created>" + vouchCreated + "</vouch_created><task_code>" + taskCode + "</task_code><due_date>" + dueDate + "</due_date>" +
								"<adj_method>" + adjMethod + "</adj_method><acct_code>" + acctCode + "</acct_code>" +
								"<cctr_code>" + cctrCode + "</cctr_code><tax_class>" + taxClass + "</tax_class>" +
								"<tax_chap>" + taxChap + "</tax_chap>" +
								"<tax_env>" + taxEnv + "</tax_env>" +
								"<retention_perc>" + retentionPerc + "</retention_perc>" +
								"<site_code__adv>" + siteCodeAdv + "</site_code__adv>" +
								"<adj_perc>" + adjPerc + "</adj_perc>" +
								"<process_date>" + processDate + "</process_date>" +
								"</Detail2>";
			
			/*selectedSampleItem = selectedSampleItem + "<Detail2  domID='" + dbIDOut + "'>" +
			"<purcOrder>" + purcOrder + "</purcOrder><line_no>" + lineNo + "</line_no><type>" + type + "</type>" +
			"<rel_agnst>" + relAgnst + "</rel_agnst><amt_type>" + amtType + "</amt_type>" +
			"<rel_amt>" + relAmt + "</rel_amt>" +
			"<rel_after>" + relAfter + "</rel_after>" +
			"<vouch_created>" + vouchCreated + "</vouch_created><task_code>" + taskCode + "</task_code><due_date>" + dueDate + "</due_date>" +
			"<adj_method>" + adjMethod + "</adj_method><acct_code>" + acctCode + "</acct_code>" +
			"<cctr_code>" + cctrCode + "</cctr_code><tax_class>" + taxClass + "</tax_class>" +
			"<tax_chap>" + taxChap + "</tax_chap>" +
			"<tax_env>" + taxEnv + "</tax_env>" +
			"<retention_perc>" + retentionPerc + "</retention_perc>" +
			"<site_code__adv>" + siteCodeAdv + "</site_code__adv>" +
			"</Detail2>";*/
			
				//alert("###########@!!! :");		
		//alert("selectedSampleItem :"+selectedSampleItem);
			//samplItem["SAVE_SAMPLE_DATA"] = "<Root>" + selectedSampleItem + "</Root>";

			
                       // post_to_url4(path,samplItem,method);

                     
                 	
			
		}
	}
	//alert("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ for save selectedSampleItem["+selectedSampleItem+"]@@@@@@@@@@@@@@@@@@@@@");
	
	//alert("issError :"+issError);	
	if(issError == false)
	{
		
		samplItem["SAVE_SAMPLE_DATA"] = "<Root>" + selectedSampleItem + "</Root>";
		//alert("samplItem :"+samplItem["SAVE_SAMPLE_DATA"]);
		post_to_url4(path,samplItem,method);
		
		//alert("response !!!!!!!!!!!!!!!!!!!!!!!!!!!");
	}
	else
	{
		alert(" please select atleast one row for process!!!!!!!!!...");
		return false;
	}
	//alert("end finishAction");
}


//function post_to_url4(path,params,method,sorderList) 
function post_to_url4(path,params,method) 
{
	
	//alert("post_to_url4@@@@@@@@@@!");
	//alert("path:"+path);
	//alert("params:"+params);
	//alert("method:"+method);
	
	
	method = method || "post"; // Set method to post by default if not specified.
	var form = document.createElement("form");
	form.setAttribute("method", method);
	form.setAttribute("action", path);
	form.target = 'Items';
	//form.target = '_self';
	//form.target = '_blank';

	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);
	//alert("wait...........");
	var p = form.submit();
	//alert("wait...........");
//alert("PPPPP"+p)
}



function setActionVal( value )
{  
	/*
	var locGroup="";
	var count = 50;
	alert("setActionVal")
	for(i = 1; i < count; i++)
	{  
		locGroup = "";
		if( document.getElementById("Detail2."+i+".loc_group") != null  &&   document.getElementById("Detail2."+i+".loc_group").value.trim().length > 0 )
		{
			locGroup = document.getElementById("Detail2."+i+".loc_group").value ;
			alert("val : i["+i+"] loc_group["+locGroup+"]");
			document.getElementById("Detail2."+i+".loc_group").value = locGroup;
		}
	}
	 */	

	document.getElementById("action").value = value;
}
/*Added By Shahu Mali on 10-01-13 */
function checkDate(field ,flag)
{   
	// alert("checkDate>>"+field.value);
	var currDateVal = new Date();
	//   alert(" currDate==>"+currDateVal);
	//var fieldValue = field.value.trim().split('/');
	var fieldValue = field.value.split('/');
	var firstDate=new Date();
	var eventDate = new Date(firstDate.setFullYear(currDateVal.getFullYear().toString().substring(0,2)+fieldValue[2],(fieldValue[1] - 1 ),fieldValue[0]));
	// alert(" eventDate==>"+eventDate);
	var finishButton = document.getElementById("ActFinish");  
	var nextButton = document.getElementById("ActNext"); 
	if(eventDate - currDateVal > 0)
	{

		if(flag==1)
		{	
			alert("ERROR::CANNOT CREATE FUTURE EVENT ");
			finishButton.style.disabled = false;
			return true;
		}
		else if(flag==2)
		{
			alert("ERROR::CANNOT CREATE FUTURE EVENT ");
			nextButton.style.disabled="disabled";
			return true;
		}	
	}
	else
	{
		return false;
	}

}


function setCheckedPlace( obj, dbID )
{
	
	//alert("for MTO validation.....");
	var MAXITEMID = 1000;
	var mfgType = "";
	var selectAllFlag= false;
	//var selectVal= false;
	
	//alert(" inside check method obj= ["+obj+"] dbID=["+dbID+"]");	
	//alert("obj.value:"+obj.value);
	if( obj.value == 'false' )
	{
		obj.value ='true';
		//orderVisit = orderVisit + 1;
		//obj1 = document.getElementById("Detail2."+dbID+".order_of_visit");
		//obj1.value = orderVisit;
	}
	else 
	{
		obj.value = 'false';
		/*if ( dbID == orderVisit )
		{
			orderVisit = orderVisit - 1;
		}
		obj1 = document.getElementById("Detail2."+dbID+".order_of_visit");*/
		obj1.value = "";
	}



	//var saleOrder="";

	for ( i = 1; i <= MAXITEMID; i++ )
	{
		if( document.getElementById("Detail2."+i+".sale_order").value != null )
		{
		//	alert("saleOrder found...");
		var selectVal = document.getElementById("Detail2."+i+".selectbox").value;
		mfgType = document.getElementById("Detail2."+i+".mfg_type").value.trim().trim();
		var	saleOrder = document.getElementById("Detail2."+i+".sale_order").value.trim().trim();
		//alert("1 saleOrder["+saleOrder+"]mfgType["+mfgType+"]selectVal["+selectVal+"]selectAllFlag["+selectAllFlag+"]");
		if ( mfgType != null ) 
		{	
			//	alert("2 saleOrder["+saleOrder+"]mfgType found ["+mfgType+"]selectVal["+selectVal+"]");
			if( ( mfgType == "O" || mfgType == "D" )  &&  ( selectVal == true || selectVal == "true" ) )
			{
			//	alert("3 saleOrder["+saleOrder+"]selectVal true found ["+selectVal+"]selectAllFlag["+selectAllFlag+"]");
				if ( selectAllFlag == true ||  selectAllFlag == "true" )
				{
					alert("Only single sales order selected for Made To Order/Design .");
					
					document.getElementById("Detail2."+dbID+".selectbox").checked = false;
					document.getElementById("Detail2."+dbID+".selectbox").value = false;
				}
				else
				{
					selectAllFlag = "true" ;
				}
			//	alert("first selectAllFlag.["+selectAllFlag+"].");
			}
			//else
			//{
			//	alert(" correct selection...");
			//}
		}
		}
	}
}

function setCheckedCustomers(obj,dbId)
{
	if( obj.value == 'false' )
	{
		obj.value ='true';
	}
	else 
	{
		obj.value = 'false';
		document.getElementById("itemCodes"+dbId).innerHTML = "";
		document.getElementById("teamCodes"+dbId).innerHTML = "";
		document.getElementById("Detail3."+dbId+".order_booked").value = "0";
		document.getElementById("Detail3."+dbId+".meet_summ").value = "";
		document.getElementById("Detail3."+dbId+".oth_participant").value = "";
		document.getElementById("Detail3."+dbId+".remarks").value = "";

	}

}

var repeatLocCnt = 0;
function setRepeatLocChecked( dbId )
{

	if ( document.getElementById( "Detail2."+dbId+".selectbox").checked == true )
	{
		repeatLocCnt = repeatLocCnt + 1;
		div = document.getElementById("repeatPlacesDiv");
		div.innerHTML = div.innerHTML + "<table id='travelTable2' class ='tableClass_rep' WIDTH='85%' CELLPADDING='1' CELLSPACING='1' ><tr>"+ displayRepeatPlace( dbId )+"</tr></table>" ;
	}
	else
	{
		alert("Place is not selected.");
	}
}


function setDrVisit( obj )
{
	if( obj.value == "Y" ) 
	{
	}
}
function setChemVisit( obj )
{
	if( obj.value == "Y" ) 
	{
	}
}

function validatePlace(formNo)
{}

function countChecked()
{
	var chkCount = 0;
	var count = 0;
	count = document.customer_deact_data.elements.length;

	action = document.getElementById("action").value;
	if( action != "previous" )
	{
		for(i = 0; i < count; i++)
		{
			if(document.customer_deact_data.elements[i].type == 'checkbox')
			{
				if(document.customer_deact_data.elements[i].checked == true)
				{chkCount = chkCount + 1;}
			}
		}

		if(chkCount == 0 )
		{
			alert("No Selection Made ! \nPlease select a record !");
			return false;
		}
	}
}

function setChecked(obj)
{
	if( obj.value == 'false' )
	{
		obj.value ='true';
	}
	else 
	{
		obj.value = 'false';
	}

}

function selectAlltr()
{
	//alert("selectAlltr");
	var value = "";
	var tr = document.getElementsByTagName("tr");
	//var count = tr.length - 1 ;

	var count = 1000;
	var j=1;
	//alert("count["+count+"]");
	//alert("value["+value+"]")
	for(i = 1; i < count; i++)
	{  

		if( document.getElementById("Detail4."+i+".source_supply") != null )
		{
			//alert("i["+i+"]");
			value = document.getElementById("tr."+i);
			//alert("value["+value+"]");
			var soursSupply = document.getElementById("Detail4."+i+".source_supply").value;
			var tranSer = document.getElementById("Detail4."+i+".tran_ser").value;
			var orderType = document.getElementById("Detail4.order_type_1").value;

			//alert("soursSupply["+soursSupply+"]");
			if( soursSupply.trim() == "S" || ( tranSer != null && tranSer.trim() == "Stock" ) )
			{
				value.className = "Stock";
				if(  orderType.trim() == "MPS"  )
				{
					document.getElementById("Detail4."+i+".selectbox").disabled = true ;
				}

			}
			else if( soursSupply.trim() == "P"  ||   soursSupply.trim() == "M" || tranSer.trim() == 'Dist Order' ||  tranSer.trim() == 'Work Order'  )
			{
				value.className = "Planned";
				if(  orderType.trim() == "MPS"  )
				{
					document.getElementById("Detail4."+i+".selectbox").disabled = true ;
				}
				else
				{
					document.getElementById("Detail4."+i+".selectbox").disabled = true ;
					document.getElementById("Detail4."+i+".selectbox").checked = true ;
				}
			}
			else if( soursSupply.trim() == "W" )
			{
				value.className = "WIP";
				if(  orderType.trim() == "MPS"  )
				{
					document.getElementById("Detail4."+i+".selectbox").disabled = true ;
				}
				else
				{	
					document.getElementById("Detail4."+i+".selectbox").disabled = true ;
					document.getElementById("Detail4."+i+".selectbox").checked = true ;
				}
			}

		}



	}
}


function selectAllbox()
{
	var value = "";
	var tr = document.getElementsByTagName("tr");
	var count = tr.length - 1 ;
	//alert("count["+count+"]");
	value = document.getElementById("Detail2.selectAllbox").checked;
	//alert("value["+value+"]")
	for(i = 1; i < count; i++)
	{  
		document.getElementById("Detail2."+i+".selectbox").checked = value;
	}
}

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

function validateCust(formNo)
{
	disableButtons(formNo);
	var chkCount = 0;
	var count = 0;
	count = document.Wizard_Customer.elements.length;

	action = document.getElementById("action").value;
	if( action != "previous"  )
	{
		for(i = 0; i < count; i++)
		{
			if(document.Wizard_Customer.elements[i].type == 'checkbox')
			{
				if(document.Wizard_Customer.elements[i].checked == true)
				{chkCount = chkCount + 1;}
			}
		}
	}

}
function validateDoctor(formNo)
{
	disableButtons(formNo);
	var chkCount = 0;
	var count = 0;
	count = document.Wizard_Customer.elements.length;

	action = document.getElementById("action").value;
	if( action != "previous"  )
	{
		for(i = 0; i < count; i++)
		{
			if(document.Wizard_Customer.elements[i].type == 'checkbox')
			{
				if(document.Wizard_Customer.elements[i].checked == true)
				{chkCount = chkCount + 1;}
			}
		}
		var drVisit;
		var isNonFW;
		if ( document.getElementById("CustomerSelected.1.is_non_fw") != null )
		{
			isNonFW =document.getElementById("CustomerSelected.1.is_non_fw").value;
		}
		if ( document.getElementById("CustomerSelected.1.dr_visit") != null )
		{
			drVisit =document.getElementById("CustomerSelected.1.dr_visit").value;
		}

		if(chkCount == 0 && drVisit =='Y')
		{
			enableButtons(formNo);
			alert("No Selection Made ! \nPlease select a Doctor visited !");         
			return false;
		}
		else if(chkCount == 0 && isNonFW =='Y')
		{
			enableButtons(formNo);
			alert("No Selection Made ! \nPlease select the record!");
			return false;
		}
	}
}
function validateChemist(formNo)
{
	disableButtons(formNo);
	var chkCount = 0;
	var count = 0;
	count = document.Wizard_Customer.elements.length;

	action = document.getElementById("action").value;
	if( action != "previous"  )
	{
		for(i = 0; i < count; i++)
		{
			if(document.Wizard_Customer.elements[i].type == 'checkbox')
			{
				if(document.Wizard_Customer.elements[i].checked == true)
				{chkCount = chkCount + 1;}
			}
		}
		var chemVisit;
		var isNonFW;
		if ( document.getElementById("CustomerSelected.1.is_non_fw") != null )
		{
			isNonFW =document.getElementById("CustomerSelected.1.is_non_fw").value;
		}
		if ( document.getElementById("CustomerSelected.1.chem_visit") != null )
		{
			chemVisit =document.getElementById("CustomerSelected.1.chem_visit").value;
		}
		if(chkCount == 0 && chemVisit =='Y')
		{
			enableButtons(formNo);
			alert("No Selection Made ! \nPlease select a Chemist visited !");
			return false;
		}
		else if(chkCount == 0 && isNonFW =='Y')
		{
			enableButtons(formNo);
			alert("No Selection Made ! \nPlease select the record!");
			return false;
		}
	}
}


function Open(dbID) {
	var spCodeWW= document.getElementById('Detail1.'+dbID+'.sales_pers').value;
	if (spCodeWW == null || spCodeWW == "" )
	{
		document.getElementById('fieldactivity_descr' + dbID).style.display = "none";
		alert("No Sales Person Selected");
	}
	else
	{	
		document.getElementById('list_worked_with' + dbID).style.display = "block";
		document.getElementById('view_worked_with' + dbID).innerHTML="<a href=\"javascript:Close('" + dbID + "');\">Close...</a>";
	}
}

function Close(dbID) {
	document.getElementById('list_worked_with' + dbID).style.display = "none";
	document.getElementById('view_worked_with' + dbID).innerHTML="<a href=\"javascript:Open('" + dbID + "');\">View Worked With List</a>";
} 

function displayWorkedWith( sprsCode, spName, spDisp )
{
	if (document.getElementById("Detail1..activity_code") != null)
	{
		document.getElementById("list_worked_with").innerHTML = spDisp;

		var manager = spDisp.substring( spDisp.indexOf("(") + 1, spDisp.lastIndexOf(")") );
		document.getElementById("Detail1..visited_with_display").value = manager;

		document.getElementById("list_worked_with").style.display = "block";
	}
}


function displayTeam(selectedTeam, maxTeamId )
{
	//MAXTEAMID = maxTeamId;
	var divTeam = document.getElementById("teamCodes" + domIDTeam);
	divTeam.innerHTML = selectedTeam;
}
function deSelectedTeam(selectedTeam, strgCode )
{
	//MAXTEAMID = maxTeamId;
	var divTeam = document.getElementById("teamCodes" + domIDTeam);
	divTeam.innerHTML = selectedTeam;

	var deselectDomID;

	var count = 0;
	if(MAXTEAMID > 0)
	{
		for ( i = 1; i <= MAXTEAMID; i++ )
		{
			if ( document.getElementById("Detail4." + i +".strg_code") != null && document.getElementById("Detail4." + i +".strg_code").value == strgCode )
			{
				if ( document.getElementById("Detail4." + i +".deselect_team") != null )
				{
					document.getElementById("Detail4." + i +".deselect_team").value = "Y";
				}
			}
		}
	}
}
//-------------------------------------------Changed By Vidhya on 08/12/09 [WS89NOV642 | function change for Work team issue] End

function callActivityTypeJSP( dbID, salesPers )
{
	var selectedActCode = document.getElementById("Detail1."+dbID+".activity_code").value;
	//Changed By Vidhya on 28/10/09[WS89NOV617 | MOZILLA COMPATIBILITY] Start
	//var url = '/ibase/webitm/jsp/ITMWizardActitvityCode.jsp?SALES_PERS='+salesPers+'&amp;SELECTED_ACT_CODE='+selectedActCode;
	var url = '/ibase/webitm/jsp/ITMWizardActitvityCode.jsp?SALES_PERS='+salesPers+'&SELECTED_ACT_CODE='+selectedActCode;
	var win = window.open( url, 'ActivityCode', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );

}
function displayActCode( actCode, actDescr )
{
	if (document.getElementById("Detail1..activity_code") != null)
	{
		document.getElementById("Detail1..activity_code").value = actCode;
		document.getElementById("Detail1..activity_descr").value = actDescr;
	}
	else
	{
		document.getElementById("Detail1.1.activity_code").value = actCode;
		document.getElementById("Detail1.1.activity_descr").value = actDescr;	
	}

	//Changed by Dipak on 31/12/12 to disable and enable fnish button based on activity type : START
	var finishButton = document.getElementById("ActFinish");  
	var nextButton = document.getElementById("ActNext");  
	if(actCode != null && (actCode == "CL" || actCode == "SL"  || actCode == "TL" || actCode == "PL" || actCode == "BD" || actCode == "HL" || actCode == "SD" || actCode == "OH" || actCode == "CO" || actCode == "ED"))
	{
		if (finishButton != null && nextButton != null )
		{
			// alert("inside if");  	
			finishButton.disabled = false;
			nextButton.disabled = true;
		}

	}
	else
	{
		if (finishButton != null && nextButton != null )
		{

			finishButton.disabled = true;
			nextButton.disabled = false;
		}

	}
	//Changed by Dipak on 31/12/12 to disable and enable fnish button based on activity type : START
}


function callSalesPersListJSP( dbID, loginId )
{
	var url = '/ibase/webitm/jsp/ITMWizardSalesPersList.jsp?LOGIN_ID='+loginId;
	var win = window.open( url, 'SalesPerson', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );

}
function displaySalesPerson( salesPers, spName )
{
	if (document.getElementById("Detail1..sales_pers") != null)
	{
		document.getElementById("Detail1..sales_pers").value = salesPers;
		document.getElementById("Detail1..sp_name").value = spName;
	}
	else
	{
		document.getElementById("Detail1.1.sales_pers").value = salesPers;
		document.getElementById("Detail1.1.sp_name").value = spName;	
	}
}


var offsetxpoint = -60 //Customize x offset of tooltip
var offsetypoint = 20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
	var tipobj = document.getElementById("itemsToolTip");
var dataEle

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor ){

	if (ns6||ie){
		tipobj = document.getElementById("itemsToolTip");
		if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
		if (typeof thecolor!="undefined" && thecolor!="" && tipobj != null ) 

			tipobj.style.backgroundColor=thecolor

			dataEle = document.getElementById(thetext);
		if( dataEle != null)
		{
			tipobj.innerHTML = dataEle.innerHTML;
		}
		if( (  dataEle != null ) && ( dataEle.innerHTML.indexOf("</font>") > 60 || dataEle.innerHTML.indexOf("</FONT>") > 55 ))
			enabletip=true
			return false
	}
}

function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//		Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
				var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

						var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//								if the horizontal distance isn't enough to accomodate the width of the context menu
								if (rightedge<tipobj.offsetWidth)
//									move the horizontal position of the menu to the left by it's width
									tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
											else if (curX<leftedge)
												tipobj.style.left="5px"
													else
//														position the horizontal position of the menu where the mouse is positioned
														tipobj.style.left=curX+offsetxpoint+"px"

//														same concept with the vertical position
														if (bottomedge<tipobj.offsetHeight)
															tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
																	else
																		tipobj.style.top=curY+offsetypoint+"px"
																		tipobj.style.visibility="visible"
	}
}

function hideddrivetip(){
	if (ns6||ie){
		if( dataEle != null )
		{
			dataEle.style.display = "none";
		}
		enabletip=false
		if( tipobj != null )
		{
			tipobj.style.visibility="hidden"
				tipobj.style.left="-1000px"
					tipobj.style.backgroundColor=''
						tipobj.style.width=''
		}
	}
}

document.onmousemove=positiontip

//------------------------------------------------------------------------------------------------------------------

function isNumberKey(e)
{
	//alert("isNumberKey called...");
	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)) {
		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;
}
//Changed By Vidhya on 09/12/09[WS89NOV643 | to alert when transaction is saved] END

//added by rakesh kumar on 22/11/12 to set the order of visit
function setOrderOfVisit( obj, dbID, formNo )
{
	if( obj.value == 'false' )
	{
		orderVisit = orderVisit + 1;
		obj1 = document.getElementById("Detail"+formNo+"."+dbID+".order_of_visit");
		obj1.value = orderVisit;
	}
	else 
	{
		if ( dbID == orderVisit )
		{
			orderVisit = orderVisit - 1;
		}
		obj1 = document.getElementById("Detail"+formNo+"."+dbID+".order_of_visit");
		obj1.value = "";
	}
}

//ended by rakesh kumar

//Added By Shahu Mali on 16-MAY-2013 [WS3BFRA007].START

function callSalesPersJSP( dbID )
{
	//alert("dbID==>"+dbID);  
	var url = '/ibase/webitm/jsp/ITMWizardAdminSalesPersList.jsp?';
	var win = window.open( url, 'SalesPerson', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );

}

function callSupplyItemJSP1( dbID , saleOrder , lineNo , qtyReqd )
{
	//alert("test callSupplyItemJSP ");
}

var DomId = 0;
var MAXITEMID = 1000;
function callSupplyItemJSP( dbID , saleOrder , lineNo , qtyReqd , dueDate1 )
{
	//alert("calling callSupplyItemJSP");
	DomId = dbID;
	var selectedItem = "";
	var eventDate = "";
	var selectedSampleItem = "";
	var itemCodeDet2="";
	var siteCodeDet2="";
	//document.getElementById("Detail2."+dbID+".selectbox").checked = true;
	//document.getElementById("Detail2."+dbID+".selectbox").value = true;

	var keyArray = new Array();
	var valueArray = new Array();

	var stockListArray = new Array();

	var saleOrder2="";
	var lineNo2="";


	var saleOrderDet2 = "";
	var lineNoDet2 = "";
	var itemCodeDescr1 = "";
	var qtyReqd2 =0; 

	var suppSour="";
	var orderType="";

	var detail2dbID = dbID;

	itemCodeDet2 = document.getElementById("Detail2."+dbID+".item_code").value.trim().trim();
	siteCodeDet2 = document.getElementById("Detail2."+dbID+".site_code").value.trim().trim();

	saleOrderDet2 = document.getElementById("Detail2."+dbID+".sale_order").value.trim();
	lineNoDet2 = document.getElementById("Detail2."+dbID+".line_no").value.trim();
	itemCodeDescr1 = document.getElementById("Detail2."+dbID+".item_code_descr").value;
	//qtyReqd2 = document.getElementById("Detail2."+dbID+".qty_reqd").value;
	if( document.getElementById("Detail2."+dbID+".demand") != null )
	{
		qtyReqd2 = document.getElementById("Detail2."+dbID+".demand").value;
		//alert("qtyReqd20["+qtyReqd2+"]");
	}
	/*else if( document.getElementById("Detail2."+dbID+".sodemand") != null )
	{
		qtyReqd2 = document.getElementById("Detail2."+dbID+".sodemand").value;
		//alert("qtyReqd21["+qtyReqd2+"]");
	}
	else
	{
		qtyReqd2 = document.getElementById("Detail2."+dbID+".qty_reqd").value;
		//alert("qtyReqd22["+qtyReqd2+"]");
	}*/
	suppSour = document.getElementById("Detail2."+dbID+".supp_sour").value;

	orderType = document.getElementById("Detail2."+dbID+".order_type").value;
	dueDate = document.getElementById("Detail2."+dbID+".due_date").value;
	//alert("MAXITEMID["+MAXITEMID+"]dbID["+dbID+"]dueDate["+dueDate+"]qtyReqd2["+qtyReqd2+"]");

	if(MAXITEMID > 0)
	{
		//var domID = 1;

		//alert("inside max");


//		for( var dbIDout=1; dbIDout <= MAXITEMID; dbIDout++ )
		{
//			saleOrder2="";
			saleOrder2 = saleOrderDet2;
			lineNo2 = lineNoDet2;
//			lineNo2="";
//			if( document.getElementById("Detail2."+dbIDout+".sale_order") != null )
//			{
//			saleOrder2 = document.getElementById("Detail2."+dbIDout+".sale_order").value.trim();
//			}
//			if( document.getElementById("Detail2."+dbIDout+".line_no") != null )
//			{
//			lineNo2 = document.getElementById("Detail2."+dbIDout+".line_no").value.trim();
//			}

			/*	if( document.getElementById("Detail2."+dbIDout+".site_code") != null ) 
			{
				siteCode1 = document.getElementById("Detail2."+dbIDout+".site_code").value.trim();
			}
			if( document.getElementById("Detail2."+dbIDout+".item_code") != null )
			{
				itemCode1 = document.getElementById("Detail2."+dbIDout+".item_code").value.trim();
			}
			if( document.getElementById("Detail2."+dbIDout+".item_code_descr") != null )
			{
				itemCodeDescr = document.getElementById("Detail2."+dbIDout+".item_code_descr").value.trim();
			}
			 */	//alert("@@@@@dbIDout["+dbIDout+"]saleOrder2["+saleOrder2+"]lineNo2["+lineNo2+"]");			
			for ( i = 1; i <= MAXITEMID; i++ )
			{
				var siteCode = "";
				var itemCode = "";
				var lotNo = "";
				var lotSl = "";
				var locCode = "";
				var tranSer = "";
				var tranId = "";
				var refLineNo = "";
				var supply=0;
				var allocQty=0;
				var availableSupply=0;
				var index="";
				var tempQty = 0;
				var parentItem="";
				var itemCodeParent="";
				//	var suppSour ="";
				//	var qtyReqd2 = 0;
				//alert("@@@@@977111saleOrder2["+saleOrder2+"."+lineNo2+"."+i+".");
				//alert("test977:[Detail4."+saleOrder2+"."+lineNo2+"."+i+".site_code]");
				//alert("test977:"+ document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+".site_code"));
				siteCode="";
				itemCode="";
				allocQty=0;
				parentItem="";
				//alert(" for so test i["+i+"]"+ document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+".site_code"));
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".site_code") != null )
				{
					siteCode =document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".site_code").value.trim();
					//	alert("test555555"+saleOrder2+"]lineNo2["+lineNo2+"]site code["+siteCode+"]");
				}
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".item_code") != null )
				{

					itemCode =document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".item_code").value.trim();
					//  alert("@@@@@@itemCode["+itemCode+"]");
				}
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".lot_no") != null )
				{
					lotNo =document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".lot_no").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".lot_sl") != null )
				{
					lotSl =document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".lot_sl").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".loc_code") != null )
				{
					locCode =document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".loc_code").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".tran_ser") != null )
				{
					tranSer =document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".tran_ser").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".tran_id") != null )
				{
					tranId =document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".tran_id").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".ref_line_no") != null )
				{
					refLineNo =document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".ref_line_no").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".alloc_qty") != null )
				{
					allocQty = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".alloc_qty").value;
				}  //parent_item
				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".parent_item") != null )
				{
					parentItem = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".parent_item").value;
				}

				if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".item_code_parent") != null )
				{
					itemCodeParent = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".item_code_parent").value;
				}
				//alert("@@@test Detail4."+saleOrder2+"."+lineNo2+"."+i+".item_code_parent");

//				alert("outside itemCode["+itemCode+"]["+itemCodeDet2+"]itemCodeParent["+itemCodeParent+"]site code["+siteCode+"]["+siteCodeDet2+"]");
//				alert("outside itemCode["+itemCode+"]["+itemCodeDet2+"]site code["+siteCode+"]["+siteCodeDet2+"]");


				if (( itemCode != null && siteCode != null  &&  tranSer != null  &&  lotNo != null && lotSl != null  && locCode != null ) && ( itemCode != "" && siteCode != "" && lotNo != "" && lotSl != "" && locCode != "" ) && ( ( itemCode == itemCodeDet2 || parentItem == itemCodeDet2 || itemCodeDet2 == itemCodeParent ) &&  siteCode == siteCodeDet2 ))
				{

					//alert("outside itemCode["+itemCode+"]["+itemCodeDet2+"]itemCodeParent["+itemCodeParent+"]site code["+siteCode+"]["+siteCodeDet2+"]");
					//alert("outside itemCode["+itemCode+"]["+itemCodeDet2+"]site code["+siteCode+"]["+siteCodeDet2+"]");

					//alert("["+i+"]itemCode["+itemCode+"]["+itemCodeDet2+"]site code["+siteCode+"]["+siteCodeDet2+"]parentItem["+parentItem+"]")
					//alert("["+i+"]itemCode["+itemCode+"]["+siteCode+"]["+tranSer+"]["+lotNo+"]["+lotSl+"]");
					tempQty = 0;
					var key = siteCode+"@"+itemCode+"@"+lotNo+"@"+lotSl+"@"+locCode+"@"+tranSer+"@"+tranId+"@"+refLineNo;
					//var key = siteCode+"@"+itemCode+"@"+lotNo+"@"+lotSl+"@"+locCode+"@"+tranSer;
					var tempQty = 0;
					//alert("key["+i+"]["+key+"]");

					if(allocQty==null || allocQty =="")
					{
						allocQty=0;
					}
					//for (ctr=0;ctr<keyArray.length;ctr++)
					//{
					//alert("@@@@@@@@@@@@@@@@@[key["+key+"]");
					//alert("@@@@@@@@@@@@@@@@@["+i+"]keyArray["+keyArray+"]");
					//alert("@@@@@@@@@@@@@@@@@@@["+i+"]valueArray["+valueArray+"]");

					//alert("@@@@@@@@@@@@@@@@@@@[index["+index+"]");
					index = keyArray.indexOf(key);
					//}
					//alert("index["+index+"]key["+key+"]");
					if(( index != 0 ) && ( index == null || index == "" || index < 0 ||  index == -1  ))
					{
						//alert("add-key["+key+"]["+index+"]:allocQty["+allocQty+"]");
						keyArray[keyArray.length] =  key;
						valueArray[valueArray.length] =  allocQty;
					}
					else
					{

						tempQty = valueArray[index];
						if( tempQty== null || tempQty =="" || tempQty== NaN || tempQty== "NaN" )
						{
							tempQty = 0;
						}
						if( allocQty > 0)
						{	
							//alert("modify-key["+key+"]:tempQty["+tempQty+"]:allocQty["+allocQty+"]");
							valueArray[index] =  (+tempQty) + (+allocQty);
							//alert("increment valueArray[index]["+index+"]["+valueArray[index]+"]");
						}	
					}

				}

				//siteCode1 = siteCode;
				//itemCode1 = itemCode;
				//itemCodeDescr1 = "";

			}
		}

		//alert("array cycle complete............")
		//alert("@@@@@@@@@@@@@@@@@final keyArray["+keyArray+"]");
		//alert("@@@@@@@@@@@@@@@@@@@final valueArray["+valueArray+"]");

		selectedSampleItem = selectedSampleItem + "<CommonDetail >" +	
		"<sale_order>" + saleOrderDet2 + "</sale_order><line_no>" + lineNoDet2 + "</line_no>" +
		"<site_code>"+siteCodeDet2 + "</site_code><item_code>"+ itemCodeDet2 + "</item_code>" +
		"<item_code_descr>" + itemCodeDescr1 + "</item_code_descr>" +
		"<qty_reqd>" + qtyReqd2 + "</qty_reqd>" +
		"<order_type>" + orderType + "</order_type>" +
		"<detail2dbID>"+detail2dbID+"</detail2dbID>" + 
		"<dueDateDet2>"+dueDate+"</dueDateDet2>" +
		"</CommonDetail>";


		///////////
		for ( i = 1; i <= MAXITEMID; i++ )
		{
			//alert("inside for i["+i+"]");
			var siteCode = "";
			var itemCode = "";
			var itemCodeDescr = "";
			var lotNo = "";
			var lotSl = "";
			var locCode = "";
			var tranSer = "";
			var tranId = "";
			var refLineNo = "";
			var supply=0;
			var allocQty=0;
			var availableSupply=0;
			var sourceSupply="";
			var plannedQty="";
			var unit="";
			var originalOrAltitem="";
			var prevItemWorkOrder="";
			var prevItem="";
			var originalOrAltitem="";
			var dueDateStock = "";
			var altItemPerc="";


			siteCode="";
			itemCode="";

			//alert(document.getElementById("Detail4.sample_item"+i+".site_code").value);
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".site_code") != null )
			{
				siteCode =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".site_code").value.trim();
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".item_code") != null )
			{
				itemCode =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".item_code").value.trim();
				//alert("itemCode["+itemCode+"]");
			}

			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".item_code_descr") != null )
			{
				itemCodeDescr =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".item_code_descr").value;
				//alert("itemCodeDescr["+itemCodeDescr+"]");
			}

			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".lot_no") != null )
			{
				lotNo =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".lot_no").value.trim();
				//alert("lotNo["+lotNo+"]dueDate["+dueDate+"]")
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".lot_sl") != null )
			{
				lotSl =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".lot_sl").value.trim();
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".loc_code") != null )
			{
				locCode =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".loc_code").value.trim();
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".tran_ser") != null )
			{
				tranSer =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".tran_ser").value.trim();
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".tran_id") != null )
			{
				tranId =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".tran_id").value.trim();
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".ref_line_no") != null )
			{
				refLineNo =document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".ref_line_no").value.trim();
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".supply") != null )
			{
				supply = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".supply").value;
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".alloc_qty") != null )
			{   //Detail4.PORF0006..2.11/03/13.alloc_qty
				allocQty = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".alloc_qty").value;
				//alert("allocQty["+allocQty+"]");
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".source_supply") != null )
			{
				sourceSupply = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".source_supply").value;
				//alert("sourceSupply["+sourceSupply+"]");
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".unit") != null )
			{
				unit = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".unit").value;
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".planned_quantity") != null )
			{
				plannedQty = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".planned_quantity").value;
			}
			if ( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".parent_item") != null )
			{
				parentItem = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+i+"."+dueDate+".parent_item").value;
				//alert("parentItem"+parentItem);
			}

			if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".item_code_parent") != null &&  document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".item_code_parent").value.length > 0  )
			{
				itemCodeParent = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".item_code_parent").value;
				//alert("itemCodeParent["+itemCodeParent+"]");
			}


			if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".originalOrAltitem") != null )
			{
				originalOrAltitem = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".originalOrAltitem").value;
			}

			if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".prev_item_worder") != null )
			{
				prevItemWorkOrder = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".prev_item_worder").value;
				//alert("prevItemWorkOrder["+prevItemWorkOrder+"]");
			}
			if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".previous_item") != null )
			{
				prevItem = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".previous_item").value;
				//alert("prevItem["+prevItem+"]");
			}

			if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".originalOrAltitem") != null )
			{
				originalOrAltitem = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".originalOrAltitem").value;
				//alert("originalOrAltitem["+originalOrAltitem+"]");
			}
			if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".due_date1") != null )
			{
				dueDateStock = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".due_date1").value;
				//alert("originalOrAltitem["+originalOrAltitem+"]");
			}
			if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".alt_item_perc") != null )
			{
				altItemPerc = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+"."+dueDate+".alt_item_perc").value;
				//alert("itemCode["+itemCode+"]altItemPerc["+altItemPerc+"]");
			}

			
			//	if ( document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+".supp_sour") != null &&  document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+".item_code_parent").value.length > 0  )
			//	{
			//		suppSour = document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+".supp_sour").value;
			//alert("itemCodeParent["+itemCodeParent+"]");
			//	}

			//alert("itemCodeDet2["+itemCodeDet2+"]==itemCode["+itemCode+"]parentItem["+parentItem+"]itemCodeParent["+itemCodeParent+"]    siteCode["+siteCode+"]siteCodeDet2["+siteCodeDet2+"]")

			//if ( (! ( itemCode == "" && siteCode == "" )) && ( itemCode == itemCodeDet2 &&  siteCode == siteCodeDet2 ))
			//alert("dueDate["+dueDate.trim()+"]==dueDateStock["+dueDateStock.trim()+"]")

			//if(  itemCode != "" && siteCode != "" &&  itemCode.trim().length > 0 && siteCode.trim().length > 0 
			//		&&( ( itemCode.trim() == itemCodeDet2.trim()  ) 
			//		&&  siteCode.trim() == siteCodeDet2.trim() )  )	

			if(  itemCode != "" && siteCode != "" &&  itemCode.trim().length > 0 && siteCode.trim().length > 0 
					&&( ( itemCode.trim() == itemCodeDet2.trim() 
							|| parentItem.trim() == itemCodeDet2.trim() 
							|| itemCodeDet2 == itemCodeParent ) 
							&&  siteCode.trim() == siteCodeDet2.trim() )  )

			{
				var key2 = "";
				var index2="";
				var tempQty2=0;
				//alert("@@test inside");
				//alert("supply["+supply+"]");
				//alert("availableSupply["+availableSupply+"]");
				//alert("allocQty["+allocQty+"]");
				if( allocQty.trim().length==0 )
				{
					allocQty=0;
				}
				if( plannedQty.trim().length==0 )
				{
					plannedQty=0;
				}
				if( supply.trim().length==0 )
				{
					supply=0;
				}
				key2 = siteCode+"@"+itemCode+"@"+lotNo+"@"+lotSl+"@"+locCode+"@"+tranSer+"@"+tranId+"@"+refLineNo;
				//var key2 = siteCode+"@"+itemCode+"@"+lotNo+"@"+lotSl+"@"+locCode+"@"+tranSer;
				//alert("@@@@@@@@@@@@@@@@@--- key2["+key2+"]");
				index2 = keyArray.indexOf(key2) ;
				//alert("@@@@@@@@@@@@@@@@@@@----- valueArray["+valueArray+"]index2["+index2+"]");
				tempQty2 = valueArray[index2];
				//alert("@@@@@@@@@@@@@@@@@--- tempQty2["+tempQty2+"]index2["+index2+"]");

				//alert("key2["+key2+"]index2["+index2+"]tempQty2["+tempQty2+"]");
				//alert("supply["+supply+"]tempQty2["+tempQty2+"]");
				//if(tempQty2 != null || tempQty2 != undefined ||  tempQty2 != "undefined" || tempQty2 == NaN || tempQty2 == "NaN")
				if( ( index2 != 0 ) && ( index2 == null || index2 == "" || index2 < 0 ||  index2 == -1  ) )
				{
					tempQty2 = 0;
					//alert("tempQty2["+tempQty2+"]");
				}
				availableSupply = supply - tempQty2;

				//alert("key2["+key2+"]:::tempQty2["+tempQty2+"]:availableSupply["+availableSupply+"]");  //Detail4.sample_item."+dbID+"."+i+".

				//alert("itemCodeDet2["+itemCodeDet2+"]itemCode["+itemCode+"]parentItem["+parentItem+"]itemCodeParent["+itemCodeParent+"]")

				//alert("itemCode["+itemCode+"]itemCodeDescr["+itemCodeDescr+"]");
				//stockListArray
				if( stockListArray.indexOf(key2) != null && stockListArray.indexOf(key2) > -1)
				{
					// key already exist
				}
				else
				{
					stockListArray[stockListArray.length] =  key2;
					//alert("for detail4 xml :: itemCode["+itemCode+"]altItemPerc["+altItemPerc+"]");
					selectedSampleItem = selectedSampleItem + "<Detail4  domID='" + i + "'>" +	
					"<sale_order>" + saleOrder + "</sale_order><line_no>" + lineNo + "</line_no><qty_reqd>" + qtyReqd + "</qty_reqd>" +
					"<site_code>" + siteCode + "</site_code><item_code>" + itemCode + "</item_code>" +
					"<item_code_descr>" + itemCodeDescr + "</item_code_descr>" +
					"<lot_no>" + lotNo + "</lot_no>" +
					"<lot_sl>" + lotSl + "</lot_sl><loc_code>" + locCode + "</loc_code><tran_ser>" + tranSer + "</tran_ser>" +
					"<tran_id>" + tranId + "</tran_id><ref_line_no>" + refLineNo + "</ref_line_no>" +
					"<supply>" + supply + "</supply><available_supply>" + availableSupply + "</available_supply>" +
					"<alloc_qty>" + allocQty + "</alloc_qty>" +
					"<source_supply>" + sourceSupply + "</source_supply><unit>" + unit + "</unit>" +
					"<planned_quantity>" + plannedQty + "</planned_quantity>" +
					"<supp_sour>" + suppSour + "</supp_sour>" +
					"<item_code_parent>" + itemCodeParent + "</item_code_parent>" +
					"<originalOrAltitem>" + originalOrAltitem + "</originalOrAltitem>" +
					"<prev_item_worder>" + prevItemWorkOrder + "</prev_item_worder>" +
					"<previous_item>" + prevItem + "</previous_item>" +
					"<originalOrAltitem>" + originalOrAltitem + "</originalOrAltitem>" +
					"<due_date>" + dueDateStock + "</due_date>" +
					"<alt_item_perc>" + altItemPerc + "</alt_item_perc>" +
					"</Detail4>";
					//domID++;
					//alert("selectedSampleItem["+selectedSampleItem+"]");
				}
			}

		}


		//alert("selectedSampleItem["+selectedSampleItem+"]");
		/*
		for ( i = 1; i <= MAXITEMID; i++ )
		{
			var siteCode = "";
			var itemCode = "";
			var lotNo = "";
			var lotSl = "";
			var locCode = "";
			var tranSer = "";
			var TranId = "";
			var lineNo = "";


			if ( document.getElementById("Detail4."+i+".site_code") != null )
			{
				siteCode =document.getElementById("Detail4."+i+".site_code").value;
			}
			if ( document.getElementById("Detail4."+i+".item_code") != null )
			{
				itemCode =document.getElementById("Detail4."+i+".item_code").value;
			}
			if ( document.getElementById("Detail4."+i+".lot_no") != null )
			{
				lotNo =document.getElementById("Detail4."+i+".lot_no").value;
			}
			if ( document.getElementById("Detail4."+i+".lot_sl") != null )
			{
				lotSl =document.getElementById("Detail4."+i+".lot_sl").value;
			}
			if ( document.getElementById("Detail4."+i+".loc_code") != null )
			{
				locCode =document.getElementById("Detail4."+i+".loc_code").value;
			}
			if ( document.getElementById("Detail4."+i+".tran_ser") != null )
			{
				tranSer =document.getElementById("Detail4."+i+".tran_ser").value;
			}
			if ( document.getElementById("Detail4."+i+".tran_id") != null )
			{
				TranId =document.getElementById("Detail4."+i+".tran_id").value;
			}
			if ( document.getElementById("Detail4."+i+".line_no") != null )
			{
				lineNo =document.getElementById("Detail4."+i+".line_no").value;
			}


			if ( ! ( itemCode == "" && salesPrdGrp == "" ) )
			{
				selectedItem = selectedItem + "<strg_item domID='" + i + "'>" +
							"<site_code>" + siteCode + "</site_code><item_code>" + itemCode + "</item_code><lot_no>" + lotNo + "</lot_no>" +
							"<lot_sl>" + lotSl + "</lot_sl><loc_code>" + locCode + "</loc_code><tran_ser>" + tranSer + "</tran_ser><tran_id>" + tranId + "</tran_id><line_no>" + lineNo + "</line_no>" +
							"</strg_item>";

			}

		}
		 */	
	}

	var win = window.open( '', 'Items', 'toolbar=no,status=YES,resizable=yes,scrollbars=yes,left=0,top=0,width=1300,height=876,fullscreen=yes' );



	var samplItem = [];
	var method = "post";
	var path="/ibase/webitm/jsp/MRPWizardSampleItems.jsp";
	samplItem["SALE_ORDER"] = saleOrder;
	samplItem["LINE_NO"] = lineNo;
	samplItem["QTY_REQD"] = qtyReqd;
	// samplItem["SELECTED_ITEM"] = "<Root>" + selectedItem + "</Root>";
	samplItem["SELECTED_SAMPLE_ITEMS"] = "<Root>" + selectedSampleItem + "</Root>";
	post_to_url(path, samplItem, method);

}

function displaysOthersInfo( refDetails , currentSorder)
{
	//var refDetails = document.getElementById("Detail2."+dbID+".refDetails").value;
	//alert(" refDetails["+refDetails+"]");
	//var url = '/ibase/webitm/jsp/ITMWizardActitvityCode.jsp?SALES_PERS='+salesPers+'&SELECTED_ACT_CODE='+selectedActCode;
	var url = '/ibase/webitm/jsp/othersDetailInfo.jsp?refDetails='+refDetails+'&current_sorder='+currentSorder;   
	var win = window.open( url, 'Others Details', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );

}

function Allocate( dbID , locGroup , dueDate ,  currentSorder, currentItemCode)
{
	//alert("Allocate called....dbID["+dbID+"]locGroup["+locGroup+"]dueDate["+dueDate+"]currentSorder["+currentSorder+"]");

	var MAXITEMID = 1000;
	DomId = dbID;
	var selectedItem = "";
	var eventDate = "";
	var selectedSampleItem = "";
	var itemCodeDet2="";
	var siteCodeDet2="";

	var keyArray = new Array();
	var valueArray = new Array();

	var saleOrder2="";
	var lineNo2="";


	var saleOrderDet2 = "";
	var lineNoDet2 = "";
	var itemCodeDescr1 = "";
	var qtyReqd2 =0; 

	var suppSour="";
	var orderType="";

	var detail2dbID = dbID;
	var qtyToBeAllocate =0;

	var detail4xml="";
	var locGroup="";
	var d4dbID = 0; 

	document.getElementById("Detail2."+dbID+".selectbox").checked = true;
	document.getElementById("Detail2."+dbID+".selectbox").value = true;

	itemCodeDet2 = document.getElementById("Detail2."+dbID+".item_code").value.trim().trim();
	siteCodeDet2 = document.getElementById("Detail2."+dbID+".site_code").value.trim().trim();
	if( document.getElementById("Detail2."+dbID+".sale_order") != null )
	{
		saleOrderDet2 = document.getElementById("Detail2."+dbID+".sale_order").value.trim();
	}
	if( document.getElementById("Detail2."+dbID+".line_no") != null )
	{
		lineNoDet2 = document.getElementById("Detail2."+dbID+".line_no").value.trim();
	}
	//itemCodeDescr1 = document.getElementById("Detail2."+dbID+".item_code_descr").value;
	if( document.getElementById("Detail2."+dbID+".demand") != null )
	{
		qtyReqd2 = document.getElementById("Detail2."+dbID+".demand").value;
	}
	if( document.getElementById("Detail2."+dbID+".loc_group") != null )
	{
		locGroup = document.getElementById("Detail2."+dbID+".loc_group").value;
	}
	if( document.getElementById("Detail2."+dbID+".due_date") != null )
	{
		dueDate = document.getElementById("Detail2."+dbID+".due_date").value;
	}
	//alert("dbID["+dbID+"]itemCodeDet2["+itemCodeDet2+"]siteCodeDet2["+siteCodeDet2+"]qtyReqd2["+qtyReqd2+"]");

	//if(MAXITEMID > 0)

	//	saleOrder2 = saleOrderDet2;
	//	lineNo2 = lineNoDet2;


	//i =dbID;
	//qtyToBeAllocate = qtyReqd2;
	for ( i = 1; i <= MAXITEMID; i++ )
	{
		var siteCode = "";
		var itemCode = "";
		var lotNo = "";
		var lotSl = "";
		var locCode = "";
		var tranSer = "";
		var tranId = "";
		var refLineNo = "";
		var supply=0;
		var allocQty=0;
		var availableSupply=0;
		var index="";
		var tempQty = 0;
		var parentItem="";
		var itemCodeParent="";
		var supply = 0;
		var saleOrder="";
		var plannedQuantity=0;
		var unit="";
		var sourceSupply="";


		//alert(" for so test i["+i+"]"+ document.getElementById("Detail4."+saleOrder2+"."+lineNo2+"."+i+".site_code"));
		//Detail4.PORF0006..1.11/03/13.site_code
		if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".item_code") != null )
		{
			itemCode =document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".item_code").value.trim();

			/*
			if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".sale_order") != null )
			{
				saleOrder = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".sale_order").value.trim();
			}
			 */
			//alert("itemCodeDet2["+itemCodeDet2+"]itemCode["+itemCode+"]saleOrder["+saleOrder+"]saleOrderDet2["+saleOrderDet2+"]");

			//if(itemCodeDet2 != null &&  itemCode != null && saleOrder != null  &&  itemCodeDet2.trim() == itemCode.trim()  &&  saleOrder.trim() ==  saleOrderDet2.trim() )	  
			//	if(itemCodeDet2 != null &&  itemCode != null && itemCodeDet2.trim() == itemCode.trim()  )
			{	  
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".site_code") != null )
				{
					siteCode = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".site_code").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".lot_no") != null )
				{
					lotNo =document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".lot_no").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".lot_sl") != null )
				{
					lotSl =document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".lot_sl").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".loc_code") != null )
				{
					locCode =document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".loc_code").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".tran_ser") != null )
				{
					tranSer =document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".tran_ser").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".tran_id") != null )
				{
					tranId =document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".tran_id").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".ref_line_no") != null )
				{
					refLineNo =document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".ref_line_no").value.trim();
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".alloc_qty") != null )
				{
					allocQty = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".alloc_qty").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".previous_item") != null )
				{
					previousItem = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".previous_item").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".prev_item_worder") != null )
				{
					prevItemWorder = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".prev_item_worder").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".unit") != null )
				{
					unit = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".unit").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".planned_quantity") != null )
				{
					plannedQuantity = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".planned_quantity").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".parent_item") != null )
				{
					parentItem = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".parent_item").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".source_supply") != null )
				{
					sourceSupply = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".source_supply").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".item_code_parent") != null )
				{
					itemCodeParent = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".item_code_parent").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".supply") != null )
				{
					supply = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".supply").value;
				}
				if ( document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".alloc_pref") != null )
				{
					allocPref = document.getElementById("Detail4."+saleOrderDet2+"."+lineNoDet2+"."+i+"."+dueDate+".alloc_pref").value;
				}

				//d4dbID++;
				//alert("");
				detail4xml = detail4xml +  "<Detail4  domID='" + i + "'>" +
				"<site_code>" + siteCode + "</site_code>" +
				"<item_code>" + itemCode + "</item_code>" +
				"<lot_no>" + lotNo + "</lot_no>" +
				"<lot_sl>" + lotSl + "</lot_sl>" +
				"<loc_code>" + locCode + "</loc_code>" +
				"<tran_ser>" + tranSer + "</tran_ser>" +
				"<tran_id>" + tranId + "</tran_id>" +
				"<supply>" + supply + "</supply>" +
				"<alloc_qty>" + allocQty + "</alloc_qty>" +
				"<unit>" + unit + "</unit>" +
				"<ref_line_no>" + refLineNo + "</ref_line_no>" +
				"<planned_quantity>" + plannedQuantity + "</planned_quantity>" +
				"<parent_item>" + parentItem + "</parent_item>" +
				"<source_supply>" + sourceSupply + "</source_supply>" +
				"<item_code_parent>" + itemCodeParent + "</item_code_parent>" +
				"<previous_item>" + previousItem + "</previous_item>" +
				"<prev_item_worder>" + prevItemWorder + "</prev_item_worder>" +
				"<alloc_pref>" + allocPref + "</alloc_pref>" +
				"</Detail4>";

			}
		}
	}

	//alert("@@@@@@ detail4xml pass for allocation:dbID["+dbID+"]:["+detail4xml+"]");

	//var win = window.open( '', 'allocateQty', 'toolbar=no,status=YES,resizable=yes,scrollbars=yes,left=0,top=0,width=1300,height=876,fullscreen=yes' );

	var samplItem = [];
	var method = "post";
	var path="/ibase/webitm/jsp/MRPWizardAllocateQty.jsp?dbId="+dbID+"&dueDate="+dueDate+"&currentSorder="+currentSorder+"&currentItemCode="+currentItemCode;   
	samplItem["SALE_ORDER"] = saleOrder;
	//samplItem["LINE_NO"] = lineNo;
	samplItem["LOC_GROUP"] = locGroup;
	samplItem["QTY_REQ"] = qtyReqd2;
	// samplItem["SELECTED_ITEM"] =  "<Root>" + selectedItem + "</Root>";
	samplItem["SELECTED_SAMPLE_ITEMS"] = "<Root>" + detail4xml + "</Root>";
	post_to_url(path, samplItem, method);

	window.close();

}



function allocateQuantity()
{
	//alert("@@@@@ allocateQuantity called...........");
	var allocateXml = document.getElementById("allocateXml").value;
	var dbId = document.getElementById("dbId").value;
	//var dueDate = document.getElementById("dueDate").value;

	//alert("@@@@@ return dbId["+dbId+"]allocateXml["+allocateXml+"]");
	//alert("@@@@@ dbId["+dbId+"]dueDate["+dueDate+"]allocateXml["+allocateXml+"]");
	//var div1 = document.getElementById("sample_item"+dbId);  

	window.opener.submitAllocateQuantity( allocateXml, dbId );    // itemCnt

	// DomId
	window.close();
	//window.close();
}

function submitAllocateQuantity( allocateXml, dbId  )
{

	//var allocateXml = document.getElementById("allocateXml").value;
	//var dbId = document.getElementById("dbId").value;
	//alert("@@@@@ submitAllocateQuantity dbId["+dbId+"]allocateXml["+allocateXml+"]");
	var div1 = document.getElementById("sample_item"+dbId);

	//alert("@@@@@ div1["+div1+"]::::div1["+document.getElementById("sample_item"+dbId).value+"]");
	//window.opener.allocateQuantity( selectedItemHtml, dbID );    //  itemCnt

	// DomId
	if( allocateXml != null )   
	{
		div1.innerHTML = allocateXml;
	}

	//window.close();
}


function recalculate()
{
	//alert("calling recalculate() method ....");
	//var path="/ibase/webitm/jsp/MRPWizardSampleItems.jsp";
	var xmldata="";
	///var win = window.open( 'http://www.google.com/' , '_self', 'toolbar=no,status=YES,resizable=yes,scrollbars=yes,left=0,top=0,width=1300,height=876,fullscreen=yes' );
	var dbID="";
	var maxId=1000;

	var saleOrder = "";
	var lineNo = "";
	var siteCode = "";
	var bomCodeParent = "";
	var itemCode = "";
	var itemCodeDescr = "";
	var qtyReqd = "";
	var unit =  "";
	var bomCodeRef="";
	var sourceSupply="";
	var itemCodeDetailMap="";
	var bomCodeOrg="";

	var Detail4SiteCode = "";
	var Detail4ItemCode = "";
	var Detail4SiteCodeDescr = "";
	var Detail4LotNo = "";
	var Detail4LotSl = "";
	var Detail4TLocCode = "";
	var Detail4TranSer = "";
	var Detail4TranId = "";
	var Detail4Supply = "";
	var Detail4AllocQty = "";
	var Detail4Unit = "";
	var Detail4RefLineNo = "";
	var Detail4PlannedQuantity = "";
	var Detail4ParentItem = "";
	var Detail4SourceSupply = "";
	var Detail4ItemCodeParent = "";
	var d4dbID=0;
	var detail4xml="";
	var cnt=1;
	var dueDate = "";

	var itemDetailsInfo=""; 
	var mfgType = "";  
	var demand =  "";
	var other =  "";
	var grossWeight = "";
	var supply = "";
	var netReq =  "";
	var orderType = "";
	var currentSorder = "";
	var dueDate = "";
	var locGroup = "";
	var sodemand=0;	
	var Detail4saleOrder  = "";
	var Detail4LineNo  = "";
	var Detail4QtyReqd  = "";
	var Detail4ItemCode_descr  = "";
	var Detail4AvailableSupply  = "";
	var Detail4OriginalOrAltitem  = "";
	var Detail4QuantityFlag  = "";
	var Detail4PrevItemWorder  = "";
	var Detail4PreviousItem  = "";
	var Detail4NewPlannedSupply  = "";
	var Detail4DueDate  = "";
	var Detail4AllocPref = "";
	
	var Detail4AltItemPerc="";


	for( dbID = 1; dbID <= maxId; dbID++)
	{
		//alert("dbID["+dbID+"]");
		detail4xml="";
		if(   document.getElementById("Detail2." +dbID+".sale_order") != null )
		{
			//alert(" record dbID ["+dbID+"]");
			saleOrder = document.getElementById("Detail2." +dbID+".sale_order").value.trim();
			lineNo = document.getElementById("Detail2." +dbID+".line_no").value.trim();
			siteCode = document.getElementById("Detail2." +dbID+".site_code").value;
			bomCodeParent = document.getElementById("Detail2." +dbID+".bom_code_parent").value;
			bomCodeRef = document.getElementById("Detail2." +dbID+".bom_code_ref").value;
			bomCodeOrg = document.getElementById("Detail2." +dbID+".bom_code_org").value;
			itemCode = document.getElementById("Detail2." +dbID+".item_code").value ;
			itemCodeDescr = document.getElementById("Detail2." +dbID+".item_code_descr").value ;
			qtyReqd = document.getElementById("Detail2." +dbID+".qty_reqd").value ;
			unit =  document.getElementById("Detail2." +dbID+".unit").value;
			sourceSupply =  document.getElementById("Detail2." +dbID+".source_supply_ref").value;

			dueDate =  document.getElementById("Detail2." +dbID+".due_date").value;

			//alert("in for itemCode["+itemCode+"]dbID["+dbID+"]");

			if( document.getElementById("Detail2." +dbID+".itemCodeDetailMap") != null )
			{
				itemCodeDetailMap =  document.getElementById("Detail2." +dbID+".itemCodeDetailMap").value;
			}

			if( document.getElementById("Detail2." +dbID+".itemDetailsInfo") != null )
			{
				itemDetailsInfo =  document.getElementById("Detail2." +dbID+".itemDetailsInfo").value;
			}
			if( document.getElementById("Detail2." +dbID+".mfg_type") != null )
			{
				mfgType =  document.getElementById("Detail2." +dbID+".mfg_type").value;  
			}
			if( document.getElementById("Detail2." +dbID+".demand") != null )
			{
				demand =  document.getElementById("Detail2." +dbID+".demand").value;
			}
			if( document.getElementById("Detail2." +dbID+".other") != null )
			{
				other =  document.getElementById("Detail2." +dbID+".other").value;
			}
			if( document.getElementById("Detail2." +dbID+".gross_weight") != null )
			{
				grossWeight =  document.getElementById("Detail2." +dbID+".gross_weight").value;
			}
			if( document.getElementById("Detail2." +dbID+".supply") != null )
			{
				supply =  document.getElementById("Detail2." +dbID+".supply").value;
			}
			if( document.getElementById("Detail2." +dbID+".net_req") != null )
			{
				netReq =  document.getElementById("Detail2." +dbID+".net_req").value;
			}
			if( document.getElementById("Detail2." +dbID+".order_type") != null )
			{
				orderType =  document.getElementById("Detail2." +dbID+".order_type").value;
			}
			if( document.getElementById("Detail2." +dbID+".current_sorder") != null )
			{
				currentSorder =  document.getElementById("Detail2." +dbID+".current_sorder").value;
			}
			if( document.getElementById("Detail2." +dbID+".due_date") != null )
			{
				dueDate =  document.getElementById("Detail2." +dbID+".due_date").value;
			}
			if( document.getElementById("Detail2." +dbID+".loc_group") != null )
			{
				locGroup =  document.getElementById("Detail2." +dbID+".loc_group").value;
			}
			if( document.getElementById("Detail2." +dbID+".sodemand") != null )
			{
				sodemand =  document.getElementById("Detail2." +dbID+".sodemand").value;
			}
			//alert("itemCodeDetailMap["+itemCodeDetailMap+"]");
			var div1="";
			//if( document.getElementById("sample_item"+dbID) != null )
			//{	

			//div1 = document.getElementById("sample_item"+dbID).innerHTML;  // DomId
			//alert("div1:dbID["+dbID+"]["+div1+"]");
			//alert("Detail4."+saleOrder+"."+lineNo+"."+dbID+".site_code");


			for(cnt=1; cnt < maxId ; cnt++)
			{
				if( document.getElementById("sample_item"+cnt) != null )
				{	
					//alert("for sample_item["+cnt+"]");
					div1 = document.getElementById("sample_item"+cnt).innerHTML;  // DomId

					//alert(cnt);   //Detail4.PORF0006..1.11/03/13.site_code
					if(  document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".item_code") != null )	
					{
						Detail4ItemCode = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".item_code").value;
					}
					else
					{
						Detail4ItemCode="";	
					}

					//alert("inside for itemCode["+itemCode+"]["+dbID+"]cnt["+cnt+"]Detail4ItemCode["+Detail4ItemCode+"]");
					if(itemCode.trim() == Detail4ItemCode.trim())
					{
						//alert("itemCode["+itemCode+"]Detail4ItemCode["+Detail4ItemCode+"]");
						//alert("@@@@dbID["+dbID+"]cnt["+cnt+"]itemCode["+itemCode+"]Detail4ItemCode["+Detail4ItemCode+"]");
						Detail4SiteCode = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".site_code").value;
						Detail4ItemCode = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".item_code").value;
						Detail4SiteCodeDescr = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".item_code_descr").value;
						Detail4LotNo = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".lot_no").value;
						Detail4LotSl = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".lot_sl").value;
						Detail4TLocCode = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".loc_code").value;
						Detail4TranSer = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".tran_ser").value;
						Detail4TranId = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".tran_id").value;
						Detail4Supply = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".supply").value;
						Detail4AllocQty = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".alloc_qty").value;
						Detail4Unit = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".unit").value;
						Detail4RefLineNo = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".ref_line_no").value;
						Detail4PlannedQuantity = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".planned_quantity").value;
						Detail4ParentItem = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".parent_item").value;
						Detail4SourceSupply = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".source_supply").value;
						Detail4ItemCodeParent = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".item_code_parent").value;

						if(document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".sale_order")  != null )
						{
							Detail4saleOrder  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".sale_order").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".line_no")  != null )
						{
							Detail4LineNo  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".line_no").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".qty_reqd") != null )
						{
							Detail4QtyReqd  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".qty_reqd").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".item_code_descr") != null )
						{
							Detail4ItemCode_descr  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".item_code_descr").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".available_supply") != null ) 
						{
							Detail4AvailableSupply  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".available_supply").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".originalOrAltitem") != null )
						{
							Detail4OriginalOrAltitem  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".originalOrAltitem").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".quantityFlag") != null )
						{
							Detail4QuantityFlag  =  document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".quantityFlag").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".prev_item_worder") != null )
						{
							Detail4PrevItemWorder  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".prev_item_worder").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".previous_item") != null )
						{
							Detail4PreviousItem  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".previous_item").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".new_planned_supply") != null )
						{
							Detail4NewPlannedSupply  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".new_planned_supply").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".due_date") != null )
						{
							Detail4DueDate  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".due_date").value;
						}
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".alloc_pref") != null )
						{
							Detail4AllocPref  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".alloc_pref").value;
						}
						
						if( document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".alt_item_perc") != null )
						{
							Detail4AltItemPerc  = document.getElementById("Detail4."+saleOrder+"."+lineNo+"."+cnt+"."+dueDate+".alt_item_perc").value;
						}

						//break;
						d4dbID++;
						detail4xml = detail4xml +  "<Detail4  domID='" + d4dbID + "'>" +
						"<site_code>" + Detail4SiteCode + "</site_code>" +
						"<item_code>" + Detail4ItemCode + "</item_code>" +
						"<item_code_descr>" + Detail4SiteCodeDescr + "</item_code_descr>" +
						"<lot_no>" + Detail4LotNo + "</lot_no>" +
						"<lot_sl>" + Detail4LotSl + "</lot_sl>" +
						"<loc_code>" + Detail4TLocCode + "</loc_code>" +
						"<tran_ser>" + Detail4TranSer + "</tran_ser>" +
						"<tran_id>" + Detail4TranId + "</tran_id>" +
						"<supply>" + Detail4Supply + "</supply>" +
						"<alloc_qty>" + Detail4AllocQty + "</alloc_qty>" +
						"<unit>" + Detail4Unit + "</unit>" +
						"<ref_line_no>" + Detail4RefLineNo + "</ref_line_no>" +
						"<planned_quantity>" + Detail4PlannedQuantity + "</planned_quantity>" +
						"<parent_item>" + Detail4ParentItem + "</parent_item>" +
						"<source_supply>" + Detail4SourceSupply + "</source_supply>" +
						"<item_code_parent>" + Detail4ItemCodeParent + "</item_code_parent>" +

						"<sale_order>" + Detail4saleOrder + "</sale_order>" +
						"<line_no>" + Detail4LineNo + "</line_no>" +
						"<qty_reqd>" + Detail4QtyReqd + "</qty_reqd>" +
						"<item_code_descr>" + Detail4ItemCode_descr + "</item_code_descr>" +
						"<available_supply>" + Detail4AvailableSupply + "</available_supply>" +
						"<originalOrAltitem>" + Detail4OriginalOrAltitem + "</originalOrAltitem>" +
						"<quantityFlag>" + Detail4QuantityFlag + "</quantityFlag>" +
						"<prev_item_worder>" + Detail4PrevItemWorder + "</prev_item_worder>" +
						"<previous_item>" + Detail4PreviousItem + "</previous_item>" +
						"<new_planned_supply>" + Detail4NewPlannedSupply + "</new_planned_supply>" +
						"<due_date>" + Detail4DueDate + "</due_date>" +
						"<alloc_pref>" + Detail4AllocPref + "</alloc_pref>" +
						
						"<alt_item_perc>" + Detail4AltItemPerc + "</alt_item_perc>" +
						
						"</Detail4>";
						//alert("detail4xml Detail4ItemCode["+Detail4ItemCode+"]["+detail4xml+"]");
					}
				}
			}
			//}
			// Detail2/reference/order

			//alert("before detail4xml ["+detail4xml+"]");

			//alert("after detail4xml ["+detail4xml+"]");
			xmldata = xmldata +  "<Detail2  domID='" + dbID + "'>" +
//			cpatil21	"<reference><order>" +	
			"<sale_order>" + saleOrder + "</sale_order>" +
			"<line_no>" + lineNo + "</line_no>" +
			"<site_code>" + siteCode + "</site_code>" +
			"<bom_code_parent>" + bomCodeParent + "</bom_code_parent>" +
			"<bom_code_ref>" + bomCodeRef + "</bom_code_ref>" +
			"<bom_code_org>" + bomCodeOrg + "</bom_code_org>" +
			"<item_code>" + itemCode + "</item_code>" +
			"<item_code_descr>" + itemCodeDescr + "</item_code_descr>" +
			"<qty_reqd>" + qtyReqd + "</qty_reqd>" +
			"<unit>" + unit + "</unit>" +
			"<source_supply>" + sourceSupply + "</source_supply>" +
			"<source_supply_ref>" + sourceSupply + "</source_supply_ref>" +
			"<itemCodeDetailMap>" + itemCodeDetailMap + "</itemCodeDetailMap>" +

			"<mfg_type>" + mfgType + "</mfg_type>" +
			"<demand>" + demand + "</demand>" +
			"<sodemand>" + sodemand + "</sodemand>" +
			"<other>" + other + "</other>" +
			"<gross_weight>" + grossWeight + "</gross_weight>" +
			"<supply>" + supply + "</supply>" +
			"<net_req>" + netReq + "</net_req>" +
			"<order_type>" + orderType + "</order_type>" +
			"<current_sorder>" + currentSorder + "</current_sorder>" +
			"<due_date>" + dueDate + "</due_date>" +
			"<loc_group>" + locGroup + "</loc_group>" +
			"<itemDetailsInfo>" + itemDetailsInfo + "</itemDetailsInfo>" +
			""+detail4xml+
			"</Detail2>";
//			cpatil21	"</order></reference>" 

			//alert("xmldata itemCode["+itemCode+"]["+xmldata+"]");
		}
	}



	//alert("test detail4xml[["+detail4xml+"]]");

	//alert("recalculate xmldata[["+xmldata+"]]");
	/// xml build
	var samplItem = [];
	var method = "post";
	var path="/ibase/webitm/jsp/MRPWizardXmlData.jsp";
	samplItem["SELECTED_SAMPLE_ITEMS"] = "<Root>" + xmldata + "</Root>";
	post_to_url1(path, samplItem, method);




}

function post_to_url1(path, params, method) {
	method = method || "post"; // Set method to post by default if not specified.

	var form = document.createElement("form");
	form.setAttribute("method", method);
	form.setAttribute("action", path);
	form.target = '_self';

	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();
}

//New Function added by Gulzar to display sample item and stock quantity on 28/MAY/13 : END
/* Added by Amit D on 27-May-13 Start */
function callTemplateJSP(obj)
{       
	var url = '/ibase/webitm/jsp/ITMWizardTemplate.jsp';
	var win = window.open( url, 'Template', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );
}
function displayTemplate( templateId )
{

	if (document.getElementById("Detail1..template_id") != null)
	{
		document.getElementById("Detail1..template_id").value = templateId;
	}
	else
	{
		document.getElementById("Detail1.1.template_id").value = templateId;
	}
}

function callItemSeriesJSP(obj)
{       
	var url = '/ibase/webitm/jsp/ITMWizardItemSeries.jsp';
	var win = window.open( url, 'Template', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );
}
function displayItemSeries( itemSer ,  itemSerDescr)
{

	if (document.getElementById("Detail1..item_ser") != null)
	{
		document.getElementById("Detail1..item_ser").value = itemSer;


	}
	else
	{
		document.getElementById("Detail1.1.item_ser").value = itemSer;

	}
}
function performNextAction( action )
{  
	document.getElementById("action").value = action;
	var flag=0; 	
	if(action == "next")
	{ 
		flag=1;
		return true;
	}
}



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();
}
/* Added by Amit D on 27-May-13 END*/ 

//New Function added by Gulzar to display period code and station code pophelp : START
var fieldName = "";
function callPeriodCodeJSP( dbID, periodCode, periodFieldName )
{

	fieldName = periodFieldName;
	var selectedPeriod = document.getElementById("Detail1."+dbID+"."+periodFieldName).value;
	var url = '/ibase/webitm/jsp/ITMWizardPeriodCode.jsp?PERIOD_CODE='+periodCode+'&SELECTED_PERIOD_CODE='+selectedPeriod;
	var win = window.open( url, 'PeriodCode', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=600,height=406' );

}

var currStationField = "";
var currDbID = "";
function callStationCodeJSP( dbID, selStanDescrFldName, selStationName, stanHq1Name, stanHq2Name )
{
	currStationField = selStanDescrFldName;
	currDbID = dbID;
	var selStationDescr = "";
	var selStationCode = "";
	var stationCode1 = "";
	var stationCode1 = "";
	if(document.getElementById("Detail1."+dbID+"."+selStanDescrFldName) != null)
	{
		selStationDescr = document.getElementById("Detail1."+dbID+"."+selStanDescrFldName).value;
	}
	if(document.getElementById("Detail1."+dbID+"."+selStationName) != null)
	{
		selStationCode = document.getElementById("Detail1."+dbID+"."+selStationName).value;
	}
	if(document.getElementById("Detail1."+dbID+"."+stanHq1Name) != null)
	{
		stationCode1 = document.getElementById("Detail1."+dbID+"."+stanHq1Name).value;
	}
	if(document.getElementById("Detail1."+dbID+"."+stanHq2Name) != null)
	{
		stationCode2 = document.getElementById("Detail1."+dbID+"."+stanHq2Name).value;
	}

	var url = '/ibase/webitm/jsp/ITMWizardStationCode.jsp?STATION_DESCR='+selStationDescr+'&SELECTED_STATION_CODE='+selStationCode+'&STATION_CODE_OTH_1='+stationCode1+'&STATION_CODE_OTH_2='+stationCode2;
	var win = window.open( url, 'StationCode', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=600,height=406' );

}


function disableButtons(formNo)
{
	//alert("formNo =["+formNo+"]");
	if (formNo == '1')
	{
		//document.Wizard_activity.next.disabled = true;
		if(document.Wizard_activity.ActNext != null && document.Wizard_activity.ActNext != 'undefined')
		{
			document.Wizard_activity.ActNext.disabled = true;
		}
		if(document.Wizard_activity.ActFinish != null && document.Wizard_activity.ActFinish != 'undefined')
		{
			document.Wizard_activity.ActFinish.disabled = true;
		}

		if(document.Wizard_activity.Cancel != null && document.Wizard_activity.Cancel != 'undefined')
		{
			document.Wizard_activity.Cancel.disabled = true;
		}
		if(document.Wizard_activity.Next != null && document.Wizard_activity.Next != 'undefined')
		{
			document.Wizard_activity.Next.disabled = true;
		}
	}
	else if (formNo == '2')
	{
		if(document.Wizard_Travel != null && document.Wizard_Travel !='undefined')
		{
			if(document.Wizard_Travel.Cancel != null)
			{
				document.Wizard_Travel.Cancel.disabled = true;
			}
			if(document.Wizard_Travel.Next != null)
			{
				document.Wizard_Travel.Next.disabled = true;
			}
		}
		if(document.Wizard_Sprs != null && document.Wizard_Sprs !='undefined')
		{
			if(document.Wizard_Sprs.Cancel != null)
			{
				document.Wizard_Sprs.Cancel.disabled = true;
			}
			if(document.Wizard_Sprs.Next != null)
			{
				document.Wizard_Sprs.Next.disabled = true;
			}
		}
	}
	/*	if (formNo == '3')
	{
		if(document.Wizard_Customer.Previous != null)
		{
			document.Wizard_Customer.Previous.disabled = true;
		}
		if(document.Wizard_Customer.Next != null)
		{
			document.Wizard_Customer.Next.disabled = true;
		}
	}
	 */	
}
function enableButtons(formNo)
{
	//alert("formNo =["+formNo+"]");
	if (formNo == '1')
	{

		var activityType = "";
		if(document.getElementById( "Detail"+formNo+".activity_type") != null)  //..
		{
			activityType = document.getElementById( "Detail"+formNo+"..activity_type").value;
		}
		else
		{
			if(document.getElementById("Detail"+formNo+".1.activity_type") != null)
			{
				activityType = document.getElementById("Detail"+formNo+".1.activity_type").value;
			}
		}
		//alert("activityType =["+activityType+"]");
		if(activityType =="LEAVE" || activityType =="NFW" )
		{
			if(document.Wizard_activity.ActNext != null && document.Wizard_activity.ActNext != 'undefined')
			{
				document.Wizard_activity.ActNext.disabled = true;
			}
			if(document.Wizard_activity.ActFinish != null && document.Wizard_activity.ActFinish != 'undefined')
			{
				document.Wizard_activity.ActFinish.disabled = false;
			}

			if(document.Wizard_activity.Cancel != null && document.Wizard_activity.Cancel != 'undefined')
			{
				document.Wizard_activity.Cancel.disabled = false;
			}
			if(document.Wizard_activity.Next != null && document.Wizard_activity.Next != 'undefined')
			{
				document.Wizard_activity.Next.disabled = true;
			}
		}
		else
		{
			if(document.Wizard_activity.ActNext != null && document.Wizard_activity.ActNext != 'undefined')
			{
				document.Wizard_activity.ActNext.disabled = false;
			}
			if(document.Wizard_activity.ActFinish != null && document.Wizard_activity.ActFinish != 'undefined')
			{
				document.Wizard_activity.ActFinish.disabled = true;
			}

			if(document.Wizard_activity.Cancel != null && document.Wizard_activity.Cancel != 'undefined')
			{
				document.Wizard_activity.Cancel.disabled = false;
			}
			if(document.Wizard_activity.Next != null && document.Wizard_activity.Next != 'undefined')
			{
				document.Wizard_activity.Next.disabled = false;
			}
		}
	}
	else if (formNo == '2')
	{
		//alert(""+document.Wizard_Travel.Cancel);
		if(document.Wizard_Travel != null && document.Wizard_Travel !='undefined')
		{
			if(document.Wizard_Travel.Cancel != null)
			{
				document.Wizard_Travel.Cancel.disabled = false;
			}
			if(document.Wizard_Travel.Next != null)
			{
				document.Wizard_Travel.Next.disabled = false;
			}
		}
		if(document.Wizard_Sprs != null && document.Wizard_Sprs !='undefined')
		{
			if(document.Wizard_Sprs.Cancel != null)
			{
				document.Wizard_Sprs.Cancel.disabled = false;
			}
			if(document.Wizard_Sprs.Next != null)
			{
				document.Wizard_Sprs.Next.disabled = false;
			}
		}
	}
	/*	if (formNo == '3')
	{
		//alert(""+document.Wizard_Travel.Cancel);
		if(document.Wizard_Customer.Previous != null)
		{
			document.Wizard_Customer.Previous.disabled = false;
		}
		if(document.Wizard_Customer.Next != null)
		{
			document.Wizard_Customer.Next.disabled = false;
		}
	}
	 */
}
function validateActivity(formNo)
{
	disableButtons(formNo);
	var value = document.getElementById("action").value;

	var flag=0; 	
	if(value =="next")
	{ 
		flag=1;
		var returnVal = checkDate(document.getElementById("Detail1..event_date"),flag);
		if(returnVal== true)
		{
			enableButtons(formNo);
			return false;
		}

	}
	else if(value=="finish")
	{
		flag=2;
		var returnValue = checkDate(document.getElementById("Detail1..event_date"),flag);
		if(returnValue== true)
		{
			enableButtons(formNo);
			return false;
		}
	}
}
function vlidateSprs(formNo)
{
	disableButtons(formNo);
	var chkCount = 0;
	var count = 0;
	count = document.Wizard_Sprs.elements.length;


	action = document.getElementById("action").value;
	if( action != "previous" )
	{

		for(i = 0; i < count; i++)
		{

			if(document.Wizard_Sprs.elements[i].type == 'checkbox')
			{
				if(document.Wizard_Sprs.elements[i].checked == true)
				{
					chkCount = chkCount + 1;
				}
			}
		}

		if(chkCount == 0 )
		{
			alert("No Selection Made ! \nPlease select a Subordinate !");

			for(i = 0; i < count; i++)
			{
				if(document.Wizard_Sprs.elements[i].type == 'submit' || document.Wizard_Sprs.elements[i].type == 'button')
				{
					var value = document.Wizard_Sprs.elements[i].value;
					var buttonDisabledId = document.getElementById("button."+value);
					if(buttonDisabledId != null && document.getElementById("button."+value).disabled == true)
					{
						document.getElementById("button."+value).disabled = false;
					}
				}
			}
			enableButtons(formNo);
			return false;
		}
	}
}
//Added by chandrashekar
/*function callRumMrpExportJSP( value )
{  
		//alert("callRumMrpExportJSP")
		document.getElementById("action").value = value;

		var samplItem = [];
		var method = "post";
		var path="/ibase/webitm/jsp/RunMrpExportExcel.jsp";
		var issError = false;

		var srNo = 1;
		var selectedSampleItem = "";
		var saleOrder = "";
		var lineNo = "";
		var itemCode = "";
		var siteCode = "";
		var qtyReqd = "";
		var lotNo = "";
		var lotSl = "";
		var locCode = "";
		var tranSer = "";
		var tranId = "";
		var refLineNo = "";
		var supply = "";
		var availableSupply = "";
		var allocQty = "";
		var maxId = 1000;
		var div1 = "";

		var itemCnt =0;
		var itemCodeDescr="";
		var finishArray = new Array();
		var flagforSO = false;
		var finishArrayKey="";

		var itemCodeHdr="";
		var parentItem="";
		var unit="";
		var plannedQuantity="";
		var sourceSupply="";
		var dateFrom="";
		var dateTo="";
		var siteCodeFrom="";
		var siteCodeTo="";

		for( var dbIDOut = 1; dbIDOut <= maxId; dbIDOut++)
		{

			if(document.getElementById("Detail2."+dbIDOut+".selectbox")!=null && document.getElementById("Detail2."+dbIDOut+".selectbox").checked )
			{	
				saleOrder = document.getElementById("Detail2."+dbIDOut+".sale_order").value.trim();
				lineNo = document.getElementById("Detail2."+dbIDOut+".line_no").value.trim();
				itemCodeHdr = document.getElementById("Detail2."+dbIDOut+".item_code").value.trim();

					for(var dbID = 1; dbID <= maxId; dbID++)
					{	

						if( document.getElementById("Detail2"+"."+dbID+".qty_reqd") != null)
						{
							qtyReqd = document.getElementById("Detail2"+"."+dbID+".qty_reqd").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;							
						}
						if( document.getElementById("Detail2.siteCodeTo_argdata") != null)
						{
							siteCodeTo = document.getElementById("Detail2.siteCodeTo_argdata").value;							
						}



						var divid= document.getElementById("sample_item"+dbID);						  
						if( divid != null)
						{ 

							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".sale_order") != null)
							{
								saleOrder = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".sale_order").value;

							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".line_no") != null)
							{
								lineNo = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".line_no").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".item_code") != null)
							{
								itemCode = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".item_code").value;
							}

							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".item_code_descr") != null)
							{
								itemCodeDescr = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".item_code_descr").value;
							}

							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".site_code") != null)
							{				
								siteCode = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".site_code").value;
							}
							if( document.getElementById("Detail2"+"."+dbID+".qty_reqd") != null)
							{
								qtyReqd = document.getElementById("Detail2"+"."+dbID+".qty_reqd").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".lot_no") != null)
							{
								lotNo = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".lot_no").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".lot_sl") != null)
							{
								lotSl = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".lot_sl").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".loc_code") != null)
							{
								locCode = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".loc_code").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".tran_ser") != null)
							{
								tranSer = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".tran_ser").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".tran_id") != null)
							{
								tranId = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".tran_id").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".ref_line_no") != null)
							{
								refLineNo = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".ref_line_no").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".supply") != null)
							{	
								supply = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".supply").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".available_supply") != null)
							{
								availableSupply = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".available_supply").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".alloc_qty") != null)
							{
								allocQty = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".alloc_qty").value;
							}

							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".parent_item") != null)
							{
								parentItem = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".parent_item").value;
							}						

							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".unit") != null)
							{
								unit = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".unit").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".planned_quantity") != null)
							{
								plannedQuantity = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".planned_quantity").value;
							}
							if( document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".source_supply") != null)
							{
								sourceSupply = document.getElementById("Detail4"+"."+saleOrder+"."+lineNo+"."+dbID+".source_supply").value;
							}

							selectedSampleItem = selectedSampleItem + "<Detail4  domID='" + dbID + "'>" +	
							"<sale_order>" + saleOrder + "</sale_order><line_no>" + lineNo + "</line_no><qty_reqd>" + qtyReqd + "</qty_reqd>" +
							"<site_code>" + siteCode + "</site_code><item_code>" + itemCode + "</item_code>" +
							"<item_code_descr>" + itemCodeDescr + "</item_code_descr>" +
							"<lot_no>" + lotNo + "</lot_no><parent_item>" + parentItem + "</parent_item>" +
							"<lot_sl>" + lotSl + "</lot_sl><loc_code>" + locCode + "</loc_code><tran_ser>" + tranSer + "</tran_ser>" +
							"<tran_id>" + tranId + "</tran_id><ref_line_no>" + refLineNo + "</ref_line_no>" +
							"<supply>" + supply + "</supply><alloc_qty>" + allocQty + "</alloc_qty>" +
							"<unit>" + unit + "</unit><planned_quantity>" + plannedQuantity + "</planned_quantity><source_supply>" + sourceSupply + "</source_supply>" +
							"<site_code__from>" + siteCodeFrom + "</site_code__from><site_code__to>" + siteCodeTo + "</site_code__to><date_from>" + dateFrom + "</date_from>" +
							"<date_to>" + dateTo + "</date_to>" +
							"</Detail4>";
							//alert("selectedSampleItem::"+selectedSampleItem);

						}



					}

			}
		}

		if( issError == false)
		{	
			samplItem["SAVE_SAMPLE_DATA"] = "<Root>" + selectedSampleItem + "</Root>";
			post_to_url2(path, samplItem, method);
		}
		else
		{
			alert(" please select all stock record of selected saleOrder for allocation...");
			return false;
		}

 }
	function post_to_url2(path, params, method) {
		method = method || "post"; // Set method to post by default if not specified.


		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 recalculate1( )
{  
	//alert("call recalculate1....!");

	//document.getElementById("action").value = value;

	var samplItem = [];
	var method = "post";
	var path="/ibase/webitm/jsp/MRPWizardRecalculate.jsp";

	var srNo = 1;
	var recalculateXml = "";
	var saleOrder = "";
	var lineNo = "";
	var itemCode = "";
	var siteCode = "";
	var qtyReqd = "";
	var lotNo = "";
	var lotSl = "";
	var locCode = "";
	var tranSer = "";
	var tranId = "";
	var refLineNo = "";
	var supply = "";
	var availableSupply = "";
	var allocQty = "";
	var maxId = 50;
	var div1 = "";
	//alert("maxId["+maxId+"]");
	var itemCnt =0;
	var itemCodeDescr="";
	var finishArray = new Array();
	var flagforSO = false;
	var finishArrayKey="";

	var itemCodeHdr="";
	var parentItem="";
	var issError = false;

	for( var dbIDOut = 1; dbIDOut <= maxId; dbIDOut++)
	{
		//alert("inside for...------------");
		//if(document.getElementById("Detail2."+dbIDOut+".selectbox")!=null && document.getElementById("Detail2."+dbIDOut+".selectbox").checked )
		if(document.getElementById("Detail2."+dbIDOut+".sale_order") != null ) 
		{

			saleOrder = document.getElementById("Detail2."+dbIDOut+".sale_order").value.trim();
			lineNo = document.getElementById("Detail2."+dbIDOut+".line_no").value.trim();
			itemCodeHdr = document.getElementById("Detail2."+dbIDOut+".item_code").value.trim();


			//alert("saleOrder["+saleOrder+"]lineNo["+lineNo+"]itemCodeHdr["+itemCodeHdr+"]");	

			var div1 = document.getElementById("sample_item"+DomId).value;  // DomId
			//alert("div1:DomId["+dbIDOut+"]["+div1+"][["+div1+"]]");
			//alert("updDetail4Div["+updDetail4Div+"]");
			//div1.innerHTML = updDetail4Div;

			recalculateXml = recalculateXml + "<Detail2  domID='" + dbIDOut + "'>" +	
			"<Detail2."+dbIDOut+".sale_order>" + saleOrder + "</Detail2."+dbIDOut+".sale_order>" +
			"<line_no>" + lineNo + "</line_no>" +
			"<qty_reqd>" + qtyReqd + "</qty_reqd>" +
			"<site_code>" + siteCode + "</site_code>" +
			"<item_code>" + itemCode + "</item_code>" +
			"<item_code_descr>" + itemCodeDescr + "</item_code_descr>" +
			"<lot_no>" + lotNo + "</lot_no>" +
			"<lot_sl>" + lotSl + "</lot_sl>" +
			"<loc_code>" + locCode + "</loc_code>" +
			"<tran_ser>" + tranSer + "</tran_ser>" +
			"<tran_id>" + tranId + "</tran_id>" +
			"<ref_line_no>" + refLineNo + "</ref_line_no>" +
			"<supply>" + supply + "</supply>" +
			"<available_supply>" + availableSupply + "</available_supply>" +
			"<alloc_qty>" + allocQty + "</alloc_qty>" +
			"</Detail2>";

		}
	}

	//alert("recalculateXml[["+recalculateXml+"]]");

	if( issError == false)
	{
		samplItem["SAVE_SAMPLE_DATA"] = "<Root>" + recalculateXml + "</Root>";
		post_to_url(path, samplItem, method);
	}
	else
	{
		alert(" please select record of ...");
		return false;
	}
}


function callPopHelpJSP( dbID, itemCode , siteCode )
{

	//var selectedItemCode = document.getElementById("Detail2."+dbID+".item_code").value;
	//alert("itemCode["+selectedItemCode+"]");
	var url = '/ibase/webitm/jsp/Bompophelp.jsp?item_code='+itemCode+'&dbID='+dbID+'&site_code='+siteCode ;
	var win = window.open( url, 'Item Code', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );

}

function setBomCode(dbID, bomCode,detail2dom )
{
	document.getElementById("Detail2."+detail2dom+".bom_code_ref").value = bomCode;
}




function callActivityTypeJSP1( dbID, salesPers )
{
	//alert("=====callActivityTypeJSP1======");
	var selectedActCode = document.getElementById("Detail1."+dbID+".purc_order").value;
	//alert("selectedActCode!!! :"+selectedActCode);
	//Changed By Vidhya on 28/10/09[WS89NOV617 | MOZILLA COMPATIBILITY] Start
	//var url = '/ibase/webitm/jsp/ITMWizardActitvityCode.jsp?SALES_PERS='+salesPers+'&amp;SELECTED_ACT_CODE='+selectedActCode;
	//var url = '/ibase/webitm/jsp/MileStonePopHelp.jsp?SELECTED_ACT_CODE='+selectedActCode;
	var url = '/ibase/webitm/jsp/MileStonePopHelp.jsp?SELECTED_ACT_CODE='+selectedActCode+"&val=purc_order";
	var win = window.open( url, 'purc_order', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );

}

function callActivityTypeJSP2( dbID, salesPers )
{
	//alert("=====callActivityTypeJSP1======");
	var selectedActCode = document.getElementById("Detail1."+dbID+".proj_code").value;
	//alert("selectedActCode!!! :"+selectedActCode);
	//Changed By Vidhya on 28/10/09[WS89NOV617 | MOZILLA COMPATIBILITY] Start
	//var url = '/ibase/webitm/jsp/ITMWizardActitvityCode.jsp?SALES_PERS='+salesPers+'&amp;SELECTED_ACT_CODE='+selectedActCode;
	//var url = '/ibase/webitm/jsp/MileStonePopHelp.jsp?SELECTED_ACT_CODE='+selectedActCode;
	var url = '/ibase/webitm/jsp/MileStonePopHelp.jsp?SELECTED_ACT_CODE='+selectedActCode+"&val=proj_code";
	var win = window.open( url, 'proj_code', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=100,top=50,width=500,height=406' );

}



