﻿//-----------------------------------------------------
//Copyright (C) SFosterMurray. All rights reserved.
//-----------------------------------------------------
//Web 2.0 open source JavaScript. Read the code, then
//make sure you understand the code, then steal it!
//-----------------------------------------------------
//LvbPianoSonatasRule.js

//-----------------------------------------------------
//Just give me some space.
//-----------------------------------------------------
var zapGiveMeSomeSpace1="&nbsp&nbsp&nbsp&nbsp";
var zapGiveMeSomeSpace2="&nbsp&nbsp&nbsp&nbsp&nbsp";
//-----------------------------------------------------
//'Session Keep Alive' Information. The ASP.NET session
//is set at 30 minutes... which can easily time-out
//during a movie. KEEP US ALIVE!
//-----------------------------------------------------
var SessionKeepAliveCounter=0;
var SessionKeepAliveValue=3000;
//-----------------------------------------------------
//Animated POPUP Info Panel Control Stuff...
//-----------------------------------------------------
var PopUpInUse=false;
var ButtonObject=null;
var videoButtonObject=null;
var PopUpDynamicContent=null;
var PopUpMagicNumberWidth=0;
var PopUpMagicNumberHeight=0;
//-----------------------------------------------------
//Need Video Button access to enable/disable.
//-----------------------------------------------------
var VideoButtonSet=new Array(32);
//-----------------------------------------------------
//Popup Pager Animation...
//-----------------------------------------------------
var PopupPagerAnimation=null;
var FadeInDelegate=null;
var FinalizeDelegate=null;
//-----------------------------------------------------
//Movie Picker MMS URL Fetch WAIT Information;
//-----------------------------------------------------
var MoviePickerWaitInProgress=false;
var MoviePickerWaitInterval=0;
//-----------------------------------------------------
//HIDDEN, FIXED POSITION MOVIE PLAYER stuff.
//-----------------------------------------------------
var isVideoPlaying=false;
var showTheMovietime=0;
var BandWidthChangeRequest=false;
var LVBPianoSonataVideoIndex= -1;
//-----------------------------------------------------
//LVB Piano [indexed] Selection Info: Popup WxH.
//-----------------------------------------------------
var PopUpFullWideMagicNumberSet=new Array(32);
var PopUpFullHighMagicNumberSet=new Array(32);
//....Sonata 1
PopUpFullWideMagicNumberSet[0]=678;
PopUpFullHighMagicNumberSet[0]=659;
//....Sonata 2
PopUpFullWideMagicNumberSet[1]=678;
PopUpFullHighMagicNumberSet[1]=625;
//....Sonata 3
PopUpFullWideMagicNumberSet[2]=678;
PopUpFullHighMagicNumberSet[2]=629;
//....Sonata 4
PopUpFullWideMagicNumberSet[3]=678;
PopUpFullHighMagicNumberSet[3]=560;
//....Sonata 5
PopUpFullWideMagicNumberSet[4]=678;
PopUpFullHighMagicNumberSet[4]=761;
//....Sonata 6
PopUpFullWideMagicNumberSet[5]=678;
PopUpFullHighMagicNumberSet[5]=490;
//....Sonata 7
PopUpFullWideMagicNumberSet[6]=678;
PopUpFullHighMagicNumberSet[6]=529;
//....Sonata 8
PopUpFullWideMagicNumberSet[7]=678;
PopUpFullHighMagicNumberSet[7]=619;
//....Sonata 9
PopUpFullWideMagicNumberSet[8]=678;
PopUpFullHighMagicNumberSet[8]=479;
//....Sonata 10
PopUpFullWideMagicNumberSet[9]=678;
PopUpFullHighMagicNumberSet[9]=427;
//....Sonata 11
PopUpFullWideMagicNumberSet[10]=678;
PopUpFullHighMagicNumberSet[10]=429;
//....Sonata 12
PopUpFullWideMagicNumberSet[11]=678;
PopUpFullHighMagicNumberSet[11]=801;
//....Sonata 13
PopUpFullWideMagicNumberSet[12]=678;
PopUpFullHighMagicNumberSet[12]=510;
//....Sonata 14
PopUpFullWideMagicNumberSet[13]=678;
PopUpFullHighMagicNumberSet[13]=610;
//....Sonata 15
PopUpFullWideMagicNumberSet[14]=678;
PopUpFullHighMagicNumberSet[14]=821;
//....Sonata 16
PopUpFullWideMagicNumberSet[15]=678;
PopUpFullHighMagicNumberSet[15]=757;
//....Sonata 17
PopUpFullWideMagicNumberSet[16]=678;
PopUpFullHighMagicNumberSet[16]=564;
//....Sonata 18
PopUpFullWideMagicNumberSet[17]=678;
PopUpFullHighMagicNumberSet[17]=499;
//....Sonata 19
PopUpFullWideMagicNumberSet[18]=678;
PopUpFullHighMagicNumberSet[18]=401;
//....Sonata 20
PopUpFullWideMagicNumberSet[19]=678;
PopUpFullHighMagicNumberSet[19]=553;
//....Sonata 21
PopUpFullWideMagicNumberSet[20]=678;
PopUpFullHighMagicNumberSet[20]=679;
//....Sonata 22
PopUpFullWideMagicNumberSet[21]=678;
PopUpFullHighMagicNumberSet[21]=698;
//....Sonata 23
PopUpFullWideMagicNumberSet[22]=678;
PopUpFullHighMagicNumberSet[22]=797;
//....Sonata 24
PopUpFullWideMagicNumberSet[23]=678;
PopUpFullHighMagicNumberSet[23]=412;
//....Sonata 25
PopUpFullWideMagicNumberSet[24]=678;
PopUpFullHighMagicNumberSet[24]=665;
//....Sonata 26
PopUpFullWideMagicNumberSet[25]=678;
PopUpFullHighMagicNumberSet[25]=728;
//....Sonata 27
PopUpFullWideMagicNumberSet[26]=678;
PopUpFullHighMagicNumberSet[26]=799;
//....Sonata 28
PopUpFullWideMagicNumberSet[27]=678;
PopUpFullHighMagicNumberSet[27]=777;
//....Sonata 29
PopUpFullWideMagicNumberSet[28]=678;
PopUpFullHighMagicNumberSet[28]=765;
//....Sonata 30
PopUpFullWideMagicNumberSet[29]=678;
PopUpFullHighMagicNumberSet[29]=734;
//....Sonata 31
PopUpFullWideMagicNumberSet[30]=678;
PopUpFullHighMagicNumberSet[30]=717;
//....Sonata 32
PopUpFullWideMagicNumberSet[31]=678;
PopUpFullHighMagicNumberSet[31]=633;
//-----------------------------------------------------
//Quasi-Class: Popup Multi-pager...
//-----------------------------------------------------
function MultiPager(elementName)
{
	//Base DIV [string] name.
	this.mpageElementName=elementName;
	//Entry *ACTIVE* flag.
	this.mpageActive=false;
	//Page information...
	this.mpageCurrentPage=0;
	this.mpagePageCount=0;
	//Page height array.
	this.mpageHeight=new Array(10);
}
//-----------------------------------------------------
//Popup Multi-pager configuration.
//-----------------------------------------------------
var PopupPagerSet=new Array(32);
var CurrentPopupPager=null;
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//All SMP Smooth Stream Control Routines... BEGIN HERE.
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//-----------------------------------------------------
//LVB Piano [indexed] SMP Manifest URI/Title info.
//-----------------------------------------------------
var LVBPianoSonataManifestURI=new Array(32);
var LVBPianoSonataDescription=new Array(32);
//....Sonata 1
LVBPianoSonataManifestURI[0]="http://snarl.balmydaze.com/LVB/LVB Sonata 01 F minor Op 2-1.ism/manifest";
LVBPianoSonataDescription[0]="Beethoven Sonata 1 F minor Op 2-1";
//....Sonata 2
LVBPianoSonataManifestURI[1]="http://snarl.balmydaze.com/LVB/LVB Sonata 02 A major Op 2-2.ism/manifest";
LVBPianoSonataDescription[1]="Beethoven Sonata 2 A major Op 2-2";
//....Sonata 3
LVBPianoSonataManifestURI[2]="http://snarl.balmydaze.com/LVB/LVB Sonata 03 C major Op 2-3.ism/manifest";
LVBPianoSonataDescription[2]="Beethoven Sonata 3 C major Op 2-3";
//....Sonata 4
LVBPianoSonataManifestURI[3]="http://snarl.balmydaze.com/LVB/LVB Sonata 04 E flat major Op 7.ism/manifest";
LVBPianoSonataDescription[3]="Beethoven Sonata 4 E flat major Op 7";
//....Sonata 5
LVBPianoSonataManifestURI[4]="http://snarl.balmydaze.com/LVB/LVB Sonata 05 C minor Op 10-1.ism/manifest";
LVBPianoSonataDescription[4]="Beethoven Sonata 5 C minor Op 10-1";
//....Sonata 6
LVBPianoSonataManifestURI[5]="http://snarl.balmydaze.com/LVB/LVB Sonata 06 F major Op 10-2.ism/manifest";
LVBPianoSonataDescription[5]="Beethoven Sonata 6 F major Op 10-2";
//....Sonata 7
LVBPianoSonataManifestURI[6]="http://snarl.balmydaze.com/LVB/LVB Sonata 07 D major Op 10-3.ism/manifest";
LVBPianoSonataDescription[6]="Beethoven Sonata 7 D major Op 10-3";
//....Sonata 8
LVBPianoSonataManifestURI[7]="http://snarl.balmydaze.com/LVB/LVB Sonata 08 C minor Op 13 [Pathetique].ism/manifest";
LVBPianoSonataDescription[7]="Beethoven Sonata 8 C minor Op 13";
//....Sonata 9
LVBPianoSonataManifestURI[8]="http://snarl.balmydaze.com/LVB/LVB Sonata 09 E major Op 14-1.ism/manifest";
LVBPianoSonataDescription[8]="Beethoven Sonata 9 E major Op 14-1";
//....Sonata 10
LVBPianoSonataManifestURI[9]="http://snarl.balmydaze.com/LVB/LVB Sonata 10 G major Op 14-2.ism/manifest";
LVBPianoSonataDescription[9]="Beethoven Sonata 10 G major Op 14-2";
//....Sonata 11
LVBPianoSonataManifestURI[10]="http://snarl.balmydaze.com/LVB/LVB Sonata 11 B flat major Op 22.ism/manifest";
LVBPianoSonataDescription[10]="Beethoven Sonata 11 B flat major Op 22";
//....Sonata 12
LVBPianoSonataManifestURI[11]="http://snarl.balmydaze.com/LVB/LVB Sonata 12 A flat major Op 26.ism/manifest";
LVBPianoSonataDescription[11]="Beethoven Sonata 12 A flat major Op 26";
//....Sonata 13
LVBPianoSonataManifestURI[12]="http://snarl.balmydaze.com/LVB/LVB Sonata 13 E flat major Op 27-1.ism/manifest";
LVBPianoSonataDescription[12]="Beethoven Sonata 13 E flat major Op 27-1";
//....Sonata 14
LVBPianoSonataManifestURI[13]="http://snarl.balmydaze.com/LVB/LVB Sonata 14 C sharp minor Op 27-2 [Moonlight].ism/manifest";
LVBPianoSonataDescription[13]="Beethoven Sonata 14 C sharp minor Op 27-2";
//....Sonata 15
LVBPianoSonataManifestURI[14]="http://snarl.balmydaze.com/LVB/LVB Sonata 15 D major Op 28 [Pastoral].ism/manifest";
LVBPianoSonataDescription[14]="Beethoven Sonata 15 D major Op 28";
//....Sonata 16
LVBPianoSonataManifestURI[15]="http://snarl.balmydaze.com/LVB/LVB Sonata 16 G major Op 31-1 [Opps].ism/manifest";
LVBPianoSonataDescription[15]="Beethoven Sonata 16 G major Op 31-1";
//....Sonata 17
LVBPianoSonataManifestURI[16]="http://snarl.balmydaze.com/LVB/LVB Sonata 17 D minor Op 31-2 [Tempest].ism/manifest";
LVBPianoSonataDescription[16]="Beethoven Sonata 17 D minor Op 31-2";
//....Sonata 18
LVBPianoSonataManifestURI[17]="http://snarl.balmydaze.com/LVB/LVB Sonata 18 E flat major Op 31-3.ism/manifest";
LVBPianoSonataDescription[17]="Beethoven Sonata 18 E flat major Op 31-3";
//....Sonata 19
LVBPianoSonataManifestURI[18]="http://snarl.balmydaze.com/LVB/LVB Sonata 19 G minor Op 49-1.ism/manifest";
LVBPianoSonataDescription[18]="Beethoven Sonata 19 G minor Op 49-1";
//....Sonata 20
LVBPianoSonataManifestURI[19]="http://snarl.balmydaze.com/LVB/LVB Sonata 20 G major Op 49-2.ism/manifest";
LVBPianoSonataDescription[19]="Beethoven Sonata 20 G major Op 49-2";
//....Sonata 21
LVBPianoSonataManifestURI[20]="http://snarl.balmydaze.com/LVB/LVB Sonata 21 C major Op 53 [Waldstein].ism/manifest";
LVBPianoSonataDescription[20]="Beethoven Sonata 21 C major Op 53";
//....Sonata 22
LVBPianoSonataManifestURI[21]="http://snarl.balmydaze.com/LVB/LVB Sonata 22 F major Op 54.ism/manifest";
LVBPianoSonataDescription[21]="Beethoven Sonata 22 F major Op 54";
//....Sonata 23
LVBPianoSonataManifestURI[22]="http://snarl.balmydaze.com/LVB/LVB Sonata 23 F minor Op 57 [Appassionata].ism/manifest";
LVBPianoSonataDescription[22]="Beethoven Sonata 23 F minor Op 57";
//....Sonata 24
LVBPianoSonataManifestURI[23]="http://snarl.balmydaze.com/LVB/LVB Sonata 24 F sharp major Op 78.ism/manifest";
LVBPianoSonataDescription[23]="Beethoven Sonata 24 F sharp major Op 78";
//....Sonata 25
LVBPianoSonataManifestURI[24]="http://snarl.balmydaze.com/LVB/LVB Sonata 25 G major Op 79.ism/manifest";
LVBPianoSonataDescription[24]="Beethoven Sonata 25 G major Op 79";
//....Sonata 26
LVBPianoSonataManifestURI[25]="http://snarl.balmydaze.com/LVB/LVB Sonata 26 E flat major Op 81a [Les Adieux].ism/manifest";
LVBPianoSonataDescription[25]="Beethoven Sonata 26 E flat major Op 81a";
//....Sonata 27
LVBPianoSonataManifestURI[26]="http://snarl.balmydaze.com/LVB/LVB Sonata 27 E minor Op 90.ism/manifest";
LVBPianoSonataDescription[26]="Beethoven Sonata 27 E minor Op 90";
//....Sonata 28
LVBPianoSonataManifestURI[27]="http://snarl.balmydaze.com/LVB/LVB Sonata 28 A major Op 101.ism/manifest";
LVBPianoSonataDescription[27]="Beethoven Sonata 28 A major Op 101";
//....Sonata 29
LVBPianoSonataManifestURI[28]="http://snarl.balmydaze.com/LVB/LVB Sonata 29 B flat major Op 106 [Hammerkalvier].ism/manifest";
LVBPianoSonataDescription[28]="Beethoven Sonata 29 B flat major Op 106";
//....Sonata 30
LVBPianoSonataManifestURI[29]="http://snarl.balmydaze.com/LVB/LVB Sonata 30 E major Op 109.ism/manifest";
LVBPianoSonataDescription[29]="Beethoven Sonata 30 E major Op 109";
//....Sonata 31
LVBPianoSonataManifestURI[30]="http://snarl.balmydaze.com/LVB/LVB Sonata 31 A flat major Op 110.ism/manifest";
LVBPianoSonataDescription[30]="Beethoven Sonata 31 A flat major Op 110";
//....Sonata 32
LVBPianoSonataManifestURI[31]="http://snarl.balmydaze.com/LVB/LVB Sonata 32 C minor Op 111.ism/manifest";
LVBPianoSonataDescription[31]="Beethoven Sonata 32 C minor Op 111";
//-----------------------------------------------------
//Silverlight Media Player Control object reference.
//-----------------------------------------------------
var smpSMoothStremPlayer=null;
var lvbPlaylist=null;
var bJustOnce=true;
//-----------------------------------------------------
//Called by the SMP whence the plug-in is loaded.
//-----------------------------------------------------
function pluginLoaded(sender,args)
{
	//Keep track of the SMP object reference...
	smpSMoothStremPlayer=sender.getHost().Content;
	//Better be good!
	if(lvbPlaylist==null)
	{
		//Go create the full playlist!
		createMasterPlaylist(sender,args);
		//Hook the SMP media opened event...
		smpSMoothStremPlayer.Player.MediaOpened=smpMediaOpened;
		//Hook the SMP playlist changed event...
		smpSMoothStremPlayer.Player.PlaylistChanged=smpPlaylistChanged;
		//Hook the SMP playlist item changed event...
		smpSMoothStremPlayer.Player.PlaylistItemChanged=smpPlaylistItemChanged;
	}
}
//-----------------------------------------------------
//Called by the SMP whence the current video is opened.
//-----------------------------------------------------
function smpMediaOpened()
{
	//Just the 1st time... force the current selection
	//here or they will play the 1st playlist item...
	if(bJustOnce)
	{
		//OK... got it!
		bJustOnce=false;
		//Make sure we are stopped...
		smpSMoothStremPlayer.Player.Stop();
		//This is the current (but 1st) selection...
		smpSMoothStremPlayer.Player.GoToPlaylistItem(LVBPianoSonataVideoIndex);
	}
	//Everybody... always show the current title here..
	var indexer=smpSMoothStremPlayer.Player.GetCurrentPlaylistIndex();
	$get("theMoviesTitleID").innerHTML=LVBPianoSonataDescription[indexer];
}
//-----------------------------------------------------
//Called by the SMP whence the playlist changes.
//-----------------------------------------------------
function smpPlaylistChanged()
{
	//Nothing for now!
}
//-----------------------------------------------------
//Called by the SMP whence a playlist item changes.
//-----------------------------------------------------
function smpPlaylistItemChanged()
{
	//Nothing for now!
}
//-----------------------------------------------------
//Create the SMP playlist for this run...
//-----------------------------------------------------
function createMasterPlaylist()
{
	//Get a new, empty SMP playlist...
	lvbPlaylist=smpSMoothStremPlayer.Player.CreatePlaylist();
	//Do it once for each sonata!
	for(i=0;i<32;i++)
	{
		//Build the next Play List item...
		var NewPlaylistItem=smpSMoothStremPlayer.Player.CreatePlaylistItem(LVBPianoSonataManifestURI[i],
																			'',
																			LVBPianoSonataDescription[i],
																			LVBPianoSonataDescription[i]);
		//Yes... it uses adaptive streaming..
		NewPlaylistItem.DeliveryMethod='AdaptiveStreaming';
		//Add the sucker to the master play list!
		lvbPlaylist.AddPlaylistItem(NewPlaylistItem);
	}
	//Stuff it all into the SMP!
	smpSMoothStremPlayer.Player.SetPlaylist(lvbPlaylist);
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//All UTILITY JS Methods... BEGIN HERE.
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//-----------------------------------------------------
//Add shuffle to core js array functionality.
//-----------------------------------------------------
(function ()
{
	var swapper=function (suffleMe,el,all)
	{
		//Random index from full array!
		var ran=Math.floor(Math.random()*all);
		//Get the current element. 
		var saver=suffleMe[el];
		//Replace it with the random selection.
		suffleMe[el]=suffleMe[ran];
		//Swap current to random slot.
		suffleMe[ran]=saver;
	};
	//Add shuffle to Array base object.
	Array.prototype.shuffle=function ()
	{
		var i=this.length;
		var Total=i;
		while(i--)
		{
			swapper(this,i,Total);
		}
	};
})();
//-----------------------------------------------------
//General Purpose [ACT-Animation] FADER... Fade away!
//-----------------------------------------------------
function JustFadeAwayDude()
{
	try
	{
		//Fade in after we fade out!
		PopupPagerAnimation.remove_ended(FinalizeDelegate);
		PopupPagerAnimation.add_ended(FadeInDelegate);
		//Show the Flyout DIV... hidden behind the PopUp.
		$get('flyoutDiv').style.display="block";
		$get('flyoutDiv').style.visibility="visible";
		//Fade out the PopUp... leaving just the Flyout DIV.
		PopupPagerAnimation.set_effect($AA.FadeEffect.FadeOut);
		//Do it!                            
		PopupPagerAnimation.play();
	}
	catch(e)
	{
		//Trouble!
		writeDebug("Error in JustFadeAwayDude ["+e.name+"]: "+e.message,true);
	}
}
//-----------------------------------------------------
//General Purpose [ACT-Animation] FADER... Fade back!
//-----------------------------------------------------
function JustFadeBackDude()
{
	try
	{
		//Finalize after we fade in!
		PopupPagerAnimation.remove_ended(FadeInDelegate);
		PopupPagerAnimation.add_ended(FinalizeDelegate);
		//Figure out the new page to show...
		CurrentPopupPager.mpageCurrentPage++;
		if(CurrentPopupPager.mpageCurrentPage>=CurrentPopupPager.mpagePageCount)
		{
			CurrentPopupPager.mpageCurrentPage=0;
		}
		//Adjust the Flyout DIV...
		var thenewHeight=CurrentPopupPager.mpageHeight[CurrentPopupPager.mpageCurrentPage];
		$get('flyoutDiv').style.height=thenewHeight+"px";
		//Build the Dynamic DIV ID string.
		var DIVSourceID=CurrentPopupPager.mpageElementName;
		if(CurrentPopupPager.mpageCurrentPage!=0)
		{
			DIVSourceID+=CurrentPopupPager.mpageCurrentPage;
		}
		//Dynamically set the Info popup CONTENT!
		$get("MainContent").innerHTML=$get(DIVSourceID).innerHTML
		//Fade in the PopUp... in front of the Flyout DIV.
		PopupPagerAnimation.set_effect($AA.FadeEffect.FadeIn);
		//Do it!                            
		PopupPagerAnimation.play();
	}
	catch(e)
	{
		//Trouble!
		writeDebug("Error in JustFadeBackDude ["+e.name+"]: "+e.message,true);
	}
}
//-----------------------------------------------------
//General Purpose [ACT-Animation] FADER... Finalize!
//-----------------------------------------------------
function FaderFinalize()
{
	try
	{
		//Hide the Flyout DIV... we are done with it.
		$get('flyoutDiv').style.display="none";
		$get('flyoutDiv').style.visibility="hidden";
	}
	catch(e)
	{
		//Trouble!
		writeDebug("Error in FaderFinalize ["+e.name+"]: "+e.message,true);
	}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//All USER CONTROL JS Methods... BEGIN HERE.
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//-----------------------------------------------------
//General Purpose LVB Sonata Video LAUNCHER...
//-----------------------------------------------------
function ShowLVBPinaoSonataVideo()
{
	try
	{
		//Not while the Popup is Visible.
		if(PopUpInUse==true)
		{
			return;
		}
		//Did they select an Video yet...
		if(LVBPianoSonataVideoIndex== -1)
		{
			return;
		}
		//Collapse the 'LVB Piano Sonata' Accordion.
		if($get("LVBPianoSonataAccordion").AccordionBehavior!=null)
		{
			$get("LVBPianoSonataAccordion").AccordionBehavior.set_SelectedIndex(-1);
		}
		//Always... Make sure all other PANELS are hidden.
		if($get("theMoviesID")!=null)
		{
			$get("theMoviesID").style.display="none";
			$get("theMoviesID").style.visibility="hidden";
		}
		//Always... Make sure the Waiting PANEL is visible.
		if($get("theWaitingMasterID")!=null)
		{
			$get("theWaitingMasterID").style.display="block";
			$get("theWaitingMasterID").style.visibility="visible";
		}
		//Hide the 'Modal Popup Drag Handle' Title...
		if($get("ClickHereAndDragID")!=null)
		{
			$get("ClickHereAndDragID").style.visibility="hidden";
		}
		//Show the ajaxToolkit ModalPopupExtender!
		if($find('ModalPopupBehaviorID')!=null)
		{
			$find('ModalPopupBehaviorID').show();
		}
		//Make'em wait.... fuck'em!
		MoviePickerWaitInProgress=true;
		MoviePickerWaitInterval=0;
	}
	catch(e)
	{
		//Trouble!
		writeDebug("Error in ShowLVBPinaoSonataVideo ["+e.name+"]: "+e.message,true);
	}
}
//-----------------------------------------------------
//Movie Player: Done with the wait... Play the Film!
//-----------------------------------------------------
function TimeToWatchLVBPianoSonataFilm()
{
	try
	{
		//Always... Make sure all other PANELS are hidden.
		if($get("theWaitingMasterID")!=null)
		{
			$get("theWaitingMasterID").style.display="none";
			$get("theWaitingMasterID").style.visibility="hidden";
		}
		//Show the 'Modal Popup Drag Handle' Title...
		if($get("ClickHereAndDragID")!=null)
		{
			$get("ClickHereAndDragID").style.visibility="visible";
		}
		//Always... Make sure the Movie Viewer PANEL is visible.
		if($get("theMoviesID")!=null)
		{
			$get("theMoviesID").style.display="block";
			$get("theMoviesID").style.visibility="visible";
		}
		//YES... Go watch the Film!
		if(isVideoPlaying)
		{
			return;
		}
		//Now... we are ACTIVE.
		isVideoPlaying=true;
		//Just getting started... point to the proper video!
		if(smpSMoothStremPlayer!=null)
		{
			smpSMoothStremPlayer.Player.GoToPlaylistItem(LVBPianoSonataVideoIndex);
		}
	}
	catch(e)
	{
		//Trouble!
		writeDebug("Error in TimeToWatchLVBPianoSonataFilm ["+e.name+"]: "+e.message,true);
	}
}
//-----------------------------------------------------
//EXIT Button Handler... Hide the entire mess!
//-----------------------------------------------------
function WeAreDone()
{
	try
	{
		//Cancel any pending wait!
		MoviePickerWaitInProgress=false;
		MoviePickerWaitInterval=0;
		//Shut down the Video player.
		isVideoPlaying=false;
		if(smpSMoothStremPlayer!=null)
		{
			smpSMoothStremPlayer.Player.Stop();
		}
	}
	catch(e)
	{
		//Trouble!
		writeDebug("Error in WeAreDone ["+e.name+"]: "+e.message,true);
	}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//POPUP Animation Control JS Methods... BEGIN HERE.
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//-----------------------------------------------------
//Move 'top' element directly on top of 'bottom'
//element (and optionally make it the same size).
//-----------------------------------------------------
function Cover(bottomTarget,topTarget,ignoreSize)
{
	try
	{
		//This is the target location.
		var thisLocation=Sys.UI.DomElement.getLocation(bottomTarget);
		//Swooooosh... move the element to be animated.
		topTarget.style.position='absolute';
		topTarget.style.top=thisLocation.y+'px';
		topTarget.style.left=thisLocation.x+'px';
		//Optionally... make the target the same size.
		if(!ignoreSize)
		{
			topTarget.style.height=bottomTarget.offsetHeight+'px';
			topTarget.style.width=bottomTarget.offsetWidth+'px';
		}
	}
	catch(e)
	{
		writeDebug("ERROR in Cover() ["+e.name+"]: "+e.message,true);
	}
}
//-----------------------------------------------------
//Move 'top' element directly on top of BUTTON
//element (and optionally make it the same size).
//-----------------------------------------------------
function CoverButton(topTarget,ignoreSize)
{
	try
	{
		//This is the target location.
		var thisLocation=Sys.UI.DomElement.getLocation(ButtonObject);
		//Swooooosh... move the element to be animated.
		topTarget.style.position='absolute';
		topTarget.style.top=thisLocation.y+'px';
		topTarget.style.left=thisLocation.x+'px';
		//Optionally... make the target the same size.
		if(!ignoreSize)
		{
			topTarget.style.height=ButtonObject.offsetHeight+'px';
			topTarget.style.width=ButtonObject.offsetWidth+'px';
		}
	}
	catch(e)
	{
		writeDebug("ERROR in CoverButton() ["+e.name+"]: "+e.message,true);
	}
}
//-----------------------------------------------------
//Dynamic Info popup Button Handler. Real slick, make
//the button that fired this EVENT the target of the
//Open Animation so the Info popup DIV fades in from
//this button. Make the button the target of the Close
//Animation EnableAction as well. COOL Stuff! Oh ya,
//and then *RUN* the fucking Open Animation.
//-----------------------------------------------------
function showModalPopupViaTargetButton(ev)
{
	try
	{
		//Do not do the 'normal' stuff.
		ev.preventDefault();
		//Just one Info popup at a time.
		if(PopUpInUse==true)
		{
			return;
		}
		//Dynamically set the Info popup CONTENT!
		$get("MainContent").innerHTML=PopUpDynamicContent.innerHTML
		//This button's location is the animation starting point.
		ButtonObject=ev.target;
		//Grab the OpenAnimation object.
		var openAnimationBehavior=$find('OpenAnimation');
		var openAnimationClickBehavior=openAnimationBehavior.get_OnClickBehavior();
		var openAnimation=openAnimationClickBehavior.get_animation();
		var openAnimationSet=openAnimation.get_animations();
		//Grab the CloseAnimation object and get the ANIMATIONS array.
		var closeAnimationBehavior=$find('CloseAnimation');
		var closeAnimationClickBehavior=closeAnimationBehavior.get_OnClickBehavior();
		var closeAnimation=closeAnimationClickBehavior.get_animation();
		var closeAnimationSet=closeAnimation.get_animations();
		//MAKE THIS BUTTON THE TARGET OF THE OpenAnimation. 
		openAnimation.set_target(ev.target);
		//TACKY... The Parallel Animation is the 4th animation child
		//of the OpenAnimation.
		var ParallelAnimation=openAnimationSet[3];
		var ParallelAnimationSet=ParallelAnimation.get_animations();
		//Calculate the Popup top centered.
		var vertTopCentered=screen.availHeight/2-PopUpMagicNumberHeight/2;
		//Move the Popup to this vertical location!
		var vertLocation=vertTopCentered-ev.clientY;
		//TACKY... The 1st animation child of the Parallel Animation
		//is the Move property... set the horizontal/vertical positions.
		ParallelAnimationSet[0].set_horizontal(-250);
		ParallelAnimationSet[0].set_vertical(vertLocation);
		//TACKY... The 2nd animation child of the Parallel Animation
		//is the Resize property... set the width and height.
		ParallelAnimationSet[1].set_width(PopUpMagicNumberWidth);
		ParallelAnimationSet[1].set_height(PopUpMagicNumberHeight);
		//TACKY... The EnableAction is the 8th animation child
		//of the CloseAnimation. Make this BUTTON its target.
		closeAnimationSet[7].set_target(ev.target);
		//BANG! Start the OpenAnimation running!
		openAnimationClickBehavior.play();
		//We are busy!
		PopUpInUse=true;
		//No [related] video when the Popup is visible!
		videoButtonObject.disabled=true;
	}
	catch(e)
	{
		writeDebug("ERROR in showModalPopupViaTargetButton() ["+e.name+"]: "+e.message,true);
	}
}
//-----------------------------------------------------
//An Accordion just closed... Kill the Popup Window!
//-----------------------------------------------------
function MakeSureThePopUpWindowIsClosed()
{
	try
	{
		//Nope!.
		if(PopUpInUse==false)
		{
			return;
		}
		//BANG! Start the CloseAnimation running!
		$find('CloseAnimation').get_OnClickBehavior().play();
	}
	catch(e)
	{
		writeDebug("ERROR in MakeSureThePopUpWindowIsClosed() ["+e.name+"]: "+e.message,true);
	}
}
//-----------------------------------------------------
//Post-Animation Cleanup....
//-----------------------------------------------------
function TheShowIsOver()
{
	//Re-enable the [related] video button.
	videoButtonObject.disabled=false;
	//DONE!
	PopUpInUse=false;
	//Reset the current Popup pager... it may be empty.
	CurrentPopupPager.mpageCurrentPage=0;
}
//-----------------------------------------------------
//Deal with the Accordion Selection Change...
//-----------------------------------------------------
function LVBPianoSonataAccordionSelectChange(target,event)
{
	try
	{
		//Accordion Selection HIT: Blow away the Popup.
		MakeSureThePopUpWindowIsClosed();
		if(event.get_selectedIndex()!= -1)
		{
			//Just in case they want to watch this video.
			LVBPianoSonataVideoIndex=event.get_selectedIndex();
			//Make sure the former Video button in enabled.
			if(videoButtonObject!=null)
			{
				if(videoButtonObject.disabled==true)
				{
					videoButtonObject.disabled=false;
				}
			}
			//Get the related panel Video button...
			videoButtonObject=VideoButtonSet[event.get_selectedIndex()];
			//Set the current Popup pager... it may be empty.
			CurrentPopupPager=PopupPagerSet[event.get_selectedIndex()];
			CurrentPopupPager.mpageCurrentPage=0;
			//Also... point to the Popup dynamic content.
			var LVBIndex=LVBPianoSonataVideoIndex+1;
			PopUpDynamicContent=$get("LVBSonata"+LVBIndex+"Content");
			//Also... this really sucks, set the width/height.
			PopUpMagicNumberWidth=PopUpFullWideMagicNumberSet[LVBPianoSonataVideoIndex];
			PopUpMagicNumberHeight=PopUpFullHighMagicNumberSet[LVBPianoSonataVideoIndex];
		}
	}
	catch(e)
	{
		//Trouble!
		writeDebug("Error in LVBPianoSonataAccordionSelectChange ["+e.name+"]: "+e.message,true);
	}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//INTERVAL RESPONSE JS Methods... BEGIN HERE.
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//-----------------------------------------------------
// Timer Manager DUDE!
//-----------------------------------------------------
function DoTimerPOP()
{
	//.................................................
	//[Timer POP Processing 01] Waiting for a FILM??
	//.................................................
	if(MoviePickerWaitInProgress==true)
	{
		//Update the wait interval by 100ms.
		MoviePickerWaitInterval+=100;
		//MUST WAIT 1 second... always!
		if(MoviePickerWaitInterval>=5000)
		{
			//DONE... go watch the Movie.
			MoviePickerWaitInProgress=false;
			MoviePickerWaitInterval=0;
			TimeToWatchLVBPianoSonataFilm();
		}
	}
	//.................................................
	//[Timer POP Processing 02] Try to keep the ASP.NET
	//Session ALIVE...
	//.................................................
	SessionKeepAliveCounter++;
	if(SessionKeepAliveCounter>=SessionKeepAliveValue)
	{
		try
		{
			//Reset to wait for the next interval...
			SessionKeepAliveCounter=0;
			//Need a unique number for each handler call to fool the MSIE cache.
			var TimeStamp=new Date();
			var Seconds=TimeStamp.getTime();
			//Just fucking do it!
			$get("ImageOne").src="whKeepSessionAliveHandler.ashx?&time="+Seconds;
		}
		catch(e)
		{
			writeDebug("ERROR in DoTimerPOP() ASP.NET Session Keep Alive: ["+e.name+"]: "+e.message,true);
		}
	}
	// Schedule the next call to method DoTimerPOP().
	window.setTimeout('DoTimerPOP()',100);
}
//-----------------------------------------------------
//ASP.NET AJAX has indicated that all external files
//have been fully loaded, similar to the way ASP.NET
//executes the server-side Page_Load() method. Is safe
//to access AJAX js objects... be carful!
//-----------------------------------------------------
function pageLoad()
{
	//Setup the [hidden] Debug DIV.
	clearDebug();
	//Setup all the Popup Pager delegates...
	FadeInDelegate=Function.createDelegate(this,this.JustFadeBackDude);
	FinalizeDelegate=Function.createDelegate(this,this.FaderFinalize);
	//We need a local Popup Pager animator...
	try
	{
		//ACT Animation [shortcut] object... better be ready!
		if($AA.Animation!=null)
		{
			//Build the Animation... change the fade in-out on the fly.
			PopupPagerAnimation=new $AA.FadeAnimation($get("info"),
													  .5,
													  40,
													  $AA.FadeEffect.FadeOut,
													  0,
													  1,
													  false);
			//Get started... add this so we can remove it [1st].
			PopupPagerAnimation.add_ended(FinalizeDelegate);
			//Let them get started.
			PopupPagerAnimation.initialize();
		}
	}
	//This control should be generated by the ASP.NET Ajax framework.
	catch(e)
	{
		//Trouble.
		writeDebug("Error in pageLoad(MovieAnimationSetup) ["+e.name+"]: "+e.message,true);
	}
	//Wire-up all the Popup Info Panel Button Handlers.
	$addHandler($get("Button1"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button3"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button5"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button7"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button9"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button11"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button13"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button15"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button17"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button19"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button21"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button23"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button25"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button27"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button29"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button31"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button33"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button35"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button37"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button39"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button41"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button43"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button45"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button47"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button49"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button51"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button53"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button55"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button57"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button59"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button61"),'click',showModalPopupViaTargetButton);
	$addHandler($get("Button63"),'click',showModalPopupViaTargetButton);
	//Wire-up the LVB Piano Sonata Accordion Select Changed EVENT.
	var thisBehavior=$get("LVBPianoSonataAccordion").AccordionBehavior;
	if(thisBehavior!=null)
	{
		thisBehavior.add_selectedIndexChanged(LVBPianoSonataAccordionSelectChange);
	}
	//Build the Video button array.
	for(i=0;i<32;i++)
	{
		var targetButt="Button"+(i+1)*2;
		VideoButtonSet[i]=$get(targetButt);
	}
	//Build the Popup Multi-pager array.
	for(i=0;i<=32;i++)
	{
		var nextIndex=i+1;
		PopupPagerSet[i]=new MultiPager("LVBSonata"+nextIndex+"Content");
	}
	//Setup the LVB Sonata 1 Multi-pager...
	PopupPagerSet[0].mpageActive=true;
	PopupPagerSet[0].mpageCurrentPage=0;
	PopupPagerSet[0].mpagePageCount=2;
	PopupPagerSet[0].mpageHeight[0]=659;
	PopupPagerSet[0].mpageHeight[1]=579;
	//Setup the LVB Sonata 2 Multi-pager...
	PopupPagerSet[1].mpageActive=true;
	PopupPagerSet[1].mpageCurrentPage=0;
	PopupPagerSet[1].mpagePageCount=2;
	PopupPagerSet[1].mpageHeight[0]=625;
	PopupPagerSet[1].mpageHeight[1]=567;
	//Setup the LVB Sonata 8 Multi-pager...
	PopupPagerSet[7].mpageActive=true;
	PopupPagerSet[7].mpageCurrentPage=0;
	PopupPagerSet[7].mpagePageCount=2;
	PopupPagerSet[7].mpageHeight[0]=619;
	PopupPagerSet[7].mpageHeight[1]=613;
	//Setup the LVB Sonata 12 Multi-pager...
	PopupPagerSet[11].mpageActive=true;
	PopupPagerSet[11].mpageCurrentPage=0;
	PopupPagerSet[11].mpagePageCount=2;
	PopupPagerSet[11].mpageHeight[0]=801;
	PopupPagerSet[11].mpageHeight[1]=805;
	//Setup the LVB Sonata 14 Multi-pager...
	PopupPagerSet[13].mpageActive=true;
	PopupPagerSet[13].mpageCurrentPage=0;
	PopupPagerSet[13].mpagePageCount=2;
	PopupPagerSet[13].mpageHeight[0]=610;
	PopupPagerSet[13].mpageHeight[1]=658;
	//Setup the LVB Sonata 21 Multi-pager...
	PopupPagerSet[20].mpageActive=true;
	PopupPagerSet[20].mpageCurrentPage=0;
	PopupPagerSet[20].mpagePageCount=2;
	PopupPagerSet[20].mpageHeight[0]=679;
	PopupPagerSet[20].mpageHeight[1]=611;
	//Setup the LVB Sonata 28 Multi-pager...
	PopupPagerSet[27].mpageActive=true;
	PopupPagerSet[27].mpageCurrentPage=0;
	PopupPagerSet[27].mpagePageCount=2;
	PopupPagerSet[27].mpageHeight[0]=777;
	PopupPagerSet[27].mpageHeight[1]=645;
	//Setup the LVB Sonata 29 Multi-pager...
	PopupPagerSet[28].mpageActive=true;
	PopupPagerSet[28].mpageCurrentPage=0;
	PopupPagerSet[28].mpagePageCount=2;
	PopupPagerSet[28].mpageHeight[0]=765;
	PopupPagerSet[28].mpageHeight[1]=781;
	//Setup the LVB Sonata 31 Multi-pager...
	PopupPagerSet[30].mpageActive=true;
	PopupPagerSet[30].mpageCurrentPage=0;
	PopupPagerSet[30].mpagePageCount=2;
	PopupPagerSet[30].mpageHeight[0]=717;
	PopupPagerSet[30].mpageHeight[1]=637;
	//Setup the LVB Sonata 32 Multi-pager...
	PopupPagerSet[31].mpageActive=true;
	PopupPagerSet[31].mpageCurrentPage=0;
	PopupPagerSet[31].mpagePageCount=2;
	PopupPagerSet[31].mpageHeight[0]=633;
	PopupPagerSet[31].mpageHeight[1]=495;
	//..................................................
	//Who'll stop the rain? 09 August 2011... bypass
	//all authentication/authorization... FUCK IT!
	//--------------------------------------------------
	//They have not selected a Video yet!
	LVBPianoSonataVideoIndex= -1;
	//Start the BALL ROLLING!
	DoTimerPOP();
}
//-----------------------------------------------------
//The HTML document load has completes... but perhaps
//not all ASP.NET Ajax objects... be carful!
//-----------------------------------------------------
function load()
{
	//Set the XHR Domain cookie exchange identifier.
	setCookie("XHRDomain","SFosterMurray",100);
	//More browser bullshit... tweak it dude!
	if(broswerId=="msie")
	{
	    $get("lvbpsSidePictureBlockClassID").style.width="322px";
	    $get("lvbpsAccordionCascadeID").style.height="1514px";
	}
	else
	{
	    $get("lvbpsSidePictureBlockClassID").style.width="325px";
	    $get("lvbpsAccordionCascadeID").style.height="1511px";
	}
}
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//DEBUG JS Routines... BEGIN HERE.
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX[JS CODE GROUP]
//-----------------------------------------------------
//SPECIAL [HIDDEN] DEBUG WINDOW JS SUPPORT.
//-----------------------------------------------------
var debugDiv=null;
var debugSpan=null;
var debugShow=false;
//-----------------------------------------------------
//DEBUG SUPPORT: Called from Main page footer [X].
//-----------------------------------------------------
function toggleDebugView()
{
	try
	{
		if(debugShow)
		{
			debugShow=false;
			hideDebug();
		}
		else
		{
			debugShow=true;
			showDebug();
		}
	}
	catch(e)
	{
		alert("toggleDebugView() call failed");
	}
}
//-----------------------------------------------------
//DEBUG SUPPORT: Show the Debug DIV above the footer.
//-----------------------------------------------------
function showDebug()
{
	try
	{
		//May sure we can see the hunk of crap!
		debugDiv=$get("debugDivContent");
		if(debugDiv!=null)
		{
			debugDiv.style.display="block";
			debugDiv.style.visibility="visible";
		}
	}
	catch(e)
	{
		alert("showDebug() call failed");
	}
}
//-----------------------------------------------------
//DEBUG SUPPORT: Hide the Debug DIV... we are done.
//-----------------------------------------------------
function hideDebug()
{
	try
	{
		//May sure we can not see the hunk of crap!
		debugDiv=$get("debugDivContent");
		if(debugDiv!=null)
		{
			debugDiv.style.display="none";
			debugDiv.style.visibility="hidden";
		}
	}
	catch(e)
	{
		alert("hideDebug() call failed");
	}
}
//-----------------------------------------------------
//DEBUG SUPPORT: Clear the Debug DIV/add clear link.
//-----------------------------------------------------
function clearDebug()
{
	try
	{
		//May sure the hunk of crap is empty!
		debugDiv=$get("debugDivContent");
		if(debugDiv!=null)
		{
			debugDiv.innerHTML="";
			writeClearLink();
		}
		//Clear the alert in the footer: No Messages.
		debugSpan=$get("debugSpanContent");
		if(debugSpan!=null)
		{
			debugSpan.style.color="#009900";
		}
	}
	catch(e)
	{
		alert("clearDebug() call failed");
	}
}
//-----------------------------------------------------
//DEBUG SUPPORT: Add the data to the Debug DIV.
//-----------------------------------------------------
function writeDebug(MessageOut,AddTime)
{
	try
	{
		//Default... no time!
		if(AddTime==null||AddTime=="")
		{
			AddTime=false;
		}
		//Grab the Debug DIV!
		debugDiv=$get("debugDivContent");
		if(debugDiv!=null)
		{
			if(AddTime)
			{
				debugDiv.innerHTML+=Date()+"<br\/>"+MessageOut+"<br\/>";
			}
			else
			{
				debugDiv.innerHTML+=MessageOut+"<br\/>";
			}
		}
		//Show the alert in the footer: Message ready.
		debugSpan=$get("debugSpanContent");
		if(debugSpan!=null&&debugSpan.style.color!="#990000")
		{
			debugSpan.style.color="#990000";
		}
	}
	catch(e)
	{
		alert("writeDebug() call failed");
	}
}
//-----------------------------------------------------
//DEBUG SUPPORT: Add the code expression to the Debug
//DIV... writeEval("document.location"); will output
//"document.location = http://www.BiteMeHere.com"
//-----------------------------------------------------
function writeEval(code)
{
	writeDebug(code+" = "+eval(code),true);
}
//-----------------------------------------------------
//DEBUG SUPPORT: Write all properties of the object.
//-----------------------------------------------------
function writeDebugObject(myobject)
{
	var strCollection="";
	//Just examine the TOP Level only.
	for(curObj in myobject)
	{
		if(typeof myobject[curObj]=="object")
		{
			strCollection+=curObj+": "+myobject[curObj]+"<br\/>";
		}
		else
		{
			try
			{
				strCollection+=curObj+": "+myobject[curObj]+"<br\/>";
			}
			catch(e)
			{
				strCollection+=curObj+": Unable to evaluate!<br\/>";
			}
		}
	}
	writeDebug(strCollection,false);
}
//-----------------------------------------------------
//DEBUG SUPPORT: Write the Debug DIV 'Clear' link.
//-----------------------------------------------------
function writeClearLink()
{
	writeDebug("<a href='#' title='Cleanup this mess!' onclick='clearDebug(); return false;'>Clear the Debug Window!</a>",false);
}
//-----------------------------------------------------
//DEBUG SUPPORT: Just dump the OBJECT to a PopUp.
//-----------------------------------------------------
function dumpToPopup(x)
{
	var win=window.open();
	for(var i in x)
	{
		try
		{
			win.document.write(i+" = "+x[i]+"<br>");
		}
		catch(e)
		{
			win.document.write(i+": Unable to evaluate!<br>");
		}
	}
}
