/*
	Site:		Camjac
	File:		/scripts/camjac.js
	Author:		Andrew Disley, Simplified http://simplified.co.uk/
	Version:	2009-09-27
----------------------------------------------- */

// preload navigation images:

if (0 && document.images) {

	about_on = new Image();
	about_on.src = "images/about_on.gif";
	about_off = new Image();
	about_off.src = "images/about_off.gif";

	contacts_on = new Image();
	contacts_on.src = "images/contacts_on.gif";
	contacts_off = new Image();
	contacts_off.src = "images/contacts_off.gif";

	products_on = new Image();
	products_on.src = "images/products_on.gif";
	products_off = new Image();
	products_off.src = "images/products_off.gif";

	categories_on = new Image();
	categories_on.src = "images/categories_on.gif";
	categories_off = new Image();
	categories_off.src = "images/categories_off.gif";
}

function hiLite(imgID,changeID) {

	if (document.images) {
		document.images[imgID].src = eval(changeID + ".src");
		return true;
	}
}

/*	Global Configuration
----------------------------------------------- */
var $j = jQuery;
var isIE6 = false;
var isSafari = false;

/*	Global Literal Object: Site-wide functions
----------------------------------------------- */
var Global = {

	/* Utility: Browser Tests / Specific Fixes/Hooks */
	utilBrowserTests : function() {

		/* Detect if User Agent is IE6 using object detection, apply fix for background flicker bug */
		if (typeof document.body.style.maxHeight == 'undefined') { isIE6 = true; try { document.execCommand('BackgroundImageCache', false, true); } catch(e) { } }

		/* Detect if User Agent is Safari, add class '.safari' to body */
		if ($j.browser.safari) { isSafari = true; $j('body').addClass('safari'); }

	},

	init : function() {

		var cc = this;

		cc.utilBrowserTests();

	}

};

/*	Component: CHomeFeatured
----------------------------------------------- */
var CHomeFeatured = {

	init : function() {

		var cc = this;

		$j('.featured-nav').tabs('.featured-tabs > div', {
			current: 'active',
			effect: 'fade',
			fadeOutSpeed: "slow",
			rotate: true
		}).slideshow({
			autoplay: true,
			interval: 10000
		});

	}

};

/*	Component: CHomeProducts
----------------------------------------------- */
var CHomeProducts = {

	init : function() {

		var cc = this;

		$j('#subfeature').tabs('.subfeature-tabs > div', {
			current: 'on',
			effect: 'fade',
			fadeOutSpeed: "slow"
		})
	}

};

/*	DOM Ready events
----------------------------------------------- */
$j(function() {

	Global.init();

	if ($j('.featured').length) {
		CHomeFeatured.init();
	}
	if ($j('.subfeature-tabs').length) {
		CHomeProducts.init();
	}

});
