var xmlHttp;

function createAjax(){
	try{ 
	  	// Firefox, Opera 8.0+, Safari  
	  	xmlHttp=new XMLHttpRequest(); 
		if ( xmlHttp.overrideMimeType ) xmlHttp.overrideMimeType ( "text/xml" ); 
		//alert('non-ie');
	}
  	catch (e)
	{ 
		try{
	    	//IE 6.0+
	    	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
	    	//alert('E 6.0+');
	    }
		catch (e)
		{ 
			try{    
		      	//IE versions 5.0+  
		      	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
		      	//alert('IE 5.0+ < 6');
		    }
			catch (e)
			{ 
				alert("Your browser does not support AJAX!");      
				return false; 
			} 
		} 
	} 
	//alert('?');
}
var xmlHttpStr="";
var divScrollTop=0;

function ajaxFunction(){
	createAjax();
	
	//alert('#'+checkFlag);
	
	nameStr=document.getElementById('name').value;
	emailStr=document.getElementById('xukdd-xukdd').value;
	conameStr=document.getElementById('company').value;
	telnoStr=document.getElementById('phone').value;
	msgStr=document.getElementById('message').value;
	moreStr=document.getElementById('more').checked;
	//alert('##');
  	xmlHttp.onreadystatechange=function(){
  		//alert('xmlHttp');
		if(xmlHttp.readyState==4){
			//alert('4');
			xmlHttpStr=xmlHttp.responseText;
			//alert(xmlHttpStr);
			if(xmlHttpStr!="not"){//sendmail.asp has worked using xmlHttp
				//alert('thanks');
				if(!checkFlag){
					//just say thanks
					location.href="thanks.html";
				}else{
					//pass on crucial detail to Campaign Monitor - only name and email vars accepted using GET
					// set CM up so redirects on receipt to thanks page
					location.href="http://rawww.createsend.com/t/r/s/xukdd/?cm-xukdd-xukdd="+ emailStr +"&cm-name=" + nameStr;
					
				}
			}else{				
				alert("There has been a problem\nPlease check that you've filled the form in correctly\nor try again later.");
			}

		}
		//alert('dead');	
	}
	//alert('###');

		//alert("sendmail.asp?email=" + emailStr + "&name=" + nameStr +"&coname=" + conameStr + "&telno=" + telnoStr + "&msg=" + msgStr + "&inform=" + moreStr);
		
		//send messsage via sendmail.asp whether mailing list subscribed to or not
		xmlHttp.open("GET","sendmail.asp?email=" + emailStr + "&name=" + nameStr +"&coname=" + conameStr + "&telno=" + telnoStr + "&msg=" + msgStr + "&inform=" + moreStr ,true);
		xmlHttp.send(null);		
/*
		//alert("http://rawww.createsend.com/t/r/s/xukdd/?cm-xukdd-xukdd="+ emailStr +"&cm-name=" + nameStr);
		//document.reqForm.action="http://rawww.createsend.com/t/r/s/xukdd/?cm-xukdd-xukdd="+ emailStr +"&cm-name=" + nameStr;
		document.reqForm.action="http://rawww.createsend.com/t/r/s/xukdd/?cm-xukdd-xukdd="+ emailStr +"&cm-name=" + nameStr +"&cm-f-djthr=" + conameStr +"&cm-f-djthy=" + telnoStr +"&cm-f-djthj=" + msgStr;
		document.reqForm.submit();
*/
	//alert('####');
}
  
checkFlag=false;

function checkSelect(obj){
	if(obj.checked)checkFlag=true;else checkFlag=false;
	//alert(checkFlag);
}