/*
 * minified javascript file
 * http://www.suzukiauto.com/_cj/brochures.js
 */


$(function(){$("#moform #btn_order_a_brochure").click(function(){if(validateForm($("#moform").get(0))){var params=$.param($("#moform :text,:radio[@checked],select"));$.getJSON("/brochures/mailOrder.gen",params,function(json){if(json.status=='success'){$("#confirm").html('<div id=\"confirm_msg\">'+"<p><b>Thank you. We have received your request for a brochure. You should be receiving it soon.</b></p>"+"<p>What would you like to do next?</p>"+"</div><br class=\"clear\">"+"<div id=\"brochure_buttons\" class=\"clearfix\">"+" <div id=\"btn_get_quote\" class=\"first-button-thanks\"><a href=\"\"></a></div>"+" <div id=\"btn_build_your_own\" class=\"second-button-thanks\"><a href=\"\"></a></div>"+" <div id=\"btn_locate_vehicle\" class=\"third-button-thanks\"><a href=\"\"></a></div>"+"</div><div id=\"bottom-spacer\">&nbsp;</div>")
var navmodel=$("select[@name=q1]").val();$("#btn_get_quote a").attr("href","/shopping_tools/get_a_quote/?"+
(navmodel&&navmodel!="all"?"model="+navmodel+"&":"")+"fname="+$("input[@name=first_name]").val()+"&lname="+$("input[@name=last_name]").val()+"&zip="+$("#moform input[@name=zip]").val()+"&email="+$("input[@name=email]").val()+"&phone_no="+$("input[@name=phone]").val());$("#btn_build_your_own a").attr("href","/shopping_tools/byo2009/"+
(navmodel&&navmodel!="all"?"byo.php?model="+navmodel:""));var year=2009;$("#btn_locate_vehicle a").attr("href","/shopping_tools/vehicle_locator/?"+"year="+year+
(navmodel&&navmodel!="all"?"&model="+escape(navmodel):"")+"&zip="+$("#moform input[@name=zip]").val());$("#moform").get(0).reset();$("#moform").hide();$("#confirm").show();}
else{alert(json.msg);}});}
return false;});$('#thumbs a').click(function(){var model=$(this).parent().get(0).id.replace(/^thumb_/,'');popBrochure(model);return false;});});function popBrochure(model){window.open('/_m/sr_09/brochures/09_'+model+'.pdf','brochure','height=500px, width=630px, resizable=1');}
function popBrochureAcc(model){window.open('/_m/sr_09/brochures/09_'+model+'_accy_brochure.pdf','brochure','height=500px, width=630px, resizable=1');}
function validateForm(F){var errorMsg="";if(!F.first_name.value.match(/^\w.*/)){errorMsg+="- Please enter your First Name.\n";}
if(!F.last_name.value.match(/^\w.*/)){errorMsg+="- Please enter your Last Name.\n";}
if(!F.address1.value.match(/^\w.*/)){errorMsg+="- Please enter your Postal Address in line 1.  Use line 2 only if needed.\n";}
else if(F.address2.value.match(/\@/)&&F.address1.value.match(/\./)){errorMsg+="- Please check the format of your Postal Address.\n";}
if((F.phone.value)&&(!F.phone.value.match(/^\D?(\d{3})\D?\D?(\d{3})\D?(\d{4})$/))){errorMsg+="- Please enter your Phone Number with area code.\n";}
if(!F.city.value.match(/^\w.*/)){errorMsg+="- Please enter your City.\n";}
if(F.state.value.match(/\XX/)){errorMsg+="- Please select a U.S. State.\n";}
var zipTrimmed=jQuery.trim(F.zip.value);if(!(zipTrimmed.length==5)||!(zipTrimmed<99990)){errorMsg+="- Please enter your 5-digit U.S. Zip Code.\n";}
if(F.q1.value=="none"){errorMsg+="- Please tell us which Suzuki you are interested in.\n";}
if((F.email.value)&&(!F.email.value.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/))){errorMsg+="- Please check the format of your Email address.\n";}
if(errorMsg){dispErrorMsg("We're sorry.  We could not send your data as it was submitted.\n",errorMsg);return false;}
else{return true;}}
function dispErrorMsg(head,errorMsg){var line="________________________________________________________\n\n";alert(line+head+line+errorMsg+"\n\n");}
function clearForm(formid){formElements=document.getElementById(formid).elements;for(i=0;i<formElements.length;i++){formElements[i].value="";formElements[i].checked=false;}
return false;}