﻿var pageHeading = { src: '/Themes/Default/Assets/pageHeading.swf' };
sIFR.activate(pageHeading);

var printState = null;

function getPrintState()
{
	return printState;
}

var Site = new Class(
{
	initialize : function()
	{

	},

	load : function()
	{
		ui.load();

		ui.onBeforeRequest = function()
		{
			$("pnlLoading").setProperty("class", "loadingA");
		}

		ui.onAfterRequest = function()
		{
			$("pnlLoading").setProperty("class", "loadingI");

			site.ensureTypo();
		}

		ui.onSetDialog = function()
		{
			if (stateHistory.active)
			{
				stateHistory.push();
			}
		}

		stateHistory.load();

		window.onresize = function()
		{
			site.ensureTypo();
		}

		this.ensureTypo();
	},

	buildState : function()
	{
		return base64Json.encode(ui.collectDialogState($("dlgPage")));
	},

	printPage : function()
	{
		printState = ui.collectDialogState($("dlgPage"));
		var wndPrint = window.open("ProxyPrint.aspx", "Print", "width=600px,height=600px,left=50px,top=50px,toolbar=no,menubar=no,scrollbars=yes");
	},

	ensureTypo : function()
	{
		sIFR.replace(pageHeading,
			{
				selector   : 'h1.menuHeading',
				forceSingleLine : true,
				fixHover   : true,
				css        : { '.sIFR-root' : { 'color' : '#A7A7A7', 'font-weight' : 'normal', 'cursor' : 'pointer' } },
				selectable : false,
				wmode      : 'transparent',

				onRollOver : function(callbackInfo)
				{
					callbackInfo.changeCSS( { '.sIFR-root' : { 'color': '#6d6d6d', 'font-weight' : 'normal', 'cursor' : 'pointer' } } );
				},

				onRollOut : function(callbackInfo)
				{
					callbackInfo.changeCSS( { '.sIFR-root' : { 'color': '#A7A7A7', 'font-weight' : 'normal', 'cursor' : 'pointer' } } );
				},
				
				onRelease : function(callbackInfo)
				{
					var parentDiv = $(callbackInfo.getAlternate()).getParent();
					var ieRouteFunc = parentDiv.click;

					if (ieRouteFunc)
					{
						ieRouteFunc();
					}
				}
			}
		);
		
		sIFR.replace(pageHeading,
			{
				selector   : 'h2.pageHeading',
				css        : { '.sIFR-root' : { 'color': '#384b6b', 'font-weight' : 'normal', 'leading' : '10'  } },
				selectable : false,
				wmode      : 'transparent'
			}
		);

		sIFR.replace(pageHeading,
			{
				selector   : 'h2.pageEntryHeading',
				css        : { '.sIFR-root' : { 'color': '#384b6b', 'font-weight' : 'normal', 'leading' : '10', 'cursor' : 'pointer'  } },
				selectable : false,
				wmode      : 'transparent',

				onRollOver : function(callbackInfo)
				{
					callbackInfo.changeCSS( { '.sIFR-root' : { 'color': '#48618A', 'font-weight' : 'normal', 'cursor' : 'pointer' } } );
				},

				onRollOut : function(callbackInfo)
				{
					callbackInfo.changeCSS( { '.sIFR-root' : { 'color': '#384b6b', 'font-weight' : 'normal', 'cursor' : 'pointer' } } );
				},
				
				onRelease : function(callbackInfo)
				{
					var parentDiv = $(callbackInfo.getAlternate()).getParent();
					var ieRouteFunc = parentDiv.click;

					if (ieRouteFunc)
					{
						ieRouteFunc();
					}
				}
			}
		);

		sIFR.replace(pageHeading,
			{
				selector   : 'h3.pageHeading',
				css        : { '.sIFR-root' : { 'color' : '#999999', 'font-weight' : 'normal', 'leading' : '10' } },
				selectable : false,
				wmode      : 'transparent'
			}
		);
	}
});

var site = new Site();

window.addEvent('domready', function()
{
	site.load();
});