/*
GreenJack v1.0.1 - Expression Engine FreeForm with AJAX
by Mark Cianciulli of Greenhouse Studio - Jacksonville, Florida

Copyright 2009 Greenhouse Studio

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
	
Read all about this script and check for updates here:
http://www.gogreenhouse.com/software/greenjack

Send us any modifications you do to the script, so we can add it to the base code.

- Requires Expression Engine - http://expressionengine.com
- Requires the FreeForm module for EE - http://www.solspace.com/software/detail/freeform/
- Requires on JQuery Min : http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
- Requires on JQuery Form : http://jquery.malsup.com/form/jquery.form.js
*/

function greenjackForm(c,g){var a="#"+c,d="#ffajaxreturn_"+c,e=[],h=$(a+" input[type=submit]").val();$(a).append('<div id="ffajaxreturn_'+c+'" style="display:none;"></div>');$(a+" input[rel]").each(function(f){e[f]=$(this).attr("rel")});$(a).ajaxForm({target:d,beforeSubmit:function(){$(a+" :input[rel]").each(function(){$(this).removeClass("error");_field=$(this).attr("rel");$("#label_"+_field).removeClass("errorlabel");$("#error_"+_field).empty();$(a+" input[type=submit]").attr("disabled","disabled")})}, success:function(f){if(f=="success"){$(a).resetForm();$("#thankyouhidden").load("/merchant-accounts/millennium-form-thank-you",function(){$("#"+g+" #thankyouhidden").siblings().fadeOut("slow",function(){$("#"+g+" #thankyouhidden").fadeIn("slow")})})}else{$(e).each(function(i){var b=e[i],j=RegExp(b,"gi");$(d+" #content ul li").each(function(){if($(this).html().replace(/ /g,"_").search(j)>0){_errormessage=$(this).html();$(a+" input[name="+b+"]").addClass("error").fadeIn("slow");$("#error_"+b).html(_errormessage).fadeIn("slow"); $("#label_"+b).addClass("errorlabel").fadeIn("slow");return false}})});$(a+" input[type=submit]").attr("disabled","").val(h);$(d).empty()}}})};

