﻿/// <reference path="~/i/iui/iui.js" />

/*	JavaScript Source File
	for Lottery Post (http://www.lotterypost.com)
	Author: Todd Northrop
	E-mail: webmaster (at) lotterypost (dot) com
	Copyright (c) 1999-2009. All Rights Reserved.
	Reproduction in whole or in part in any form or medium without express written permission of the Author is prohibited.
	Lottery Post and the Lottery Post logo are trademarks of Todd Northrop, and may not be used without express written permission.
------------------------------------------------------*/

(function () {

var createDelegate = function (instance, method) {
	return function() {
		return method.apply(instance, arguments);
	};
};

window.iLP = {
	/// <summary>
	/// Lottery Post for iPhone/iPod Touch client library. Supplements the iUI library.
	/// </summary>
	
	homeButton: null,
	
	initialize: function () {
		this.homeButton = document.getElementById("homeButton");
	},

	afterNewPage: function (newPage, fromPage) {
		var pageUrl, track,
			newId = newPage.id;
		
		if (newId === "home") {
			this.homeButton.style.display = "none";
		}
		else if (fromPage.id === "home") {
			this.homeButton.style.display = "";
		}
		
		if (pageTracker && (track = pageTracker._trackPageview)) {
			
			if (newId === "home") {
				track("/i/default.aspx");
			}
			else if (pageUrl = document.getElementById("pageUrl", newPage)) {
				track(pageUrl.value);
			}
		}
	}
};

iui.animOn = true;
iui.onLoad = createDelegate(iLP, iLP.initialize);
iui.onPageUpdated = createDelegate(iLP, iLP.afterNewPage);
})();
