var xmlHttp
var please_wait = null;

function getData(source,target)
	{ 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
	
	if (please_wait != null) {
		document.getElementById('loading').innerHTML = please_wait;
 	}
	var url=source;
	
	xmlHttp.onreadystatechange=function(){stateChanged(target)}
	
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}

function stateChanged(target) 
{ 

	if (xmlHttp.readyState==4)
		{ 
			document.getElementById(target).innerHTML= xmlHttp.responseText ;
			document.getElementById('loading').innerHTML = "";
			
		} 
}

function GetXmlHttpObject()
	{
		var xmlHttp=null;
		try
			{
			// Firefox, Opera 8.0+, Safari
			xmlHttp=new XMLHttpRequest();
			}
		catch (e)
			{
				// Internet Explorer
				try
					{
						xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
					}
				catch (e)
					{
						xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
			}
		return xmlHttp;
	}

function set_loading_message(msg) 
	{
		please_wait = msg;
	}
	
function set_title(title) 
	{
		document.getElementById('displaytop').innerHTML = title;
	}

function sendMail()
{ 
		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert('not support');
		document.frmcontact.submit();
	  return;
	  } 
	
	params="";
	  
	
	for (i=0; i<document.frmcontact.elements.length; i++){
		params += document.frmcontact.elements[i].name + "=" + document.frmcontact.elements[i].value + "&";
		
	}
	


	
	xmlHttp.open("POST","sendmail.php",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlHttp.onreadystatechange=stateChangeds;	
	xmlHttp.send(params);
	
}
function stateChangeds() 
{ 
	document.getElementById("loading").innerHTML="Sending...";
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("showPage").innerHTML=xmlHttp.responseText;	
		document.getElementById("loading").innerHTML="";
	}
	
}
