// JavaScript Document

// JavaScript Document

function checkFormpost(form){

                 theform=document.frmpost;

				  if (theform.posttitle.value==""){ 

                     alert("Post Title is required!")

                     theform.posttitle.focus()

                     return false;

                }			

			

				if ((!theform.choose[0].checked) && (!theform.choose[1].checked)){

						alert("Either Zipcode or Country is required!")

						return false;

				}

					if(theform.choose[0].checked){

							if (theform.zipcode.value==""){

							 alert("Zipcode is required!")

							 theform.zipcode.focus()

							 return false;

						}

						

						if (isNaN(theform.zipcode.value)){ 

							 alert("Zipcode must be number!")

							 theform.zipcode.focus()

							 return false;

						}			

						if ((theform.zipcode.value).length<5){ 

							 alert("Zipcode must be five digit number!")

							 theform.zipcode.focus()

							 return false;

						}

				}

				if(theform.choose[1].checked){

							if (theform.country.value==""){

							 alert("Country is required!")

							 theform.country.focus()

							 return false;

						}

							if (!isNaN(theform.country.value)){ 

							 alert("Country should not be number!")

							 theform.country.focus()

							 return false;

						}	

				}	

				if(theform.choose[1].checked){
				if (theform.location.value==""){ 

                     alert("City/Town is required for country!")

                     theform.location.focus()

                     return false;

                }}

								  

                     if (theform.message_box.value==""){ 

                     alert(" Post details  is required!")

                     theform.message_box.focus()

                     return false;

                }

                     if (theform.notification.value==""){ 

                     alert("Choose notification level!")

                     theform.notification.focus()

                     return false;

                }

							 

				  if (theform.postcategory.value==""){ 

                     alert("Select Category is required!")

                     theform.postcategory.focus()

                     return false;

                }

				var chks = theform.elements['type[]'];		

				var hasChecked = false;

				for (var i=0;i<chks.length;i++){

				if (chks[i].checked){

				hasChecked = true;

				break;

				}

				}

				

				if (!hasChecked){

					alert("At least one type is required!");				

					return false;

				}

				

				

				

								/*if (theform.paymenttype.value==""){ 

                     alert("Select payment Type   is required")

                     theform.paymenttype.focus()

                     return false;

                }*/

				

				/*if (theform.verify_input.value==""){ 

                     alert("Image text is required")

                    theform.verify_input.focus()

                     return false;

                }*/

				

                    

     // Check that the form has an email specified in the field called "email"

		var emailaddress = theform.email.value;

		var emailexp = /^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))$/i;

		if (!emailexp.test(emailaddress)) { 

		alert('Email address is missing or invalid, please check your email address!')

		theform.email.focus();

		return false;

		}

							

						

		

		<!--

		//Validate Email

		function isEmail(strFieldName,strMsg)

		{

			 var strEmail = strFieldName.value;

			 var bolValid = true;

			 if(strEmail.length == 0){

				  bolValid = false;

			 }

			 if(strEmail.length < 7){

				  bolValid = false;

			 }

			 if(strEmail.lastIndexOf(" ") >0){

				  bolValid = false;

			 }

			 var intLastDot = strEmail.lastIndexOf(".")

			 if(intLastDot == -1 ||  strEmail.length - intLastDot >4){

				  bolValid = false;

			 }

			 var intAt = strEmail.lastIndexOf("@")

			 if(intAt == -1 ||  strEmail.length - intAt < 5){

				  bolValid = false;

			 }

			 if(! bolValid){

				  alert(strMsg.toUpperCase() +" is either empty or is not in the correct format");

					   strFieldName.focus();

					   }

			 return bolValid;

		}

		function validateForm(fObj){

			 if(!isEmail(fObj["email"],"email")){

				  return false;

			 }

			 return true;

		}



}
