//For Email box
var emailfilter=/^\w+[\+\.\w-]*@([\w-]+\.)*\w+[\w-]*\.([a-z]{2,4}|\d+)$/i
function checkmail(e){
var returnval=emailfilter.test(e.value)
if (returnval==false){
alert("Please enter a valid email address.")
e.select()
}
return returnval
}	
//End Email box



//====================Start Form Reset====================

function setValue()
{
       //alert('here');
	   
	   
       if(document.formcheck.Name.value=="Enter your name") 
	   {
		      //alert('heredfgdfgfdg');
	          document.formcheck.Name.value="";
			  document.formcheck.Name.focus();
			  return false;	   
	   }	   	   
       if(document.formcheck.Name.value!="Enter your name")
	   {
	          
		      return true;
	   }
	   
}

function setValue1()
{
       //alert('seach section ');
	   
	   
       if(document.formSearch.Search.value=="Search") 
	   {
	          document.formSearch.Search.value="";
			  document.formSearch.Search.focus();
			  return false;	   
	   }	   	   
       if(document.formSearch.Search.value!="Search")
	   {
	          
		      return true;
	   }
	   
}
   
  function setValue2()
   {
	     // alert('your comment section ');
	     
	    if(document.formcheck.comments.value=="Your comments...")
	   {
		      // alert('fgsdbgdgbfdgd');
	           document.formcheck.comments.value="";			
			   document.formcheck.comments.focus();
			   return false;
	   }	   
       else if(document.formcheck.comments.value!="Your comments...")
	   {
	        return true;
	   }
	   
}
   
   
//====================End Form Reset====================





function formCheck(formobj)
{
	// Enter name of mandatory fields
	//alert('i am in form check');
	var fieldRequired = Array("Name", "Address", "myemail", "comments");
	
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Name", "Address",  "myemail", "comments");
	
	// dialog message
	var alertMsg = "Please complete the following fields:\n";
	
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}


		//Added for non numeric phone no checking

    if(document.formcheck.Phone.value=="")
	{
	    alert('Please enter the  phone no.');
		document.formcheck.Phone.focus();
		return false;
					 
	}
				
	if(document.formcheck.Phone.value!="")
	{
					  var ch=isNaN(document.formcheck.Phone.value);
					  if(ch==true)
					   {
						   
						   alert('Please enter numeric value');
						   return false;
						   
					   }
					 
					
				}


    //End of  non numeric phone no checking
       

	if (alertMsg.length == l_Msg){
		return true;
	}else{
		alert(alertMsg);
		return false;
	}
}
