$(document).ready(function() {
/*EXPAND and COLLAPSE */
 $(".show-hide-innactive").click(function(){
		var $this = $(this);
		if( $this.is('.show-hide-active') ) {
						$this.next().slideUp("fast");
						$this.removeClass('show-hide-active');
						$this.addClass('show-hide-innactive');
		}
		else {
						$this.next().slideDown("fast");
						$this.removeClass('show-hide-innactive');
						$this.addClass('show-hide-active');
		}
		return false;
		});
 
$(document).ready(function() {

   $('#quoteTrigger').click(function() {
    $('#quoteBox').fadeIn('fast');
			return false;
  });

  $('#quoteClose').click(function() {
    $('#quoteBox').fadeOut('fast');
			return false;
  });
 
 });

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 9/11/2008
 * @author Ariel Flesler
 * @version 1.4
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(h){var m=h.scrollTo=function(b,c,g){h(window).scrollTo(b,c,g)};m.defaults={axis:'y',duration:1};m.window=function(b){return h(window).scrollable()};h.fn.scrollable=function(){return this.map(function(){var b=this.parentWindow||this.defaultView,c=this.nodeName=='#document'?b.frameElement||b:this,g=c.contentDocument||(c.contentWindow||c).document,i=c.setInterval;return c.nodeName=='IFRAME'||i&&h.browser.safari?g.body:i?g.documentElement:this})};h.fn.scrollTo=function(r,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};a=h.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=h(k),d=r,l,e={},p=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(d)){d=n(d);break}d=h(d,this);case'object':if(d.is||d.style)l=(d=h(d)).offset()}h.each(a.axis.split(''),function(b,c){var g=c=='x'?'Left':'Top',i=g.toLowerCase(),f='scroll'+g,s=k[f],t=c=='x'?'Width':'Height',v=t.toLowerCase();if(l){e[f]=l[i]+(p?0:s-o.offset()[i]);if(a.margin){e[f]-=parseInt(d.css('margin'+g))||0;e[f]-=parseInt(d.css('border'+g+'Width'))||0}e[f]+=a.offset[i]||0;if(a.over[i])e[f]+=d[v]()*a.over[i]}else e[f]=d[i];if(/^\d+$/.test(e[f]))e[f]=e[f]<=0?0:Math.min(e[f],u(t));if(!b&&a.queue){if(s!=e[f])q(a.onAfterFirst);delete e[f]}});q(a.onAfter);function q(b){o.animate(e,j,a.easing,b&&function(){b.call(this,r,a)})};function u(b){var c='scroll'+b,g=k.ownerDocument;return p?Math.max(g.documentElement[c],g.body[c]):k[c]}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);


 /* FORM VALIDATONS */
 
 $("#contactForm").validate({
														 rules: {
			inquiry_topic: "required",
			name: "required",
			state: "required",
			city: "required",
			address: "required",
			ZIP: {
			required: true,
			number: true,
			minlength: 5,
			maxlength: 5 
			},				
			home_phone: {
			required: true,
			minlength: 10,
			maxlength: 14
			},				
			business_phone: {
			required: true,
			minlength: 10,
			maxlength: 14
			},				
			security_code: {
			required: true,
			minlength: 6,
			maxlength: 6
			},
			email: {
			required: true,
			email: true
			}
		},
		messages: {
			inquiry_topic: "",
			name: "",
			city: "",
			ZIP: "",
			state: "",
			address: "",
			business_phone: "",
			email: "",
			home_phone: "",
			security_code: "",
			password: {
			required: "",
			minlength: ""
			}
		}
		});
 

	
$('.makkForm form').each( function(){
$(this).validate({
		rules: {
			inquiry_topic: "required",
			name: "required",
			state: "required",
			city: "required",
			address: "required",
			ZIP: {
			required: true,
			number: true,
			minlength: 5,
			maxlength: 5 
			},				
			home_phone: {
			required: true,
			minlength: 10,
			maxlength: 14
			},				
			business_phone: {
			required: true,
			minlength: 10,
			maxlength: 14
			},				
			security_code: {
			required: true,
			minlength: 6,
			maxlength: 6
			},
			email: {
			required: true,
			email: true
			}
		},
		messages: {
			inquiry_topic: "",
			name: "",
			city: "",
			ZIP: "",
			state: "",
			address: "",
			business_phone: "",
			email: "",
			home_phone: "",
			security_code: "",
			password: {
			required: "",
			minlength: ""
			}
		}
		});
		});

/* ADD VEHICLE FOR AUTO FORM */
$(
	function(){
		// Get the add new link.
		var jAddNewVehicle = $( "#add-vehicle" );
 
		// Hook up the click event.
		jAddNewVehicle
			.attr( "href", "javascript:void( 0 )" )
			.click(
				function( objEvent ){
					AddNewVehicle();
 
					// Prevent the default action.
					objEvent.preventDefault();
					return( false );
				}
				)
		;
 
	}
	)
 
 
function AddNewVehicle(){
	var jVehiclesContainer = $( "#vehicles" );
	var jVehicleTemplate = $( "#vehicle-template div.row" );
 
		var jVehicle = jVehicleTemplate.clone();
 
	var strNewHTML =  jVehicle.html();
 
	var intNewFileCount = (jVehiclesContainer.find( "div.row" ).length + 1);
 
	jVehicle.attr( "id", ("vehicle" + intNewFileCount) );
 
if (intNewFileCount<=3) {  

	strNewHTML = strNewHTML
		.replace(
			new RegExp( "::FIELD0::", "i" ),
			intNewFileCount
			)
		.replace(
			new RegExp( "::FIELD1::", "i" ),
			intNewFileCount
			)
		.replace(
			new RegExp( "::FIELD2::", "i" ),
			(intNewFileCount)
			)
		.replace(
			new RegExp( "::FIELD3::", "i" ),
			(intNewFileCount)
			)
		.replace(
			new RegExp( "::FIELD4::", "i" ),
			(intNewFileCount)
			)
		.replace(
					new RegExp( "::FIELD5::", "i" ),
					(intNewFileCount)
					)
		
		.replace(
					new RegExp( "::FIELD6::", "i" ),
					(intNewFileCount)
					)
		.replace(
					new RegExp( "::FIELD7::", "i" ),
					(intNewFileCount)
					)
		.replace(
					new RegExp( "::FIELD8::", "i" ),
					(intNewFileCount)
					)
		.replace(
					new RegExp( "::FIELD9::", "i" ),
					(intNewFileCount)
					)
		.replace(
					new RegExp( "::FIELD10::", "i" ),
					(intNewFileCount)
					);
 
	jVehicle.html( strNewHTML );

	jVehiclesContainer.append( jVehicle );
}
else 
{ alert ("You may only add up to three vehicles.");
document.getElementById('add-vehicle').style.display = 'none';  //alert ("You may only add a maximum of 3 vehicles.");
}
}
		});



