var msg;
function check_validation(){
	flag=false;
	var required_values=new Array("contact",
							"email",
							"super",
							"phone",
							"billtoname",
							"contactbtmc",
							"phonebtmc",
							"addressbtmc",
							"citybtmc",
							"statebtmc",
							"zipbtmc",
							"storenumloc",
							"contactloc",
							"phoneloc",
							"addressloc",
							"cityloc",
							"stateloc",
							"ziploc",
							"installer",
							"contactins",
							"phoneins",
							"addressins",
							"cityins",
							"stateins",
							"zipins");
	for (x in required_values)
	{
	temp=required_values[x];
	if ($('#'+temp).val().length == 0){
		flag=true;
		}
	/*var patt=/zip|phone/g;
	var patt2=/[0-9]/g;
	if(patt.test(required_values[x])){
		if(patt2.test($(required_values[x]).val())){
			msg+='<br>'+required_values[x]+' has to be number';
		}
	}*/
	
	}
	
	if (flag){
		alert ("All the Required Fields have not been filled");
	} else {
		datastring=$("form").serialize();
		$.ajax({  
		type: "POST",  
		url: "common.php",
		data: datastring,
		success: function(msg) {
			$('#msg').html(msg);
			$(":input").val('');
			$("#submit").val('submit');
		//display message back to user here  
		}  
		});
	}
	return false;
}


function check_contact_validation(){
	flag=false;
	var required_values=new Array("name",
							"email",
							"comments");
	for (x in required_values)
	{
	temp=required_values[x];
	if ($('#'+temp).val().length == 0){
		flag=true;
		}
	if (temp == 'email' && flag==false){
		var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		temp_val = $('#'+temp).val();
		
		if(temp_val.match(emailRegEx)){
			
		} else {
			alert('Invalid Email');
			return false;
		}
	}
	}
	
	if (flag){
		alert ("All the Required Fields have not been filled");
	} else {
		datastring=$("form").serialize();
		$.ajax({  
		type: "POST",  
		url: "send_contact_inf.php",
		data: datastring,
		success: function(msg) {
			$('#msg').html(msg);
			$(":input").val('');
			$("#submit").val('submit');
		//display message back to user here  
		}  
		});
	}
	return false;
}
