function pop_help(field,fieldname,label,extra)
{
		var url = "/ibase/webitm/jsp/PordAmdPopHelp.jsp?field="+field+"&fieldname="+fieldname+"&label="+label+"&extra="+extra;
		var win = window.open( url, 'Supplier Code', 'toolbar=no,status=yes,resizable=no,scrollbars=yes,left=500,top=50,width=500,height=550');		
}

function select()
{
		var supp_code="";
		var det="";
		var extra="";
		
		var field = document.getElementById("erp").value;
		
		if(field=="supp_code")
		{	
			if(Wizard_SuppDetails.selectbox.length==undefined )  //this is for if only one checkbox
			{
				if(Wizard_SuppDetails.selectbox.checked)
				{
					supp_code=supp_code+document.getElementById("DetailITCode.1.fieldId").value;
				}	
			}
			else
			{	
			for (var i = 1; i<=Wizard_SuppDetails.selectbox.length; i++)
			{
				 if (Wizard_SuppDetails.selectbox[i-1].checked)
				{
					supp_code=supp_code+document.getElementById("DetailITCode."+ i +".fieldId").value;
				}
			}
			}
			if(supp_code=="")
			{
				alert('No Selection Made ! \nPlease Select the Code !');
			}
			else
			{
				window.opener.document.getElementById("supp_code").value=supp_code;
				window.close();
			}
		}
		
		else if(field=="purc_order")
		{	
			if(Wizard_SuppDetails.selectbox.length==undefined )  //this is for if only one checkbox
			{
				if(Wizard_SuppDetails.selectbox.checked)
				{
					supp_code=supp_code+document.getElementById("DetailITCode.1.fieldId").value;
				}	
			}
			else
			{	
			for (var i = 1; i<=Wizard_SuppDetails.selectbox.length; i++)
			{
				 if (Wizard_SuppDetails.selectbox[i-1].checked)
				{
					supp_code=supp_code+document.getElementById("DetailITCode."+ i +".fieldId").value;
				}
			}
			}
			if(supp_code=="")
			{
				alert('No Selection Made ! \nPlease Select the Code !');
			}
			else
			{
				window.opener.document.getElementById("purc_order").value=supp_code;
				window.opener.document.getElementById("extra3").value=supp_code;
				window.close();
			}
		}
		
		else if(field=="item_parnt")
		{	
			if(Wizard_SuppDetails.selectbox.length==undefined )  //this is for if only one checkbox
			{
				if(Wizard_SuppDetails.selectbox.checked)
				{
					supp_code=supp_code+document.getElementById("DetailITCode.1.fieldId").value;
				}	
			}
			else
			{	
			for (var i = 1; i<=Wizard_SuppDetails.selectbox.length; i++)
			{
				 if (Wizard_SuppDetails.selectbox[i-1].checked)
				{
					supp_code=supp_code+document.getElementById("DetailITCode."+ i +".fieldId").value;
				}
			}
			}
			if(supp_code=="")
			{
				alert('No Selection Made ! \nPlease Select the Code !');
			}
			else
			{
				window.opener.document.getElementById("item_parnt").value=supp_code;
				window.close();
			}
		}
}		

function setActionVal(value)
{  
		//alert("in ammend");
	    document.getElementById("action").value = value;
}

function trimSpace()
{ 
		var suppCode = document.getElementById("supp_code").value;
		var purcOrder = document.getElementById("purc_order").value;
		var itemParnt = document.getElementById("item_parnt").value;
		
		suppCode  = suppCode.trim();
		purcOrder = purcOrder.trim();
		itemParnt = itemParnt.trim();
		
		document.getElementById("supp_code").value  = suppCode;
		document.getElementById("purc_order").value = purcOrder;
		document.getElementById("item_parnt").value = itemParnt;
		
		document.getElementById("extra3").value = purcOrder;
}		


function validation()
{
	var supp_code = document.getElementById("supp_code").value;
	var purc_order = document.getElementById("purc_order").value;
	var item_parnt = document.getElementById("item_parnt").value;
	
	if(supp_code == "")
	{
		if(purc_order == "")
		{
			if(item_parnt == "")
			{
				alert("Please enter data in atleast one text field...!");
				return false;
			}	
		}	
	}
}	


function dateChange(id)
{
	//alert(id);
	document.getElementById("Detail2."+id+".dlv_date").value = document.getElementById("new_date"+id).value;
	//alert(document.getElementById("Detail2."+id+".dlv_date").value);
}


function final()
{
	var count = 0;
	
	for(var i=1; i<=100 ; i++)
	{
		if(document.getElementById("Detail2."+id+".selectbox").checked == true)
		{
			count++;
			continue;
		}
	}
	
	if(count == 0)
	{
		alert("Please select atleast one checkbox..!");
		return false;
	}
}

function amdPrevious() 
{	
    	var element = $( "input[name^='Detail2.1.']" );
		
		var DOMeles = element.get();
		
		var xmlString = "<?xml version = \"1.0\"?><Root><header><editFlag></editFlag></header>" +
				"<Detail1 domID='1' selected = 'N'>";
		
		for (var i = 0; i < DOMeles.length; i++)
		{
			if ( DOMeles[i] != null )
			{
				xmlString = xmlString + "<" + DOMeles[i].getAttribute('id') + ">" +
								"<![CDATA[" + DOMeles[i].getAttribute('value') + "]]>" +
								"</" + DOMeles[i].getAttribute('id') + ">";
			}
		}
		
		xmlString = xmlString + "</Detail1></Root>";
		//alert(xmlString);
		document.getElementById("PRE_FORM_VAL").value = xmlString;
		
		setActionVal( "previous" );

		document.getElementById("pordAmdFormII").action = "/ibase/PordAmdPreServlet";
		document.getElementById("pordAmdFormII").submit();
}



function checkone(id)
{
    for (var i = 1;i<=Wizard_SuppDetails.selectbox.length; i++)
    {
        document.getElementById("DetailITCode."+ i +".selectbox").checked = false;
    }
    
    document.getElementById(id).checked = true;
}

//this function used to set checkbox tick when cliking on row in popup
function rowChecked(id)
{
		for (var i = 1;i<=Wizard_SuppDetails.selectbox.length; i++)
		{
			document.getElementById("DetailITCode."+ i +".selectbox").checked = false;
		}
		
		document.getElementById("DetailITCode."+ id +".selectbox").checked = true;
}

//this function used to set checkbox tick after reopen popup
function easy(tick)
{
	if(tick=="prlist")
	{
		for (var i = 1; i<=Wizard_SuppDetails.selectbox.length; i++)
			{
				 if (document.getElementById("DetailITCode."+ i +".fieldId").value==window.opener.document.getElementById(tick).value && document.getElementById("DetailITCode."+ i +".fieldValue").value==window.opener.document.getElementById("prdescr").value)
				{
					document.getElementById("DetailITCode."+ i +".selectbox").checked = true;
					break;
				}	
			}
	}
	else
	{
		for (var i = 1; i<=Wizard_SuppDetails.selectbox.length; i++)
			{
				 if (document.getElementById("DetailITCode."+ i +".fieldId").value==window.opener.document.getElementById(tick).value)
				{
					document.getElementById("DetailITCode."+ i +".selectbox").checked = true;
				}	
			}
			
		if(Wizard_SuppDetails.selectbox.length==undefined)  //this is for if only one checkbox
		{
				if (document.getElementById("DetailITCode."+ 1 +".fieldId").value==window.opener.document.getElementById(tick).value)
				{
					Wizard_SuppDetails.selectbox.checked = true;
				}
		}	
	}		
}




