﻿/*
    @Australian Unity
    @Author reactive.com
    @October 2010

*/

/*
* EASING
*/
var easingMethod = 'easeInOutCubic';
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend(jQuery.easing, {
    def: 'easeOutQuad',
    easeInOutCubic: function (x, t, b, c, d) {
        if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
        return c / 2 * ((t -= 2) * t * t + 2) + b;
    }
});

/*
*  ausunity class
*/
var cacheActive;
var brand;
var utilities;
var header;
var trigger;
var nav;
var pns;
var brand;
var utilities;
var header;
var pns;


var ausunity = {
	init: function() {
		$(document).ready(function () {
			var trigger = $('#pnsHandler');
			var nav = $('#nav');
			var cacheActive = $('> li.active', nav);
			header = $('#globalHeader');
			utilities = $('.utilitiesHolder', header);
			brand = $('#globalHeader .brand');
			pns = $('#pnsMenu', header);
		
			trigger.click(function () {
				if ($(this).parent().hasClass('active')) {
					cacheActive.addClass('active');
					$(this).parent().removeClass('active');
					ausunity.menu.hideWithAnimation();
				} else {
					cacheActive.removeClass('active');
					$(this).parent().addClass('active');
					ausunity.menu.showWithAnimation();
				}
				return false;
			});
		});
	},
	menu: {
		showWithAnimation: function() {
			brand.fadeOut({ easing: easingMethod, duration: 500, queue: false });
			utilities.fadeOut({ easing: easingMethod, duration: 500, queue: false });
			header.animate({ height: 322 }, { easing: easingMethod, duration: 500, queue: false });
			pns.fadeIn({ easing: easingMethod, duration: 500, queue: false }).slideDown({ easing: easingMethod, duration: 500, queue: false });
		},
		hideWithAnimation: function(){
			brand.fadeIn(300);
			utilities.fadeIn({ easing: easingMethod, duration: 500, queue: false });
			header.animate({ height: 143 }, { easing: easingMethod, duration: 500, queue: false });
			pns.slideUp({ easing: easingMethod, duration: 500, queue: false }).fadeOut({ easing: easingMethod, duration: 500, queue: false });
		}
	}	
};

ausunity.init();

/*
*   FONT RE-SIZER
*   Recycled from old site
*/
var CurrentFontMultiplier = 0;

function resizeText(multiplier) {
    if (multiplier > 0) {
        if (CurrentFontMultiplier >= 0.3)
            return;
    } else {
        if (CurrentFontMultiplier <= -0.3)
            return;
    }

    //increaseSize("pageBody", multiplier);
    //increaseSize("allContentsContainerTable", multiplier);
    increaseSize("contentAreaContainer", multiplier);

    if (multiplier > 0)
        CurrentFontMultiplier += 0.1;
    else
        CurrentFontMultiplier -= 0.1;

}

function increaseSize(elementId, multiplier) {
    if (document.getElementById(elementId).style.fontSize == "") {
        document.getElementById(elementId).style.fontSize = "1em";
    }

    document.getElementById(elementId).style.fontSize = parseFloat(document.getElementById(elementId).style.fontSize) + (multiplier * 0.1) + "em";

}

 $(document).ready(function () {

 //$('#pageBody').css({ 'fontSize': '1em' });

     $('.textsize .decrease').click(function () {
         resizeText(-1);
         return false;
     });

     $('.textsize .increase').click(function () {
         resizeText(1);
         return false;
     });


     $('.input-search').focus(function () {
         if ($(this).val() == "Search")
             $(this).val("");
     });

     $('.input-search').blur(function () {
         if ($(this).val() == "")
             $(this).val("Search");
     });

 });
