function init(formname, text, cont, email)
	{
	formname=formname?formname:'thing';
	text=text?text:'contactText';
	cont=cont?cont:'contactCont';
	email=email?email:'email';
	
	data=get_form_data(formname);
	
	if(!data)
		{
		message('<div style="color:red;">All Feilds Are Required</div>',text);
		}
	else 
		{
		if(em_val(document.getElementById(email).value) || document.getElementById(email).value == '')
			ajax('wpro/form-to-email-thing.php',data,text,cont);
		else message('<div style="color:red;">Please provide a valid email.</div>',text);
		}
	}
	
function get_form_data(formId,required)
	{	
	var tmp=val='';
	var elms=document.getElementById(formId).elements;
	for(i=0;i<elms.length;++i){
		val=((elms[i].type!='checkbox')?elms[i].value:elms[i].checked.toString());
		if(val!=''||required&&required.indexOf(elms[i].id)==-1)tmp+=elms[i].id+'='+val+'&';
		else return(false);}
	return(tmp);
	}
	
function ajax(to,postData,messid,cid)
	{
	var xmlHttp=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('MSXML2.XMLHTTP.3.0');
	xmlHttp.open(postData?'POST':'GET',to,true);
	xmlHttp.onreadystatechange=function(){
		if(xmlHttp&&xmlHttp.readyState==4){
			if(xmlHttp.responseText.indexOf('-true-')!=-1)document.getElementById(cid).innerHTML='';
			message(xmlHttp.responseText,cid);}}
	if(!postData)postData='';
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", postData.length);
	xmlHttp.send(postData);
	}

//function return_tracker_stuff(data, messid) {
	//window.ysm_customData = new Object();
	//window.ysm_customData.conversion = "transId=,currency=,amount=";
	//var ysm_accountid  = "1OLL8G6FGH19BHC8U21BCQGFDKS";
	//document.write("<SCRIPT language='JavaScript' type='text/javascript' SRC=//srv1.wa.marketingsolutions.yahoo.com/script/ScriptServlet?aid=" + ysm_accountid + "></SCRIPT>");
	//message(data, messid);
//}

function message(data,messid){document.getElementById(messid).innerHTML=data;}
function em_val(em){return(em.indexOf('@')<3 || em.indexOf('.')<5?false:true);}
