function validate_email(field) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2) {
			return false;
		} else {
			return true;
		}
	}
}


function validate_required(field) {
	with (field) {
	  	if (value==null||value=="") {
		  	return false;
	  	} else {
			return true;
	  	}
	}
} 


function verifyCUform() {
	if(!validate_required(document.getElementById('name'))) {
		alert('Name Required');
		return false;
	}
	if(!validate_required(document.getElementById('message'))) {
		alert('Please Provide a Message');
		return false;
	}
	if(!validate_email(document.getElementById('em'))) {
		alert('Invalid E-Mail Address');
		return false;
	}
	return true;
																 
}


var hao = new Array(); //settings ajax objects

function contactUs(name, title, company, email, number, topic, newsletter, message, formpage, demo)
	{
		if(verifyCUform()) {
			//alert(newsletter);
			document.getElementById('contactform').innerHTML = '<img src="images/red-ajax-loader.gif">';
			var ajaxIndexh = hao.length;
			hao[ajaxIndexh] = new sack();
			hao[ajaxIndexh].requestFile = '/ajax_contactus.php';
			hao[ajaxIndexh].setVar("name", name);
			hao[ajaxIndexh].setVar("title", title);
			hao[ajaxIndexh].setVar("company", company);
			hao[ajaxIndexh].setVar("email", email);		
			hao[ajaxIndexh].setVar("number", number);
			hao[ajaxIndexh].setVar("topic", topic);			
			hao[ajaxIndexh].setVar("newsletter", newsletter);		
			hao[ajaxIndexh].setVar("message", message);		
			hao[ajaxIndexh].setVar("formpage", formpage);		
			hao[ajaxIndexh].setVar("demo", demo);
			hao[ajaxIndexh].onCompletion = function()
				{  
					if(document.getElementById('contactform')) {
						if(demo) {
							var pageTracker = _gat._getTracker("UA-6044853-1");	
							pageTracker._trackPageview("/formsubmitted.php");
						}
						document.getElementById('contactform').innerHTML = hao[ajaxIndexh].response;
					}
				};
			hao[ajaxIndexh].runAJAX();
		}
	}


function ShowContactForm()
	{
		var ajaxIndexh = hao.length;
		hao[ajaxIndexh] = new sack();
		hao[ajaxIndexh].requestFile = '/contactform.php';
		hao[ajaxIndexh].onCompletion = function()
			{  
				if(document.getElementById('contactform')) {
					document.getElementById('contactform').innerHTML = hao[ajaxIndexh].response;
				}
			};
		hao[ajaxIndexh].runAJAX();
	}

function ShowDemoForm()
	{
		var ajaxIndexh = hao.length;
		hao[ajaxIndexh] = new sack();
		hao[ajaxIndexh].requestFile = '/demorequest.php';
		hao[ajaxIndexh].onCompletion = function()
			{  
				if(document.getElementById('contactform')) {
					document.getElementById('contactform').innerHTML = hao[ajaxIndexh].response;
				}
			};
		hao[ajaxIndexh].runAJAX();
	}
