//=======================================================================================================================
// Function: checkform
// Description: For Checking the Registration Form Details
//=======================================================================================================================
function checkform(form){

	with (form) {
		if (company_name.value == '') {
			alert("Please enter your company name. Thank you.");
			company_name.focus();
			return false;
		}
		
		if (mailing_address.value == '') {
			alert("Please enter your mailing address. Thank you.");
			//Name.focus();
			return false;
		} 
	
		if (city.value == '') {
			alert("Please enter your city. Thank you.");
			city.focus();
			return false;
		}
		
		
		if (zip.value == '') {
			alert("Please enter your company zip code. Thank you.");
			zip.focus();
			return false;
		}		
		
		if (state.value == '') {
			alert("Please enter your state. Thank you.");
			state.focus();
			return false;
		}
		
		if (Country.value == '') {
			alert("Please select your country. Thank you.");
			//PostCode.focus();
			return false;
		}

		if (tel.value == '') {
			alert("Please enter your telephone number. Thank you.");
			tel.focus();
			return false;
		}
		
		if (email.value == '') {
			alert("Please enter your email address. Thank you.");
			email.focus();
			return false;
		}
		else {
			if(!ValidEmail(email,"That is not a valid email address. Please check and try again. Thank you.", false)) {
				email.focus();
				return false;
			}
		}

		if (representative_name.value == '') {
			alert("Please enter your representative name. Thank you.");
			representative_name.focus();
			return false;
		}
		
		if (representative_designation.value == '') {
			alert("Please enter your representative designation. Thank you.");
			representative_designation.focus();
			return false;
		}


		if (representative_mobile.value == '') {
			alert("Please enter your representative mobile number. Thank you.");
			representative_mobile.focus();
			return false;
		}

		if (representative_email.value == '') {
			alert("Please enter your representative email address. Thank you.");
			representative_email.focus();
			return false;
		}
		else {
			if(!ValidEmail(representative_email,"That is not a valid representative email address. Please check and try again. Thank you.", false)) {
				representative_email.focus();
				return false;
			}
		}
		
		if (!(activity_manufacturer.checked) && !(activity_importer.checked)  && !(activity_serviceprovider.checked)
		&& !(activity_distributor.checked)  && !(activity_exporter.checked)  && !(activity_government.checked)
		 && !(activity_wholesaler.checked) && !(activity_wholesaler.checked) && !(activity_academic.checked)
		  && !(activity_agent.checked) && !(activity_retailer.checked) && !(activity_others.checked)) {
			alert("Please check at least one type of activities. Thank you.");			
			return false;
		}
		

	}
}



//====================================================================================================================
//--Function ValidCharacter (Client side validation)
//--Description:- To validate the sring; return true when input string contain only A-Z or a-z. Else return false.
//====================================================================================================================
function ValidCharacter(field, errormsg, focusOnError) { 
	var testresults = true;
	var re = /^[A-z-' ']*$/;
	
	if (!re.test(field.value)) { 
		alert(errormsg); 
		if (focusOnError == true) {
			field.focus();
		}
		//field.value = field.value.replace(/[^0-9-A-z]/g,""); 	
		testresults = false;
	} 
	return testresults;
}  

//====================================================================================================================
//--Function ValidEmail (Client side validation)
//--Description:- To Validate the email pattern
//====================================================================================================================
function ValidEmail(field, errormsg, focusOnError) {
	var str = field.value;
	var testresults = true;
	var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/;
	
	if (str != '') {
		if (filter.test(str)) {
			testresults = true;
			//return true;
		}
		else {
			alert(errormsg);
			testresults = false;
			//return false;
			if (focusOnError == true) {
				field.focus();
			}
		}
	}
	return testresults;
}