// JavaScript Document
document.write('<script language="JavaScript" type="text/javascript" src="scripts/general.js"></script>');
document.write('<script language="JavaScript" type="text/javascript" src="scripts/val_functions.js"></script>');
document.write('<link href="css/evaluation.css" rel="stylesheet" type="text/css" />');

	var	 today 		 =	new	Date()
	var	 dateNow	 = today.getDate()
	var	 monthNow = today.getMonth()
	var	 yearNow	 = today.getYear()
	var	 ns4=document.layers
	var ie=document.all
		if (!ns4)
		{if (!ie) { yearNow += 1900	}}

function calc()
{	
	total=0;
	for(rr=0;rr<document.frmApply.radReport.length;rr++)
		if(document.frmApply.radReport[rr].checked)
		{
			total = document.frmApply.radReport[rr].id
			document.frmApply.rr.value = document.frmApply.radReport[rr].value
		}
		
	for(rc=0;rc<document.frmApply.radService.length;rc++)
		if(document.frmApply.radService[rc].checked)
		{
			total = eval(total) + eval(document.frmApply.radService[rc].id);
			document.frmApply.rs.value = document.frmApply.radService[rc].value
		}
		total = eval(total) + eval(document.frmApply.courier_total.value)
	if((document.frmApply.txtCopies.value)>0)
		total = eval(total) + (eval(document.frmApply.txtCopies.value)*10)
	if(document.frmApply.cboCourier.value == "US/Canada $35")
		total = eval(total) + (35)	
	else if(document.frmApply.cboCourier.value == "International $50")
		total = eval(total) + (50)	
	if(document.frmApply.cboFaxcopy.value == "Yes")
		total = eval(total) + (10)	
	/*if(eval(document.frmApply.txtFaxnum.value)>0)
		total = eval(total) + (eval(document.frmApply.txtFaxnum.value)*10)*/
		
	document.frmApply.txtTotal.value = 	"$"+total;

}
function sbt(frm,chc)
{
		form =document.frmApply;
	if(frm=="stp1")
	{
		if(document.frmApply.txtFirstname.value=="")
		{
			alert("Please enter your First Name");
			document.frmApply.txtFirstname.focus();
			return false;
		}
		
		else if(document.frmApply.txtLastname.value=="")
		{
			alert("Please enter your Last Name");
			document.frmApply.txtLastname.focus();
			return false;
		}
		else if(document.frmApply.txtAddress.value=="")
		{
			alert("Please enter Complete Address");
			document.frmApply.txtAddress.focus();
			return false;
		}
		
		else if(document.frmApply.txtPhone1.value=="")
		{
			alert("Please enter Phone1");
			document.frmApply.txtPhone1.focus();
			return false;
		}
		val=(document.frmApply.txtPhone1.value);
		if(isNaN(val)){
		alert("Please enter Valid Phone 1");
		document.frmApply.txtPhone1.focus();
		return false;
		}
		else if(document.frmApply.txtPhone2.value!="")
		{
		val=(document.frmApply.txtPhone2.value);
		if(isNaN(val)){
		alert("Please enter Valid Phone 2 ");
		document.frmApply.txtPhone2.focus();
		return false;
		}
		}
		 if(document.frmApply.txtFax.value!="")
		{
			val=(document.frmApply.txtFax.value);
			if(isNaN(val)){
			alert("Please enter valid fax number");
			document.frmApply.txtFax.focus();
			return false;
			}
		
		}
		 if(document.frmApply.chkICEmail.checked)
		{
			
		 if((document.frmApply.txtEmail.value)=="")
			{
			alert ("Please enter Email-ID ");
			document.frmApply.txtEmail.focus();
			return false;
			}
		
			else if(checkEmail(document.frmApply.txtEmail.value)==false)
			{
			alert("Invalid e-mail address! Please re-enter.");
			document.frmApply.txtEmail.focus()
			return false;
			}
			
		}
		if(document.frmApply.cboDate.value=="")  
		{
			alert("Please select Day");
			document.frmApply.cboDate.focus();
			return false;
		}
		else if(document.frmApply.cboMonth.value=="")
		{
			alert("Please select Month");
			document.frmApply.cboDate.focus();
			return false;
		}
		else if(document.frmApply.cboYear.value=="")
		{
			alert("Please select Year");
			document.frmApply.cboDate.focus();
			return false;
		}	
		else if(document.frmApply.cboGender.value=="")
		{
			alert("Please Select Gender");
			document.frmApply.cboGender.focus();
			return false;
		}
		else if(document.frmApply.cboCountry.value=="")
		{
			alert("Please Select Country");
			document.frmApply.cboCountry.focus();
			return false;
		}
		else if(document.frmApply.chkSubmitted.checked)
		{
			 if((document.frmApply.txtRefnum.value)=="")
			{
			alert ("Please enter Reference Number ");
			document.frmApply.txtRefnum.focus();
			return false;
			}
		  
		}
		
		if(document.frmApply.chkArrangements.checked)
		{
			 if((document.frmApply.txtSpellname.value)=="")
			{
			alert ("Please enter Name Spelled ");
			document.frmApply.txtSpellname.focus();
			return false;
			}
		  
		}
		
			document.frmApply.action = "template.php?opt="+chc;
			document.frmApply.submit();
		
	}
	else if(frm=="stp2")
	{
		var rr_checked = false;
		for(rr=0;rr<document.frmApply.radReport.length;rr++)
			if(document.frmApply.radReport[rr].checked)
				rr_checked = true;
		if(!rr_checked)
		{
			alert("Please Select report type");
			document.frmApply.radReport[0].focus();
			return false;				
		}
		var rc_checked = false;
		for(rc=0;rc<document.frmApply.radCopy.length;rc++)
			if(document.frmApply.radCopy[rc].checked)
				rc_checked = true;
				
	 	if(!document.frmApply.radReport[0].checked)
		{
			if(document.frmApply.radService[0].checked)
			{
				alert("1 Business Day rush only available for General report");
				return false;
			}
		}
		
		
		if(!rc_checked)
		{
			alert("Please Select report copy option");
			document.frmApply.radCopy[0].focus();
			return false;				
		}	
		if(document.frmApply.txtCopies.value!="")
		{
			val=(document.frmApply.txtCopies.value);
			if(isNaN(val))
			{
				alert("Please enter valid No of report copies");
				document.frmApply.txtCopies.focus();
				return false;	
			}
		}
			if(document.frmApply.cboFaxcopy.value=="Yes")
			{
				if(document.frmApply.txtFaxnum.value=="")
				{ 
					alert("Please enter fax number");
					documnet.frmApply.txtFaxnum.focus();
					return false;
				}
				val=(document.frmApply.txtFaxnum.value);
				if(isNaN(val))
				{
					alert("Please enter valid Fax Number");
					document.frmApply.txtFaxnum.focus();
					return false;				
				}
			}
		if(document.frmApply.radCopy[1].checked)
		{
			if(document.frmApply.isAddress.value=="")
			{
				alert("Please enter mailing address(es)");
				return false;
			}
		}
	if((document.frmApply.txtCopies.value)<0 || isNaN(document.frmApply.txtCopies.value))
		document.frmApply.txtCopies.value = 0;
	
		document.frmApply.action = "template.php?opt="+chc;
		document.frmApply.submit();
	}
	else if(frm=="stp3")
	{
		if(document.frmApply.pe.value != "1")
		{
			alert('Please select purpose');
			return false;
		}
		if(document.frmApply.chkEducation.checked)
		{
			
			if(!document.frmApply.radEdutype[0].checked && !document.frmApply.radEdutype[1].checked && !document.frmApply.radEdutype[2].checked)
			{
				alert("Please select any eduction type");
				document.frmApply.radEdutype[0].focus();
				return false;
			}
			else if(document.frmApply.txtField_Study.value=="")
			{
				alert("Please enter Field of Study");
				document.frmApply.txtField_Study.focus();
				return false;
			}
			else if(document.frmApply.txtInstitution.value=="")
			{
				alert("Please enter Desired Institution");
				document.frmApply.txtInstitution.focus();
				return false;
			}
		}
		
		if(document.frmApply.chkLicense.checked)
		{
			if(document.frmApply.cboState.value=="")
			{
				alert("Please select state");
				document.frmApply.cboState.focus();
				return false;
			}
			else if(document.frmApply.txtProfession.value=="")
			{
				alert("Please enter Profession");
				document.frmApply.txtProfession.focus();
				return false;
			}
		}
		if(document.frmApply.chkOther.checked)
		{
			if(document.frmApply.txtOtherEdu.value=="")
			{
				alert("Please specify others");
				document.frmApply.txtOtherEdu.focus();
				return false;
			}
		}
		document.frmApply.action = "template.php?opt="+chc;
		document.frmApply.submit();
	}
	else if(frm=="stp4")
	{
		
		if(document.frmApply.isHistory.value=="")
		{
			alert("Please provide Education History Details");
			return false;
		}
		if(document.frmApply.chkUnderstood.checked=="")	
		{
			alert("Please review Required Documentation");
			document.frmApply.chkUnderstood.focus();
			return false;
		}
		if(document.frmApply.chkTerms.checked=="")	
		{
			alert("Please review Terms and Conditions");
			document.frmApply.chkTerms.focus();
			return false;
		}
		else
		{
			document.frmApply.action = "template.php?opt="+chc;
			document.frmApply.submit();
		}
	}

}
function goBack(where)
{
	document.frmApply.action = "template.php?go="+where;
	document.frmApply.submit();
}	
function addaddress(frm)
{
	if(document.frmAddress.txtName.value=="")
		{
			alert("Please enter Name");
			document.frmAddress.txtName.focus();
			return false;
		}
}

function display_alert(flag)
{
	if(flag == "chkEducation")
	{
		if(document.frmApply.chkNabp.checked)
		{
			if(confirm("NABP/PFGEC requires an application form that is specific to pharmacy applicanta.If you are requesting a report for NABP/PFGEC based on your pharmacy studies,then select \"OK\" to be switched to the NABP/PFGEC application form.If you are not requesting a report for NABP/PFGEC based on pharmacy studies,then slect \"Cancel\" to continue with the non-pharmacy application"))
			{
				document.frmApply.chkNabp.checked = true
				goBack('1&chkEdu=1')
			}
			else
			{		
				document.frmApply.chkNabp.checked = false
				return false;
			}
		}
		else if(!document.frmApply.chkNabp.checked)
		{
			if(confirm("NABP/PFGEC requires an application form that is specific to pharmacy applicanta.If you are requesting a report for NABP/PFGEC based on your pharmacy studies,then select \"OK\" to be switched to the NABP/PFGEC application form.If you are not requesting a report for NABP/PFGEC based on pharmacy studies,then slect \"Cancel\" to continue with the non-pharmacy application"))
			{
				document.frmApply.chkNabp.checked = true
				//goBack('1&chkEdu=1')
			}
			else
			{		
				document.frmApply.chkNabp.checked = false
				goBack('1&chkEdu=0')
			}			
		}
	}
}