//##########################################################################################

//--> Begin Function :: ValidateForm

	function ValidateForm(){
		if(document.$("captcha_code").value == ""){
			alert("Please enter a code");
			return;
		}
		if(document.$("website_url").value == ""){
			alert("Please enter a website url!");
			return;
		}		
		
		var SubmitData = {};
		SubmitData["name_first"] 	= document.$("name_first").value;
		SubmitData["name_last"] 	= document.$("name_last").value;
		SubmitData["email"] 		= document.$("email").value;
		SubmitData["phone"] 		= document.$("phone").value;
		SubmitData["url"] 			= document.$("website_url").value;
		SubmitData["source_id"] 	= "110";
		SubmitLead(SubmitData);
		
		SendSubmission("google");
		SendSubmission("scrubtheweb");
		SendSubmission("splatsearch");
		SendSubmission("entireweb");
		SendSubmission("gigablast");
		SendSubmission("aesop");
		SendSubmission("changinglinks");
		SendSubmission("exactseek");
		SendSubmission("jayde");
	}

//--> End Function :: ValidateForm

//##########################################################################################

//--> Begin Function :: SendSubmission

	function SendSubmission(SearchEngine) {
		
		var MyAjax = new powerHTTP();

	//begin handling loading
		MyAjax.loading = function() {
			document.$('loading_report').style.display = "";
		};
	//end handling loading
	
	//begin handling response
		MyAjax.complete = function(response) {
			if(MyAjax.was_successful()) {
				//test for scraping
				if(response.text.indexOf("bad_captcha") != -1){
					var its_random = new Date().getTime();
					document.$("captcha").setAttribute('src', '/seo-tools/_captcha.aspx?' + its_random);
					document.$("captcha_code").value = "";					
					document.$("captcha_alert").innerHTML = "Incorrect Code.";
					document.$("submission_form").style.display = "";
					document.$("submission_result").style.display = "none";
					document.$('loading_report').style.display = "none";					
				}else{
					document.$('loading_report').style.display = "none";
					document.$("submission_form").style.display = "none";
					document.$("submission_result").style.display = "";
					document.$("captcha_code").value = "";					
					document.$("captcha_alert").innerHTML = "";
					document.$(SearchEngine + "_status").innerHTML = response.text;
				}
			}
			else {
				//show error in popup
				//document.$('txt_main2').innerHTML = "*server side error*";
				var ErrorWindow = window.open('','Error','status=no,scrollbars=yes,resizable=yes,width=640,height=480');
				ErrorWindow.document.write(response.text);
			}
		};
	//end handling response

	//begin execute request	
		var Data = new Array();
		Data.push("site=" + SearchEngine);
		Data.push("website_url=" + document.$("website_url").value);
		Data.push("captcha_code=" + document.$("captcha_code").value);
		var myPostData = Data.join("&");
		MyAjax.post("/seo-tools/search-engine-submission.html?r=submit_to", myPostData);	
	//end execute request*/
	
	}

//--> End Function :: SendSubmission