/*Basic text*/
Cufon('#quote-slot, H2, H3, H4, H5, .main-quote P, .column_title, .success, .spam-wait', { fontFamily: 'Myriad Pro' });
Cufon('.content-split .title, #latest .top SPAN', { fontFamily: 'Folk Solid' });

/*Basic hovers*/
Cufon('#heading UL LI UL LI A, #quote-slot A, .content-split A, #latest UL LI A, .backlink, .borderbox .type-B LI A', { hover: true, fontFamily: 'Myriad Pro' });

/*Dropshadow text*/
Cufon('.borderbox .type-A .text P, .borderbox .type-B .top, #latest-sm .top, .borderbox H3, .sidebox-list .top', { fontFamily: 'Myriad Pro', textShadow: '0px 1px rgba(255,255,255,255)' });
Cufon('#footer .social, #latest-sm .signup, #latest .signup', { fontFamily: 'Folk Solid', textShadow: '0px 1px rgba(255,255,255,255)' });

/*Dropshadow hovers*/
Cufon('#footer .top-nav', { fontFamily: 'Myriad Pro', textShadow: '0px 1px rgba(255,255,255,255)', hover: true });

$(document).ready(function(){
	$('#hero-slot').cycle({
		fx: 'fade',
		pause: true,
		before: onBefore,
		after: onAfter
	});

	$("#heading UL LI").hover(function() {
		$(this).find("ul.subnav").stop(true, true).slideDown('fast').show();

		$(this).hover(function() {
		}, function(){
			$(this).find("ul.subnav").stop(true, true).fadeOut('1000');
		});

		}).hover(function() {
			$(this).addClass("active");
		}, function(){
			$(this).removeClass("active");
	});

	if ($('#hero-slot').length) {
		$('#tab-0').addClass('active');
	}

	$('.hst-first').hover(function(){
		$('#hero-slot').cycle(0);
		$(this).addClass('active');
		$('.hst-middle, .hst-last').removeClass('active');
	});
	$('.hst-middle').hover(function(){
		$('#hero-slot').cycle(1);
		$(this).addClass('active');
		$('.hst-first, .hst-last').removeClass('active');
	});
	$('.hst-last').hover(function(){
		$('#hero-slot').cycle(2);
		$(this).addClass('active');
		$('.hst-middle, .hst-first').removeClass('active');
	});
});

function onBefore(curr, next, opt) {
	$('#tab-' + opt.currSlide).removeClass('active');
	$('#tab-' + opt.nextSlide).addClass('active');
};

function onAfter(curr, next, opt) {
	$('#tab-' + opt.nextSlide).removeClass('active');
};

var site = {}

site.base =
{
	initialised : false,
	expanderBusy : false,
	expanderOpen : false,
	expanderContents : 0, // 0 = None, 1 = Newsletter, 2 = Client Login

	init : function() {
		if (this.initialised) {
			return true;
		}

		//Code here etc
		this.setup_contact_form();
		this.initialised = true;

		return true;
	},

	setup_contact_form : function() {
		$("form input[type='text'], form textarea").live("focus", function()
		{
			if ($(this).val() == site.base.get_original_contact_value($(this).attr("name")))
			$(this).val("");
		});
		$("form input[type='text'], form textarea").live("blur", function()
		{
			if (jQuery.trim($(this).val()) == "")
			$(this).val(site.base.get_original_contact_value($(this).attr("name")));
		});
		$("form .error + input + .input").css('border-color', $(".error").eq(0).css("color"));
	},

	get_original_contact_value : function(field) {
		orig_field = "#" + field + "_default";
		return $(orig_field).val();
	}
}

//Dom ready
$(function()
{
	site.base.init();
});
