
var Slideshow_Name;
var Current_Slide;
var Old_Slideshow_Name;


// Banner Rotation ...

function Start_Banner_Rotation()
{
	setTimeout("Show_Next_Banner(1)", 30000);
}

function Show_Next_Banner(Banner_Index)
{
	Fade_Banner(Banner_Index, 0);
}

function Fade_Banner(Banner_Index, Fade_Step)
{
	Last_Banner_Element = document.getElementById("Banner_" + Banner_Index);
	Fade_Step++;
	if (Last_Banner_Element)
		Last_Banner_Element.style.opacity = (10 - Fade_Step) / 10;
	
	if (Fade_Step < 10)
	{
		setTimeout("Fade_Banner(" + Banner_Index + ", " + Fade_Step + ")", 20)
	}
	else
	{
		Banner_Index++;
		if (Banner_Index > 1)
			Banner_Index = 0;
		Next_Banner_Element = document.getElementById("Banner_" + Banner_Index);
		
		if (Last_Banner_Element)
		{
			Last_Banner_Element.style.display = "none";
			Next_Banner_Element.style.opacity = 1;
			Next_Banner_Element.style.display = "block";
		}
		
		setTimeout("Show_Next_Banner(" + Banner_Index + ")", 30000);
	}
		
}

var Total_Photos = 0;
var Current_Photo_Index = 0;
var Slideshow_Timer = 0;
var Slideshow_Photoset_ID  = 0;
// Photo Rotation ... 
function Start_Photo_Rotation(Photoset_ID, Total_Photos_Parameter)
{	
	Slideshow_Photoset_ID = Photoset_ID;
	Total_Photos = Total_Photos_Parameter;
	Slideshow_Timer = setTimeout("Next_Photo()", 10000);
}

function Next_Photo()
{
	clearTimeout(Slideshow_Timer);
	Current_Photo_Index++;
	if (Current_Photo_Index == Total_Photos)
		Current_Photo_Index = 0;
	Fill("Next_Slideshow_Photo", "/block/flickr_slideshow_picture/raw:Flickr_Photoset=" + Slideshow_Photoset_ID +",Flickr_Photo_Index=" + Current_Photo_Index, function() {Super_Fade_Photo(0);});		
}

function Previous_Photo()
{
	clearTimeout(Slideshow_Timer);
	Current_Photo_Index--;
	if (Current_Photo_Index < 0)
		Current_Photo_Index = Total_Photos - 1;
	Fill("Next_Slideshow_Photo", "/block/flickr_slideshow_picture/raw:Flickr_Photoset=" + Slideshow_Photoset_ID +",Flickr_Photo_Index=" + Current_Photo_Index, function() {Super_Fade_Photo(0);});		
}

function Super_Fade_Photo(Fade_Step)
{
	var Photo_Element = document.getElementById("Slideshow_Photo");
	Photo_Element.style.opacity = (10 - Fade_Step) / 10;
	
	Fade_Step++;	
	if (Fade_Step < 10)
		Fade_Timer = setTimeout("Super_Fade_Photo(" + Fade_Step + ")", 20)
	else
	{
		Photo_Element.innerHTML = document.getElementById("Next_Slideshow_Photo").innerHTML;
		Photo_Element.style.opacity = 1;
		Slideshow_Timer = setTimeout("Next_Photo()", 10000);
	}
}

function Fade_Photo(Fade_Step, Reverse_Direction)
{
	clearTimeout(Slideshow_Timer);
	
	Last_Photo_Element = document.getElementById("Photo_" + Current_Photo_Index);
	Fade_Step++;
	if (Last_Photo_Element)
		Last_Photo_Element.style.opacity = (10 - Fade_Step) / 10;
	
	if (Fade_Step < 10)
	{	
		Slideshow_Timer = setTimeout("Fade_Photo(" + Fade_Step + ", " + Reverse_Direction + ")", 20)
	}
	else
	{	
		Last_Caption_Element = document.getElementById("Caption_" + Current_Photo_Index);	
			
		if (Reverse_Direction)
		{
			Current_Photo_Index--;
			if (Current_Photo_Index < 0)
				Current_Photo_Index = Total_Photos - 1;
		}
		else
		{
			Current_Photo_Index++;			
			if (Current_Photo_Index == Total_Photos)
				Current_Photo_Index = 0;			
		}
		console.log(Current_Photo_Index);

		Next_Photo_Element = document.getElementById("Photo_" + Current_Photo_Index);
		Next_Caption_Element = document.getElementById("Caption_" + Current_Photo_Index);
		
		if (Last_Photo_Element)
		{	
			Last_Photo_Element.style.display = "none";
			Next_Photo_Element.style.opacity = 1;
			Next_Photo_Element.style.display = "block";
			
			Last_Caption_Element.style.display = "none";
			Next_Caption_Element.style.display = "inline";	
		}
		
		Slideshow_Timer = setTimeout("Fade_Photo(0, " + Reverse_Direction + ")", 10000);
	}
		
}


// Letter Rotation ...

var Total_Letter_Count = 0;
var Letter_Rotation_Interval = 30;
var Letter_Rotation = true;

function Stop_Letter_Rotation()
{	
//	console.log("worked");
	Letter_Rotation = false;
}

function Start_Letter_Rotation(Letter_Count)
{
	Total_Letter_Count = Letter_Count;
	
	Random_Letter = Math.floor(Math.random() * Letter_Count);	
	document.getElementById("Letter_" + Random_Letter).style.display = "block";	
	setTimeout("Show_Next_Letter(" + Random_Letter + ")", Letter_Rotation_Interval * 1000);
}

function Show_Next_Letter(Letter_Index)
{
//	console.log("WTF:" + Letter_Index);
	if (Letter_Rotation)
		Fade_Letter(Letter_Index, 0);
}

function Fade_Letter(Letter_Index, Fade_Step)
{	
	Last_Letter_Element = document.getElementById("Letter_" + Letter_Index);
	Fade_Step++;
	if (Last_Letter_Element)
		Last_Letter_Element.style.opacity = (10 - Fade_Step) / 10;
	
	if (Fade_Step < 10)
	{
		setTimeout("Fade_Letter(" + Letter_Index + ", " + Fade_Step + ")", 20)
	}
	else
	{
		Letter_Index = (Letter_Index + 1) % Total_Letter_Count;
		console.log(Letter_Index);
		Next_Letter_Element = document.getElementById("Letter_" + Letter_Index);
		
		if (Last_Letter_Element)
		{
			Last_Letter_Element.style.display = "none";
			Next_Letter_Element.style.opacity = 1;
			Next_Letter_Element.style.display = "block";
		}
		
		setTimeout("Show_Next_Letter(" + Letter_Index + ")", Letter_Rotation_Interval * 1000);
	}
		
}


// Others ...

var Rotation_Categories = ["Media", "Archive", "Members", "Discussion"];
var Rotation_Seconds = 15;
var Rotation = null;

function Start_Front_Page_Rotation(Rotation_Data)
{
	Rotation = Rotation_Data;
	for (Category_Index in Rotation_Categories)
	{
		Rotation[Rotation_Categories[Category_Index] + "_Index"] = -1;
	}	
	Rotation[Rotation.Current_Category + "_Index"]++;
	Rotation.Current_Element_ID = Rotation.Current_Category + "_" + Rotation[Rotation.Current_Category + "_Index"];
	
	setTimeout("Next_Front_Page_Rotation()", Rotation_Seconds * 1000);
}

function Next_Front_Page_Rotation()
{	
	Old_Rotation_Element = document.getElementById(Rotation.Current_Element_ID);
	
	for (Category_Index in Rotation_Categories)
	{	
		if (Rotation.Current_Category == Rotation_Categories[Category_Index])
		{
			Rotation.Current_Category = Rotation_Categories[(parseInt(Category_Index)+ 1)% Rotation_Categories.length];
			break;
		}
	}	
	Rotation[Rotation.Current_Category + "_Index"] = (parseInt(Rotation[Rotation.Current_Category + "_Index"]) + 1) % Rotation[Rotation.Current_Category + "_Count"];
	
	Target_Element = document.getElementById(Rotation.Current_Category + "_" + Rotation[Rotation.Current_Category + "_Index"]);
	if (!Target_Element)
	{
		setTimeout("Next_Front_Page_Rotation()", 10);
		return;
	}	
	
	Old_Rotation_Element.style.overflow = "hidden";	

	Target_Element.style.position = "absolute";	
	Target_Element.style.top = "-1000px";
	Target_Element.style.position = "";
	Target_Element.style.width = Old_Rotation_Element.offsetWidth + "px";	
	Target_Element.style.display = "block";	
	Start_Height = Old_Rotation_Element.offsetHeight;
	Target_Height = Target_Element.offsetHeight;	
	Target_Element.style.display = "none";	
	Target_Element.style.top = "";
	Target_Element.style.width = "";
			
	Log("Start:" + Start_Height);
	Log("Target:" + Target_Height);

	Scale_And_Fade(Old_Rotation_Element.id, Target_Element.id, Start_Height, Target_Height, 0);
	
	Rotation.Current_Element_ID = Rotation.Current_Category + "_" + Rotation[Rotation.Current_Category + "_Index"];
	setTimeout("Next_Front_Page_Rotation()", Rotation_Seconds * 1000);
}

function Log(Text)
{	
	if (console)
		console.log(Text);
}


function Scale_And_Fade(Placeholder_ID, Target_ID, Start_Height, Target_Height, Percent)
{
	New_Percent = Percent + 10;
	
	Placeholder_Element = document.getElementById(Placeholder_ID);
	Placeholder_Element.style.height = Math.floor(Start_Height + (Target_Height - Start_Height) * (New_Percent / 100)) + "px";
	Placeholder_Element.style.opacity = 1 - ((Percent + 10) / 100);
	Placeholder_Element.style.display = "block";
	
	if (New_Percent < 100)
		setTimeout("Scale_And_Fade('" + Placeholder_ID + "', '" + Target_ID + "', " + Start_Height + ", " + Target_Height + ", " + New_Percent + ");", 5);
	else
	{
		Placeholder_Element.style.display = "none";
		Placeholder_Element.style.height = "";
		Placeholder_Element.style.width = "";
		Placeholder_Element.style.opacity = "1";
		Target_Element = document.getElementById(Target_ID);
		Target_Element.style.display = "block";
	}
}

function alertSize() {
	var myWidth = 0, myHeight = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
	myWidth = document.documentElement.clientWidth;
	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
	myWidth = document.body.clientWidth;
	myHeight = document.body.clientHeight;
	}
	window.alert( 'Width = ' + myWidth );
	window.alert( 'Height = ' + myHeight );
}

function Show_Video(Event_ID)
{
	Toggle_Media(Event_ID, true, true, 540, 415, 0, 10);
}
function Close_Video(Event_ID)
{
	Toggle_Media(Event_ID, false, true, 540, 415, 10, 10);
}
function Show_Audio(Event_ID)
{
	Toggle_Media(Event_ID, true, false, 540, 40, 0, 10);
}
function Close_Audio(Event_ID)
{
	Toggle_Media(Event_ID, false, false, 540, 40, 10, 10);
}
/*
function Show_External_Video(ID)
{
	Video_Frame = document.getElementById("Embed_Video_" + ID);
	console.log(Video_Frame);
	// Video_Frame.click();onclick="Show_Embedded_Video([Event:ID/]);"
	return true;
}

function Embed_External_Video(ID)
{	
	Video_Handler = document.getElementById("Embed_Video_Handler_" + ID);
	Video_Handler.addEventListener("mouseover", function() {
			
			console.log("Mouse Entered Iframe");
		}, false
	);
	
	Video_Handler.addEventListener("click", function () 
	{ 
		console.log("HEJ");
		Show_External_Video(ID);
	}, false
	);
}
*/

function Embed_Media(Container_ID, File_Path, Title, Width, Height, Is_Audio, Offset_In_Minutes)
{
	File_Path = File_Path.toLowerCase();
	console.log(File_Path);
	Letter_Rotation = false;
	if (Is_Audio)	
		Container_Padding = 40;
	else
		Container_Padding = 20;
		
	$(Container_ID).style.height = (Height + Container_Padding) + "px";
	
	// SWFObject 2
	// Amazing - SWFObject 2 doesn't work in IE yet. That's offensively idiotic considering what it claims to be.
	/*
	var flashvars = {
		autostart: "true",
		file: File_Path,
		title: Title,
		enablejs : "true",
		javascriptid : Container_ID + "_Player",
		displayheight : Height
	};
	
	var params = {
		allowfullscreen: "true"
	}

	swfobject.embedSWF('/jelly/player/mp3player.swf', Container_ID, Width, Height + Container_Padding, "9.0.0", "", flashvars, params);
	*/
	
	// SWFObject 1
	
	var Media_Player = new SWFObject('/jelly/player/player.swf',Container_ID + "_Object", Width, Height + Container_Padding,'9');	
	Media_Player.addVariable("autostart","true");
	Media_Player.addVariable("file", File_Path);
	Media_Player.addVariable("title", Title);
	Media_Player.addVariable("enablejs","true");
	Media_Player.addVariable("javascriptid", Container_ID + "_Player");
	Media_Player.addVariable("displayheight", Height);	
	Media_Player.addParam("allowfullscreen","true");
	Media_Player.addParam("allowscriptaccess","always");	
	
	// TODO: Stream audio.
	if (Is_Audio)
	{
		//Media_Player.addVariable("streamer", "http://philoctetes.org/xsexamples/servers/audio/");
	}
	// Stream video.
	else
	{		
		Media_Player.addVariable("provider", "http");
		Media_Player.addVariable("streamer", "http://philoctetes.org/xsexamples/servers/video/");
	}
	
	if (Offset_In_Minutes)
			Media_Player.addVariable("start", Offset_In_Minutes * 60);
	
	
	Media_Player.write(Container_ID);
}

function Toggle_Media(Event_ID, Showing_Media, Video_Media, Full_Width, Full_Height, Current_Step, Step_Count)
{
	var Small_Width = 60;
	var Small_Height = 78;
	var Full_Height_With_Controls = Full_Height + 30;
	
	Element_ID = "Media_Container_" + Event_ID;
	Scale_Element = document.getElementById(Element_ID);
	
	if (Showing_Media)
		Current_Step++;
	else
		Current_Step--;
	
	if (Showing_Media && Current_Step == 1)
	{
		Scale_Element.style.display = "block";
		document.getElementById("Media_Links_" + Event_ID).style.display = "none";
	}
	if (!Showing_Media && Current_Step == 0)
	{
		Scale_Element.style.display = "none";
		document.getElementById("Media_Links_" + Event_ID).style.display = "block";
	}
	if (!Showing_Media && Current_Step == 9)
	{
		
		/*
		var Media = document.getElementById("Media_" + Event_ID);
		var Media_Object = document.getElementById("Media_Object_" + Event_ID);
		var Media_Object_Embed = document.getElementById("Media_Embed_" + Event_ID);
		var Media_Object_Source = document.getElementById("Media_Source_" + Event_ID);
		
		try
		{
			// If object, stop video object
			Media_Object.Stop();
		}
		catch (Error)
		{
			// If embed, stop embedded video
			var Media_Object = document.getElementById("Philoctetes_Media_Embed");
			try
			{
				Media_Object.Stop();
			}
			catch (Error)
			{
				// If not yet loaded, do nothing.
				// TODO: cancel loading
			}
		}
	
		Media_Object_Source.value = "";
		Media_Object_Embed.src = "";	
		Media.innerHTML = "";
		*/
		Scale_Element.innerHTML = "&nbsp;";
	}
	
	Scale_Element.style.width = Math.floor(Small_Width + (Full_Width - Small_Width) * (Current_Step / Step_Count)) + "px";
	Scale_Element.style.height = Math.floor(Small_Height + (Full_Height_With_Controls - Small_Height) * (Current_Step / Step_Count)) + "px";
	
	if ((Showing_Media && Current_Step < Step_Count) || (!Showing_Media && Current_Step > 0))
		setTimeout("Toggle_Media(" + Event_ID + ", " + Showing_Media + ", " + Video_Media + ", " + Full_Width + ", " + Full_Height + ", " + Current_Step + ", " + Step_Count + ")", 5);
//		setTimeout("Show_Video('"+Event_ID+ "'," + New_Percent +" );", 5);
	else
	{
		if (Video_Media)
			Fill(Element_ID, '/Event/' + Event_ID  + '/Video_Player/Raw/');
		else
			Fill(Element_ID, '/Event/' + Event_ID  + '/Audio_Player/Raw/');
	}
}

var Last_Author = null;
var Last_Subject = null;
function Filter_Bibliography_By_Author()
{
	Last_Subject = null;
	Last_Author = document.getElementById('Author_Select').options[document.getElementById('Author_Select').selectedIndex].value;
	document.getElementById('Subject_Select').selectedIndex = 0; 
	if (document.getElementById('Author_Select').selectedIndex > 0)
	{
		Fill('Bibliography_Entries', '/User/' + Last_Author + '/Bibliograph/Raw');
	}
	else
	{
		Fill('Bibliography_Entries','/Block/Bibliography_Block/Raw');
	}
}

function Filter_Bibliography_By_Subject()
{
	Last_Subject = document.getElementById('Subject_Select').options[document.getElementById('Subject_Select').selectedIndex].value;
	Last_Author = null;
	document.getElementById('Author_Select').selectedIndex = 0; 	
	if (document.getElementById('Subject_Select').selectedIndex > 0)
	{		
		Fill('Bibliography_Entries', '/Subject/' + Last_Subject + '/Bibliograph/Raw');
	}
	else
	{
		Fill('Bibliography_Entries','/Block/Bibliography_Block/Raw');
	}
}

function Next_50_Bibliography_Entries(Start_Entry)
{
	if (Start_Entry < 0)
		Start_Entry = 0;
	if (Last_Subject)
	{
		Fill('Bibliography_Entries', '/User/' + document.getElementById('Author_Select').options[document.getElementById('Author_Select').selectedIndex].value + '/Bibliograph/Raw:Start_Entry=' + Start_Entry);
	}
	else if (Last_Author)	
	{
		Fill('Bibliography_Entries', '/Subject/' + document.getElementById('Subject_Select').options[document.getElementById('Subject_Select').selectedIndex].value + '/Bibliograph/Raw:Start_Entry=' + Start_Entry);
	}
	else
	{
//		alert('/Block/Bibliography_Block/Raw:Start_Entry=' + Start_Entry);
		Fill('Bibliography_Entries','/Block/Bibliography_Block/Raw:Start_Entry=' + Start_Entry);
	}
}

function Jump_Bibliography_To_Letter(Letter)
{
	Fill('Bibliography_Entries', '/Bibliography_Block/Raw:Start_Letter=' + Letter);
}

var Chat_Event_ID = 0;
var Chat_Last_Comment_ID = 0;
var Update_Chat_Flag = false;
var Update_Chat_Wait_Count = 0;

function Update_Chat()
{
//	alert("/Event/" + Chat_Event_ID + "/Chat/Raw:Last_Comment_ID=" + Chat_Last_Comment_ID);
	if (!Update_Chat_Flag)
	{
		Update_Chat_Flag = true;
		var myAjax = new Ajax.Request(
			"/Event/" + Chat_Event_ID + "/Chat/Raw:Last_Comment_ID=" + Chat_Last_Comment_ID,
			{method: 'get', onComplete: HandleNewChat}
		);
	}
	else
	{
		Update_Chat_Wait_Count ++;
		if (Update_Chat_Wait_Count >= 5)
		{
			Update_Chat_Flag = false;
			Update_Chat_Wait_Count = 0;
		}
	}
}

function HandleNewChat(originalRequest)
{
	Update_Chat_Flag = false;
	Update_Chat_Wait_Count = 0;
	
	originalRequest.responseText.evalScripts();
	if (originalRequest.responseText == "<!-- Event Chat Template -->")
	{
	}
	else
	{
		//alert("New" + Chat_Last_Comment_ID);
		//alert(originalRequest.responseText);
	}
}

function AlertResponse(originalRequest)
{
	alert(originalRequest.responseText);
}

function Get_Scroll()
{
	var Scroll_Amount = Array();
	if (self.pageYOffset) // all except Explorer
	{
		Scroll_Amount.x = self.pageXOffset;
		Scroll_Amount.y = self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		Scroll_Amount.x = document.documentElement.scrollLeft;
		Scroll_Amount.y = document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		Scroll_Amount.x = document.body.scrollLeft;
		Scroll_Amount.y = document.body.scrollTop;
	}
	return Scroll_Amount;
}

//Past programs mouseover
function Show_Roundtables()
{
	$('Past_Programs_Browse_Roundtables').style.height = "auto";
//	$('Past_Programs_Browse_Roundtables').style.overflow="visible";
//	$('Past_Programs_Browse_Roundtables').style.borderColor="#CCCCCC";
}
function Hide_Roundtables()
{
	$('Past_Programs_Browse_Roundtables').style.height = "20px";
//	$('Past_Programs_Browse_Roundtables').style.overflow="hidden";
//	$('Past_Programs_Browse_Roundtables').style.borderColor="#FFFFFF";
}

function Sort_Programs( Sort_By)
{
	$('Past_Programs').innerHTML = "<img src='/dynamicsite/images/loading.gif'/>";
	Fill("Past_Programs", "/Block/Past_Programs_By_" + Sort_By + "/Raw");
}


// Date localization scripts

function Get_NYC_Timezone()
	{
		// Find the time in NYC right now.
		var Current_Date = new Date(); 
		//document.write(Current_Date + "<br/>");
		var NYC_Hour = Current_Date.getUTCHours() - 5;
		// It'll evaluate around 2 am, so there is no need to calculate this accurately.
		if (NYC_Hour < 0)
			NYC_Hour = 0;
		Current_Date.setTime(Date.parse((Current_Date.getUTCMonth() + 1) + "/" + Current_Date.getUTCDate() + "/" + Current_Date.getUTCFullYear() + " " + NYC_Hour + ":" + Current_Date.getUTCMinutes()));
		//document.write((Current_Date.getUTCMonth() + 1) + "/" + Current_Date.getUTCDate() + "/" + Current_Date.getUTCFullYear() + " " + NYC_Hour + ":" + Current_Date.getUTCMinutes() + "<br/>");

		
		// Construct border dates around EDT (-0400), between the second sunday of march and the first sunday of november.
		var Border_Date = new Date();
		
		Border_Date.setTime(Date.parse("Mar 1 " + Current_Date.getFullYear()));
		var March_First_Day = Border_Date.getDay();
		var Summer_Start_Date = new Date();
		Summer_Start_Date.setTime(Date.parse("Mar " + (March_First_Day?(15-March_First_Day):8) + " " + Current_Date.getFullYear() + " 02:00"));
					
		Border_Date.setTime(Date.parse("Nov 1 " + Current_Date.getFullYear()));
		var November_First_Day = Border_Date.getDay();	
		var Summer_End_Date = new Date();
		Summer_End_Date.setTime(Date.parse("Nov " + (November_First_Day?(8-November_First_Day):1) + " " + Current_Date.getFullYear() + " 02:00"));		
		//document.write(Summer_Start_Date + "<br/>");
		//document.write(Summer_End_Date + "<br/>");
		
		// Compare the current date with these border dates to determine the current NYC timezone offset.
		var NYC_Timezone_Offset = "";
		var NYC_Timezone = "";
		if (Current_Date > Summer_Start_Date && Current_Date < Summer_End_Date)
			return "EDT";
		else
			return "EST";
	}
	
	// Format a date object into a time string.
	function Get_Time_From_Date(Date_Object)
	{		
		Date_Hours = Date_Object.getHours();
		if (Date_Hours > 12)
		{
			Date_Hours -= 12;
			Date_AM_PM = "PM";
		}
		else
			Date_AM_PM = "AM";
			
		var Date_Minutes = Date_Object.getMinutes();
		if (Date_Minutes < 10)
			Date_Minutes = "0" + Date_Minutes;
			
		return Date_Hours + ":" + Date_Minutes + " " + Date_AM_PM;
	}


//	Automatic time localization removed!	
	function Get_Local_Time(NYC_Date_String)
	{
		// Make formatted NYC time string
		NYC_Date = new Date();
		NYC_Date.setTime(Date.parse(NYC_Date_String));
		NYC_Time_String = Get_Time_From_Date(NYC_Date);
		
		// Convert NYC time zone to NYC time zone offset.
		NYC_Timezone = Get_NYC_Timezone();
		if (NYC_Timezone == "EDT")
		{
			NYC_Timezone_Offset = -4;
			NYC_Timezone_Offset_String = "GMT-0400";
		}
		else
		{
			NYC_Timezone_Offset = -5;
			NYC_Timezone_Offset_String = "GMT-0500";
		}
			
		// Return the NYC time string and current time zone, with a trailing comma.
		return NYC_Time_String + " " + "<span style='font-size:10px'>(</span>" + "<span style='font-size:10px'>" + NYC_Timezone + "</span>"+ "<span style='font-size:10px'>)</span>" + ", ";
	}

/*
	Original automatic time localization.
	function Get_Local_Time(NYC_Date_String)
	{
		// Make formatted NYC time string
		NYC_Date = new Date();
		NYC_Date.setTime(Date.parse(NYC_Date_String));
		NYC_Time_String = Get_Time_From_Date(NYC_Date);
		
		// Convert NYC time zone to NYC time zone offset.
		NYC_Timezone = Get_NYC_Timezone();
		if (NYC_Timezone == "EDT")
		{
			NYC_Timezone_Offset = -4;
			NYC_Timezone_Offset_String = "GMT-0400";
		}
		else
		{
			NYC_Timezone_Offset = -5;
			NYC_Timezone_Offset_String = "GMT-0500";
		}
			
		// If the local timezone offset is the same as the current NYC timezone offset, return NYC time string, with a comma trailing.
		var Local_Date = new Date();
		if (-1 * Local_Date.getTimezoneOffset()/60 == NYC_Timezone_Offset)
			return NYC_Time_String + ", ";
		
		// Otherwise, return both NYC time string and local time string, with a line break trailing.
		Local_Date = new Date();		
		//document.write(Local_Date + "<br/>");
		//document.write(NYC_Date_String + " " + NYC_Timezone_Offset_String + "<br/>");
		Local_Date.setTime(Date.parse(NYC_Date_String + " " + NYC_Timezone_Offset_String));
		//document.write(Local_Date + "<br/>");
		Local_Time_String = Get_Time_From_Date(Local_Date);
		return Local_Time_String + " " + "(" + " " + NYC_Time_String + " " + NYC_Timezone + " " + ")" + "<br/>";
		//return NYC_Time_String + " " + NYC_Timezone + " ( " + Local_Time_String + " local )" + "<br/>";
	}
*/
