
/*---------------------------------- Check any form......

!!!!!!!!!!!----------------------------------------------------\/
in order to use this valedation you first have to enter 
the next data in each field you ant to validate:
validate="1" 
caption="ма иеб"  ---> the msg to show in the alert
regEx="(.*@{1}.*\..*)"  --> what content can this field get!
!!!!!!!!!!!----------------------------------------------------/\


Input ===> this.form (the form Object to be checked)
Output ==> Boolean result (true/false)

The form element should have these properties :
{
	validate --> either 1 or 0 (check or not).
	regEx --> the first regular expression.
	regEx2 --> the second regular expression.
		*(note)--> the check is regEx or regEx2 but not both.
	caption --> the text you want the user to get.
}

An example of a regular expression :
{
	(.*@{1}.*\..*) --> checks the email to be valid.
	(.{5,7}) --> any text at least 5 chars long but less then 7
	([0-9]) --> just the numeric values.
	(.*@{1}.*\..*) --> email
	regEx='([\W])' regEx2='([\w])'")' any text
	
	regEx=([0-9]{0,})
	regEx2=([a-zA-Z])
		result:
		{
			(the text box can be empty or has numbers but not letters)
				or
			(the text box can't be empty and contains only english letters)
		}
	Note: You don't have to put regEx, if none is present the field is checked to have something.
	Note: You can read all about Regular Expressions in the MSDN Library.
}
--------------------------------------------------------*/
function checkForm(formObj)
{
	var formObj=formObj;
	
	var elmLength=formObj.elements.length;
	var i,globalAlertString="";
	
	
	for(i=0;i<elmLength;i++)
	{	
		
		if(eval(formObj.elements[i].getAttribute('validate')))
			globalAlertString+=checkItem(formObj.elements[i]);
		
	}
			
	if(globalAlertString.length)
	{
		alert(globalAlertString);
		return false;
	}
	return true;
}

function checkItem(item)
{

	var item=item;
	var regEx,result=true,result2=false;
	var temp;
//	alert(item.getAttribute('regEx'))
	if	(item.getAttribute('regEx')=='notEmpty')	{temp=item.getAttribute('value');result=temp.getAttribute('length')}
	else 
	{
		if(item.getAttribute('regEx')!=null)
		{
			regEx=new RegExp(item.getAttribute('regEx'),"gi");
			result=regEx.test(item.value);			
			if(item.getAttribute('regEx2')!=null)
			{
				regEx=new RegExp(item.getAttribute('regEx2'),"gi");
				result2=regEx.test(item.value);
			}
			result^=result2;
		}
		else
			result=item.getAttribute('length');
	}	
	if(!result)
		return item.getAttribute('caption')+"\t\n";
	else
		return "";
		
}

function checkEmpty(formObj,field)
{
	alert("formObj.field.value")
}

//----------------- End Check form functions



// vereds addition--------------

function checkform2(frm){
		if(checkForm(frm))
		{	
			//if((!(frm.capacity1.checked))&& (!(frm.capacity2.checked)) && (!(frm.capacity3.checked)))
			//{
			//	alert("You must check at least one item")
			//		return false;
			//}	
			return true;
		}
		return false;
	}		
	
function checkform3(frm){
		if(frm.zip_code.value=="" && frm.city.value=="" && frm.bus_name.value=="" && frm.phone_no.value=="" && frm.address.value=="" && frm.state.value=="All States")
			{
				alert("You must fill at least one of the fields")
				return false;
			}
		return true;
	}	

//------------------------------	
