/*
	Site:		Greater Grimsby
	File:		/assets/scripts/global.js
	Author:		Andrew Disley for Creative Lynx Limited http://www.creativelynx.co.uk/
	Version:	2009-12-23
----------------------------------------------- */

/*	Global Configuration
----------------------------------------------- */
var $j = jQuery;
var isIE = false;
var isIE6 = false;
var isSafari = false;

/*	Global Literal Object: Site-wide functions
----------------------------------------------- */
var SGlobal = {

	/* Configuration, Flags and Messages */

	/* jQuery Object References  */
	jEOBody: null,

	/* Utility: Browser Tests / Specific Fixes/Hooks */
	utilBrowserTests : function() {

		if ($j.browser.msie) { isIE = true; }

		/* 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 div#Container */
		if ($j.browser.safari) { isSafari = true; $j('div#Container').addClass('safari'); }

	},

	init : function() {

		var cc = this;

		/* ADD class to body so we can apply CSS only for when jQuery is available, different to hasJS */
		cc.jEOBody = $j('body');
		cc.jEOBody.addClass('jQ');

		cc.utilBrowserTests();

	}

};

/*	Components Object
----------------------------------------------- */
var SComponents = {

	/* jQuery Object References  */
	jEOWhyLocateHere: null,
	jEOWhyLocateHereInner: null,

	cWhyLocateHere  : function() {

		var cc = this;

		cc.jEOWhyLocateHereInner = $j('.inner', cc.jEOWhyLocateHere);

		cc.jEOWhyLocateHere.tabs(cc.jEOWhyLocateHereInner, {current: 'active', effect: 'slide', tabs: 'h3', initialIndex: 0});

		if (isIE) {
			$j('h3', cc.jEOWhyLocateHere).hover(function() {
				$j(this).addClass('hover');
			}, function() {
				$j(this).removeClass('hover');
			});
		}

	},

	init : function() {

		var cc = this;

		cc.jEOWhyLocateHere = $j('.Content div.c-whylocatehere');

		if (cc.jEOWhyLocateHere.length) {
			cc.cWhyLocateHere();
		}

	}

};

/*	DOM Ready events
----------------------------------------------- */
$j(function() {

	SGlobal.init();

	SComponents.init();

});
