﻿// VARIABLES
var _windowHeight;
var _pageHeight;
var _pageWidth;
var _footerExpanded = false;

// PROGRAM STARTS -----------------------------------------------------------------------------//
var $j = jQuery.noConflict();
$j(document).ready(function() {

	var isIE6 = ($j.browser.msie && $j.browser.version=="6.0")

	if(!isIE6){
		/* initialise page */
		InitPage();

		/* set default variables */	
		PositionFooter();

		/* click events */
		$j('#FooterMoreInfo').click(function() { AnimateFooter(); });
	}
});


// METHODS ----------------------------------------------------------------------------------//
function InitPage() {
	_pageHeight = $j(document.body).height();
	_windowHeight = $j(window).height();
}

function PositionFooter() {
	var location = 0;
	var footerHeight = $j('#Footer').outerHeight();

//	if (_windowHeight >= _pageHeight) {
//		location = footerHeight;		
//	}
//	else if (_windowHeight < _pageHeight) {
//		location = _pageHeight - _windowHeight;
//	}

//	location = 0;	

	$j('#Footer').css({ 
		"position": "fixed",
		"bottom": location + "px"
	});
}

function AnimateFooter() {
	var footer = $j('#Footer');
	var footerContent = $j('#FooterContent');
	var location = 0;
	var contentHeight = 0;
	var displayType = "none";
	var span = $j('#FooterExpandText');
	
	if (_footerExpanded) {
		location = 0;		
	}
	else {
		location = contentHeight = 204;
		displayType = "block";
	}

	if (footer != null && footerContent != null) {
		footer.animate({ "bottom": location + "px" }, 800, "swing");
		footerContent.css({ "border-width": "0 1px" });
		footerContent.animate({ "height": contentHeight + "px" }, 800, "swing");
	}

	// Set the current footer state
	_footerExpanded = !_footerExpanded;

	var moreInfo = $j('#MoreInfo');
	if (_footerExpanded) {
		var cssObj = {
		'background': 'url(../Site/Resources/Images/layout/footer_arrow_down.gif) left center no-repeat'}		
	
		span.text('close');
	} else {
		var cssObj = {
		'background': 'url(../Site/Resources/Images/layout/footer_arrow.gif) left center no-repeat'}

		span.text('information');		
	}
	moreInfo.css(cssObj);
}

