﻿// JScript File

function SendContact(f)
{
    var e = document.getElementById('ContactDiv');
	var xmlHttpReq = false;
	
	// Mozilla/Safari
	var strURL = "";
	var userid = "";
	var uu = document.getElementById('user-id');
	if(uu != null) userid = uu.value;
	
	try
	{
	    strURL = "/controls/ajax.aspx?auto=1&method=contact&email=" + escape(f.Email.value) + "&phone=" + escape(f.Phone.value) + '&name=' + escape(f.Name.value) + '&text=' + escape(f.contacttext.value) + '&user-id=' + escape(userid);
	}
	catch(ex)
	{
	    strURL = "";
	    return false;
	}

	if (window.XMLHttpRequest) xmlHttpReq = new XMLHttpRequest();
	else if (window.ActiveXObject) xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	else return;

	xmlHttpReq.open('GET', strURL, true);
	xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	xmlHttpReq.onreadystatechange = function()
	{
		if (xmlHttpReq.readyState == 4)
		{
			var s = new String(xmlHttpReq.responseText);
			
			try
			{
			    if(userid == '1')
			    {
			        e.innerHTML = '<div id=ContactSent>' + s + '</div>';
			    }
			    else
			    {
                    e.innerHTML = '<div id=ContactSent>Message Sent!!</div>';
                }
			}
			catch(ex)
			{
			    alert(ex.toString());
			}
		}
	}
	
	xmlHttpReq.send(strURL);
}
