function chknotnull(x)
{
	myflag=false
	if (x=="")
		return false;
	else
	{
		for (N=0;N<x.length;N++)
		{
			if (x.charAt(N).indexOf(" ")<0)
				myflag=true;
		}
		return myflag;
	}
return true;
}


function limitme(field,maxlen) 
{
  var max = maxlen;

  if (field.value.length > max) 
  {
    alert("Please do not enter more than " + max + " characters.");
    field.value = field.value.substring(0, max);
  }
}

function isan(string){
    if (string.length == 0)
        return false;
    for (var i=0;i < string.length;i++){
        if ((string.substring(i,i+1) < '0') || (string.substring(i,i+1) > '9'))
            return false;
    }
    return true;
}


function payment_receive()
{

		
	if (document.form1.TotalAmountReceived.value=="")
	{
		alert("Please enter the total amount you received.");
		document.form1.TotalAmountReceived.focus();
		return false;
	}

	if (!parseFloat(document.form1.TotalAmountReceived.value))
	{
		alert("Please enter a valid total amount you received.");
		document.form1.TotalAmountReceived.focus();
		return false;
	}

	if (document.form1.Gst_Rate.value==0)
	{
		if (!document.form1.TotalGSTReceived.value=="")
		{
			alert("Please note that GST is only applicable for Singapore delegates.");
			return false;
		}
	}

	if (document.form1.Gst_Rate.value>0)
	{
		if (document.form1.TotalGSTReceived.value=="")
		{
			alert("Please enter the total GST you received.");
			document.form1.TotalGSTReceived.focus();
			return false;
		}

		if (!parseFloat(document.form1.TotalGSTReceived.value))
		{
			alert("Please enter a valid total GST you received.");
			document.form1.TotalGSTReceived.focus();
			return false;
		}
	}




	var a = parseFloat(document.form1.TotalAmountReceived.value)
	
	if (document.form1.TotalGSTReceived.value=="")
	{
		var totalReceive = a
	}
	else
	{
		var b = parseFloat(document.form1.TotalGSTReceived.value)
		var totalReceive = a + b
	}



	if (document.form1.OutstandingAmount.value < totalReceive)
	{
		alert("Amount received exceeded the outstanding amount!");
		document.form1.TotalAmountReceived.focus();
		return false;
	}



	if (!document.form1.BankCharge.value=="")
	{
		if (!parseFloat(document.form1.BankCharge.value))
		{
			alert("Please enter a valid bank charge.");
			document.form1.BankCharge.focus();
			return false;
		}
	}

	if (document.form1.PaymentType.selectedIndex == 0)
	{
		alert("Please select payment type.");
		document.form1.PaymentType.focus();
		return (false);
	}


	if (document.form1.PaymentDate.value=="")
	{
		alert("Please enter the payment date.");
		document.form1.PaymentDate.focus();
		return false;
	}




	return (true);

}


function remove_Conf_Visit_Accompanying()
{
	document.getElementById('Conf_Visit_Accompanying').checked = false;
	document.form1.AccompanyingPersonName.disabled=true;
	document.form1.vegetarian_Accompanying.disabled=true;
	document.form1.halal_Accompanying.disabled=true;
}

function getInfo()
{
	document.getElementById('BillingContactPerson').value = document.form1.NamePassport.value
	document.getElementById('BillingAddress').value = document.form1.MailingAddress.value + " " + document.form1.Country.value + " " + document.form1.Postal.value
}


function Click_Accompanying()
{
	document.form1.AccompanyingPersonName.disabled=false;
	document.form1.vegetarian_Accompanying.disabled=false;
	document.form1.halal_Accompanying.disabled=false;
}

function payment_check()
{
	if ((document.form1.payment[0].checked == false) &&(document.form1.payment[1].checked == false) &&(document.form1.payment[2].checked == false))
	{
		alert("Please indicate your payment mode");
		document.form1.payment[0].focus();
		return false;
	}
	return (true);
}


function EditValidation()
{
	if (document.form1.Title.selectedIndex == 0)
	{
		alert("Please enter your title.");
		document.form1.Title.focus();
		return (false);
	}

	if (document.form1.NamePassport.value == "")
	{
		alert("Please enter your full name as in passport.");
		document.form1.NamePassport.focus();
		return (false);
	}

	if (document.form1.NameBadge.value == "")
	{
		alert("Please enter your preferred name on badge.");
		document.form1.NameBadge.focus();
		return (false);
	}

	if (document.form1.Nationality.value == "")
	{
		alert("Please enter your nationality.");
		document.form1.Nationality.focus();
		return (false);
	}

	if (document.form1.JobTitle.value == "")
	{
		alert("Please enter your job title.");
		document.form1.JobTitle.focus();
		return (false);
	}

	if (document.form1.Organisation.value == "")
	{
		alert("Please enter your organisation.");
		document.form1.Organisation.focus();
		return (false);
	}


	if (document.form1.MailingAddress.value == "")
	{
		alert("Please enter your mailing address.");
		document.form1.MailingAddress.focus();
		return (false);
	}



	if (document.form1.Postal.value == "")
	{
		alert("Please enter your postal code.");
		document.form1.Postal.focus();
		return (false);
	}


	if (document.form1.TelephoneCCode.value == "")
	{
		alert("Please enter your country code.");
		document.form1.TelephoneCCode.focus();
		return (false);
	}

	if (document.form1.TelephoneNum.value == "")
	{
		alert("Please enter your telephone no.");
		document.form1.TelephoneNum.focus();
		return (false);
	}




	if (document.form1.Email.value == "") 
	{
		alert("Please enter your email address.");
		document.form1.Email.focus();
		return (false);
	}


	if ((document.form1.Email.value.indexOf("@") == -1) || (document.form1.Email.value.indexOf(".")==-1) || (document.form1.Email.value.indexOf(" ")>1) || (document.form1.Email.value.indexOf(",")>0))
	{
		alert("Please enter a valid email address.");
		document.form1.Email.focus();
		return (false);
	}

	return (true);
}



function validation()
{
	if (document.form1.Title.selectedIndex == 0)
	{
		alert("Please enter your title.");
		document.form1.Title.focus();
		return (false);
	}

	if (document.form1.NamePassport.value == "")
	{
		alert("Please enter your full name as in passport.");
		document.form1.NamePassport.focus();
		return (false);
	}

	if (document.form1.NameBadge.value == "")
	{
		alert("Please enter your preferred name on badge.");
		document.form1.NameBadge.focus();
		return (false);
	}

	if (document.form1.Nationality.value == "")
	{
		alert("Please enter your nationality.");
		document.form1.Nationality.focus();
		return (false);
	}

	if (document.form1.JobTitle.value == "")
	{
		alert("Please enter your job title.");
		document.form1.JobTitle.focus();
		return (false);
	}

	if (document.form1.Organisation.value == "")
	{
		alert("Please enter your organisation.");
		document.form1.Organisation.focus();
		return (false);
	}


	if (document.form1.MailingAddress.value == "")
	{
		alert("Please enter your mailing address.");
		document.form1.MailingAddress.focus();
		return (false);
	}



	if (document.form1.Country.selectedIndex == 0)
	{
		alert("Please enter your country.");
		document.form1.Country.focus();
		return (false);
	}

	if (document.form1.Postal.value == "")
	{
		alert("Please enter your postal code.");
		document.form1.Postal.focus();
		return (false);
	}


	if (document.form1.TelephoneCCode.value == "")
	{
		alert("Please enter your country code.");
		document.form1.TelephoneCCode.focus();
		return (false);
	}

	if (document.form1.TelephoneNum.value == "")
	{
		alert("Please enter your telephone no.");
		document.form1.TelephoneNum.focus();
		return (false);
	}




	if (document.form1.Email.value == "") 
	{
		alert("Please enter your email address.");
		document.form1.Email.focus();
		return (false);
	}


	if ((document.form1.Email.value.indexOf("@") == -1) || (document.form1.Email.value.indexOf(".")==-1) || (document.form1.Email.value.indexOf(" ")>1) || (document.form1.Email.value.indexOf(",")>0))
	{
		alert("Please enter a valid email address.");
		document.form1.Email.focus();
		return (false);
	}


	if (document.form1.BillingContactPerson.value == "") 
	{
		alert("Please enter your contact person for billing.");
		document.form1.BillingContactPerson.focus();
		return (false);
	}

	if (document.form1.BillingAddress.value == "") 
	{
		alert("Please enter your billing address.");
		document.form1.BillingAddress.focus();
		return (false);
	}


	if (!document.form1.Conf_Special.value=="")
	{
		if ((document.form1.Conf_Visit[0].checked == true) || (document.form1.Conf_Visit[1].checked == true) || (document.form1.Conf_Visit[2].checked == true) || (document.form1.Conf_Visit[3].checked == true) || (document.form1.Conf_Visit[4].checked == true) || (document.form1.Conf_Visit_Accompanying.checked == true))
		{
			alert("Please note that options 1 -4 are unavailable if you choose to fill in the special fees  field.");
			document.form1.Conf_Special.focus();
			return false;
		}
	}

	if (!document.form1.Conf_Special.value=="")
	{
		if (!parseFloat(document.form1.Conf_Special.value))
		{
			alert("Please enter a valid special fees value");
			document.form1.Conf_Special.focus();
			return false;
		}
	}

	if (!document.form1.Conf_Special.value=="")
	{
		if (document.form1.Conf_SpecialRemarks.value=="")
		{
			alert("Please fill in special fees remark");
			document.form1.Conf_SpecialRemarks.focus();
			return false;
		}
	}




	if ((document.form1.Conf_Visit[0].checked == false) &&(document.form1.Conf_Visit[1].checked == false) &&(document.form1.Conf_Visit[2].checked == false) &&(document.form1.Conf_Visit[3].checked == false) && (document.form1.Conf_Visit[4].checked == false) && document.form1.Conf_Special.value=="")
	{
		alert("Which conference(s) are you attending?");
		document.form1.Conf_Visit[0].focus();
		return false;
	}


	if (document.form1.LAS_IFLA_Check.value=="")
	{
		if ((document.form1.Conf_Visit[0].checked == true) ||(document.form1.Conf_Visit[3].checked == true))
		{
			if (document.form1.IFLAMembershipNo.value == "")
			{
				alert("Please enter your IFLA membership no.");
				document.form1.IFLAMembershipNo.focus();
				return false;
			}
		}
	}
	else
	{
		if (document.form1.Conf_Visit[0].checked == true)
		{
			if (document.form1.IFLAMembershipNo.value == "")
			{
				alert("Please enter your IFLA membership no.");
				document.form1.IFLAMembershipNo.focus();
				return false;
			}
		}
	}




	if ((document.form1.Conf_Visit[3].checked == true) ||(document.form1.Conf_Visit[4].checked == true))
	{
		if (document.form1.LASMembershipNo.value == "")
		{
			alert("Please enter your LAS membership no.");
			document.form1.LASMembershipNo.focus();
			return false;
		}
	}


	if (document.form1.Conf_Visit[2].checked == true)
	{
		if (document.form1.StudentMatriculationNumber.value == "")
		{
			alert("Please enter your student matriculation number");
			document.form1.StudentMatriculationNumber.focus();
			return false;
		}
	}



	if (document.form1.Conf_Visit_Accompanying.checked == true)
	{
		if (document.form1.AccompanyingPersonName.value == "")
		{
			alert("Please enter name of accompanying person");
			document.form1.AccompanyingPersonName.focus();
			return false;
		}
	}




	if ((document.form1.SocialEvents28_Oct[0].checked == false) &&(document.form1.SocialEvents28_Oct[1].checked == false))
	{
		alert("Please indicate your attendance for 28 October 2007 Social Events");
		document.form1.SocialEvents28_Oct[0].focus();
		return false;
	}


	if ((document.form1.SocialEvents29_Oct[0].checked == false) &&(document.form1.SocialEvents29_Oct[1].checked == false))
	{
		alert("Please indicate your attendance for 29 October 2007 Social Events");
		document.form1.SocialEvents29_Oct[0].focus();
		return false;
	}

	if ((document.form1.SocialEvents30_Oct[0].checked == false) &&(document.form1.SocialEvents30_Oct[1].checked == false))
	{
		alert("Please indicate your attendance for 30 October 2007 Social Events");
		document.form1.SocialEvents30_Oct[0].focus();
		return false;
	}

	if ((document.form1.LibaryTour28_Oct[0].checked == false) &&(document.form1.LibaryTour28_Oct[1].checked == false))
	{
		alert("Please indicate your attendance for 28 October 2007 Library Tours");
		document.form1.LibaryTour28_Oct[0].focus();
		return false;
	}

	if ((document.form1.LibaryTour30_Oct[0].checked == false) &&(document.form1.LibaryTour30_Oct[1].checked == false) &&(document.form1.LibaryTour30_Oct[2].checked == false) &&(document.form1.LibaryTour30_Oct[3].checked == false))
	{
		alert("Please indicate your attendance for 30 October 2007 Library Tours");
		document.form1.LibaryTour30_Oct[3].focus();
		return false;
	}

	if ((document.form1.LibaryTour31_Oct[0].checked == false) &&(document.form1.LibaryTour31_Oct[1].checked == false) &&(document.form1.LibaryTour31_Oct[2].checked == false) &&(document.form1.LibaryTour31_Oct[3].checked == false))
	{
		alert("Please indicate your attendance for 31 October 2007 Library Tours");
		document.form1.LibaryTour31_Oct[3].focus();
		return false;
	}


	if ((document.form1.vegetarian_Self.checked == true) &&(document.form1.halal_Self.checked == true))
	{
		alert("you can choose either the vegetarian or Halal meal for yourself");
		document.form1.vegetarian_Self.focus();
		return false;
	}

	if ((document.form1.vegetarian_Accompanying.checked == true) &&(document.form1.halal_Accompanying.checked == true))
	{
		alert("you can choose either the vegetarian or Halal meal for your accompanying person");
		document.form1.vegetarian_Accompanying.focus();
		return false;
	}


	if (document.form1.AgreeTerms.checked == false)
	{
		alert("You have to read, understood and accept the terms and conditions of this registration and the cancellation and refund policy before you can proceed with the submission.");
		document.form1.AgreeTerms.focus();
		return false;
	}


	return (true);
}




function selOther(objSel, objOther)
{
    if (objSel.selectedIndex == objSel.options.length-1) {
        //objOther.style = ""
        objOther.disabled = false
    } else {
        //objOther.style = "HiddenInput"
        objOther.value = ""
        objOther.disabled = true;
    }
}

function unselectable(index)
{

 alert("Country cannot be changed for other delegates.") 
 document.form1.Country.value = index

}

function addDelegate()
{
	document.form1.action = "add_navig.asp?type=collect";
	document.form1.submit();	
}

function editDelegate(strhref)
{
	document.form1.action = strhref;
	document.form1.submit();	
}

function clearDelegate()
{
	document.form1.action = "reg_summit.asp?clear=delegate";
	document.form1.submit();	
}

function goToURL(id, regno) { window.location = "show_costs.asp?id="+id+"&regno="+regno ; }
