/// <reference path="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.1-vsdoc.js" />
/// <reference path="cufon/cufon-yui.js.js" />
var WKN0001Global = (function ($) {

	var PrivateMethod = function () {
		return true;
	};

	var ReplaceFonts = function () {
		Cufon.replace
		('.productCategory .slider h2 a')
		('.hintsAndTips h6')
		('.storeSearch h6')
		('.h1Container ul.tabs li a')
		('h1')
		('h3')
		('.homeSections a', { hover: true })
		('ul.leftNavigation > li > a', { hover: true })
		('ul.leftNavigation > li ul > li a', { hover: true })
		('ul.nav-main li a', { hover: true });
	};
	var HideBreadCrumb = function () {
		$('ul.breadcrumb').hide();
	};

	var SetUpSearchText = function (obj) {
		obj.val('Search:');
		obj.focus(function () {
			var term = obj.val();
			//if (term === 'Search:')
				obj.val('');

		});

		obj.blur(function () {
			var term = obj.val();
			if (term === '') {
				obj.val('Search:');
			}
		});
	};

	SetUpLeftNav = function () {

		$('.SubCategory').children('ul').hide();
		$('.SubCategory.on').children('ul').show();
		$('.SubCategory:not(.on) a').click(function () {
			var sCat = $(this).parent();
			sCat.children('ul').slideToggle(500, "easeInQuart",
				function () {
					//sCat.toggleClass('on');//menu on state;
					Cufon.replace('.SubCategory a');
				} //end call back
			); //end slide toggle
		}); //end click.
		$('ul.leftNavigation > li > ul').hide();
		$('ul.leftNavigation > li.on > ul').show();
	};

	SetContainerHeights = function () {
		//would need to fire each time somehting is expanded
		//in either the main container or the left nav container. Apart from that works fine at setting the heights. KJ
		var main = $('#main div.content');
		var nav = $('#leftNav div.content');
		var navPadding = 105; //the extra padding on the bottom of nav to hold the need help image
		if (main.height() > (nav.height() + navPadding)) {//main is bigger
			nav.css({ 'min-height': main.height() - navPadding })
		} else {//nav is bigger
			main.css({ 'min-height': nav.height() + navPadding });
		}
		//console.log('Main height = ' + main.height() + " and Nav Height= " + nav.height());
	};

	var ReplaceCMSElements = function () {
		jQuery('.cms ul:not(#SiteMapHolder)').before('<div class="hr"></div>');
		jQuery('.cms ul:not(#SiteMapHolder)').after('<div class="hr"></div>')
		//$('.cms > ol').addClass('clearfix');
		$('.cms ul:not(#SiteMapHolder) li').prepend('<span></span>');

	};

	return {

		//used on the home page to hide the bread crumb
		HomeInit: function () {
			HideBreadCrumb();
		},

		ReplaceCMSElements: function () {
			ReplaceCMSElements();
		},

		Init: function () {
			SetUpSearchText($('.searchBar input.text'));
			SetUpSearchText($('.storeSearch input.text'));
			ReplaceFonts();
			SetUpLeftNav();
			//SetContainerHeights();//Make public and appply to pages as needed... standard page contact us page etc.
		}
	}
})(jQuery);
