// JavaScript Document

/*****************************************************************************************************
 ** File Name : common-function.js
 ** Objective : This holds all the javascript functions of the site
 ** Created By : 
 ** Created On : 20/03/2009
 ****************************************************************************************************/

//Alert message for deleting a member
function memberDelete(id) {
	if(confirm("Are you sure to delete the member?")) {
	    document.form1.action="member.php?action1=delete&status=submit&member_id="+id;
		document.form1.submit();
 	}  
}

function paymentDelete(id,mid) {
	if(confirm("Are you sure to delete the payment history?")) {
	    document.form1.action="paymentHistory.php?action1=delete&status=submit&payment_id="+id+"&payment_memberId="+mid;
		document.form1.submit();
 	}
}

function adminDelete(id) {
	if(confirm("Are you sure to delete the admin?")) {
	    document.form1.action="admin.php?action1=delete&status=submit&admin_id="+id;
		document.form1.submit();
 	}  
}

function rewardCategoryDelete(id) {
	if(confirm("Are you sure to delete the reward category?")) {
	    document.form1.action="rewardCategory.php?action1=delete&status=submit&rewardCategory_id="+id;
		document.form1.submit();
 	}  
}

function rewardDelete(id,rCid) {
	if(confirm("Are you sure to delete the reward?")) {
	    document.form1.action="reward.php?action1=delete&status=submit&reward_id="+id+"&reward_catgId="+rCid;
		document.form1.submit();
 	}  
}

function transactionDelete(id,memid,deamt) {
	if(confirm("Are you sure to refund money for this transaction?")) {
	    document.form1.action="transaction.php?action1=delete&status=submit&wallet_transaction_id="+id+"&member_id="+memid;
		document.form1.submit();
 	}  
}

function productCategoryDelete(id) {
	if(confirm("Are you sure to delete the product category?")) {
	    document.form1.action="productCategory.php?action1=delete&status=submit&productCategory_id="+id;
		document.form1.submit();
 	}  
}

function productDelete(id,rCid) {
	if(confirm("Are you sure to delete the product?")) {
	    document.form1.action="product.php?action1=delete&status=submit&product_id="+id+"&product_catgId="+rCid;
		document.form1.submit();
 	}  
}

function loginValidate() {	
	if(TextValidate(document.frmLogin.txtMembershipNo,"Membership No.")== false) { return false; }
	if(TextValidate(document.frmLogin.txtPassword,"Password")== false) { return false; }
	
	//document.frmLogin.submit();
}

function forgotPasswordValidate() {	
	if(TextValidate(document.frmForgotPassword.txtemail,"Email Address")== false) { return false; }
	if(isEmail(document.frmForgotPassword.txtemail,"Email Address")== false) { return false; }
	if(TextValidate(document.frmForgotPassword.txtMembershipNo,"Membership No.")== false) { return false; }
	
	//document.frmLogin.submit();
}

function productCategoryValidate()
{
	if(TextValidate(document.frmproductCategory.txtProductCategory,"Product Category")== false) { return false; }
	
	if(document.frmproductCategory.action1.value == "Add"){
		document.frmproductCategory.action = "productCategory.php?status=submit";
	}else{
		document.frmproductCategory.action = "productCategory.php?status=submit&action1=edit";
	}
	document.frmproductCategory.submit();
}

function pageValidate()
{
	if(TextValidate(document.frmproductCategory.txtProductCategory,"Page Title")== false) { return false; }
	if(TextValidate(document.frmproductCategory.txtProductCategory1,"Page Title (Ind)")== false) { return false; }
	var editor_id = tinyMCE.getInstanceById('txtmemberarticle');
	if(Remove_Spaces_Editor((tinyMCE.getContent('txtmemberarticle')),editor_id,"Please enter a Description")==false) { return false; }
	var editor_id1 = tinyMCE.getInstanceById('txtmemberarticle1');
	if(Remove_Spaces_Editor((tinyMCE.getContent('txtmemberarticle1')),editor_id1,"Please enter a Description (Ind)")==false) { return false; }

	if(document.frmproductCategory.action1.value == "Add"){
		document.frmproductCategory.action = "viewPage.php?status=submit";
	}else{
		document.frmproductCategory.action = "viewPage.php?status=submit&action1=edit";
	}
	document.frmproductCategory.submit();
}

function productValidate() {	
	if(document.frmproduct.action1.value == "Add"){
		if(TextValidate(document.frmproduct.txtProductCode,"Product Code")==false) { return false;	}
		if(isAlphanum(document.frmproduct.txtProductCode.value)==false) { 
			alert('Please enter only alphanumeric characters');
			document.frmproduct.txtProductCode.focus();
			return false;
		}
	}
	
	if(TextValidate(document.frmproduct.txtProductName,"Product Name")==false) { return false;	}	
	
	var editor_id = tinyMCE.getInstanceById('txtProductDescription');
	if(Remove_Spaces_Editor((tinyMCE.getContent('txtProductDescription')),editor_id,"Please enter a Description")==false) { return false; }
	
	if(NumberValidate(document.frmproduct.txtProductStock,"Stock")==false) { return false;	}
	
	if(TextValidate(document.frmproduct.txtProductPrice,"Price")==false) { return false; }
	if(PriceValidateOnly(document.frmproduct.txtProductPrice,"Price")==false) { return false; }
	
	
	if(document.frmproduct.hidImage.value == ""){
		if(document.frmproduct.product_image.value == "") {
			alert("Please choose a image file to upload");
			document.frmproduct.product_image.focus();
			return false;
		}
		if(ImageFormatValidate(document.frmproduct.product_image)==false) { return false; }
	}
	else{		
		if(ImageFormatValidate(document.frmproduct.product_image)==false) { return false; }
	}
	
	if(document.frmproduct.action1.value == "Add"){
		document.frmproduct.action = "product.php?status=submit";		
	}else{
		document.frmproduct.action = "product.php?status=submit&action1=edit";
	}
	document.frmproduct.submit();
}

function rewardCategoryValidate()
{
	if(TextValidate(document.frmrewardCategory.txtRewardCategory,"Reward Category")== false) { return false; }
	
	if(document.frmrewardCategory.action1.value == "Add"){
		document.frmrewardCategory.action = "rewardCategory.php?status=submit";
	}else{
		document.frmrewardCategory.action = "rewardCategory.php?status=submit&action1=edit";
	}
	document.frmrewardCategory.submit();
}

function rewardValidate() {	
	if(document.frmreward.action1.value == "Add"){
		if(TextValidate(document.frmreward.txtRewardCode,"Reward Code")==false) { return false;	}
		if(isAlphanum(document.frmreward.txtRewardCode.value)==false) { 
			alert('Please enter only alphanumeric characters');
			document.frmreward.txtRewardCode.focus();
			return false;
		}
	}
	
	if(TextValidate(document.frmreward.txtRewardName,"Reward Name")==false) { return false;	}	
	
	var editor_id = tinyMCE.getInstanceById('txtRewardDescription');
	if(Remove_Spaces_Editor((tinyMCE.getContent('txtRewardDescription')),editor_id,"Please enter a Description")==false) { return false; }
	
	if(NumberValidate(document.frmreward.txtnoOfRewards,"No. of Rewards")==false) { return false;	}
	if(NumberValidate(document.frmreward.txtPoints,"Points")==false) { return false;	}
	
	if(document.frmreward.hidImage.value == ""){
		if(document.frmreward.reward_image.value == "") {
			alert("Please choose a image file to upload");
			document.frmreward.reward_image.focus();
			return false;
		}
		if(ImageFormatValidate(document.frmreward.reward_image)==false) { return false; }
	}
	else{		
		if(ImageFormatValidate(document.frmreward.reward_image)==false) { return false; }
	}
	
	if(document.frmreward.action1.value == "Add"){
		document.frmreward.action = "reward.php?status=submit";		
	}else{
		document.frmreward.action = "reward.php?status=submit&action1=edit";
	}
	document.frmreward.submit();
}


function transactionValidate() {	
	
	
	if(NumberValidate(document.frmtrans.txtPointsDeducted,"amount deducted")==false) { return false;	}
	
	if(document.frmtrans.txtPointsDeducted.value==0){
		alert("Please enter numeric value for amount deducted");
		document.frmtrans.txtPointsDeducted.focus();
		return false;
	}
	var editor_id = tinyMCE.getInstanceById('txtService');
	if(Remove_Spaces_Editor((tinyMCE.getContent('txtService')),editor_id,"Please enter Service")==false) { return false; }
	
	if(document.frmtrans.selcurrencytype.value=="SGD"){
		var balanceamount=document.frmtrans.txtbalancepointsinsgd.value;
	}
	if(document.frmtrans.selcurrencytype.value=="USD"){
		var balanceamount=document.frmtrans.txtbalancepointsinusd.value;
	}
	
	if(balanceamount=="" || balanceamount==0){
		alert("Deducted amount is higher than available balance");
		document.frmtrans.txtPointsDeducted.focus();
		return false;
	}
	
	if(parseInt(document.frmtrans.txtPointsDeducted.value)>parseInt(balanceamount)){
		alert("Deducted amount is higher than available balance");
		document.frmtrans.txtPointsDeducted.focus();
		return false;
	}
	
	if(document.frmtrans.action1.value == "Add"){
		document.frmtrans.action = "transaction.php?status=submit";		
	}else{
		document.frmtrans.action = "transaction.php?status=submit&action1=edit";
	}
	document.frmtrans.submit();
}

function paymentValidate()
{
	/*var editor_id = tinyMCE.getInstanceById('txtPaymentDesc');
	if(Remove_Spaces_Editor((tinyMCE.getContent('txtPaymentDesc')),editor_id,"Please enter Payment Description")==false) { return false; }*/
	if(TextValidate(document.frmpayment.txtPaymentDesc,"Payment Description")==false) { return false; }
	
	if(TextValidate(document.frmpayment.txtPaymentAmt,"Amount Paid")==false) { return false; }
	
	
	if(document.frmpayment.action1.value == "Add"){
		document.frmpayment.action = "paymentHistory.php?status=submit";		
	}else{
		document.frmpayment.action = "paymentHistory.php?status=submit&action1=edit";
	}
	document.frmpayment.submit();
}

function adminValidate() {	
	if(TextValidate(document.frmAdmin.txtAdminName,"Admin name")== false) { return false; }
	if(TextValidate(document.frmAdmin.txtAdminUsername,"User name")== false) { return false; }
	
	if(document.frmAdmin.action1.value == 'Add'){
		if(TextValidate(document.frmAdmin.txtAdminPassword,"Password")== false) { return false; }
		if(TextValidate(document.frmAdmin.txtAdminConfirmPassword,"Confirm password")== false) { return false; }
		if(Comparetextboxes(document.frmAdmin.txtAdminPassword,document.frmAdmin.txtAdminConfirmPassword)==false){return false;}
	}	
	
	if(document.frmAdmin.action1.value == "Add"){
		document.frmAdmin.action = "admin.php?status=submit";
	}else{
		document.frmAdmin.action = "admin.php?status=submit&action1=edit";
	}
	document.frmAdmin.submit();
}

function enrollPersonalValidate() {	
	
	if(document.frmenroll.member_type.value == "")
	{
		alert("Please select a Membership type");
		document.frmenroll.member_type.focus();
		return false;
	}
	
	if(document.frmenroll.member_type.value == "Corporate"){
	
		var txtcompanyname=document.getElementById("txtcompanyname").value;
		
		if(txtcompanyname==""){
			alert("Please enter the Company Name");
			document.getElementById("txtcompanyname").focus();
			return false;
		}
		
		if(document.getElementById("selassistancetype").value==""){
			alert("Please select the Assistance Type");
			document.getElementById("selassistancetype").focus();
			return false;
		}
		
		if(document.getElementById("chkdiving").checked==false && document.getElementById("chkmaritime").checked==false && document.getElementById("chktopside").checked==false && document.getElementById("chkoffshore").checked==false){
			alert("Please select the Support Type");
			document.getElementById("chkdiving").focus();
			return false;
		}
		
		if(document.getElementById("selregionsupport").value==""){
			alert("Please select the Region of Support");
			document.getElementById("selregionsupport").focus();
			return false;
		}
	}
	
	
	
	if(TextValidate(document.frmenroll.txtfname,"First Name")== false) { return false; }
	if(TextValidate(document.frmenroll.txtlname,"Last Name")== false) { return false; }
	if(OptValidate(document.frmenroll.elements.rdgender,"Gender")== false) { 
		document.getElementById('rdgender').focus();
		return false;
	}
	/*if(TextValidate(document.frmenroll.txtdob,"Date of Birth")== false) { return false; }*/
	if(document.frmenroll.member_date.value == "")
	{
		alert("Please select a Date");	
		document.frmenroll.member_date.focus();
		return false;
	}
	if(document.frmenroll.member_month.value=="")
	{
		alert("Please select a Month");	
		document.frmenroll.member_month.focus();
		return false;
	}
	if(document.frmenroll.member_year.value=="")
	{
		alert("Please select a Year");	
		document.frmenroll.member_year.focus();
		return false;
	}
	//if(TextValidate(document.frmenroll.txthomeaddr1,"Home Address")== false) { return false; }	
	if(TextValidate(document.frmenroll.txthomepostalcode,"Post Code")== false) { return false; }
	if(document.frmenroll.member_country.value == 0)
	{
		alert("Please select a Country");
		document.frmenroll.member_country.focus();
		return false;
	}
	
	
	
	if(document.frmenroll.member_country.value == 'US' || document.frmenroll.member_country.value == 'CA')
		if(SelectValidate(document.frmenroll.selHomeState,"State")== false) { return false; }
	if(TextValidate(document.frmenroll.txtcityHome,"City")== false) { return false; }		
	if(NumberValidate(document.frmenroll.txtcontactno,"Contact Telephone")== false) { return false; }
	if(document.frmenroll.txteveningno.value) if(NumberValidateOnly(document.frmenroll.txteveningno,"Evening Telephone")== false) { return false; }
	if(document.frmenroll.txtfmobileno.value) if(NumberValidateOnly(document.frmenroll.txtfmobileno,"Mobile Telephone")== false) { return false; }
	if(TextValidate(document.frmenroll.txtemail,"Email Address")== false) { return false; }
	if(document.frmenroll.txtemail.value) if(isEmail(document.frmenroll.txtemail,"Email Address")== false) { return false; }
	
	
	
	if(document.frmenroll.member_type.value == 'Corporate'){
		document.frmenroll.action="register1.php?statype=c";
		document.frmenroll.submit();
	}else{
		document.frmenroll.action="register1.php";
		document.frmenroll.submit();
	}
	
	//document.frmenroll.submit();
}

// To validate jobs form fields
function enrollFamilyValidate() { 

	if(document.frmenroll.chkFather.checked){
		if(TextValidate(eval('document.frmenroll.txtfathfname'),"Name - Father")== false) { return false; }
	}
	
	if(document.frmenroll.chkMother.checked){
		if(TextValidate(eval('document.frmenroll.txtmothfname'),"Name - Mother")== false) { return false; }
	}
	
	if(document.frmenroll.chkSpouse.checked){
		if(TextValidate(document.frmenroll.txtspfname,"First Name - Spouse")== false) { return false; }
		if(TextValidate(document.frmenroll.txtsplname,"Last Name - Spouse")== false) { return false; }
		if(OptValidate(document.frmenroll.elements.rdspgender,"Gender - Spouse")== false) { 
			document.getElementById('rdspgender').focus();		
			return false; 
		}
		if(document.frmenroll.sp_date.value == "")
		{
			alert("Please select a Date");	
			document.frmenroll.sp_date.focus();
			return false;
		}
		if(document.frmenroll.sp_month.value=="")
		{
			alert("Please select a Month");	
			document.frmenroll.sp_month.focus();
			return false;
		}
		if(document.frmenroll.sp_year.value=="")
		{
			alert("Please select a Year");	
			document.frmenroll.sp_year.focus();
			return false;
		}
		//if(TextValidate(document.frmenroll.txtspdob,"Date of Birth - Spouse")== false) { return false; }
		if(OptValidate(document.frmenroll.elements.rdspmembershipcard,'"Membership Card?" - Spouse')== false) { 
			document.getElementById('rdspmembershipcard').focus();				
			return false; 
		}
	}
	
	var num = parseInt(document.frmenroll.txtChildNum.value);
	var i;
	if(num > 0){
		for(i=1;i<=num;i++)	{
			/*if(TextValidate(document.getElementById('txtchfname_'+i),"First Name - Child "+i)== false) { return false; }
			if(TextValidate(document.getElementById('txtchlname_'+i),"Last Name - Child "+i)== false) { return false; }
			if(OptValidate(document.getElementById('rdspgender_'+i),"Gender - Child "+i)== false) { return false; }
			if(OptValidate(document.getElementById('rdfulltime_'+i),'"Full-Time Student?" - Child '+i)== false) { return false; }	
			if(TextValidate(document.getElementById('txtchdob_'+i),"Date of Birth - Child "+i)== false) { return false; }
			if(OptValidate(document.getElementById('rdchmembershipcard_'+i),'"Membership Card?" - Child '+i)== false) { return false; }*/
			
			if(TextValidate(eval("document.frmenroll.txtchfname_"+i),"First Name - Child "+i)== false) { 
				return false; 
			}
			if(TextValidate(eval("document.frmenroll.txtchlname_"+i),"Last Name - Child "+i)== false) {
				return false; 
			}
			if(OptValidate(eval("document.frmenroll.elements.rdchgender_"+i),"Gender - Child "+i)== false) { 
				objgender = 'rdchgender_' + i ;
				document.getElementById(objgender).focus();
				return false; 
			}
			if(OptValidate(eval("document.frmenroll.elements.rdfulltime_"+i),'"Full-Time Student?" - Child '+i)== false) { 
				objfull = 'rdfulltime_' + i ;
				document.getElementById(objfull).focus();				
				return false; 
			}	
			/*if(TextValidate(eval("document.frmenroll.txtchdob_"+i),"Date of Birth - Child "+i)== false) { 
				return false; 
			}*/
			//alert(document.getElementById("txtchdat_"+i).value);
			if(document.getElementById("txtchdat_"+i).value == "")
			{
				alert("Please select a Date");
				document.getElementById("txtchdat_"+i).focus();
				return false;
			}
			if(document.getElementById("txtchmon_"+i).value == "")
			{
				alert("Please select a Month");
				document.getElementById("txtchmon_"+i).focus();
				return false;
			}
			if(document.getElementById("txtchyear_"+i).value == "")
			{
				alert("Please select a Year");
				document.getElementById("txtchyear_"+i).focus();
				return false;
			}
			/*if(document.frmenroll.txtchmon_+i.value == "")
			{
				alert("Please select a Month");
				document.frmenroll.txtchmon_+i.focus();
				return false;
			}
			if(document.frmenroll.txtchyear_+i.value == "")
			{
				alert("Please select a Year");
				document.frmenroll.txtchyear_+i.focus();
				return false;
			}*/
			if(OptValidate(eval("document.frmenroll.elements.rdchmembershipcard_"+i),'"Membership Card?" - Child '+i)== false) { 
				objshipcard = 'rdchmembershipcard_' + i ;
				document.getElementById(objshipcard).focus();								
				return false; 
			}
		}
	}
	
	//document.frmenroll.submit();
}

function contactEditValidate() {	

	// Validate Personal details
	
	if(TextValidate(document.frmenroll.txtfname,"First Name")== false) { return false; }
	if(TextValidate(document.frmenroll.txtlname,"Last Name")== false) { return false; }
	//if(TextValidate(document.frmenroll.txthomeaddr1,"Home Address")== false) { return false; }	
	if(TextValidate(document.frmenroll.txthomepostalcode,"Post Code")== false) { return false; }
	if(document.frmenroll.member_country.value == 0)
	{
		alert("Please select a Country");
		document.frmenroll.member_country.focus();
		return false;
	}
	if(document.frmenroll.member_country.value == 'US' || document.frmenroll.member_country.value == 'CA')
		if(SelectValidate(document.frmenroll.selHomeState,"State")== false) { return false; }
	if(TextValidate(document.frmenroll.txtcityHome,"City")== false) { return false; }		
	if(NumberValidate(document.frmenroll.txtcontactno,"Contact Telephone")== false) { return false; }
	if(document.frmenroll.txteveningno.value) if(NumberValidateOnly(document.frmenroll.txteveningno,"Evening Telephone")== false) { return false; }
	if(document.frmenroll.txtfmobileno.value) if(NumberValidateOnly(document.frmenroll.txtfmobileno,"Mobile Telephone")== false) { return false; }
	if(TextValidate(document.frmenroll.txtemail,"Email Address")== false) { return false; }
	if(document.frmenroll.txtemail.value) if(isEmail(document.frmenroll.txtemail,"Email Address")== false) { return false; }

}

// To validate change password form fields
function changePwdvalidate()
{
	var form_name=document.frmpassword;
	if(TextValidate(form_name.admin_username,"User Name")==false){return false;}
	if(TextValidate(form_name.old_password,"Old Password")==false){return false;}
	if(TextValidate(form_name.new_password,"New Password")==false){return false;}
	if(TextValidate(form_name.confirm_password,"Confirm Password")==false){return false;}
	if(Comparetextboxes(form_name.new_password,form_name.confirm_password)==false){return false;}
	//document.frmpassword.action = "admin_home.php";
	//document.frmpassword.submit();
}
function checktype()
{
	
	if(document.frmenroll.member_type.value == "Individual")
	{
		document.frmenroll.check_type_hidden.value = 1;
	}else{
		document.frmenroll.check_type_hidden.value = 0;	
	}
	
	if(document.frmenroll.member_type.value == "Corporate")
	{
		document.getElementById("companyname").style.display="";
		document.getElementById("affiliateof").style.display="";
		document.getElementById("assitancetype").style.display="";
		document.getElementById("supporttype").style.display="";
		document.getElementById("regionofsupport").style.display="";
		document.getElementById("membershipfee").style.display="";
		document.getElementById("companydirectorparticulars").style.display="";
		document.getElementById("checkbutton").style.display="";
		document.getElementById("nextbutton").style.display="none";
	}else{
		
		document.getElementById("companyname").style.display="none";
		document.getElementById("affiliateof").style.display="none";
		document.getElementById("assitancetype").style.display="none";
		document.getElementById("supporttype").style.display="none";
		document.getElementById("regionofsupport").style.display="none";
		document.getElementById("membershipfee").style.display="none";
		document.getElementById("companydirectorparticulars").style.display="none";
		document.getElementById("nextbutton").style.display="";
		document.getElementById("checkbutton").style.display="none";
	}
}

function checkOffshore()
{
	if(document.getElementById("chkoffshore").checked==true){
		document.getElementById("chkdiving").disabled=true;
		document.getElementById("chkdiving").checked=false;
		document.getElementById("chkmaritime").disabled=true;
		document.getElementById("chkmaritime").checked=false;
		document.getElementById("chktopside").disabled=true;
		document.getElementById("chktopside").checked=false;
	}else{
		document.getElementById("chkdiving").disabled=false;
		document.getElementById("chkmaritime").disabled=false;
		document.getElementById("chktopside").disabled=false;
	}
}

function checkMembershipFee(){
	var xmlhttp;
	var selassistancetype=document.getElementById("selassistancetype").value;
	var selregionsupport=document.getElementById("selregionsupport").value;
	var txtcompanyname=document.getElementById("txtcompanyname").value;
	if(txtcompanyname==""){
		alert("Please enter the Company Name");
		document.getElementById("txtcompanyname").focus();
		return false;
	}
	
	if(document.getElementById("chkdiving").checked==true){
		var chkdiving=document.getElementById("chkdiving").value;
	}else{
		var chkdiving="";
	}
	
	if(document.getElementById("chkmaritime").checked==true){
		var chkmaritime=document.getElementById("chkmaritime").value;
	}else{
		var chkmaritime="";
	}
	
	if(document.getElementById("chktopside").checked==true){
		var chktopside=document.getElementById("chktopside").value;
	}else{
		var chktopside="";
	}
	
	if(document.getElementById("chkoffshore").checked==true){
		var chkoffshore=document.getElementById("chkoffshore").value;
	}else{
		var chkoffshore="";
	}
	
	if(selassistancetype==""){
		alert("Please select the Assistance Type");
		document.getElementById("selassistancetype").focus();
		return false;
	}
	
	if(chkdiving=="" && chkmaritime=="" && chktopside=="" && chkoffshore==""){
		alert("Please select the Support Type");
		document.getElementById("chkdiving").focus();
		return false;
	}
	
	if(selregionsupport==""){
		alert("Please select the Region of Support");
		document.getElementById("selregionsupport").focus();
		return false;
	}
	
	if(window.XMLHttpRequest){
			//Intiate the object
			xmlhttp = new XMLHttpRequest();				
	}
	// If the user is using IE
	else if (window.ActiveXObject) { 
			//Intiate the object
			  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	var url = 'checkmemberfee.php?selassistancetype='+selassistancetype+'&selregionsupport='+selregionsupport+'&chkdiving='+chkdiving+'&chkmaritime='+chkmaritime+'&chktopside='+chktopside+'&chkoffshore='+chkoffshore;	
		//alert(url);
		xmlhttp.open('GET', url, true);
		//Check that the PHP script has finished sending us the result
		xmlhttp.onreadystatechange = function() {
				if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
					//Replace the content of the "result" DIV with the result returned by the PHP script
					var response     = xmlhttp.responseText;
					if(response!=""){
						document.getElementById("membershiptotalfee").innerHTML="&nbsp;$"+response;
						document.getElementById("txtmembershipfee").value=response;
					}
				}
		}
	xmlhttp.send(null);	
	
}



var xmlHttp;

function listStates(val, ctrlname, container)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null){
	 alert ("Browser does not support HTTP Request");
	 return;
	}

	var url="listStates.php";
	url=url+"?countryCode="+val;
	url=url+"&ctrl="+ctrlname;
	url=url+"&container="+container;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4){
			 //alert(xmlHttp.responseText);
			 var result = xmlHttp.responseText;
			 var arrSplit = result.split('$$');
			 if(arrSplit[0] != ''){
				document.getElementById("trState"+container).style.display = '';
			 	document.getElementById("tdState"+container).innerHTML = '&nbsp;'+arrSplit[0];
			 }else if(arrSplit[1] != ''){
				document.getElementById("trState"+container).style.display = 'none'; 
				document.getElementById("divCity"+container).innerHTML = '&nbsp;'+arrSplit[1];
			 }
		 } 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function listTerritories(val, container)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null){
	 alert ("Browser does not support HTTP Request");
	 return;
	}
	if(container == 'Mail')var country = 'Alt';else var country = '';
		var countryCode = eval('document.frmenroll.member_country'+country).options[eval('document.frmenroll.member_country'+country).selectedIndex].value;
		
	var url="listTerritories.php";
	url=url+"?stateCode="+val;
	url=url+"&countryCode="+countryCode;
	url=url+"&container="+container;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4){
			 //alert(xmlHttp.responseText);
			 var result = xmlHttp.responseText;
			 if(result != '')
			 	document.getElementById("divCity"+container).innerHTML = result;
		 }
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	try{
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
	}catch (e){
		 //Internet Explorer
		 try{
		  	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e){
		 	 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
	}
	return xmlHttp;
}

function assignValue(selectbox, hiddenfield)
{
	var territory = selectbox.options[selectbox.selectedIndex].text;
	hiddenfield.value = territory;
}

function resetFilter()
{
	document.frmSearch.txtMembershipNo.value = '';
	document.frmSearch.selMemberType.options[0].selected = true;
	document.frmSearch.txtMemberName.value = '';
	document.frmSearch.txtAge.value = '';
	
	document.frmSearch.submit();
}

function checkOutNow()
{
	if(document.getElementById("txtaddamt").value=="")
	{
		alert("Please enter wallet amount");
		document.getElementById("txtaddamt").focus();
		return false;
	}
	if(document.getElementById("txtaddamt").value==0){
		alert("Please enter valid amount");
		document.getElementById("txtaddamt").focus();
		return false;
	}
	if(isNaN(document.getElementById("txtaddamt").value))
	{
		alert("Please enter valid amount");
		document.getElementById("txtaddamt").focus();
		return false;
	}
	var limitAmt = 15000;
	if(document.getElementById("currencyCodeType").value=='USD') limitAmt = 9000;
	if(document.getElementById("txtaddamt").value>limitAmt){
		alert("You are limited to only a maximum of $"+limitAmt+" per transaction.");
		document.getElementById("txtaddamt").focus();
		return false;
	}
	document.frmcheckout.submit();
	
}

function enterPress(e)
{
	if(window.event){ // IE
		var unicode = e.keyCode;
		if (unicode!=8 && unicode !=9)
		{ 
			if (unicode<48 || unicode>57) 
				return false ;
		}
		
	}else if(e.which){ // Netscape/Firefox/Opera
		var unicode=e.charCode? e.charCode : e.keyCode;
		if (unicode!=8 && unicode !=9 && e.keyCode !=46 && e.keyCode !=39 && e.keyCode !=37 && e.keyCode !=116)
		{ 
			if (unicode<48 || unicode>57) 
				return false ;
		}
	}
}
