(function($) {
	$(document).ready(function() {
		
	
		$(".view_gallery").click(function() {
			$("a.first_vehicle").click();
		});
		
		var options = $('.options');
		
		$("a.more_options").click(function(e) {
			e.preventDefault();
			if (options.is(":visible")) {
				options.hide();
				$(this).text("More options");
			} else {
				options.show();
				$(this).text("Less options");
			}
		});
		
		$("html").addClass("js");
		
		$("form#app fieldset:even, form.calculator fieldset:even").addClass("row");
		
		// Menu
		function addMenu() {
			$(this).find("#submenu").slideDown(150);
		}

		function removeMenu() {
			$(this).find("#submenu").slideUp(150);
		}

		var hoverIntentConfig = {
			sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)
			interval: 50,   // number = milliseconds for onMouseOver polling interval
			over: addMenu,     // function = onMouseOver callback (required)
			timeout: 300,   // number = milliseconds delay before onMouseOut
			out: removeMenu       // function = onMouseOut callback (required)
		}

		$("#nav li").hoverIntent(hoverIntentConfig);
		// Homepage
		$(".slideshow").cycle({
			fx:     'scrollHorz',
			pager:  '.banner_nav',
			prev:   '#prev1',
		    next:   '#next1',
			speed: 1500,
			sync: 1,
			timeout: 6500
		});
		
		// Easy Slider
		$("#slider").easySlider({
			prevId: 'prevBtn', /* previous button id */
			prevText: '', /* previous button text display */
			nextId: 'nextBtn', /* next button id */
			nextText: '', /* next button text display */
			controlsShow: true, /* 'true' => buttons on, 'false' => buttons off */
			controlsBefore: '', /* this allow extra markup added before the buttons */
			controlsAfter: '', /* this allow extra markup added after the buttons */
			controlsFade: false, /* buttons disapper when gets to end (only when continous set to false)*/
			firstId: 'firstBtn', /* first button id */
			firstText: 'First', /* the text shown when firstShow set to true */
			firstShow: false, /* shows link to first slide */
			lastId: 'lastBtn', /* Last button id */
			lastText: 'Last', /* last button text */
			lastShow: false, /* shows link to last slide */
			vertical: false, /* 'true' => scroll vertically, 'false' => scroll horizontally */
			speed: 500, /* speed of slide */
			auto: true, /* 'true' => automatic scroll, 'false' => button progress only */
			continuous: true, 
			pause: 7000, /* duration of image pause */
			numeric: false,
			numericId: 'controls'
		});
		
		// PrettyPhoto
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animation_speed: 'fast', /* fast/slow/normal */
			slideshow: false, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 0.80, /* Value between 0 and 1 */
			show_title: false, /* true/false */
			allow_resize: true, /* Resize the photos bigger than viewport. true/false */
			default_width: 500,
			default_height: 344,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
			changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			callback: function(){} /* Called when prettyPhoto is closed */
		});
		
	})
})(jQuery);

