
var jq = jQuery.noConflict();

jq.fn.vAlign = function() {
	return this.each(function(i){
		var ah = jq(this).height();
		var ph = jq(this).parent().height();
		var mh = (ph - ah) / 2;
		jq(this).css('top', mh);
	});
};

jq(document).ready(function(){

	
	jq(".primaryNav li a span").vAlign();
	
	// This if statement is to make sure the subnav doesn't get hidden
	// in the SiteFinity admin, cos then you can't edit the template
	if(document.location.href.indexOf("cmspagemode") <= 0)
	{
		jq(".subnav .RadMenu li").length == 0 ? jq(".subnav").hide() : null;
	}
	
	jq(".form_row_wrapper").hover(
			function(){ jq(this).addClass("form_row_hover"); },
			function(){ jq(this).removeClass("form_row_hover"); }
	);
	jq(".form_row_wrapper input, .form_row_wrapper textarea").focus( function(){ jq(this).parents(".form_row_wrapper").addClass("form_field_focus"); } );
	jq(".form_row_wrapper input, .form_row_wrapper textarea").blur( function(){ jq(this).parents(".form_row_wrapper").removeClass("form_field_focus"); } );
	


    jq(".home_flash ol").cycle({
		fx:     'fade', 
		speed:  'slow', 
		timeout: 3000, 
		next:   '.but_flash_next', 
		prev:   '.but_flash_prev' 
	});
	
	jq(".sub_flash ol").cycle({
		fx:     'fade', 
		speed:  'slow', 
		timeout: 3000, 
		next:   '.but_flash_next', 
		prev:   '.but_flash_prev' 
	});

	jq(".maincontent table").each(function(){
		jq(this).width() > 645 ? jq(this).width(645) : null;
	});
	
	
	/* ------------------------------------------------ FONT SIZE TOGGLE ------------------------------------------------ */
	// If there's a cookie present for this site, assign the font size based on this value.
	if(jq.cookie('fontSizeCookie'))
	{
		var getCookie = parseFloat(jq.cookie('fontSizeCookie'));
		jQuery(".contentwrapper").css({ 'font-size' : getCookie+'em' });
	}
	
	// Increase the font size based on <current cookie size> + 0.25.
	jQuery("a.font_inc").click(function() 
	{
		if(jq.cookie('fontSizeCookie'))
		{
			
			jq.cookie('fontSizeCookie', parseFloat(jq.cookie('fontSizeCookie'))+0.25, { path: '/' });
			jQuery(".contentwrapper").css({ 'font-size' : parseFloat(jq.cookie('fontSizeCookie'))+'em' });
		}
		else // No Cookie Present? Set a Cookie based on initial step-up (0.25), then increase font size
		{
			jq.cookie('fontSizeCookie', 1.25, { path: '/' });
			jQuery(".contentwrapper").css({ 'font-size' : parseFloat(jq.cookie('fontSizeCookie'))+'em' });
		}
	});
	
	// Decrease the font size based on <current cookie size> - 0.25.
	jQuery("a.font_dec").click(function() 
	{
		if(jq.cookie('fontSizeCookie'))
		{
			if(parseFloat(jq.cookie('fontSizeCookie')) > 1.0)
			{
				jq.cookie('fontSizeCookie', parseFloat(jq.cookie('fontSizeCookie'))-0.25, { path: '/' });
				jQuery(".contentwrapper").css({ 'font-size' : parseFloat(jq.cookie('fontSizeCookie'))+'em' });
			}
		}
	});
	/* ------------------------------------------------ FONT SIZE TOGGLE ------------------------------------------------ */

	
});


