	
	
	function createRequestObject(){
	   var http1;
	   if (window.XMLHttpRequest) {
	        http1 = new XMLHttpRequest();
	    } else if (window.ActiveXObject) {
	        http1 = new ActiveXObject("Microsoft.XMLHTTP");
	    }
	
	    return http1;
	}
	var http = createRequestObject();
	
	function startShare(){
		var emailObj = document.getElementById("shareForm");
		emailObj.style.display = "block";
		 
		 
		
	}
	
	function showEmail(title){
		var emailObj = document.getElementById("email");
		var dragShow = new Draggable('email');
		var pos = Position.cumulativeOffset($("emailLink"));
		new Effect.Move($("email"), {x:pos[0], y: pos[1], mode: "absolute"});
		emailObj.style.display = "block";
		 
		var pageSend = document.getElementById("pageSend");
		pageSend.innerHTML = title;
		
	}
	
	function closeShare(){
		var emailObj = document.getElementById("shareForm");
		emailObj.style.display = "none";
	}
	
	function closeEmail(){
		var emailObj = document.getElementById("email");
		emailObj.style.display = "none";
	}
	
	function makeRequest(url, alertContents) {
	    http = createRequestObject();
	    http.onreadystatechange = alertContents;
	    http.open('GET', url, true);
		http.send(null);
	}

	function startEmail(){
		return true;
	}

	function endEmail(){
	    if(http.readyState == 4 ){
	        if(http.status == 200){
	            alert("Email Sent");
	           
	        }
	     }
	    }

	function endEmailShare(){
	    if(http.readyState == 4 ){
	        if(http.status == 200){
		    window.location = "thank-you-share.html";
	           
	        }
	     }
	    }

	function sendContactWi(formObj){
		 var qStr = Form.serialize("contactForm");
                var allItems = Form.serialize("contactForm", true);
                if(allItems['message'].length == 0){
                        alert("Please enter your message.");
                        return;
                }
                if(allItems['your_name'].length == 0){
                        alert("Please enter your name.");
                        return;
                }
                 
                if(allItems['your_phone'].length == 0){
                        alert("Please your phone number.");
                        return;
                }
                new Ajax.Request('/sendWIP.php',
                {       method:'post',
                        parameters:'type=workinponca&' + qStr,
                        onSuccess:contactSent});
	}
	
	function sendContact(formObj){
		var qStr = Form.serialize("contactForm");
		var allItems = Form.serialize("contactForm", true);
		if(allItems['your_name'].length == 0){
			alert("Please enter your name");
			return;
		}
		if(allItems['your_email'].length == 0){
			alert("Please enter your email address");
			return;
		}
		 
		if(allItems['message'].length == 0){
			alert("Please your message.");
			return;
		}
		new Ajax.Request('/sendEmail.php',
		{	method:'post', 
			parameters:'type=contactus&' + qStr, 
			onSuccess:contactSent});
	}

	function contactSent(t){
		window.location = "thank-you.html";
	}

 	function signUp(){
 	
		var qStr = Form.serialize("signUp");
		var allItems = Form.serialize("signUp", true);
		if(allItems['email_address'].length == 0 || allItems['email_address'] == "your email address"){
			alert("Please enter your email address");
			return;
		}
		new Ajax.Request('/sendEmail.php',
		{	method:'post', 
			parameters:'type=signup&' + qStr, 
			onSuccess:contactSent});

 	}
	
	function sendEmail(formObj){
		 
		if(formObj.emailsString.value == ""){
			alert("Please enter at least one email to send to");
			return;
		}
		
		if(formObj.fromEmail.value == ""){
			alert("Please enter your email address");
			return;
		}
		
		if(formObj.fromName.value == ""){
			alert("Please enter your name");
			return;
		}
		var toEmail = formObj.emailsString.value;
		var fromEmail = formObj.fromEmail.value;
		var fromName = formObj.fromName.value;
		var message = formObj.message.value;
		var pageSend = document.getElementById("pageSend").innerHTML;
		var url = "sendEmail.php?toEmail=" + toEmail + "&fromEmail=" + fromEmail +
			"&fromName=" + fromName + "&interest=" + pageSend + "&message=" + message +
			"&url=" + window.location;
			
		makeRequest(url, endEmail);
	}
