﻿// GOLF CAR SYSTEMS -- Change the below text

var bgs_folder = "/Assets/SiteImages/"; // Must end with forward slash

var bgs_general = ["gcsbg-building.jpg", "imag0191.jpg"];
var bgs_sales = ["gcsbg-sales.jpg", "gcsbg-rentals.jpg"];
var bgs_service = ["gcsbg-service.jpg", "bg-service-1.jpg", "bg-service-2.jpg"];
var bgs_rentals = ["gcsbg-rentals.jpg", "imag0191.jpg", "gcsbg-sales.jpg"];

/*** DO NOT EDIT BELOW THIS LINE ***/

// Preload Image Script

(function ($) {
	var cache = [];
	// Arguments are image paths relative to the current page.
	$.preLoadImages = function () {
		var args_len = arguments.length;
		for (var i = args_len; i--; ) {
			var cacheImage = document.createElement("img");
			cacheImage.src = arguments[i];
			cache.push(cacheImage);
		}
	}
	$.preLoadImagesAsArray = function (arrayStrings) {
		var args_len = arrayStrings.length;
		for (var i = args_len; i--; ) {
			var cacheImage = document.createElement("img");
			cacheImage.src = bgs_folder + arrayStrings[i];
			cache.push(cacheImage);
		}
	}
})(jQuery);

// Email fixer-upper

function fixEmailLinks() {

	$("a:contains( d0t )").each(function () {
		$(this).attr("href", $(this).attr("href").replace(" @t ", "@").replace(" d0t ", "."));
		$(this).html($(this).html().replace(" @t ", "@").replace(" d0t ", ".").replace("mailto:", ""));
	});

}

// On start

$(function () {

	/*
	var bodyId = $("body").attr("id");

	if (bodyId == "golf-car-sales")
	setupRotatingBackground(bgs_sales);
	else if (bodyId == "golf-car-service")
	setupRotatingBackground(bgs_service);
	else if (bodyId == "golf-car-rentals")
	setupRotatingBackground(bgs_rentals);
	else
	setupRotatingBackground(bgs_general);
	*/

	jQuery(".nivoSlider").nivoSlider({
		effect: "sliceDown,sliceDownLeft,sliceUp,sliceUpLeft,sliceUpDown,sliceUpDownLeft,fold,fade,slideInRight,slideInLeft,boxRandom,boxRain,boxRainReverse,boxRainGrow,boxRainGrowReverse",
		slices: 15,
		boxCols: 8,
		boxRows: 4,
		animSpeed: 200,
		pauseTime: 10000,
		startSlide: 0,
		directionNav: true,
		directionNavHide: true,
		controlNav: true,
		controlNavThumbs: true,
		controlNavThumbsFromRel: false,
		keyboardNav: true,
		pauseOnHover: true,
		manualAdvance: false
	});

	fixEmailLinks();

	// Set up photo viewer
	$(".photos a, .photo a, a.photo").fancybox({
		'type': 'image',
		'transitionIn': 'elastic',
		'transitionOut': 'elastic',
		'speedIn': 600,
		'speedOut': 200,
		'overlayShow': true
	});

	// Set up image mouseovers
	$(".productList .product ul.photos a").hover(function (e) {
		var $this = $(this);
		var $img = $this.parent(".product").find("a.photo img");
		$img.attr("tag", $img.find("img").attr("src"));
		$img.attr("src", $this.attr("href"));
	}, function (e) {
		var $this = $(this);
		var $img = $this.parent(".product").find("a.photo img");
		$img.attr("src", $img.attr("tag"));
	});

	// Google Analytics
	
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-22322462-1']);
	_gaq.push(['_trackPageview']);

	(function () {
	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();

});




