/*--Ludwig Double POST Script--*/
/*--Rewritten 10/14/2008--*/

//make document registration.php ready -- always required
$(document).ready(function() {
//find element tagged 'submit' and on click...
$("#submit").click(function(e) {
		//prevent the default action that a click on a submit button would normally provide
		e.preventDefault();
		//run function SubmitForm
		submitForm();
});
    
//This is my function.  There are many like it but this one is mine
function submitForm() {
	//here, I create variables and assign them the values from the input fields tagged with like-named ids in registration.php
	//see <input name="FirstName" type="text" class="textbox" value="" size="25" maxlength="70" id="FirstName" />
	var LID = $("#LID").val();
	var VID = $("#VID").val();
	var Source = $("#Source").val();
	var Name = $("#Name").val();
	var Country = $("#Country").val();
	var Email = $("#Email").val();
	var Comments = $("#Comments").val();
	
	//regular expression search and replace
	var myRegExp1 = /slow|Slow|SLOW|Website|website|WEBSITE|Web|web|WEB|sucks|SUCKS|Sucks|Serial|serial|SERIAL/;
	var myRegExp2 = /speed|Speed|SPEED|Design|design|DESIGN|Page|page|PAGE|load|LOAD|Load|Internet|INTERNET|internet/;
	
	var matchPos1 = Comments.search(myRegExp1);
	var matchPos2 = Comments.search(myRegExp2);
	
	if (matchPos1 != -1 || matchPos2 != -1) { alert("Thank you for contacting us! You may now close this window."); window.location="http://www.armstrongflutes.net/contact/success.php"; 
	} else { 
	
		// post
		$.ajax({
			type: "POST",
			url: "test1.php",
			data: "Name="+Name+"&Source="+Source+"&Country="+Country+"&Email="+Email+"&VID="+VID+"&LID="+LID+"&Comments="+Comments,
		   success: function(msg){
			   //alert("Your submission has been accepted.");
			}
		});
		
		// post 2
		$.ajax({
			type: "POST",
			url: "test2.php",
			data: "Name="+Name+"&Source="+Source+"&Country="+Country+"&Email="+Email+"&VID="+VID+"&LID="+LID+"&Comments="+Comments,
		   success: function(msg){
			   alert("Thank you for contacting us! You may now close this window.");
			   window.location="http://www.armstrongflutes.net/contact/success.php";
			}
		});
		
		// post 3
		//http://www.leadproweb.com/services/interfaces/public/LeadImport.asmx/LeadReceiver
		/*$.ajax({
			type: "POST",
			url: "../leadpro/services/interfaces/public/LeadImport.asmx/LeadReceiver",
			data: "Name="+Name+"&Country="+Country+"&Email="+Email+"&VID="+VID+"&LID="+LID+"&Comments="+Comments,
		   success: function(msg){
			   alert("Thank you for contacting us! You may now close this window.");
			   window.location="http://www.henriselmerparis.com/feedback/?success=1";
			}
		});*/
	
	}		

	}
});