/**** Incurrent Interstitial Window v1.1.0  REK  (c)HSBC Card Services Inc. 2006. All rights reserved. ****/

Incurrent = new function ( )
{
	this.Promote = function( PopupFile, Width, Height )
	{
		var HorzPos, VertPos;

		this.PopupFileName.Compare( PopupFile );

		if( this.InSession == false && this.EntryCount < 3 )
		{
			this.EntryCount.Increment( );
			
			if( navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf( 'MSIE 4' ) == -1 )
				HorzPos = window.screenLeft + 50, VertPos = window.screenTop + 50;
			else if( navigator.appName == "Netscape" )
				HorzPos = window.screenX + 50, VertPos = window.screenY + 50;
			else
				HorzPos = 50, VertPos = 50;
			
			this.IPopup = new Popup( PopupFile, ( Width == null ? 330 : Width ), ( Height == null ? 330 : Height ), false, false, false, false, HorzPos, VertPos )
			this.IPopup.Open( );
			this.IPopup.Window.IncurrentPtr = this;
		}
		this.InSession.Enable( );
	}

	this.PopupFileName = new Cookie( 'PopupFile' );
	this.PopupFileName.Compare = function ( PopupFile )
	{
		if( this.GetValue( ) != PopupFile )
		{
			Incurrent.EntryCount.SetValue( 1 );
			this.SetValue( PopupFile );
			this.ResetExpiry( 60 * 60 * 24 * 30 * 3 ); // 3 months
		}
	}
	
	this.EntryCount = new Cookie( 'EntryCount' );
	this.EntryCount.Increment = function ( )
	{
		this.SetValue( this.GetValue( ) + 1 );
		this.ResetExpiry( 60 * 60 * 24 * 30 * 3 ); // 3 months
	}
	this.EntryCount.toString = function ( )
	{
		return this.Exists == false ? 0 : this.GetValue( );
	}
	
	this.InSession = new Cookie( 'InSession' );
	this.InSession.toString = function ( )
	{
		return this.Exists.toString( );
	}
	this.InSession.Enable = function ( )
	{
		this.SetValue( true );
	}
}

/**** PopupLib v1.2.1  REK  (c)HSBC Card Services Inc. 2006. All rights reserved. ****/

function Popup( Path, Width, Height, HasMenubar, HasScrollbars, HasStatusbar, IsResizeable, HorzPos, VertPos, Target )
{
	// handle parameter defaults

	this.Path = Path;
	this.Width = Width == null ? 550 : Width; 
	this.Height = Height == null ? 400 : Height;
	this.HasMenubar = HasMenubar == null ? true : HasMenubar;
	this.HasScrollbars = HasScrollbars == null ? true : HasScrollbars;
	this.IsResizeable = IsResizeable == null ? true : IsResizeable;
	this.HasStatusbar = HasStatusbar == null ? true : HasStatusbar;
	this.HorzPos = HorzPos == null ? ( window.screen.availWidth - this.Width ) / 2 : HorzPos;  // center on screen
	this.VertPos = VertPos == null ? ( window.screen.availHeight - this.Height ) / 2 : VertPos;
	this.Target = Target;
	
	// maintain a reference stack of popup windows
	
	this.PrevPopup = window.LastPopup;
	window.LastPopup = this;
	this.Id = this.PrevPopup == null ? 0 : this.PrevPopup.Id + 1;

	this.Open = function ( )
	{
	  	// test to see if window needs to be reopened or brought to front
		if( this.Window == null || this.Window.closed == true )
			if (navigator.appVersion.indexOf('AOL')==-1) 
				this.Window = window.open( "", ( this.Target == null ? "Popup" + this.Id : Target ), "left=" + this.HorzPos + ",top=" + this.VertPos + ",height=" + this.Height + ",width=" + this.Width + ",status=" + ( this.HasStatusbar ? "yes" : "no" ) + ",toolbar=no,menubar=" + ( this.HasMenubar ? "yes" : "no" ) + ",location=no,resizable=" + ( this.IsResizeable ? "yes" : "no" ) + ",scrollbars=" + ( this.HasScrollbars ? "yes" : "no" ) );
			else
				this.Window = window.open( "", ( this.Target == null ? "Popup" + this.Id : Target ), "height=" + this.Height + ",width=" + this.Width + ",status=" + ( this.HasStatusbar ? "yes" : "no" ) + ",toolbar=no,menubar=" + ( this.HasMenubar ? "yes" : "no" ) + ",location=no,resizable=" + ( this.IsResizeable ? "yes" : "no" ) + ",scrollbars=" + ( this.HasScrollbars ? "yes" : "no" ) );				

		else if( navigator.appVersion.indexOf( 'MSIE 4' ) == -1 )  // refocus doesn't work in IE 4.0
			this.Window.focus( );
		this.Window.location.href = this.Path;  // (re)load the page
	}
	this.Close = function ( )
	{
		if( this.Window.closed == false ) { this.Window.close( ) };
	}
}

// ensure extraneous spawned windows close when user leaves relevant page

window.onunload = function ClosePopups( )
{
	var CurrentPopup;

	CurrentPopup = window.LastPopup;
	while( CurrentPopup != null )
	{
		if( CurrentPopup.Window != null && CurrentPopup.Window.closed == false )
			CurrentPopup.Window.close( );

		CurrentPopup = CurrentPopup.PrevPopup;
	}
}


/**** CookieLib v1.0.0  REK  (c)HSBC Card Services Inc. 2006. All rights reserved. ****/

function Cookie( Name, Value, Expiry, Directory, Domain, IsSecure )
{
	this.Name = Name == null ? 'Default' : Name;
	this.Expiry = Expiry;
	this.Directory = Directory;
	this.Domain = Domain;
	this.IsSecure = IsSecure == null ? false : IsSecure;

	this.ResetExpiry = function ( Seconds ) // input raw seconds relative to current time
	{
		this.SetExpiry( new Date( ( new Date( ) ).getTime( ) + 1000 * Seconds ) );
	}
	this.SetExpiry = function ( ExpiryDate ) // input fully qualified date object
	{
		this.SetAttribs( null, ExpiryDate );
	}
	this.SetValue = function ( Value )
	{
		this.SetAttribs( Value );
	}
	this.SetAttribs = function( Value, Expiry )
	{
		var CookieString;
		
		// only Value and Expiry can be altered after cookie is created
		if( Value == null ) Value = this.GetValue( );
		if( Expiry == null ) Expiry = this.Expiry;
		
		CookieString = escape( this.Name ) + '=' + escape( Value );
		if( Expiry != null )
			CookieString += '; EXPIRES=' + Expiry.toGMTString( );
		if( this.Directory != null )
			CookieString += '; PATH=' + this.Directory;
		if( this.Domain != null )
			CookieString += '; DOMAIN=' + this.Domain;
		if( this.IsSecure == true )
			CookieString += '; SECURE';
		document.cookie = CookieString;
	}
	
	this.GetValue = function ( )
	{
		if( document.cookie.search( '^(.*; )?' + escape( this.Name ) + '(=([^;]*))?(;.*)?$' ) != -1 )
			return isNaN( RegExp.$3 ) ? RegExp.$3 : parseFloat( RegExp.$3 );  // convert to number if possible
		else
			return null;
	}
	this.toString = this.GetValue;
	
	this.Exists = new Object ( );
	this.Exists.toString = function ( )
	{
		return document.cookie.search( '^(.*; )?' + escape( this.Parent.Name ) + '(=([^;]*))?(;.*)?$' ) != -1;
	}
	this.Exists.Parent = this;
	
	this.Delete = function ( )
	{
		this.ResetExpiry( -( 60 * 60 ) );  // one hour ago
	}
	
	if( Value != null )
		this.SetAttribs( );
	
	if( document.cookies == null )   //-- add to cookie array of document
		document.cookies = new Object( );
	document.cookies[ Name ] = this;
}
