﻿jQuery(document).ready(function()
{
	App.initialise();

});

var App =
{
	initialise: function()
	{
		App.bindHomePage();
	},
	
	bindHomePage: function()
	{
		// Position the drop shadow background image based on the position of the boxes of content.
		var offsetFromBoxTop = 122;
		if (jQuery(".Feature").length)
		{
			jQuery("#BodyWrapper").css({ backgroundPosition: "center " + (jQuery(".Box").position().top + offsetFromBoxTop) + "px" });
			jQuery(".Feature ul li").css({ display: "block" });
		}
	}
}

function openWindow(url, name, width, height, resizable, scrollbars, statusbar, menubar, toolbar)
{
	var optionString = '';
	if (width) optionString += 'width=' + width + ',';
	if (height) optionString += 'height=' + height + ',';
	if (resizable) optionString += 'resizable=' + resizable + ',';
	if (scrollbars) optionString += 'scrollbars=' + scrollbars + ',';
	if (statusbar) optionString += 'status=' + statusbar + ',';
	if (menubar) optionString += 'menubar=' + menubar + ',';
	if (toolbar) optionString += 'toolbar=' + toolbar + ',';
	win = window.open(url,name,optionString);
	if (win) win.focus();
}

function printPage()
{
	if (window.print) window.print();
	else alert("Please select \"Print...\" from the File menu.");
}

function trim(theString)
{
	var newString = theString;
	while (newString.charAt(0) == " " || newString.charCodeAt(0) == 10 || newString.charCodeAt(0) == 13 || newString.charCodeAt(0) == 9)
	{
		newString = newString.substring(1,newString.length);
	}
	while (newString.charAt(newString.length - 1) == " " || newString.charCodeAt(newString.length - 1) == 10 || newString.charCodeAt(newString.length - 1) == 13 || newString.charCodeAt(newString.length - 1) == 9)
	{
		newString = newString.substring(0,newString.length - 1);
	}
	return newString;
}

function getCookie(name)
{
	var cookies = document.cookie.split(";")
	for (var i=0; i<cookies.length; i++)
	{
		var nameVal = cookies[i].split("=");
		if (nameVal.length == 2 && trim(nameVal[0]) == trim(name))
		{
			return trim(nameVal[1]);
		}
	}
	return "";
}

function setCookie(name, value, expires)
{
	document.cookie = name + "=" + value + ";path=/;" + (expires ? " expires=" + expires.toGMTString() + ";" : "");
}

function removeCookie(name)
{
	setCookie(name, "", new Date("2 January 1970"));
}

function createBookmarkLink(url, title)
{
	if (window.sidebar)
		// Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url, "");
	else if (window.external)
		// IE Favorite
		window.external.AddFavorite(url,title);
	else if (window.opera && window.print)
		// Opera Hotlist
		return true;
}