// JavaScript Document

$(document).ready(function(){
		
	resetForm("k2qq");
	resetForm("contactform");
	resetForm("custompagequoteform");
		
	$(window).unload(function(){sendPartialForm();});
		
	$("#k2qq").submit(function(){
		sendPartialForm = null;
		window.onunload = null;

	});

	$("#custompagequoteform").submit(function(){
		sendPartialForm = null;
		window.onunload = null;
	});


	$("#contactform").submit(function(){
		sendPartialForm = null;
		window.onunload = null;
	});
						 
});

// reset forms on load
function resetForm(id) {
	$('#'+id).each(function(){
	        this.reset();
	});
}

// argument is id of targeted form
function sendPartialForm(){
	
	if(document.getElementById("k2qq")){
		
		// be sure to adjust name fields as appropriate for your form
		if($("#k2qq input[name='qqemail']").attr("value") !== "" || $("#k2qq input[name='qqphone']").attr("value") !== ""){
			// hopefully, this link will never have to change
    		$.get('http://apps2.memorysuppliers.com/js/general/partialforms/partialProcess.php', $("#k2qq").serialize());
	
		}
	} else if(document.getElementById("custompagequoteform")){
		
		// be sure to adjust name fields as appropriate for your form
		if($("#custompagequoteform input[name='liame']").attr("value") !== "" || $("#custompagequoteform input[name='enohp']").attr("value") !== ""){
			// hopefully, this link will never have to change
    		$.get('http://apps2.memorysuppliers.com/js/general/partialforms/partialProcess.php', $("#custompagequoteform").serialize());
	
		}		
	} else if(document.getElementById("contactform")){
		
		// be sure to adjust name fields as appropriate for your form
		if($("#contactform input[name='client_email']").attr("value") !== "" || $("#contactform input[name='client_phone']").attr("value") !== ""){
			// hopefully, this link will never have to change
    		$.get('http://apps2.memorysuppliers.com/js/general/partialforms/partialProcess.php', $("#contactform").serialize());
	
		}			
	}
	
	
}