
	
	Cufon.replace('#heading.home a', {hover: true, fontFamily: 'Grotesk Bold' });
	Cufon.replace('.tooltipcontent h2', {hover: true, fontFamily: 'Grotesk Bold' });

	//*****************************
	// SHOW AND HIDE HIDDEN CONTENT
	//*****************************
	
	jQuery(document).ready(function($){ 
	
		$('.homeTeaser li.large').hover(
			function(){
				$(this).find('p').show('fast');
			},
			function() {
				$(this).find('p').hide('fast');
			}
		);
		
		$('.homeTeaser li.text').hover(
			function(){
				//$(this).find('p').show('fast');
			},
			function() {
				//$(this).find('p').hide('fast');
			}
		);		
	
		for(var i=1; i <= $("#thumbGallery li").length; i++) {
			var reg = /.*(\d)/;
			$("#thumbGallery .tt"+i).live("hover", function(event) {
				reg.exec($(this).attr("class"));
				var tt = ".tooltipcontent" + RegExp.$1;
				if( event.type == "mouseenter" ) {
					$("#thumbGallery").find(tt).addClass("show");
				} else {
					$("#thumbGallery").find(tt).removeClass("show");
				}
			});	
		}
	});

	//*************************************************
	// CUSTOM CONFIGURATION FOR HOMEPAGE
	// CHANGE BACKGROUNDS AND THUMBSLIDER CONFIGURATION
	//*************************************************
	
    jQuery(document).ready(function ($) {	
		var tSlider = $("#thumbSlider");
		
		$('li:first', tSlider)
			.addClass("slide-active");
		
		tSlider
			.data('slide-active', 1)
			.data('slide-total', $("li", tSlider).length);


		var tsFn = {
			changeBackground : function (indx) {

				var size = arrayImg.length;

				if (indx == size) {
					indx = 0;
				}

				var imgSrc = arrayImg[indx];

				var img = new Image();
				img.src = imgSrc;

				$(img).bind('load', function () {
					$(img).addClass('background').fadeTo('slow', 0.5);
					$(img).data("oWidth", img.width).data("oHeight", img.height);
					$("#background").append(img);
					tsFn.onResize($("#background"));
					$(img).fadeTo('slow', 1, function() { $(this).prev().remove(); });
				});
				
			},
			onResize : function (context) {
				$("img", context).each(function() {
					var oWidth = parseInt($(this).data("oWidth")), oHeight = parseInt($(this).data("oHeight")),
						cWidth = $(window).width(), cHeight = $(window).height();

					var scaleWidth = cWidth / oWidth, scaleHeight = cHeight / oHeight;
					var width = 0, height = 0;
					var imgScale = Math.max(scaleWidth, scaleHeight);
					width = imgScale * oWidth;
					height = imgScale * oHeight;

					$(this)
						.attr("width", width).attr("height", height)
						.css("margin-left", ((cWidth - width) / 2) + 'px')
						.css("margin-top", ((cHeight - height) / 2) + 'px');
					
				});
			},
			onPrevSlide : function() {
				if(changeDirection) {
					thumbSlider.stopShow();
					thumbSlider.setOption('autoDirection', 'prev');
					thumbSlider.startShow();
				}

				changeDirection = false;
			},
			onNextSlide : function() {
				if(changeDirection) {
					thumbSlider.stopShow();
					thumbSlider.setOption('autoDirection', 'next');
					thumbSlider.startShow();
				}

				changeDirection = false;
			}
		};
		
		$(window).resize(function () {
			tsFn.onResize($('#background'));
		});
		
		var img = $("#background img:first");
		
			
		var imgLoaded = function() {
			img.data("oWidth", img[0].width).data("oHeight", img[0].height);
			tsFn.onResize($('#background'));
		};
		
		if(img[0].width > 0) {
			imgLoaded.call(this);	
		} else {
			img.load(imgLoaded);
		}
			
		
		var changeDirection = false, hasClicked = false;
		

		var thumbSlider = tSlider.bxSlider({
			auto: true,
			startingSlide: 2,
			displaySlideQty: 3,
			moveSlideQty: 1,
			randomStart: false,
			autoStart: true,
			pause: 5000,
			speed: 500,
			controls: true,
			infiniteLoop: true,
			onPrevSlide: function(currentSlide){
				changeDirection = true;
				tsFn.onPrevSlide();
			},
			onPrevArrowClick : function () {
				changeDirection = true;
				tsFn.onPrevSlide();
				thumbSlider.goToPreviousSlide();
			},
			onBeforeSlide : function(currentSlideNumber, totalSlideQty, currentSlideHtmlObject) {
				$("li", tSlider).removeClass("slide-active");
				tsFn.changeBackground(currentSlideNumber + 1);
				$(currentSlideHtmlObject).next().addClass("slide-active");
			},
			onNextSlide: function(currentSlide){
				changeDirection = true;
				tsFn.onNextSlide();
			},
			onNextArrowClick: function () {
				changeDirection = true;
				tsFn.onNextSlide();
				thumbSlider.goToNextSlide();
			}
		});	
		
		

		$('a', tSlider).click(function(){
			var page = $(this).parent().parent();

			if(page.hasClass("slide-active")) return false;
			
			hasClicked = true;
			changeDirection = true;
			
			if(page.index() > $("li.slide-active", tSlider).index())
				thumbSlider.goToNextSlide();
			else
				thumbSlider.goToPreviousSlide();
			
			return false;
		}).mouseenter(function(){
			thumbSlider.stopShow();	
		}).mouseleave(function() {
			if(!hasClicked) {

				
				thumbSlider.startShow();
			}
			hasClicked = false;
		});		
	});	

