
//
//JAVASCRIPT FUNCTIONS FOR ESCROW TEMPLATE FORM
//
//
var txt1

function checkfromsite(value1)
{
	if (value1=="yes")
	{
		document.getElementById("fromsite_true" ).style.visibility="visible"
	}

	if (value1=="no")
	{
		document.getElementById("fromsite_true" ).style.visibility="hidden"
		//open a new window ti fill material details
		window.open("materialDesc.asp","newwin","scrollbars=yes,resizable=yes,width=677;height=100%;top=0")
	}
}

function step3(value2)
{
	if (value2=="buyer")
	{
		//document.getElementById("email_title" ).style.innerText="hr>"
		//document.getElementById("step3_empty" ).style.display="none"
		//document.getElementById("step3_seller" ).style.display="inline"
		//document.getElementById("step3_buyer" ).style.display="none"
	}

	else
	{
			//alert(document.getElementById("email_title" ).style.innerText)
			//document.getElementById("email_title" ).style.innerText="hr>"
		///document.getElementById("step3_empty" ).style.display="none"
		//document.getElementById("step3_buyer" ).style.display="inline"
		//document.getElementById("step3_seller" ).style.display="none"
	}
}

function checkform()
{
	if (document.fr2.fromsite[0].checked==true || document.fr2.fromsite[1].checked==true)	 //must choose one of the two
	{
		if (document.fr2.fromsite[0].checked==true && document.fr2.newmaterial.value=="no")	//if not from site & didnt fill material details
		{
			alert("Please insert the Material Details ")
				window.open("materialDesc.asp","newwin","scrollbars=yes,resizable=yes,width=677;height=100%;top=0")
				return;
		}

		if (document.fr2.fromsite[1].checked==true &&(document.fr2.category.value=="0" || document.fr2.item_num.value==document.fr2.item_num.defaultValue))
		{
			alert("Please check the Material Number & Section")
				return;
		}

		if (document.fr2.mem1[0].checked==true || document.fr2.mem1[1].checked==true)	//what is he? seller or buyer
		{
			if (document.fr2.email.value==document.fr2.email.defaultValue )	 //if didnt enter other part email
			{
					alert("Please fill the Other part Email!")
						return;
			}

			else	//entered the email & can continue
			{
				var new_dd=document.fr2.dd.value
				var new_mm=document.fr2.mm.value
				var new_yy=document.fr2.yy.value
				var new_date=new_dd+'/'+new_mm+'/'+new_yy
					document.fr2.fulldate.value=new_date
					//var myDate=new Date(new_date)
					//myDate=myDate.toGMTString();
					//alert(new_date)

				
					if (document.fr2.part_ship[0].checked==true || document.fr2.part_ship[1].checked==true)	//can continue
					{
						if (document.fr2.Transhipment[0].checked==true || document.fr2.Transhipment[1].checked==true)//Transhipment ok can continue
						{
							if (document.fr2.payby[0].checked==true || document.fr2.payby[1].checked==true)	 //payby was fiiled can continue
							{
								//loop on the terms radio buttons to check if one is checked
								var check="no"
								var checknum
									
								for (i=0;i<document.fr2.terms.length ;i++ )
								{
									
									if (document.fr2.terms[i].checked==true)
									{
										check="ok"
										checknum=document.fr2.terms[i].value
											
									}
								}

								if (check=="ok")	//one terms was selected
								{
									if (checknum=="2" && (document.fr2.terms_2.value=="XX" || document.fr2.terms_2.value==""))	 //if 2 check if filled the XX text
									{
										alert ("Please fill in all fields in the Terms section")
											return;
									}

									if (checknum=="5" && (document.fr2.terms_5.value=="XX" || document.fr2.terms_5.value==""))	//if 5 check if filled the XX text
									{
										alert ("Please fill in all data in the Terms section")
										return;
									}
									
									
									//check documntation requirments

									//check the first 2 lines
									if (document.fr2.documentation_1_1.value==document.fr2.documentation_1_1.defaultValue || document.fr2.documentation_1_2.value==document.fr2.documentation_1_2.defaultValue ||document.fr2.documentation_2_1.value==document.fr2.documentation_2_1.defaultValue || document.fr2.documentation_2_2.value==document.fr2.documentation_2_2.defaultValue)
									{
										alert("Please check the Documentation Requirements")
											return;
									}

									else	//2 first lines are ok
									{
										//check the shipper etc details????????????????????/

										//send form
										document.fr2.submit()
									}
								}

								else	//terms was not filled
								{
									alert("Please choose your terms")
										return;
								}
							}

							else	//pay by was not filled
							{
								alert("Please choose the Payment System")
									return;
							}
						}

						else	//Transhipment not filled
						{
							alert("Please check the Transhipment")
								return;
						}
					}

					else	 //part ship is not filled
					{
						alert("Please check the Partial Shipment")
							return;
					}
				
			}
		}

		else	//if not choosen if seller or buyer
		{
			alert("Please choose if you are the Seller ot the Buyer!")
				return;
		}

	}	

	else 
	{
		alert("Please choose if the  material is from Earam's website materials")
			return;
	}


}

function calculate()
{
	//cost=parseFloat(document.c1.tran.value)

var cost=document.c1.tran.value
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(cost)){
testresult=true
	cost=parseFloat(document.c1.tran.value)
		fee=(cost*3)	
		fee=(fee/100)
	document.c1.fee.value=fee
		fee=fee+150
	document.c1.totalfee.value=fee
	return
	

}
else{
alert("Please input a valid number!")
testresult=false
}
//return (testresult)

		
	//alert(cost)
}




function Double_checkform()
{
	if (document.fr2.fromsite[0].checked==true || document.fr2.fromsite[1].checked==true)	 //must choose one of the two
	{
		if (document.fr2.fromsite[0].checked==true && document.fr2.newmaterial.value=="no")	//if not from site & didnt fill material details
		{
			alert("Please insert the Material Details ")
				window.open("materialDesc.asp","newwin","scrollbars=yes,resizable=yes,width=677;height=100%;top=0")
				return;
		}

		if (document.fr2.fromsite[1].checked==true &&(document.fr2.category.value=="0" || document.fr2.item_num.value==""))
		{
			alert("Please check the Material Number & Section")
				return;
		}

		if (document.fr2.mem1[0].checked==true || document.fr2.mem1[1].checked==true)	//what is he? seller or buyer
		{
			if (document.fr2.email.value=="" )	 //if didnt enter other part email
			{
					alert("Please fill the Other part Email!")
						return;
			}

			else	//entered the email & can continue
			{
				var new_dd=document.fr2.dd.value
				var new_mm=document.fr2.mm.value
				var new_yy=document.fr2.yy.value
				var new_date=new_dd+'/'+new_mm+'/'+new_yy
					document.fr2.fulldate.value=new_date
					//var myDate=new Date(new_date)
					//myDate=myDate.toGMTString();
					//alert(new_date)

				
					if (document.fr2.part_ship[0].checked==true || document.fr2.part_ship[1].checked==true)	//can continue
					{
						if (document.fr2.Transhipment[0].checked==true || document.fr2.Transhipment[1].checked==true)//Transhipment ok can continue
						{
							if (document.fr2.payby[0].checked==true || document.fr2.payby[1].checked==true)	 //payby was fiiled can continue
							{
								//loop on the terms radio buttons to check if one is checked
								var check="no"
								var checknum
									
								for (i=0;i<document.fr2.terms.length ;i++ )
								{
									
									if (document.fr2.terms[i].checked==true)
									{
										check="ok"
										checknum=document.fr2.terms[i].value
											
									}
								}

								if (check=="ok")	//one terms was selected
								{
									if (checknum=="2" && (document.fr2.terms_2.value=="XX" || document.fr2.terms_2.value==""))	 //if 2 check if filled the XX text
									{
										alert ("Please fill in all fields in the Terms section")
											return;
									}

									if (checknum=="5" && (document.fr2.terms_5.value=="XX" || document.fr2.terms_5.value==""))	//if 5 check if filled the XX text
									{
										alert ("Please fill in all data in the Terms section")
										return;
									}
									
									
									//check documntation requirments

									//check the first 2 lines
									if (document.fr2.documentation_1_1.value=="" || document.fr2.documentation_1_2.value=="" ||document.fr2.documentation_2_1.value=="" || document.fr2.documentation_2_2.value=="")
									{
										alert("Please check the Documentation Requirements")
											return;
									}

									else	//2 first lines are ok
									{
										//check the shipper etc details????????????????????/

										//send form
										document.fr2.submit()
									}
								}

								else	//terms was not filled
								{
									alert("Please choose your terms")
										return;
								}
							}

							else	//pay by was not filled
							{
								alert("Please choose the Payment System")
									return;
							}
						}

						else	//Transhipment not filled
						{
							alert("Please check the Transhipment")
								return;
						}
					}

					else	 //part ship is not filled
					{
						alert("Please check the Partial Shipment")
							return;
					}
				
			}
		}

		else	//if not choosen if seller or buyer
		{
			alert("Please choose if you are the Seller ot the Buyer!")
				return;
		}

	}	

	else 
	{
		alert("Please choose if the  material is from Earam's website materials")
			return;
	}


}

function calculate()
{
	//cost=parseFloat(document.c1.tran.value)

var cost=document.c1.tran.value
var anum=/(^\d+$)|(^\d+\.\d+$)/
if (anum.test(cost)){
testresult=true
	cost=parseFloat(document.c1.tran.value)
		fee=(cost*3)	
		fee=(fee/100)
	document.c1.fee.value=fee
		fee=fee+150
	document.c1.totalfee.value=fee
	return
	

}
else{
alert("Please input a valid number!")
testresult=false
}
//return (testresult)

		
	//alert(cost)
}
