// WGME13 Javascript
// Mike McFadden

function ShowBanner(theMode)
{
	var time = new Date()
	var theDay = time.getDay()
	var theHour = time.getHours()
	var theBanner = "None"
	var isWeekDay = true
		
	if (theDay==0 || theDay==6)
		isWeekDay = false
		
	theTalentArea = document.getElementById('talent')
	theGlassArea  = document.getElementById('glass')
		
//	if (theMode != Undefined)
//	{
//		theHour=theMode
//	}
		
	if (isWeekDay)
	{			
		if (theHour<=4)
			{
			theTalentArea.src='/_parts/header/hdr_blank.jpg'
			theGlassArea.src='/_parts/header/glass_blank.jpg'
			}
		else
		if (theHour<=9)
			{
			theTalentArea.src='/_parts/header/hdr_daybreak.jpg'
			theGlassArea.src='/_parts/header/glass_daybreak.jpg'
			}
		else
		if (theHour<=13)
			{
			theTalentArea.src='/_parts/header/hdr_noon.jpg'
			theGlassArea.src='/_parts/header/glass_noon.jpg'
			}
		else
		if (theHour<=20)
			{
			theTalentArea.src='/_parts/header/hdr_fivesix.jpg'
			theGlassArea.src='/_parts/header/glass_fivesix.jpg'
			}
		else
		if (theHour<=24)
			{
			theTalentArea.src='/_parts/header/hdr_eleven.jpg'
			theGlassArea.src='/_parts/header/glass_eleven.jpg'
			}
		else	
			{
			theTalentArea.src='/_parts/header/hdr_blank.jpg'
			theGlassArea.src='/_parts/header/glass_blank.jpg'
			}
	}
	else
	{
		theTalentArea.src='/_parts/header/hdr_weekend.jpg'
		theGlassArea.src='/_parts/header/glass_weekend.jpg'
	}
	
	return
};

function ShowNewsStreamcast ()
{
	var time = new Date();
	var theDay = time.getDay();
	var theHour = time.getHours();
	var theStream = "None";
	var isWeekDay = true;
		
	if (theDay==0 || theDay==6)
		isWeekDay = false;
		
	if (isWeekDay)
	{			
		if (theHour<=8)
			theStream = "<img src='/_parts/common/topstories_streamcast_off.jpg' alt='' height='36' width='404' border='0' />";
		else
		if (theHour<=14)
			theStream = "<a href='/News/streamcast_flash.shtml' target='_blank'><img src='/_parts/common/topstories_streamcast_on.jpg' border='0'></a>";					
		else
			theStream = "<img src='/_parts/common/topstories_streamcast_off.jpg' alt='' height='36' width='404' border='0' />";
	}
	else
	{
			theStream = "<img src='/_parts/common/topstories_streamcast_off.jpg' alt='' height='36' width='404' border='0' />";
	}
	
	return theStream

};

function ShowWeatherPanel ()
{
	/* document.getElementById('v1').src='<!--#include virtual="/_txt/weather_panel.inc" -->'; */
	document.getElementById('v2').src='http://www.wgme.com/Weather/wxcentral/7_Day_Forecast_Coast_thumb.JPG';
	document.getElementById('v3').src='http://www.wgme.com/webcam/port.jpg';
	document.getElementById('v4').src='http://www.wgme.com/Weather/wxcentral/Local_Temps_thumb.JPG';
	document.getElementById('v5').src='http://www.wgme.com/Weather/wxcentral/Local_Doppler_HD_thumb.JPG';
	document.getElementById('v6').src='http://www.wgme.com/Weather/wxcentral/Regional_Sat_Rad_thumb.JPG';
	document.getElementById('v7').src='http://www.wgme.com/Weather/wxcentral/National_Sat_Rad_thumb.JPG';
};

function ShowWeatherMap (mapPictURL)
{
	theFullURL="/Weather/Maps/mapviewer.shtml?"+mapPictURL;
	theWindowTitle="StormTeam13 Weather Map Viewer";
	theWindowSize="width=880,height=550";
	
	if (IE == 1)
	{
		window.location.href=theFullURL;
	}
	else
	{
		window.open(theFullURL,theWindowTitle,theWindowSize);
	}
	
	//window.open("/Weather/Maps/mapviewer.shtml?"+mapPictURL,"StormTeam13 Weather Map Viewer","width=820,height=620");
};

function ShowWeatherMap2 (mapPictURL)
{
	theFullURL="/Weather/Maps/mapviewer2.shtml?"+mapPictURL;
	theWindowTitle="StormTeam13 Weather Map Viewer";
	theWindowSize="width=880,height=550";
	
	if (IE == 1)
	{
		window.location.href=theFullURL;
	}
	else
	{
		window.open(theFullURL,theWindowTitle,theWindowSize);
	}
	
	//window.open("/Weather/Maps/mapviewer2.shtml?"+mapPictURL,"StormTeam13 Weather Map Viewer","width=820,height=620");
};

function ShowBreakingWeather(theType,theMarquee)
{
	switch (theType)
	{
		case ('Red'):
			theBWStyle="bw_Red";
			theBackground="bw_Red.jpg";
			break;
		case ('Orange'):
			theBWStyle="bw_Orange";
			theBackground="bw_Orange.jpg";
			break;
		case ('Yellow'):
			theBWStyle="bw_Yellow";
			theBackground="bw_Yellow.jpg";
			break;
		default:
			return
	}
	
	theBreakingWX="<table width='612' border='0' cellspacing='0' cellpadding='0' background='/Weather/graphics/"+theBackground+"' height='36'>";
	theBreakingWX=theBreakingWX+"<tr height='16'><td height='16'></td></tr><tr>";
	theBreakingWX=theBreakingWX+"<td class='"+theBWStyle+"'><marquee>"+theMarquee+"</marquee></td></tr></table>";
	document.write(theBreakingWX);
}

function LoadHomePage ()
{
	ShowBanner();
	ShowWeatherPanel();
};

function getAge (theTime)
{
	oneMin = 60*1000
	oneHour = oneMin * 60
	oneDay = oneHour * 24
	
	timeIn = theTime.substr(4,2)+'/'+theTime.substr(6,2)+'/'+theTime.substr(0,4)
	timeIn = timeIn+' '+theTime.substr(9,2)+':'+theTime.substr(11,2)+':'+theTime.substr(13,2)
		
	currentTime = new Date()
	targetTime = new Date(timeIn)
	
	diff = (currentTime - targetTime)
	
	theDays = parseInt(diff / oneDay)
	dayLabel=''
	dayPart=''
	if (theDays>0)
	{
		if (theDays==1)
			dayLabel=' day'
		else
			dayLabel=' days'
		dayPart=theDays+dayLabel+' '
	}
	
	diff = diff - (theDays*oneDay)	
	theHours = parseInt(diff/ oneHour)
	hourLabel=''
	hourPart=''
	if (theHours>0)
	{
		if (theHours==1)
			hourLabel=' hour'
		else
			hourLabel=' hours'
		hourPart=theHours+hourLabel+' '
	}
	
	diff = diff -(theHours*oneHour)
	theMin = parseInt(diff / oneMin)
	minLabel=''
	minPart=''
	if (theMin>0)
	{
		if (theMin==1)
			minLabel=' minute'
		else
			minLabel=' minutes'
		minPart=theMin+minLabel
	}
	
	retVal = dayPart+hourPart+minPart
		
	if (retVal == '')
		retVal='Moments'
	
	return retVal
	
}	
