
function ContactMe(EmID)	{

	var Name = $('Name').value;  // required
	var Email = $('Email').value;  // required
	var Reason = 99;  // required
	var Phone = $('PhoneNumber').value;
	var Zip = $('Zip').value;  // required
	var Agency = $('AgencyName').value;
	var Comments = $('Comments').value;
	
	var missing = '';
	var numtodo = 0;
	
	if (Name.length == 0) {
		numtodo = numtodo + 1;
		missing = missing + '  (' + numtodo + ') Name \n ';
	}
	if (Email.length == 0) {
		numtodo = numtodo + 1;
		missing = missing + '  (' + numtodo + ') Email Address \n ';
	}
	if (Reason == 0) {
		numtodo = numtodo + 1;
		missing = missing + '  (' + numtodo + ') Reason \n ';
	}
	if (Zip.length == 0) {
		numtodo = numtodo + 1;
		missing = missing + '  (' + numtodo + ') 5-Digit Zipcode \n ';
	}
	missing = 'There are ' + numtodo + ' required item(s) missing: \n ' + missing;
	if (numtodo > 0) {
		alert(missing);
		return;
	}
	
	missing = '';
	var atemail = Email.indexOf('@');
	if (atemail < 0) {
		numtodo = numtodo + 1;
		missing = missing + 'Invalid Email Address \n ';
	}
	missing = 'There are ' + numtodo + ' item(s) to correct: \n ' + missing;
	if (numtodo > 0) {
		alert(missing);
		return;
	}
	
	Name = encodeURIComponent(Name);
	Agency = encodeURIComponent(Agency);
	Comments = encodeURIComponent(Comments);
	
	var url = 'addr_ContactUs.asp?EmID=' + EmID + '&Name=' + Name + '&Email=' + Email + '&Reason=' + Reason + '&Phone=' + Phone + '&Zip=' + Zip + '&Agency=' + Agency + '&Comments=' + Comments;
	//var oSubTextbox = $('commentslisted');
	//oSubTextbox.value = url;
	//return;
	
	new Ajax.Request(url, 
		{	method: 'get', 
			onSuccess: function(transport)	{
				
				if (transport.responseText == 'Recorded')	{
					alert('Thank you for contacting AgentMailings! A representative will contact you shortly.');
					$('Img2').style.visibility = 'hidden';
					return;
				}
			},
			onFailure: function(transport)	{
				alert('Sorry, the server is off-line and failed to record your contact message.  Please call us using the 800# provided on this form.');
				return;
			}
		}
	)
}

function RequestPC(AgID) {

    var ListAddr = $('ListAddr').value;  // required
    var ListML = $('ListML').value;  // required

    var missing = '';
    var numtodo = 0;

    if (ListAddr.length == 0) {
        numtodo = numtodo + 1;
        missing = missing + '  (' + numtodo + ') Listing Address \n ';
    }
    if (ListML.length == 0) {
        numtodo = numtodo + 1;
        missing = missing + '  (' + numtodo + ') ML Number of listing \n ';
    }

    missing = 'There are ' + numtodo + ' required item(s) missing: \n ' + missing;
    if (numtodo > 0) {
        alert(missing);
        return;
    }

    ListAddr = encodeURIComponent(ListAddr);

    var url = 'addr_RequestPC.asp?ListAddr=' + ListAddr + '&ListML=' + ListML + '&AgID=' + AgID;
    new Ajax.Request(url,
		{ method: 'get',
		    onSuccess: function(transport) {

		        if (transport.responseText == 'Recorded') {
		            alert('Thank you for requesting a new postcard from AgentMailings! You will be contacted shortly.');
		            $('Img3').style.visibility = 'hidden';
		            return;
		        } else {
		            alert('Sorry, the server is off-line and failed to record your request.  Please call us using the 800# provided on the main form.');
		            return;
		        }
		    },
		    onFailure: function(transport) {
		        alert('Sorry, the server is off-line and failed to record your request.  Please call us using the 800# provided on the main form.');
		        return;
		    }
		}
	)
    
}
