// Use this include file with cookieBasicFunctions include file...

function delWeatherCookies()
{
    delCookie('userstate', "/");   // "/dij/", document.domain )
    delCookie('usercity', "/");

    window.location.reload();
}

function fixCity(CityName)
{

    var i;
    var oldCity = new String(CityName);
    var fixCity = new String();

    for(i = 0; i < oldCity.length; i++)
    {
        if(oldCity.charAt(i) != ' ')
        {
            fixCity += oldCity.charAt(i);
        }
        else
        {
            fixCity += "_";
        }
    }

    return fixCity;
}

function setWeatherCookies()
{

    //set to expire 5 years from today
    var expiration = new Date();
    expiration.setTime(expiration.getTime() + (157680000000));

    var fixedCity;

  // New York should be New_York, etc.
    fixedCity = fixCity(document.WeatherInfo.city.value);

    setCookie('userstate', document.WeatherInfo.State.options[document.WeatherInfo.State.selectedIndex].value, expiration, "/");
    setCookie('usercity', fixedCity, expiration, "/");
    window.location.reload();
}

function writeWeatherLink()
{
    var i;
    var stateName = getCookie('userstate');
    var cityName = getCookie('usercity');

  // If user has Weather cookie...
    if(stateName != null && cityName != null)
    {

        var gifURL = "<img src=\"http://banners.wunderground.com/banner/smalltemp/US/" + stateName + "/" + cityName + ".html\"" + "Align=\"top\"" + ">";

        document.write(gifURL);
        document.write("&nbsp;<A href=\"javascript:delWeatherCookies();\"><FONT SIZE=-2>SET</FONT></A><BR />");
     //document.write("&nbsp;&nbsp;<INPUT TYPE='button' VALUE='Set' onClick='delWeatherCookies();'><BR />");
        document.write("<a href=javascript:showDoc(\"http://www.wunderground.com/US/" + stateName + "/" + cityName + ".html\")>" + cityName + ", " + stateName + "</A>");

    }
    else
    {

        document.write("<FORM name=\"WeatherInfo\">");
        document.write("Set City/State for local weather...<BR />");

     // City text box
        document.write("<INPUT TYPE='text' size='16' name='city' value='Enter your city'>");

        var aStates = new Array("AK", "AL", "AR", "AZ", "CA", "CO", "CT", "DC", "DE", "FL", "GA", "HA", "IA", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "MA", "MD", "ME", "MI", "MN", "MS", "MO", "MT", "NB", "NC", "ND", "NH", "NJ", "NM", "NV", "NY", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VA", "VT", "WA", "WI", "WV", "WY");

     // State list box
        document.write("<SELECT NAME='State' SIZE=1>");
        for(i = 0; i < aStates.length; i++) document.write("<option value=" + aStates[i] + ">" + aStates[i] + "</option>");
        document.write("</SELECT>");

        document.write("<INPUT TYPE='button' VALUE='Set' onClick='setWeatherCookies();'>");
        document.write("</FORM>");
    }
}


