/*
	Site:		Camjac
	File:		/scrips/camjac.js
	Author:		Andrew Disley, Simplified http://simplified.co.uk/
	Version:	2009-09-27
----------------------------------------------- */

// preload navigation images:

if (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('#scroller .scrollable').before('<a class="scrollable-nav prev"></a>').after('<a class="scrollable-nav next"></a>');
		$j('#scroller #scrollnav').tabs('#scrolltabs > div', {
			current: 'highlight'
		});
		$j('#scroller .scrollable').scrollable({
			loop: true,
			size: 3
		}).autoscroll({
			autoplay: true,
			interval: 10000, /* time to autoscroll miliseconds (curentl 10) */
			steps: 1 /* items to scroll on autoscroll (curentl 1) */
		});
	}

};

/*	DOM Ready events
----------------------------------------------- */
$j(function() {

	Global.init();

	if ($j('.featured').length) {
		CHomeFeatured.init();
	}
	if ($j('#scroller').length) {
		CHomeProducts.init();
	}

});