function get_xmlhttp()
{
	var xmlhttp=false; //Clear our fetching variable
        try {
                xmlhttp = new ActiveXObject('Msxml2.XMLHTTP'); //Try the first kind of active x object…
        } catch (e) {
                try {
                        xmlhttp = new
                        ActiveXObject('Microsoft.XMLHTTP'); //Try the second kind of active x object
            } catch (E) {
                xmlhttp = false;
                        }
        }
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
                xmlhttp = new XMLHttpRequest(); //If we were able to get a working active x object, start an XMLHttpRequest
        }
	return xmlhttp;
}
var xmlHttp=get_xmlhttp();
function replace_page(divId,url)
{
	xmlHttp.onreadystatechange=function() {
    if (xmlHttp.readyState==4) 
		{ //Check if it is ready to recieve data
			//alert (xmlHttp.responseText);       
			document.getElementById(divId).innerHTML=xmlHttp.responseText; //The content data which has been retrieved ***
		}
    }
	xmlHttp.open('GET', url, true); //Open the fle through GET, and add the page we want to retrieve as a GET variable **
    xmlHttp.send(null) //Nullify the XMLHttpRequest
	
}

function replace_iframe(Id,url,width,height)
{
	document.getElementById(Id).src=url;
	document.getElementById(Id).width=width;
	document.getElementById(Id).height=height;	
}

function tell_needs(divId)
{
	var name=document.getElementById('tell_name').value;
	var email=document.getElementById('tell_email').value;
	var phone=document.getElementById('tell_phone').value;
	var comments=document.getElementById('tell_comments').value;
	var captcha_code=document.getElementById('security_captcha').value;
	var captcha=document.getElementById('ctl00_LeftControl1_txtCaptchaText').value;
	var err;
	if(name=="" || name=="Your Name")
	{	alert("Please Enter Name");	return false;}
	if(phone=="" || phone==" ")
	{	alert("Please Enter Phone Number"); return false;}
	if(comments=="" || comments==" ")
	{	alert("Please Enter Comments");	return false;}
	if(captcha!=captcha_code)
	{ alert("Please Enter valid Characters"); return false;}
	
	var url="inc/mailer.php?name="+name+"&email="+email+"&phone="+phone+"&comm="+comments;
	xmlHttp.onreadystatechange=function() {
    if (xmlHttp.readyState==4) 
		{ //Check if it is ready to recieve data
		//alert (xmlHttp.responseText);       
		document.getElementById(divId).innerHTML=xmlHttp.responseText; //The content data which has been retrieved ***
		}
    }
	xmlHttp.open('GET', url, true); //Open the fle through GET, and add the page we want to retrieve as a GET variable **
    xmlHttp.send(null) //Nullify the XMLHttpRequest
	
}

//captcha Functions
//Initiate the AJAX request
function makeRequest(url, param) {
//If our readystate is either not started or finished, initiate a new request
 if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) {
   //Set up the connection to captcha_test.html. True sets the request to asyncronous(default) 
   xmlHttp.open("POST", url, true);
   //Set the function that will be called when the XmlHttpRequest objects state changes
   xmlHttp.onreadystatechange = updatePage; 

   //Add HTTP headers to the request
   xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
   xmlHttp.setRequestHeader("Content-length", param.length);
   xmlHttp.setRequestHeader("Connection", "close");

   //Make the request
   xmlHttp.send(param);
 }   
}
//Called every time our XmlHttpRequest objects state changes
function updatePage() {
 //Check if our response is ready
 if (xmlHttp.readyState == 4) {
   //Set the content of the DIV element with the response text
   document.getElementById('result').innerHTML = xmlHttp.responseText;
   //Get a reference to CAPTCHA image
   img = document.getElementById('imgCaptcha'); 
   //Change the image
   img.src = 'create_image.php?' + Math.random();
 }
}
//Called every time when form is perfomed
function getParam(theForm) {
 //Set the URL
 var url = 'captcha.php';
 //Set up the parameters of our AJAX call
 var postStr = theForm.txtCaptcha.name + "=" + encodeURIComponent( theForm.txtCaptcha.value );
 //Call the function that initiate the AJAX request
 makeRequest(url, postStr);
}

//// Captcha Part Ended

