// JavaScript Document

/*

 * Image preview script 

 * powered by jQuery (http://www.jquery.com)

 * 

 * written by Alen Grakalic (http://cssglobe.com)

 * 

 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery

 *

 */

 

this.imagePreview = function(){	

	/* CONFIG */

		

		xOffset = 10;

		yOffset = 30;

		

		// these 2 variable determine popup's distance from the cursor

		// you might want to adjust to get the right result

		

	/* END CONFIG */

	$("a.preview").hover(function(e){

		this.t = this.title;

		this.title = "";	

		var c = (this.t != "") ? "<br/>" + this.t : "";

		$("body").append("<p id='preview'><img src='"+ $(this).attr("alt") +"' alt='Image preview' />"+ c +"</p>");								 

		$("#preview")

			.css("top",(e.pageY - xOffset) + "px")

			.css("left",(e.pageX + yOffset) + "px")

			.fadeIn("fast");						

    },

	function(){

		this.title = this.t;	

		$("#preview").remove();

    });	

	$("a.preview").mousemove(function(e){

		$("#preview")

			.css("top",(e.pageY - xOffset) + "px")

			.css("left",(e.pageX + yOffset) + "px");

	});			

};





// starting the script on page load

$(document).ready(function(){

	imagePreview();

});

jQuery(document).ready(function() {
	
	$('.preview_list .preview_excerpt').setEqualHeight();
	
	
	
	$('.drawer_items li').each(function(){
		var aTag = $(this).find('a').eq(0);

		if($(this).children('ul').length > 0)
			$(aTag).css('background', 'url(images/bullet-red-down-small.png) no-repeat 8px 8px');
		else
			$(aTag).css('background', 'url(images/bullet-red.png) no-repeat 8px 8px');
	});
	
	/*
	$('.drawer_items li>a').mouseover(function(){
		if(!$(this).is(':last-child'))
			$(this).next().show();
	});
	*/

	//initialize navigation for the dropdown effect
	jQuery('#navigation').superfish({
		delay: 0,
		animation: {
			opacity: 'show',
			height: 'show'
		},
		speed: 300,
		autoArrows: true,
		anchorClass: 'sf-with-ul',
		arrowClass: 'sf-sub-indicator',
		dropShadows: false
	});
	
	jQuery('.drawers_list').accordion({
		header: ".drawer_handle"
	})
	
	/*** FX ***/
	/** ----------------------------------------------------- **/
	
	jQuery('.fx_button_hover').hover(function() {
		jQuery(this).css('background-position', 'left bottom');
	}, function() {
		jQuery(this).css('background-position', 'left top');
	});
	
	jQuery('.fx_input_field').focus(function() {
		if (this.value == this.defaultValue) {
			jQuery(this).css("color", "#eee");
			this.value = '';
		}
		if (this.value != this.defaultValue) {
			this.select();
		}
	});
	jQuery('.fx_input_field').blur(function() {
		if ($.trim(this.value) == '') {
			this.value = (this.defaultValue ? this.defaultValue : '');
			jQuery(this).css("color", "#777");
		}
	});
	
	$('.mini_img').click(function() {
		var src = $(this).attr('src');
		$('#vehicle_image_main img').attr('src', src.replace('small', 'large'));
		$('#vehicle_image_main img').attr('height', '482');
		$('#vehicle_image_main img').attr('width', '623');
	});
	
	
});

/*** Functions ***/
/** ----------------------------------------------------- **/

jQuery(function() { //smoothscroll
	jQuery('.smooth_scroll').click(function() {
		if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') &&
		location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) + ']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({
					scrollTop: targetOffset
				}, 1000);
				return false;
			}
		}
	});
});

function zebra_table() { //zebra table
	jQuery('tbody tr:nth-child(odd)').addClass('odd');
	
}

Cufon.replace('.font_univers_condensed', {
	fontFamily: 'univers condensed',
	hover: true
});

Cufon.replace('.font_bd_hanover, ' +
'.home_section_title, ' +
'.drawer_handle, ' +
'.basic_style_1 h1, .basic_style_1 h2, .basic_style_1 h3, .basic_style_1 h4, .basic_style_1 h5, .basic_style_1 h6,', {
	fontFamily: 'BD Hanover',
	hover: true
});

