/*
	Generic Drag Script- © Dynamic Drive (www.dynamicdrive.com)
	For full source code and terms of usage,
	visit http://www.dynamicdrive.com

	Heavily modified by Adam McKee
	modified again by Andy Rosenbaum
*/
var maxWins = 15;
var winArray = new Array(maxWins);
var winObsArray = new Array (maxWins);
var numWins = 0;
var adCount = 0;
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var liveObs = "liveobs";
var liveObsText = "liveobstext";
var radar = "radar";
var extForecast = "extforecast";
var forecast = "forecast";
var camera = "camera";

var dragApproved = false;
var c,r,z,x,y;
var resizeApproved = false;
var curId= "";
var isLoading = false;


function snapToGrid()
{
    for (i = 0; i < numWins; i++)
	{
	    
	}
}

function move(e)
{
	if (dragApproved)
	{
		z.style.left = ns6 ? temp1 + e.clientX - x + "px" : temp1 + event.clientX - x;
		z.style.top = ns6 ? temp2 + e.clientY - y + "px": temp2 + event.clientY - y;
		return false;
	}
}

function windowOpen(url, title)
{
	window.open(url, title);
}

function bringToFront(id)
{
	try
	{
		win = document.getElementById(id);
		win.style.zIndex = 99;					
		//sort the windows by zIndex
		for (i = 0; i < numWins; i++)
		{
			for (j = i + 1; j < numWins; j++)
			{
				iwin = document.getElementById(winArray[i]);
				jwin = document.getElementById(winArray[j]);
				
				if ((jwin.id.indexOf("Advertisement") == -1 ) && (iwin.id.indexOf("Advertisement") == -1 ))
				{
					if ((iwin.style.zIndex > jwin.style.zIndex))
					{
						tempWin = winArray[j];
						winArray[j] = winArray[i];
						winArray[i] = tempWin;
					}
				}
			}
		}					
		//re-assign the windows a new zIndex
		for (i = 0; i < numWins; i++)
		{
			iwin = document.getElementById(winArray[i]);
			if (iwin.id.indexOf("Advertisement") == -1 )
			{
				iwin.style.zIndex = i + 1;
			}
			else
			{
				iwin.style.zIndex = 999;
			}
		}
		win.style.visibility = "visible";
	}
	catch (e) 
	{
		window.alert(e.message);
		
	}
	curId = id; 
}

function redoList()
{
	listText = "";
	for (i = 0; i < numWins; i++)
	{
		listText += "<a href=\"JavaScript:bringToFront('" + winArray[i] + "');\">" + winArray[i] + "</a><br />";
	}
	//document.getElementById("windowlist").innerHTML = listText;
}

function resize(e)
{
	if (resizeApproved)
	{
		z.style.width = ns6 ? temp1 + e.clientX - x : temp1 + event.clientX - x;
		z.style.height = ns6 ? temp2 + e.clientY - y : temp2 + event.clientY - y;
		r.style.left = ns6 ? rtemp1 + e.clientX - x : rtemp1 + event.clientX - x;
		r.style.top = ns6 ? rtemp2 + e.clientY - y : rtemp2 + event.clientY - y;
		c.style.left = ns6 ? ctemp1 + e.clientX - x : ctemp1 + event.clientX - x;
		return false;
	}
}

function close(id)
{
	if (document.getElementById("imgClose" + id).src.indexOf("images/open.gif") != -1)
	{
		if ((id.indexOf ("liveobs") > -1) && (id.indexOf ("text") == -1))
		{
			document.getElementById(id).style.height=194;
			reload(id)
		}
		else if(id == "launch")
		{
			document.getElementById(id).style.height=100;
			buildLauncherHtml();
		}
		else
		{
			reload(id)
		}
		document.getElementById("imgClose" + id).src = "images/close.gif";
	}
	else
	{
		if ((id.indexOf ("liveobs") > -1) && (id.indexOf ("text") == -1))
		{
			document.getElementById(id + "div").innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"193\"><tr><td></td></tr></table>";
			document.getElementById(id).style.height=10;
		}
		else if(id == "launch")
		{
			document.getElementById(id + "div" ).innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\"  height=\"15\" border=\"0\" width=\"180\"><tr><td height=\"15\" align=\"center\" class=\"controllerhdr\">WeatherBug Bytes</td></tr></table>";
			document.getElementById(id).style.height=10;
		}
		else if((id.indexOf(radar)>-1) || (id.indexOf(camera)>-1))
		{
			document.getElementById(id + "div").innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"270\"><tr><td></td></tr></table>";
			document.getElementById(id).style.height=10;
		}
		else if (id.indexOf (extForecast) > -1)
		{
			document.getElementById(id + "div").innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"400\"><tr><td></td></tr></table>";
			document.getElementById(id).style.height=10;
		}
		else
		{
			document.getElementById(id + "div").innerHTML = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"200\"><tr><td></td></tr></table>";
			document.getElementById(id).style.height=10;
		}
		
		document.getElementById("imgClose" + id).src = "images/open.gif";
	}
		
}

function reopen(id)
{
	document.getElementById(id).style.visibility = 'visible';		
}

function reload(id)
{
	var url = "";
	curId = id;
	
	var thisZip = GetCookie(curId + "zip") + "";
	
	if (thisZip.length == 0)
	{
		thisZip = "20876";
	}
	
	if ((curId.indexOf ("liveobs") > -1) && (curId.indexOf ("text") == -1))
	{
		document.getElementById (curId + "div").innerHTML = buildObsHtml(thisZip, curId);
		document.getElementById("imgClose" + id).src = "images/close.gif";
	}
	else if (curId.indexOf(camera)>-1)
	{
		var thisStation = GetCookie(curId + "stationid") + "";
		AwsSendSyncGetReq(thisZip, curId, thisStation);
		document.getElementById("imgClose" + id).src = "images/close.gif";
	}
	else
	{
		AwsSendSyncGetReq(thisZip, curId, "");
		document.getElementById("imgClose" + id).src = "images/close.gif";
	}
	
	AwsSendSyncGetReq(thisZip, "alerts", "");
}

function drags(e)
{
	try
	{
	    if (!ie && !ns6) return;
	    var firedobj = ns6 ? e.target : event.srcElement;
	    var topelement = ns6 ? "HTML" : "BODY";
    	
	    while ((firedobj.tagName != topelement) && !hasClass(firedobj.className,"drag") && !hasClass(firedobj.className,"resize"))
	    {
		    if ((firedobj.tagName == "INPUT")  || (firedobj.tagName == "SELECT")) return true;					
		    firedobj = ns6 ? firedobj.parentNode : firedobj.parentElement;
	    }

	    if (hasClass(firedobj.className,"drag"))
	    {
	        if ((firedobj.id.indexOf("Advertisement") == -1) && (firedobj.id.indexOf("Advertisement") == -1))
		    {
			    dragApproved = true;
		    }
		    else 
		    {
			    dragApproved = false;
		    }
		    resizeApproved = false;
		    z = firedobj;
		    try
		    {
			    document.getElementById(z.id + "cover").style.visibility = 'visible';
		    }
		    catch (e) {}
		   
		    bringToFront(z.id);
		    temp1 = parseInt(z.style.left + 0);
		    temp2 = parseInt(z.style.top + 0);
		    if ((temp1==0) && (temp2 == 0))
		    {
		        temp1=400;
		        temp2=200;
		    }
		    x=ns6 ? e.clientX : event.clientX;
		    y=ns6 ? e.clientY : event.clientY;
		    document.onmousemove = move;
		    return false;
		   
	    }
	    else if (hasClass(firedobj.className,"resize"))
	    {				
		  /*  r = firedobj;
		    firedobj2 = ns6 ? firedobj.parentNode : firedobj.parentElement;
		    if ((firedobj.id.indexOf("Advertisement") == -1) && (firedobj.id.indexOf("Advertisement") == -1))
		    {
			    resizeApproved = true;
		    }
		    else 
		    {
			    resizeApproved = false;
		    }
		    //resizeApproved = true;
		    dragApproved = false;
		    z = firedobj2;					
		    c = document.getElementById(z.id + "closer");		
		    bringToFront(z.id);
		    rtemp1 = parseInt(r.style.left + 0);
		    ctemp1 = parseInt(c.style.left + 0);
		    rtemp2 = parseInt(r.style.top + 0);
		    temp1 = parseInt(z.style.width + 0);
		    temp2 = parseInt(z.style.height + 0);
		    x=ns6 ? e.clientX : event.clientX;
		    y=ns6 ? e.clientY : event.clientY;
		    document.onmousemove = resize;*/
		    return false;
	    }
	    else if (firedobj.className == "windowOpen")
	    {
		    return true;
	    }
    }
    catch(f)
    {}
}

function hasClass(objClassName,className)
{
    if (objClassName == "") return false;
	var re = new RegExp(" ?" + className + " ?");
	return objClassName.match(re);
}

function nowindowaction()
{
	dragApproved = false;
	resizeApproved = false;
	try
	{
		document.getElementById(z.id + "cover").style.visibility = 'hidden';
		storeWindowPosition(z.id,z.style.left,z.style.top,z.style.width,z.style.height,z.style.zIndex);
	}	
	catch (e) {}
	z = null;
}

function formCreate(ctlId)
{
	id = document.launchform.id.value;
	url = document.launchform.url.value;
	title = document.launchform.title.value;
	width = document.launchform.width.value;
	height = document.launchform.height.value;
	createWindow(id,url,title,width,height);
}

function createWindow(id,title,width,height)
{
	try
	{
	    document.getElementById("helperDiv").style.visibility="hidden";
	    if (id == "") 
	    {
		    window.alert("Window id must not be blank.  Please enter an id");
		    return;
	    }
    	
	    if (numWins + 1 > maxWins)
	    {
		    window.alert("You have added the maximum number of controls.");
		    return;
	    }
	    if (isNaN(id.substring(id.length-1, id.length)))
	    {
	        var myControlCount = 0;
            for (i = 0; i < numWins; i++)
            {
                if (winArray[i].indexOf(id) != -1)
                {
                    myControlCount++;
                }
            }
    		
		    id = id + myControlCount;    	
		}
		
		 
	    curId = id;
	    var thisZip = GetCookie(curId + "zip") + "";
        
        if ((thisZip == "") || (thisZip == "null") || thisZip == null)
        {
		    var defaultZip = GetCookie ("defaultZip");
		    if ((defaultZip == "") || (defaultZip == "null") || (defaultZip == null))
    	    {
		        SetCookie (curId + "zip", "20876", new Date(2020,1,1));
		        thisZip = "20876";
	        }
	        else
	        {
	            SetCookie (curId + "zip", defaultZip, new Date(2020,1,1));
	            thisZip = defaultZip
	        }
        }
        else
        {
            SetCookie (curId + "zip", thisZip, new Date(2020,1,1));
        }
      	
	     title = title.replace ('20876', thisZip);
     	
	    win = "<div id=\"" + curId + "\" class=\"drag\" style=\"visibility:hidden; width:" + width + "px; height:" + height + "px; z-index:2; \">" +
			    "<table bgcolor=\"white\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"  width=\"" + width + "\" height=\"100%\">" +
				    "<tr><td id=\"tdtitle" + curId +"\" align=\"center\" height=\"20\" background=\"images/titlebg.JPG\" class=\"titlebar\">" + title + "</td></tr>" +
				    "<tr><td>" +
					    "<div  class=\"bordered\" id=\"" + curId + "div\"></div>" +
					    "<div id=\"" + curId + "cover\" style=\"visibility:hidden; background-color:transparent; position:absolute; left:0px; left:0px; width:100%; height:100%; z-index:3;\">" +
					    "<table border=\"0\" style=\"width:100%; height:100%;\"><tr><td>&#160;</td></tr></table></div>" +
				    "</td></tr>" +
				    //"<tr><td id=\"" + id + "status\" align=\"center\" class=\"bottombar\" height=\"15\" /></tr>" +
				    //"<tr><td id=\"" + id + "status\" align=\"center\" class=\"windowOpen\" height=\"20\"><a href=\"javascript:window.open('http://www.weatherbug.com');\" style=\"forecasthdr\" target=\"_new\">Brought to you by WeatherBug</a></div></td></tr>" +
			    "</table>" +
			    "<div id=\"" + curId + "closer\" style=\"position:absolute; top:5px; left:" + (width - 33) + "px; z-index:1;\"><a href=\"javascript:close('" + id + "');\"><img id=\"imgClose" + curId + "\" src=\"images/close.gif\" border=\"0\" alt=\"\" /></a></div>" +
			    "<div id=\"" + curId + "remover\" style=\"position:absolute; top:5px; left:" + (width - 18) + "px; z-index:1;\"><a href=\"javascript:removeWindow('" + id + "');\"><img id=\"imgRemove" + curId + "\" src=\"images/remove.gif\" border=\"0\" alt=\"\" /></a></div>" +
			    "<a href=\"javascript:reload('" + id + "');\"><img src=\"images/reload.gif\" alt=\"\" border=\"0\" style=\"position:absolute; top:3px; left:5px; z-index:1;\" /></a>" +
			    //"<img id=\"" + id + "resizer\" src=\"resizer.gif\" alt=\"\" style=\"position:absolute; top:" + (height - 15) + "px; left:" + (width - 15) + "px; z-index:1;\" class=\"resize\" />" +
		    "</div>";
        document.getElementById("launcher").innerHTML += win;
	    winArray[numWins] = curId;
	    numWins++;
    	
	    resetWindowPosition(curId);
    	
	    if ((curId.indexOf (liveObs) > -1) && (curId.indexOf ("text") == -1))
	    {
		    document.getElementById (curId + "div").innerHTML = buildObsHtml(thisZip, curId);
	    }
	    else
	    {
		    if (curId.indexOf(camera) > -1)
		    {
			    var thisStation = GetCookie(curId + "stationid") + "";
			    AwsSendSyncGetReq(thisZip, curId, thisStation);
		    }
		    else 
		    {
			    AwsSendSyncGetReq(thisZip, curId, "");
		    }
	    }

	    var windowList = GetCookie("WinList") + "";
	    SetCookie ("WinList", windowList + "|" + curId, new Date(2020,1,1));
    	
	    AwsSendSyncGetReq(thisZip, "alerts", "");

	    for (i = 0; i < numWins ; i++)
	    {
		    if ((winArray[i].indexOf(liveObs) > -1) && (winArray[i].indexOf("text") == -1))
		    {
			    if (document.getElementById("imgClose" + winArray[i]).src.indexOf("images/open.gif") == -1)
			    {
				    var liveObsZip = GetCookie (winArray[i] + "zip") + "";
				    if ((liveObsZip == "") || (liveObsZip == "null") || (liveObsZip == null))
				    {
                         var defaultZip = GetCookie ("defaultZip");
		                 if ((defaultZip == "") || (defaultZip == "null") || (defaultZip == null))
    	                 {					   
					        liveObsZip = "20876";
				         }
				         else
				         {
				            liveObsZip = defaultZip;
				         }
    				}
				    document.getElementById (winArray[i] + "div").innerHTML = buildObsHtml(liveObsZip, winArray[i]);
			    }
		    }
	    }
	    bringToFront(id);	
    }
	catch(e)
	{
	    window.alert(e.message);
	}
}

function awsGetData()
{
	//only used for alerts
	if (awsHttp.readyState==4) 
	{
		if (awsHttp.status==200)
		{
			document.getElementById ("alertsdiv").innerHTML = buildAlertsHtml(awsHttp.responseText);
		}
		
	}
}
document.onmousedown = drags;
document.onmouseup = nowindowaction;

try
{
	document.write("<div id=\"launcher\" style=\"visibility:hidden;\">&#160;</div>");
	document.domain = "weatherbug.com";
}
catch (e) {}


// ---------------------------------------------------------------
//  Cookie Functions - Second Helping  (21-Jan-96)
//  Written by:  Bill Dortch, hIdaho Design <BDORTCH@NETW.COM>
//  The following functions are released to the public domain.
//  ONCE AGAIN, these were heavily modified by Adam McKee
//	modified again by Andy Rosenbaum
//
//  The Second Helping version of the cookie functions dispenses with
//  my encode and decode functions, in favor of JavaScript's new built-in
//  escape and unescape functions, which do more complete encoding, and
//  which are probably much faster.
//
//  The new version also extends the SetCookie function, though in
//  a backward-compatible manner, so if you used the First Helping of
//  cookie functions as they were written, you will not need to change any
//  code, unless you want to take advantage of the new capabilities.
//
//  The following changes were made to SetCookie:
//
//  1.  The expires parameter is now optional - that is, you can omit
//      it instead of passing it null to expire the cookie at the end
//      of the current session.
//
//  2.  An optional path parameter has been added.
//
//  3.  An optional domain parameter has been added.
//
//  4.  An optional secure parameter has been added.
//
//  For information on the significance of these parameters, and
//  and on cookies in general, please refer to the official cookie
//  spec, at:
//
//      http://www.netscape.com/newsref/std/cookie_spec.html    
//
//
// "Internal" function to return the decoded value of a cookie
//
function getCookieVal (offset) 
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

//
//  Function to return the value of the cookie specified by "name".
//    name - String object containing the cookie name.
//    returns - String object containing the cookie value, or null if
//      the cookie does not exist.
//
function GetCookie (name) 
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) 
    {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
    }
    return null;
}

//
//  Function to create or update a cookie.
//    name - String object object containing the cookie name.
//    value - String object containing the cookie value.  May contain
//      any valid string characters.
//    [expires] - Date object containing the expiration data of the cookie.  If
//      omitted or null, expires the cookie at the end of the current session.
//    [path] - String object indicating the path for which the cookie is valid.
//      If omitted or null, uses the path of the calling document.
//    [domain] - String object indicating the domain for which the cookie is
//      valid.  If omitted or null, uses the domain of the calling document.
//    [secure] - Boolean (true/false) value indicating whether cookie transmission
//      requires a secure channel (HTTPS).  
//
//  The first two parameters are required.  The others, if supplied, must
//  be passed in the order listed above.  To omit an unused optional field,
//  use null as a place holder.  For example, to call SetCookie using name,
//  value and path, you would code:
//
//      SetCookie ("myCookieName", "myCookieValue", null, "/");
//
//  Note that trailing omitted parameters do not require a placeholder.
//
//  To set a secure cookie for path "/myPath", that expires after the
//  current session, you might code:
//
//      SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);
//
function SetCookie (name, value) 
{
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
}

//  Function to delete a cookie. (Sets expiration date to current date/time)
//    name - String object containing the cookie name
//
function DeleteCookie (name) 
{
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);  // This cookie is history
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


function storeWindowPosition(id,x,y,w,h,z)
{
	// elements of a single window are | separated
	// windows are , separated
	try
	{
		var windowPositionArray = new Array();
		try
		{
			windowPositionArray = GetCookie("miniWinPos").split(',');
		}
		catch (e) {}
		found = false;
		
		for (i = 0; i < windowPositionArray.length; i++)
		{
			try
			{
				var posArray = windowPositionArray[i].split('|');
				if (posArray[0] == id)
				{
					windowPositionArray[i] = id + "|" + x + "|" + y + "|" + w + "|" + h + "|" + z;
					found = true;
					break;
				}
			}
			catch (e) {}
		}
		if (!found)
		{
			windowPositionArray[windowPositionArray.length] = id + "|" + x + "|" + y + "|" + w + "|" + h + "|" + z;
		}
		var cookieString = "";
		for (i = 0; i < windowPositionArray.length; i++)
		{
			cookieString += windowPositionArray[i];
			cookieString += ",";
		}
		SetCookie("miniWinPos",cookieString,new Date(2020,1,1));
	}
	catch (e) {}	
}

function resetWindowPosition(id)
{
	// elements of a single window are | separated
	// windows are , separated
	try
	{
		var windowPositionArray = new Array();
		try
		{
			windowPositionArray = GetCookie("miniWinPos").split(',');
		}
		catch (e) {}
		
		for (i = 0; i < windowPositionArray.length; i++)
		{
			try
			{
				var posArray = windowPositionArray[i].split('|');
				if (posArray[0] == id)
				{
					resetMiniWinPos(posArray);
					return;
				}
				
				if (i==windowPositionArray.length-1)
				{
					openMiniWinPos(id, windowPositionArray[0].split('|'), 20);
					return;
				}
				
			}
			catch (e) {}
		}
	}
	catch (e) {}	
}
function getStartWindowPosition(id)
{
	// elements of a single window are | separated
	// windows are , separated
	try
	{
		var windowPositionArray = new Array();
		try
		{
			windowPositionArray = GetCookie("miniWinPos").split(',');
		}
		catch (e) {}
		
		for (i = 0; i < windowPositionArray.length; i++)
		{
			try
			{
				var posArray = windowPositionArray[i].split('|');
				if (id = posArray[0])
				{
			        openMiniWinPos(id, posArray, 0);
				}
			}
			catch (e) {}
		}
	}
	catch (e) {}	
}

function openMiniWinPos(winId, posArray, offSet)
{
	try
	{
		win = document.getElementById(winId);
		win.style.left = parseInt(posArray[1])+offSet;
		if ((parseInt(posArray[2])+offSet) < 200)
		{
		    win.style.top = 210;
		}
		else
		{
		    win.style.top = parseInt(posArray[2])+offSet;
		}
		win.style.zIndex = posArray[5];
		r = document.getElementById(posArray[0] + "resizer");
		c = document.getElementById(posArray[0] + "closer");
		r.style.left = parseInt(posArray[3]) - 15;
		r.style.top = parseInt(posArray[4]) - 15;
		c.style.left = parseInt(posArray[3]) - 18;;
	}
	catch (e) { }
}

function resetMiniWinPos(posArray)
{
	try
	{
		win = document.getElementById(posArray[0]);
		win.style.left = posArray[1];
		win.style.top = posArray[2];
		win.style.width = posArray[3];
		win.style.height = posArray[4];
		win.style.zIndex = posArray[5];
		r = document.getElementById(posArray[0] + "resizer");
		c = document.getElementById(posArray[0] + "closer");
		r.style.left = parseInt(posArray[3]) - 15;
		r.style.top = parseInt(posArray[4]) - 15;
		c.style.left = parseInt(posArray[3]) - 18;;
	}
	catch (e) { }
}
    
function loadMyWindows()
{
	var winList = GetCookie("WinList") + "";
	var winListAry = new Array(maxWins);
	var winCount = 0;
	isLoading = true;
	if (winList != "")
	{
		winListAry = winList.split("|");
		if (winListAry.length > maxWins)
		{
		    winCount = maxWins;
		}
		else
		{
		    winCount = winListAry.length;
		}
		
		SetCookie("WinList", "");
        for (var i = 0; i < winCount; i++)
		{
			if ((winListAry[i].indexOf(liveObs)>-1) && (winListAry[i].indexOf("text")==-1))
			{
				//createEmptyWindow(winArray[i],'My Live Obs - 20876','193','194');
				createWindow(winListAry[i],'Live-20876','193','194');
				getStartWindowPosition(winListAry[i]);
			}
			else if (winListAry[i].indexOf(liveObsText) != -1 )
			{
				//createEmptyWindow(winArray[i],'My Location - 20876','250','200');
				createWindow(winListAry[i],'My Location - 20876','270','200');
				getStartWindowPosition(winListAry[i]);
			}
			else if ((winListAry[i].indexOf(forecast) > -1) && (winListAry[i].indexOf(extForecast)==-1))
			{
				//createEmptyWindow(winArray[i],'My Forecast - 20876','250','200');
				createWindow(winListAry[i],'My Forecast - 20876','270','200');
				getStartWindowPosition(winListAry[i]);
			}
			else if (winListAry[i].indexOf(radar)>-1)
			{
				//createEmptyWindow(winArray[i],'My Radar - 20876','270','200');
				createWindow(winListAry[i],'My Radar - 20876','270','200');
				getStartWindowPosition(winListAry[i]);
			}
			else if (winListAry[i].indexOf(camera)>-1)
			{
			    //createEmptyWindow(winArray[i],'My Camera - 20876','270','200');
		        createWindow(winListAry[i],'My Camera - 20876','270','200');
				getStartWindowPosition(winListAry[i]);
			}
			else if (winListAry[i].indexOf(extForecast)>-1)
			{
				//createEmptyWindow(winArray[i],'My Extended Forecast - 20876','400','200');
				createWindow(winListAry[i],'My Extended Forecast - 20876','400','200');
				getStartWindowPosition(winListAry[i]);
			}
		}
	}
	
	var defaultZip = GetCookie ("defaultZip");
	if ((defaultZip == "") || (defaultZip == "null") || (defaultZip == null))
	{
	    AwsSendSyncGetReq(defaultZip, "alerts", "");
	}
	buildLauncherHtml()
	isLoading = false;
}

function removeWindow(id)
{
    var tmpArray = new Array (maxWins);
    var j=0 ;
    var childNode = document.getElementById(id);
    var topNode = document.getElementById("launcher");
    var garbage = topNode.removeChild(childNode);
    numWins--;
    for (var i=0; i < winArray.Length ; i++)
	{
	    /*if ((winArray[i] != id) && (winArray[i] != ""))
	    {
	        tmpArray[j] = winArray[i];
	        j++;
	    }*/
	    if (winArray[i] == id)
	    {
	        winArray.pop();
	    }
	}
	
	//winArray = tmpArray;
	var windowList = GetCookie("WinList") + "";
	var cookieAry = windowList.split("|");
	windowList="";
	for (var j=0;j<cookieAry.length; j++)
	{
	    if ((cookieAry[j] != id) && (cookieAry[j] != "null"))
	    {
	        windowList += cookieAry[j] + "|";
	    }
	}
	
	DeleteCookie ("WinList");
	SetCookie ("WinList", windowList, new Date(2020,1,1));
	
}