<?xml version="1.0" encoding="UTF-8" ?>
<Module>

	<!-- 
	Weather Gadget
	Design & Code: LabPixies
	All subsequent code and resources used are proprietary of LabPixies unless directly stated otherwise.
	Copyright (C) 2006 LabPixies.    
	www.labpixies.com

	This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 2.5 License.
	To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/2.5/ or
	send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
	-->
	
	<ModulePrefs 
		height="230"
		author="LabPixies"
		author_email="info@labpixies.com"
		description="__MSG_description__" 
		thumbnail="http://www.labpixies.com/campaigns/weather/images/thumbnail.jpg"
		screenshot="http://www.labpixies.com/campaigns/weather/images/screenshot.png"
		title="__MSG_gTitle__"
		title_url="http://www.labpixies.com" >
		
    <Locale messages="http://www.labpixies.com/campaigns/weather/i20/all_all.xml" />
    
		<Locale lang="de" messages="http://www.labpixies.com/campaigns/weather/i20/de_all.xml" />
		<Locale lang="it" messages="http://www.labpixies.com/campaigns/weather/i20/it_all.xml" />
		<Locale lang="fr" messages="http://www.labpixies.com/campaigns/weather/i20/fr_all.xml" />
		<Locale lang="es" messages="http://www.labpixies.com/campaigns/weather/i20/es_all.xml" />
		<Locale lang="pl" messages="http://www.labpixies.com/campaigns/weather/i20/pl_all.xml" />
		<Locale lang="pt-PT" messages="http://www.labpixies.com/campaigns/weather/i20/pt_pt_all.xml" />
		<Locale lang="pt-BR" messages="http://www.labpixies.com/campaigns/weather/i20/pt_br_all.xml" />
		<Locale lang="nl" messages="http://www.labpixies.com/campaigns/weather/i20/nl_all.xml" />
		<Locale lang="ja" messages="http://www.labpixies.com/campaigns/weather/i20/ja_all.xml" />
		<Locale lang="zh-CN" messages="http://www.labpixies.com/campaigns/weather/i20/zh_cn_all.xml" />
    <Locale lang="ru" messages="http://www.labpixies.com/campaigns/weather/i20/ru_all.xml" />
    
    <Locale lang="bg" messages="http://www.labpixies.com/campaigns/weather/i20/bg_all.xml" />
    <Locale lang="ca" messages="http://www.labpixies.com/campaigns/weather/i20/ca_all.xml" />
    <Locale lang="zh-TW" messages="http://www.labpixies.com/campaigns/weather/i20/zh_tw_all.xml" />
    <Locale lang="hr" messages="http://www.labpixies.com/campaigns/weather/i20/hr_all.xml" />
    <Locale lang="cs" messages="http://www.labpixies.com/campaigns/weather/i20/cs_all.xml" />
    <Locale lang="da" messages="http://www.labpixies.com/campaigns/weather/i20/da_all.xml" />
    <Locale lang="fi" messages="http://www.labpixies.com/campaigns/weather/i20/fi_all.xml" />
    <Locale lang="el" messages="http://www.labpixies.com/campaigns/weather/i20/el_all.xml" />
    <Locale lang="iw" messages="http://www.labpixies.com/campaigns/weather/i20/iw_all.xml" />
    <Locale lang="hi" messages="http://www.labpixies.com/campaigns/weather/i20/hi_all.xml" />
    <Locale lang="hu" messages="http://www.labpixies.com/campaigns/weather/i20/hu_all.xml" />
    <Locale lang="ko" messages="http://www.labpixies.com/campaigns/weather/i20/ko_all.xml" />
    <Locale lang="lv" messages="http://www.labpixies.com/campaigns/weather/i20/lv_all.xml" />
    <Locale lang="lt" messages="http://www.labpixies.com/campaigns/weather/i20/lt_all.xml" />
    <Locale lang="ms" messages="http://www.labpixies.com/campaigns/weather/i20/ms_all.xml" />
    <Locale lang="no" messages="http://www.labpixies.com/campaigns/weather/i20/no_all.xml" />
    <Locale lang="ro" messages="http://www.labpixies.com/campaigns/weather/i20/ro_all.xml" />
    <Locale lang="sr" messages="http://www.labpixies.com/campaigns/weather/i20/sr_all.xml" />
    <Locale lang="sk" messages="http://www.labpixies.com/campaigns/weather/i20/sk_all.xml" />
    <Locale lang="sl" messages="http://www.labpixies.com/campaigns/weather/i20/sl_all.xml" />
    <Locale lang="sv" messages="http://www.labpixies.com/campaigns/weather/i20/sv_all.xml" />
    <Locale lang="tl" messages="http://www.labpixies.com/campaigns/weather/i20/tl_all.xml" />
    <Locale lang="th" messages="http://www.labpixies.com/campaigns/weather/i20/th_all.xml" />
    <Locale lang="tr" messages="http://www.labpixies.com/campaigns/weather/i20/tr_all.xml" />
    <Locale lang="uk" messages="http://www.labpixies.com/campaigns/weather/i20/uk_all.xml" />
    <Locale lang="vi" messages="http://www.labpixies.com/campaigns/weather/i20/vi_all.xml" />
    
    <Locale lang="en" country="US" messages="http://www.labpixies.com/campaigns/weather/i20/en_us.xml"/>
            
    <Require feature="setprefs" />
		<Require feature="analytics" /> 
		<Require feature="dynamic-height" />
		<Require feature="views" />
	</ModulePrefs>
	
	<UserPref name="degree_unit_type"		datatype="hidden"			default_value="0" /> 
	<UserPref name="first_load"  datatype="hidden" default_value="1" />
	<UserPref name="locations"  datatype="hidden" default_value="0" />
	<UserPref name="zip_code" datatype="hidden" default_value="0" />
	<UserPref name="city_code"  datatype="hidden" default_value="0" />
	<UserPref name="disable_os" datatype="hidden" default_value="0" />
	<UserPref name="ver" datatype="hidden" default_value="none" />
<Content type="html" view="home,profile"> <![CDATA[
<title>Weather</title>
<!-- PUT THIS TAG IN THE head SECTION -->
<script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js">
</script>
<script type="text/javascript">
  GS_googleAddAdSenseService("ca-pub-8123415297019784");
  GS_googleEnableAllServices();
</script>
<script type="text/javascript">
  GA_googleAddSlot("ca-pub-8123415297019784", "live_weather_txt");
</script>
<script type="text/javascript">
  GA_googleFetchAds();
</script>
<!-- END OF TAG FOR head SECTION -->
<style type="text/css">
body {
    margin:0;
    padding:0;
}

#loading_block {
    width:100%;
    height:100%;
    position:absolute;
    left:0px;
    top:0px;
    z-index:500;
    background:white;
}

#menu {

}

#container {
    width:240px;
    text-align:left;
    margin-top:6px;
}

#main {
    width:240px;
}

#main_sliding {
    padding-left:18px;
}

#whitearea {
    margin-top:3px;
    padding-bottom:5px;
}

#title,.title_max {
    font-family:arial;
    font-size:14px;
    color:#ffe600;
    padding-top:10px;
    font-weight:bold;
    float:left;
    cursor:default;
}

#weatherbug_link {
    width:90px;
    height:34px;
    cursor:pointer;
    float:right;
}

#left_col, #right_col {
    width:105px;
    float:left;
}

#today_img, #tomorrow_img {
    display:none;
}

#today_img_box, #tomorrow_img_box {
    padding-left:2px;
    padding-top:2px;
    width:54px;
    height:46px;
    float:left;
    cursor:pointer;
}

.day_title {
    font-family:arial;
    font-size:11px;
    font-weight:bold;
    color:#113571;
}

.forecast {
    font-family:arial;
    font-size:11px;
    font-weight:bold;
    color:#889ab8;
}

.forecast img {
    margin-right:3px;
}

.textual {
    clear:left;
    font-family:arial;
    font-size:10px;
    color:#595959;
    width:100px;
    cursor:pointer;
    height:28px;
    line-height:14px;
    overflow:hidden;
    
}

.more_div {
    padding-bottom:5px;
}

a.more {
    display:none;
}

a.more, a.more:visited {
    font-family:arial;
    font-size:10px;
    color:#fe9111;
    text-decoration:none;

}

a.more:hover {
    text-decoration:underline;
}

#weather_alert {
    height:23px;
    display:none;
    cursor:pointer;
    background-position:0px -208px;
}

#footer {
    height:33px;
    padding-left:8px;
    text-align:center;
}

#footer a, #footer a:visited {
    font-family:arial;
    font-size:__MSG_profile_links_size__;
    color:#ffe600;
    font-weight:bold;
    margin-left:3px;
    margin-right:3px;
}

.forecast .hi, .forecast .lo {
    font-family:arial;
    font-size:10px;
    font-weight:bold;
    color:#889ab8;
}

.forecast .large {
    font-family:arial;
    font-size:18px;
    font-weight:bold;
    color:#113571;
    line-height:0.95;
}

#edit_location {
    margin-top:12px;
    margin-left:4px;
    float:left;
    display:none;
}

#edit_location a, #edit_location a:visited{
    color:#113571;
    font-family:arial;
    font-size:10px;
    font-weight:bold;
    text-decoration:none;
}

td.error {
    height:90px;
    vertical-align:center;
    width:194px;
    font-size:12px;
    text-align:center;
}

</style>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
var _gadgetID = 49;
var $lp = jQuery.noConflict();
var ver;
var VER_A = "A";
var VER_B = "B";

  /* page tracker for regular reporting*/
  var lp_pageTracker = _gat._getTracker("UA-345375-1");
  lp_pageTracker._initData();
  
  /* page tracker for A/B testing reports*/
  var lp_pageTrackerTest = _gat._getTracker("UA-345375-3");
  lp_pageTrackerTest._initData();

function lp_trackEvent(eventName,eventLable,eventVar) {
    try {
	   lp_pageTracker._trackEvent('Weather - Home',eventName,eventLable,eventVar);
	   lp_pageTrackerTest._trackEvent('Weather - Home_'+ver,eventName,eventLable,eventVar);
    }
    catch(ee) {

    }
}

//var mSIDEBAR = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_sidebar.js");
//document.write('<scr'+'ipt type="text/javascript" src="'+mSIDEBAR+'"></scr'+'ipt>');
</script>
<script type="text/javascript">

	var is_gadget_ready = false;
	var images_url = "http://cdn.labpixies.com/campaigns/weather/images/";

	//current loaction
	var city_name			= "";
	var state_name			= "";
	var country_name		= "";
	var zip_code			= "";
	var city_code			= "";
	var cur_url				= "none";
	
	//actions
	var cur_action			= "FORECAST"; //FORECAST , SEARCH_CITY 
	
	//loading cities message
	var stop_loading		=	0;
	var is_loading			=	0;
	var h_timeout;
	var cur_loading_str		=	"";
	var live_stop_loading	=	0;
	var live_is_loading		=	0;
	
	//degree values
	var degree 		= 0;
	
	//forecast array
	var forecastText = new Array();
	var arrDate		 = new Array();
	arrDate[0]		 = "Today";
	
	//timeout handle
	var hTime = 0;
	
	//globals
	var g_partner_id = "BFB7BE81-EF74-4b7b-A9EF-A82D059992EF";
	var g_zcode		 = "z6070";
	var g_link_str = "http://www.weatherbug.com/?zcode="+g_zcode;
	
	var g_is_os;
	var g_prefs = new _IG_Prefs();

	_IG_RegisterOnloadHandler(init_module);
	
	function setVersion(){
    ver = g_prefs.getString("ver");
    //if the user isnt from US he wont be part of the experiment
    if (!(__MSG_in_ab__)){
      ver = VER_A;
      g_prefs.set("ver",ver);
    }
    else{
	    if ((ver!=VER_A) && (ver!=VER_B)){
	      ver = VER_A;
	      var rand = Math.ceil(Math.random()*100);
	      //for 1% we are giving the tested version
	      if (rand==1){
	        ver = VER_B;
	      }
	      g_prefs.set("ver",ver);
	    }
    }
    

    if (ver==VER_B){
    	//full report button
    	var out = [];
    	var background = "background: url"+"("+_IG_GetImageUrl(images_url+"weather_ab_sprite.png") +");";
    	out.push('<table height="17" cellpadding="0" cellspacing="0" border="0" valign="middle" style="margin-right:8px;">');
      out.push('<tr onclick="lp_trackEvent(\'Open Canvas\',\'Full Report button\'); switchToCanvas();" onmouseover="changeButtonBackground(\'full\',\'-17px\',\'#FFFFFF\');" onmouseout="changeButtonBackground(\'full\',\'0px\',\'#FFFFFF\');" style="cursor:pointer;">');
      out.push('<td id="full_left" style="height:17px; font-size:10px; font-weight:bold; color:#FFFFFF; padding-left:7px; cursor:pointer; padding-top:2px; '+background+' background-position:0px 0px;" valign="top">__MSG_full_report__ &gt;</td>');
      out.push('<td id="full_right" style="height:17px; width:7px; cursor:pointer; '+background+' background-position:right 0px;"></td>');
      out.push('</tr>');
      out.push('</table>');
    	document.getElementById("full_report_button").innerHTML = out.join('');
    	document.getElementById("full_report_button").style.height = "17px"; 
    	
    	//bottom buttons
    	out = [];
    	out.push('<div style="float:left;"><table height="16" cellpadding="0" cellspacing="0" border="0" valign="middle" style="margin-top:3px; margin-left:5px;">');
      out.push('<tr onclick="switchToCanvas(); lp_trackEvent(\'Open Canvas\',\'7 Day Forecast button\');" onmouseover="changeButtonBackground(\'aws\',\'-50px\',\'#002E7F\');" onmouseout="changeButtonBackground(\'aws\',\'-34px\',\'#FFE600\');" style="cursor:pointer;">');
      out.push('<td id="aws_left" style="height:16px; font-size:10px; font-weight:bold; color:#FFE600; padding-left:7px; cursor:pointer; padding-top:2px; '+background+' background-position:0px -34px;" valign="top">__MSG_7dayforecast__</td>');
      out.push('<td id="aws_right" style="height:16px; width:7px; cursor:pointer; '+background+' background-position:right -34px;"></td>');
      out.push('</tr>');
      out.push('</table></div>');
      
     	out.push('<div style="float:right;"><table height="16" cellpadding="0" cellspacing="0" border="0" valign="middle" style="margin-top:3px; margin-right:15px;">');
      out.push('<tr onclick="switchToCanvas(\'add\'); lp_trackEvent(\'Open Canvas\',\'Add Location button\');" onmouseover="changeButtonBackground(\'add_location\',\'-50px\', \'#002E7F\');" onmouseout="changeButtonBackground(\'add_location\',\'-34px\',\'#FFE600\');" style="cursor:pointer;">');
      out.push('<td id="add_location_left" style="height:16px; font-size:10px; font-weight:bold; color:#FFE600; padding-left:7px; cursor:pointer; padding-top:2px; '+background+' background-position:0px -34px;" valign="top">+__MSG_add_location__</td>');
      out.push('<td id="add_location_right" style="height:16px; width:7px; cursor:pointer; '+background+' background-position:right -34px;"></td>');
      out.push('</tr>');
      out.push('</table></div>');
    	document.getElementById("footer").innerHTML = out.join('');
    }
    
		lp_pageTrackerTest._trackPageview("/weather_v2_home_"+ver);
    //_IG_Analytics("UA-345375-3", "/weather_v2_home_"+ver);
  }
  
  function changeButtonBackground(name, yPos, color){
  	document.getElementById(name+"_left").style.backgroundPosition = "0px "+yPos;
  	document.getElementById(name+"_left").style.color = color;
  	document.getElementById(name+"_right").style.backgroundPosition = "right "+yPos;
  }
  
  
    function reportFirstInteraction(){
      lp_trackEvent("User Interaction","Roll Over gadget");
      document.getElementById("container").onmouseover=function(){};
    }
	
	
	
	function gadget_ready() {
	    if(is_gadget_ready) {
		return;
	    }
	    is_gadget_ready = true;
	    $lp('#loading_block').remove();
	}

	function setErrorMsg() {
	    document.getElementById('whitearea').innerHTML = '<table><tr><td class="error">__MSG_unavailable__</td></tr></table>';
	    document.getElementById('title').style.display = 'none';
	    document.getElementById('edit_location').style.display = 'none';
	    document.getElementById('footer').innerHTML = '';
	    _IG_AdjustIFrameHeight();
	}

	function init_module(){
			setVersion();
			document.getElementById("container").onmouseover = reportFirstInteraction;
	    if( g_prefs.getString('zip_code') == 'none' ) {g_prefs.set('zip_code','0');}
	    if( g_prefs.getString('city_code') == 'none' ) {g_prefs.set('city_code','0');}

	    g_is_os = !g_prefs.getInt('disable_os') && lpgadgets.lp.utils.isOpenSocialSupported();

	    loadImages();
		
	    if(g_is_os) loadLocationsFromOS();
	    else loadLocationsFromPref();
	}

	function loadLocationsFromPref() {
	    document.getElementById('edit_location').style.display = 'block';

	    var json = g_prefs.getString('locations');
	    json = lpgadgets.lp.utils.unescapeString(json);

	    if(json && json != '0') {
		var obj = lpgadgets.lp.utils.jsonParse(json);

		
		zip_code = obj.zip_code[ obj['default'] ] || 0;
		city_code = obj.city_code[ obj['default'] ] || 0;
	    }
	    else {
		var zip_pref = g_prefs.getString('zip_code');
		var city_pref = g_prefs.getString('city_code');

		if( (zip_pref&&zip_pref!='0') || (city_pref&&city_pref!='0') ) { // "import" locations from old gadget
		    obj = {};

		    locations_zip = [];
		    locations_city = [];
		    locations_name = [];
		    locations_country = [];
		    
		    var location_callback = function (response) {
		    
			if( response == null || typeof(response) != 'object' ) {
			    setErrorMsg();
			    return;
			}
			
			locationTags = response.getElementsByTagName('location');

			locations_name.push( locationTags[0].getAttribute('city') );
			var country = locationTags[0].getAttribute('country');
			if( locationTags[0].getAttribute('state') ) country = locationTags[0].getAttribute('state') + ', ' + country;

			locations_country.push( country );

			obj.name = locations_name;
			obj.zip_code = locations_zip;
			obj.city_code = locations_city;
			obj.country = locations_country;
			obj['default'] = 0;

			json = lpgadgets.lp.utils.jsonStringify(obj);
			g_prefs.set('locations', json);
			
			g_prefs.set('zip_code','0');
			g_prefs.set('city_code','0');
		    };

		    if( zip_pref&&zip_pref!='0' ) {
			locations_zip.push( zip_pref );
			_IG_FetchXmlContent( 'http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId='+g_partner_id+'&zipcode='+zip_pref, 
					     location_callback );

			zip_code = zip_pref;
		    }
		    else {
			locations_city.push( city_pref );
			_IG_FetchXmlContent( 'http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId='+g_partner_id+'&citycode='+city_pref, 
					     location_callback );
			
			city_code = city_pref;
		    }
		}
		else {
		    zip_code = '10001';
		}
	    }

	    degree = g_prefs.getString("degree_unit_type");
	    show_forecast(zip_code,city_code,1);
	}
	
	function loadLocationsFromOS() {
	    var json;

	    var zip_pref = g_prefs.getString('zip_code');
	    var city_pref = g_prefs.getString('city_code');

	    if( (zip_pref&&zip_pref!='0') || (city_pref&&city_pref!='0') ) { // "import" locations from old gadget
		obj = {};

		locations_zip = [];
		locations_city = [];
		locations_name = [];
		locations_country = [];
		
		var location_callback = function (response) {
		    if( response == null || typeof(response) != 'object' ) {
			setErrorMsg();
			return;
		    }
		    
		    locationTags = response.getElementsByTagName('location');

		    locations_name.push( locationTags[0].getAttribute('city') );
		    var country = locationTags[0].getAttribute('country');
		    if( locationTags[0].getAttribute('state') ) country = locationTags[0].getAttribute('state') + ', ' + country;

		    locations_country.push( country );

		    obj.name = locations_name;
		    obj.zip_code = locations_zip;
		    obj.city_code = locations_city;
		    obj.country = locations_country;
		    obj['default'] = 0;

		    json = lpgadgets.lp.utils.jsonStringify(obj);

		    var req = opensocial.newDataRequest();
		    req.add( req.newUpdatePersonAppDataRequest("VIEWER", "locations", json));
		    req.send( function(response) {
			if( !response.hadError() ) {
			    g_prefs.set('first_load','0');
			}
			else {
			    showErrorDialog('__MSG_data_error__');
			}
		    } );					    

		    g_prefs.set('zip_code','0');
		    g_prefs.set('city_code','0');

		    degree = g_prefs.getString("degree_unit_type");
		    
		    show_forecast(obj.zip_code[0] || '0' ,obj.city_code[0] || '0' ,1);
		};

		if( zip_pref&&zip_pref!='0' ) {
		    locations_zip.push( zip_pref );
		    _IG_FetchXmlContent( 'http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId='+g_partner_id+'&zipcode='+zip_pref, 
					 location_callback );

		    zip_code = zip_pref;
		}
		else {
		    locations_city.push( city_pref );
		    _IG_FetchXmlContent( 'http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId='+g_partner_id+'&citycode='+city_pref, 
					 location_callback );
		    
		    city_code = city_pref;
		}
		return;
	    }

	    var req = opensocial.newDataRequest();
	    req.add( req.newFetchPersonRequest( opensocial.DataRequest.PersonId.VIEWER ), "viewer");
	    req.add( req.newFetchPersonRequest( opensocial.DataRequest.PersonId.OWNER), "owner");
	    req.add( req.newFetchPersonAppDataRequest(opensocial.DataRequest.PersonId.OWNER, "locations"), "locations" );
	    req.send( 
		function(data) {
		    try {
			var viewer = data.get("viewer").getData();
			var me = data.get("owner").getData();

			if( typeof(viewer) == 'object' && me.getId() == viewer.getId() ) { //display edit location links
			    document.getElementById('edit_location').style.display = 'block';
			}

			var mydata = data.get("locations").getData()[me.getId()];
			if( typeof(mydata) == 'object' ) {

			    json = mydata['locations'];

			    json = gadgets.util.unescapeString(json);

			    if(json) {
				obj = gadgets.json.parse(json);

				zip_code = obj.zip_code[ obj['default'] ] ;
				city_code = obj.city_code[ obj['default'] ];
			    }
			}
			else {
			    zip_code = '10001';
			}
			
			degree = g_prefs.getString("degree_unit_type");

			show_forecast(zip_code || '0',city_code || '0',1);
		    }
		    catch(ee) {
			setErrorMsg();
		    }
		});

	}

	var IMAGES_BASE = 'http://cdn.labpixies.com/campaigns/weather/images/';

	function loadImages() {

	    document.getElementById('main').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'gadget_images_sprites_new.png')+') no-repeat';
	    document.getElementById('main_sliding').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'background_middle.png')+') bottom no-repeat';
	    document.getElementById('weather_alert').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'gadget_images_sprites_new.png')+') 0px -208px no-repeat';
	    document.getElementById('footer').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'gadget_images_sprites_new.png')+') 0px -231px no-repeat';

	    document.getElementById('today_img_box').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'gadget_images_sprites_new.png')+') 0px -264px no-repeat';
	    document.getElementById('tomorrow_img_box').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'gadget_images_sprites_new.png')+') 0px -264px no-repeat';

	}

	//---------------------------------------------
	// Live weather - get current temperature
	//---------------------------------------------

	function getLiveWeather(){

	    var cur_live_url = "";
	    
	    //set url with the correct city code or zip code
	    if (zip_code!=0){
		cur_live_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId="+g_partner_id+"&zipcode=" + zip_code + "&unittype=" + degree;
	    }
	    else if(city_code!=0){
		cur_live_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId="+g_partner_id+"&citycode=" + city_code + "&unittype=" + degree;
	    }

	    
	    //fetch data
	    _IG_FetchXmlContent(cur_live_url,parseRSS_LiveWeather);
	}

	function parseRSS_LiveWeather(response) {
	    
	    try{
		if (response == null || typeof(response) != "object") {return;}
		if(response.firstChild == null){return;}
		
		var itemList = response.getElementsByTagName("condition");

		if(itemList.item(0)){
		    document.getElementById("today_temp_live").innerHTML = itemList.item(0).getAttribute("temp") + "&deg;";
		}
	    }
	    catch(e){}
	}	

	//---------------------------------------------
	//show forecast
	//---------------------------------------------
	
	var forecast_timeout;
	function show_forecast(zip_code_arg,city_code_arg){
    	    gadget_ready();
	    //prepare the url 					
	    var url ="";
	    if(zip_code_arg != 0){
		
		url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode="+zip_code_arg+"&UnitType="+degree+"&ForecastType=1";
		
		//fix bug of 4 digits
		var temp_code = zip_code_arg.toString();
		if(temp_code.length==4){
		    url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode=0"+zip_code_arg+"&UnitType="+degree+"&ForecastType=1";
		}
	    }
	    else if(city_code_arg != 0){
		url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&CityCode="+city_code_arg+"&UnitType="+degree+"&ForecastType=1";
	    }
	    else{
		if(zip_code != 0){
		    url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&UnitType="+degree+"&ForecastType=1";
		    //fix bug of 4 digits
		    if(zip_code.length==4){
			url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode=0"+zip_code+"&UnitType="+degree+"&ForecastType=1";
		    }
		}
		else{
		    url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&CityCode="+city_code+"&UnitType="+degree+"&ForecastType=1";
		}
	    }
	    
	    //fetch forecast
	    cur_action 			= "FORECAST";
	    cur_url 			= url;
	    
	    //fix bug of 4 digits
	    if(zip_code_arg.length==4 || zip_code_arg.toString().length==4){
		zip_code = "0" + zip_code_arg;
	    }

	    //update gui with degree type
	    forecast_timeout = setTimeout("setErrorMsg()",10000);
	    _IG_FetchXmlContent(url,parseRSS_Forecast);

	}

	function switchToCanvas( param ) {
	    var params = {};

	    if( !param ) params.day="1";
	    else if( typeof(param) != 'string' ) params.day = param.toString();
	    else if( param == 'edit' ) params.edit = '1';
	    else if( param == 'add' ) params.add = '1';
	    
	    map = gadgets.views.getSupportedViews();
	    gadgets.views.requestNavigateTo( map['canvas'], params );
	}


	//---------------------------------------------
	// parse RSS Forecast
	//---------------------------------------------
	
	function parseRSS_Forecast(response) {
	    clearTimeout(forecast_timeout);
	    if (response == null || typeof(response) != "object") {
		setErrorMsg();
		return;
	    }
	    
	    if(response.firstChild == null){
		setErrorMsg();
		return;
	    }
	    
	    //--------------------------------------------
	    // Get Location name - city and state
	    //--------------------------------------------
	    
	    var itemList_2 = response.getElementsByTagName("aws:location");
	    if(itemList_2.length==0){itemList_2 = response.getElementsByTagName("location");}
	    
	    var state_name_str 	= "";
	    var city_name_str 	= "";
	    for (var k=0; k < itemList_2.length; k++) { 
		
		var nodeList_2 = itemList_2.item(k).childNodes;
		
		for (var l=0; l < nodeList_2.length; l++) {
		    
		    var node_2 = nodeList_2.item(l);
		    
		    var inner;
		    //city name
		    if(node_2.nodeName=="aws:city" || node_2.nodeName=="city"){
			/*if(node_2.firstChild.nodeValue.length>15){
			    document.getElementById('title').innerHTML = node_2.firstChild.nodeValue.substring(0,14)+'...';
			}
			else{
			    document.getElementById('title').innerHTML = node_2.firstChild.nodeValue;
			}*/
			inner = node_2.firstChild.nodeValue;

			city_name_str = node_2.firstChild.nodeValue + ", ";
			document.getElementById('title').title = city_name_str;
		    }
		    
		    //state name or country name
		    if(node_2.nodeName=="aws:state" || node_2.nodeName=="state" ||node_2.nodeName=="aws:country" ||node_2.nodeName=="country"){
			state_name_str = node_2.firstChild.nodeValue;
			document.getElementById('title').title += state_name_str;
		    }
		    
		    var text_max_width_div = document.getElementById('max_width');
		    function textMaxWidth(text,width,clss) {
			text_max_width_div.style.display="inline";
			text_max_width_div.className = clss;
			text_max_width_div.innerHTML = _hesc(text);
			var len = text.length;
			try {
			    while (text_max_width_div.offsetWidth>width && len>0) {
				len--;
				text_max_width_div.innerHTML = _hesc(text.slice(0,len))+'…';
			    }
			} catch (e) {}
			var ret = text_max_width_div.innerHTML;
			text_max_width_div.style.display="none";
			return ret;
		    }
		    document.getElementById('title').innerHTML = textMaxWidth(inner,120-document.getElementById('edit_location').offsetWidth,"title_max");
		}
	    }
	    
	    //update city title
	    //_gel("city_name_text").title = city_name_str + state_name_str;
	    
	    //--------------------------------------------		
	    // Get Forecast
	    //--------------------------------------------
	    
	    //temp values
	    var tmp_name  	=	"";
	    var tmp_image 	=	"";
	    var tmp_hi 		=	"";
	    var tmp_low 	=	"";
	    var tmp_desc	= 	"";
	    var cursor 		= 0;
	    
	    var extractNodeData = function(node) {
			var nodeList = node.childNodes;
			for (var j=0; j < nodeList.length; j++) {
			    
			    var node = nodeList.item(j);
			    
			    if (node.firstChild) {
    			    //day image
    			    if(node.nodeName=="aws:image" || node.nodeName=="image"){tmp_image = node.firstChild.nodeValue;}

    			    //day hi temp
    			    if(node.nodeName=="aws:high" || node.nodeName=="high")	{tmp_hi = node.firstChild.nodeValue;}

    			    //day low temp
    			    if(node.nodeName=="aws:low" || node.nodeName=="low")	{tmp_low = node.firstChild.nodeValue;}

    			    //day forecast text
    			    if(node.nodeName=="aws:prediction" || node.nodeName=="prediction"){
    				tmp_desc = node.firstChild.nodeValue;
    				if(tmp_desc.length>56)
    				    tmp_desc = tmp_desc.substring(0,56) + "... ";
    			    }
    			 }
			    
			}

			return { hi:tmp_hi, lo:tmp_low, img:tmp_image, desc:tmp_desc };
	    }

	    var itemList = response.getElementsByTagName("aws:forecast");
	    if(itemList.length == 0){itemList = response.getElementsByTagName("forecast");}		

	    var tomorrow_node = 1;

	    var today = extractNodeData( itemList.item(0) );
	    
	    if( today.lo == '--' ) {
			tomorrow_node ++;
			
			var tonight = extractNodeData( itemList.item(1) );
			
			document.getElementById('today_img').src = today.img;
			document.getElementById('today_img').style.display = 'block';
			document.getElementById('today_hi').innerHTML = '__MSG_hi__:'+today.hi+'&deg;';
			document.getElementById('today_lo').innerHTML = '__MSG_lo__:'+tonight.lo+'&deg;';
			document.getElementById('today_textual').innerHTML = today.desc;

	    }
	    else {
			document.getElementById('today_img').src = today.img;
			document.getElementById('today_img').style.display = 'block';
			document.getElementById('today_hi').innerHTML = '__MSG_hi__:'+today.hi+'&deg;';
			document.getElementById('today_lo').innerHTML = '__MSG_lo__:'+today.lo+'&deg;';
			document.getElementById('today_textual').innerHTML = today.desc;
	    }

	    var tomorrow = extractNodeData( itemList.item(tomorrow_node) );
	    
	    if( tomorrow.lo == '--' ) {
		
			var tomorrow_night = extractNodeData( itemList.item(tomorrow_node+1) );
			
			document.getElementById('tomorrow_img').src = tomorrow.img;
			document.getElementById('tomorrow_img').style.display = 'block';
			document.getElementById('tomorrow_hi').innerHTML = '__MSG_hi__:'+tomorrow.hi+'&deg;';
			document.getElementById('tomorrow_lo').innerHTML = '__MSG_lo__:'+tomorrow_night.lo+'&deg;';
			document.getElementById('tomorrow_textual').innerHTML = tomorrow.desc;

	    }
	    else {
		document.getElementById('tomorrow_img').src = tomorrow.img;
		document.getElementById('tomorrow_img').style.display = 'block';
		document.getElementById('tomorrow_hi').innerHTML = '__MSG_hi__:'+tomorrow.hi+'&deg;';
		document.getElementById('tomorrow_lo').innerHTML = '__MSG_lo__:'+tomorrow.lo+'&deg;';
		document.getElementById('tomorrow_textual').innerHTML = tomorrow.desc;
	    }
	    
	    $lp('.more').css('display','inline');
	    
	    //call live weather - > try catch 
	    try{getLiveWeather();}
	    catch(e){}
	    
	    //get links
	    //getAwsLinks();
	    getAwsWeatherAlerts();

	    _IG_AdjustIFrameHeight();
	}

	function getAwsLinks() {
	    //getAwsLinks_News();
	    //getAwsLinks_Cameras();
	    //getAwsLinks_Radar();
	    //getAwsLinks_Video();
	    var cur_url = "";
	    
	    //set url with the correct city code or zip code

	    if (zip_code!=0){
		cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&LinkName=news_topstories,cameras_local,maps_doppler,video_local&Zcode="+g_zcode;
	    }
	    else if(city_code!=0){
		cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&CityCode="+city_code+"&LinkName=news_topstories,cameras_local,maps_doppler,video_local&Zcode="+g_zcode;
	    }

	    //fetch data
	    _IG_FetchXmlContent(cur_url,parseRSS_AWS_LINKS);
	}

	function parseRSS_AWS_LINKS(response) {
	    
	    try{
		if (response == null || typeof(response) != "object") {return;}
		if(response.firstChild == null){return;}
		
		var itemList = response.getElementsByTagName("aws:Link");
		if(itemList.length==0){itemList = response.getElementsByTagName("Link");}
		
		document.getElementById('aws_video').href = "http://www.weatherbug.com/?zcode="+g_zcode;
		document.getElementById('aws_cameras').href = "http://www.weatherbug.com/?zcode="+g_zcode;
		document.getElementById('aws_radar').href = "http://www.weatherbug.com/?zcode="+g_zcode;
		document.getElementById('aws_news').href = "http://www.weatherbug.com/?zcode="+g_zcode;

		//check if we have any items
		for( i=0;i<itemList.length;i++ ) {
		    if(itemList[i].getAttribute("linkname")=="news_topstories"){
			document.getElementById('aws_news').href = itemList[i].getAttribute("url");
		    }
		    else if(itemList[i].getAttribute('linkname')=='cameras_local') {
			document.getElementById('aws_cameras').href = itemList[i].getAttribute('url');
		    }
		    else if(itemList[i].getAttribute('linkname')=='maps_doppler') {
			document.getElementById('aws_radar').href = itemList[i].getAttribute('url');
		    }
		    else if(itemList[i].getAttribute('linkname')=='video_local') {
			document.getElementById('aws_video').href = itemList[i].getAttribute('url');
		    }
		    
		}
				
	    }
	    catch(e){}
	}

	function getAwsWeatherAlerts(){
		
		var cur_url = "";
		
		//set url with the correct  zip code - US ONLY
		if (zip_code!=0){
			cur_url = "http://datafeed.weatherbug.com/getxml.aspx?RequestType=6&PartnerId="+g_partner_id+"&ZipCode="+ zip_code;
			_IG_FetchXmlContent(cur_url,parseRSS_AWS_ALERTS);
		}
	}
	
	function parseRSS_AWS_ALERTS(response) {
		
		if (response == null || typeof(response) != "object") {return;}
		if(response.firstChild == null){return;}
		
		var itemList = response.getElementsByTagName("aws:alert");
		if(itemList.length==0){itemList = response.getElementsByTagName("alert");}
		
		//check if we have any items
		if(itemList.length!=0){
			//we have alerts for this place - fetch link
			var cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&LinkName=severeweather_localalerts&Zcode="+g_zcode;
			//fetch data
			_IG_FetchXmlContent(cur_url,parseRSS_AWS_ALERTS_LINK);
		}
	}

	function parseRSS_AWS_ALERTS_LINK(response) {
		
		if (response == null || typeof(response) != "object") {return;}
		if(response.firstChild == null){return;}
		
		var itemList = response.getElementsByTagName("aws:Link");
		if(itemList.length==0){itemList = response.getElementsByTagName("Link");}
		
		//check if we have any items
		if(itemList.length!=0){
			if(itemList[0].getAttribute("linkname")=="severeweather_localalerts"){
			    document.getElementById('weather_alert').href = itemList[0].getAttribute("url");
			    document.getElementById('weather_alert').style.display = 'block';
			    _IG_AdjustIFrameHeight();
			}
		}
	}
	lp_pageTracker._trackPageview("/Weather_" + gadgets.views.getCurrentView().getName());
	//_IG_Analytics("UA-345375-1", "/Weather_" + gadgets.views.getCurrentView().getName());
	_IG_Analytics("UA-335767-2", "/WeatherBug");
</script>
<div id="realcontainer">
<center>
<div id="container">
	<div id="full_report_button" align="right"></div>
	<div id="loading_block">&nbsp;</div>
	<div id="main">
	<div id="main_sliding">
		<div id="weatherbug_link" onclick="top.location='http://www.weatherbug.com/?zcode=z6070';"></div>
		<div id="title">__MSG_loading__</div>
		<div id="edit_location"><a href="#" onclick="switchToCanvas('edit'); lp_trackEvent('Open Canvas','Edit button'); return false;">__MSG_edit__</a></div>
		<div style="clear:both"></div>
		<div id="whitearea">
			<div id="left_col">
				<div class="day_title">__MSG_today__</div>
				<div class="forecast">
					<div id="today_img_box"><img id="today_img" onclick="switchToCanvas(1); lp_trackEvent('Open Canvas','Today forecast');" /></div>
					<div id="today_hi" class="hi"></div>
					<div id="today_temp_live" class="large"></div>
					<div id="today_lo" class="lo"></div>
				</div>
				<div id="today_textual" class="textual" onclick="switchToCanvas(1);  lp_trackEvent('Open Canvas','Today forecast');"></div>
				<div class="more_div"><a href="#" class="more" onclick="switchToCanvas(1);  lp_trackEvent('Open Canvas','Today more... button'); return false;">__MSG_more__</a></div>
			</div>
			<div id="right_col">
				<div class="day_title">__MSG_tomorrow__</div>
				<div class="forecast">
					<div id="tomorrow_img_box"><img id="tomorrow_img" onclick="switchToCanvas(2); lp_trackEvent('Open Canvas','Tomorrow forecast');" /></div>
					<div id="tomorrow_hi" class="hi"></div>
					<div id="tomorrow_lo" class="lo"></div>
				</div>
				<div id="tomorrow_textual" class="textual" onclick="switchToCanvas(2); lp_trackEvent('Open Canvas','Tomorrow forecast');"></div>
				<div class="more_div"><a href="#" class="more" onclick="switchToCanvas(2); lp_trackEvent('Open Canvas','Tomorrow more... button'); return false;">__MSG_more__</a></div>
			</div>

			<div style="clear:both"></div>

		</div>
	</div>
	</div>
	<div id="weather_alert" onclick="top.location = this.href;"></div>
	<div id="footer">
		<a id="aws_forecast" href="#" style="margin-top:4px;float:left" onclick="switchToCanvas(); lp_trackEvent('Open Canvas','7 Day Forecast button'); return false">__MSG_7dayforecast__</a>
		<a id="add_location" href="#" style="margin-top:4px;float:right;margin-right:11px" onclick="switchToCanvas('add'); lp_trackEvent('Open Canvas','Add Location button');  return false">+__MSG_add_location__</a>
		<!--<a id="aws_news" href="#" target="_blank" onclick="lp_trackEvent('news link');">__MSG_news__</a>
		<a id="aws_video" href="#" target="_blank" onclick="lp_trackEvent('video link');">__MSG_video__</a>
		<a id="aws_radar" href="#" target="_blank" onclick="lp_trackEvent('radar link');">__MSG_radar__</a>
		<a id="aws_cameras" href="#" target="_blank" onclick="lp_trackEvent('cameras link');">__MSG_cameras__</a>-->
	</div>
</div>
<div style="width:240px">
	<script type="text/javascript">
	  GA_googleFillSlot("live_weather_txt");
	</script>
</div>

<div>
	<script type="text/javascript">
        var mMENU = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_footer.js");
	    document.write('<scr'+'ipt type="text/javascript" src="'+mMENU+'"></scr'+'ipt>');
     </script>
</div>
</center>
</div>
<div id="max_width" style="visibility:hidden;"></div>

<iframe width="1" height="1" style="width:1px; height:1px; overflow:hidden; position:absolute; visibility:hidden;" src="http://static.labpixies.com/campaigns/weather/analytics.html"></iframe>
]]> 
</Content>
<Content type="html" view="canvas">
<![CDATA[
<title>Weather</title>
<!--[if IE 6]>
<style type="text/css">
.gainlayout {
    zoom:1;
}
</style>
<![endif]-->
<style type="text/css">

body, form {
    margin:0;
    padding:0;
}

#loading_block {
    width:100%;
    height:100%;
    position:absolute;
    left:0px;
    top:0px;
    z-index:500;
    background:white;
}

#side_panel {
    width:200px;
    float:right;
}

#container {
    width:510px;
    overflow:hidden;
    text-align:left;
    position:relative;
}

#weatherbug {
    border:0;
    float:right;
    margin-right:14px;
}

#titlebar {
    height:42px;
}

#forecast {

}

#forecast table {
    width:100%;
/*    margin-left:3px;
    margin-right:3px;*/
}

#forecast td {
    width:14.3%;
    text-align:center;
}

#day1 {
    margin-left:17px;
}

#day7 {
    margin-right:17px;
}

.day_title {
    font-family:arial;
    font-weight:bold;
    font-size:11px;
    color:#fff;
    margin-top:9px;
}

.day_hi {
    font-family:arial;
    font-size:10px;
    font-weight:bold;
    color:#f49e1c;
}

.day_lo {
    font-family:arial;
    font-size:10px;
    font-weight:bold;
    color:#5ea3e3;
    margin-bottom:2px;
}

.icon_background {
    padding-top:6px;
    padding-bottom:6px;
    width:62px;
    hiehgt:54px;
    margin:0 auto;
    cursor:pointer;
}

#bottom_outer, #bottom_left, #bottom_right, #bottom_left_white_corner, #bottom_right_white_corner {
    height:28px;
}

#bottom_left {
    padding-left:16px;
}

#bottom_right {
    padding-right:16px;
}

#whitearea {
    padding-left:24px;
    padding-right:24px;
}

table.details td {
    padding:0;
    vertical-align:top;
}

table.details td.dayimg{
    padding-bottom:10px
}

#whitearea img {
    width:50px;
    height:42px;
}

#whitearea .temp {
    margin-left:10px;
    font-family:arial;
    font-size:11px;
    font-weight:bold;
    width:40px;
    padding-left:5px;
}

#whitearea .daytemp {
    color:#e4771d;
}

#whitearea .nighttemp {
    color:#2345c3;
}

#whitearea .textual {
    font-family:arial;
    font-size:11px;
    color:#000;
    line-height:13px;
}

#whitearea_top, #whitearea_top_left, #whitearea_top_right {
    height:7px;
}

#whitearea_top {
    margin-left:16px;
    margin-right:16px;
}

#city_name {
    margin-left:20px;
    font-family:arial;
    font-size:14px;
    font-weight:bold;
    color:#fbe41c;
    cursor:default;
}

#edit_location {
    font-family:arial;
    font-size:12px;
    color:#12365d;

    margin-left:5px;
    display:none;
}

#titlebar_text {
    margin-top:14px;
    float:left;
}

.clear {
    clear:left;
    height:0;
    line-height:0;
    font-size:0;
}

.degree_radio {
    font-family:arial;
    font-size:11px;
    color:#000;
    vertical-align:2px;
}

#locations {
    float:left;
    margin-bottom:6px;
}

#edit_locations {
    line-height:18px;
    color:#12365d;
    font-size:11px;
    margin-left:10px;
    display:none;
}

.location_button_outer {
    padding-left:8px;
    float:left;
    cursor:pointer;
    margin-left:4px;
}

.location_button {
    font-family:arial;
    font-size:12px;
    color:#13265d;
    height:18px;
    line-height:18px;
    padding-right:8px;
    float:left;
}

#friends_title_left {
    margin-top:10px;
    padding-left:4px;
    margin-left:7px;
}

#friends_title_right {
    padding-right:4px;
    margin-right:7px;
}

#friends_title {
    font-family:arial;
    font-size:11px;
    font-weight:bold;
    color:#fff;
    height:23px;
    line-height:23px;
}

#friends_map {
    height:350px;
    margin-left:7px;
    margin-right:7px;
    margin-top:13px;
    border:1px solid #a8a6a9;
}

#locations_editor_outer {
    width:100%;
    margin-right:10px;
}

#locations_editor {
    display:none;
    border:1px solid #213fb7;
    margin-left:4px;
    margin-right:4px;
    margin-bottom:4px;
}

#locations_editor table {
    width:100%;
}

#locations_editor table td {
    border-bottom:1px solid #e1e4ef;
}

#locations_editor table td, #locations_editor table th {
    text-align:left;
    padding:5px;
    font-family:arial;
    font-size:12px;
    font-weight:bold;
    color:#12365d;
}

#locations_editor table th {
    font-size:10px;
    text-align:center;
}

#locations_editor .header {
    background:#e1e4ef;
    height:23px;
}

#locations_editor .last {
    width:40%;
    text-align:right;
}

#locations_editor td.radio {
    padding-left:10px;
    width:8%;
}

#locations_editor td.location {
    width:30%;
    padding-left:10px;
}

#locations_editor td.edit {
    width:8%;
    text-align:center;
}

#locations_editor td.edit img {
    cursor:pointer;
}

#locations_editor td.delete {
    width:8%;
    text-align:center;
}

#locations_editor td.delete img {
    cursor:pointer;
}

#locations_editor_close_left {
    float:right;
    cursor:pointer;
    padding-left:17px;
}

#locations_editor_close {
    float:left;
    color:#fff;
    font-size:11px;
    height:15px;
    line-height:15px;
    padding-right:7px;

}

#add_location_left {
    float:left;
    padding-left:14px;
    clear:left;
    margin-left:10px;
    margin-top:10px;
    margin-bottom:10px;
    cursor:pointer;
}

#add_location {
    float:left;
    color:#fff;
    font-family:arial;
    font-size:12px;
    font-weight:bold;
    padding-right:8px;
    height:18px;
    line-height:18px;
}

#locations_search {
    display:none;
    border:1px solid #213fb7;
    margin-left:4px;
    margin-right:4px;
}

#locations_search .header {
    background:#e1e4ef;
    padding:5px;
}

#locations_search_back_left {
    float:left;
    padding-left:18px;
    cursor:pointer;
}

#locations_search_back {
    float:left;
    padding-right:7px;
    height:15px;
    line-height:15px;
    font-family:arial;
    font-size:11px;
    font-weight:bold;
    color:#fff;
}

#locations_search_close_left {
    float:right;
    padding-left:17px;
    cursor:pointer;
}

#locations_search_close {
    float:left;
    height:15px;
    line-height:15px;
    padding-right:7px;
    font-family:arial;
    font-size:11px;
    font-weight:bold;
    color:#fff;
}

#search_area {
    padding-top:5px;
    padding-bottom:10px;
    padding-left:10px;
    clear:left;
}

#search_link {
    font-family:arial;
    font-size:11px;
    color:#dc4a20;
    text-decoration:none;
    margin-left:10px;
}

#search_link:hover {
    text-decoration:underline;
}

#search_title {
    font-family:arial;
    font-size:11px;
}

#locations_results {
    font-family:arial;
    font-size:11px;
    line-height:18px;
    border-top:1px solid #e1e4ef;
    overflow:auto;
}

#locations_results ul {
    padding:0;
    margin:0;
    margin-left:10px;
    list-style:none;
}

#locations_results ul li a, #locations_results ul li a:visited {
    color:#13265d;
    text-decoration:none;
}

#locations_results ul li a:hover {
    color:#dc4a20;
    text-decoration:underline;
}

img.map_profile_pic {
    float:left;
    margin-right:5px;
    width:64px;
    height:64px;
}

img.map_weather_pic {
    float:left;
    margin-right:5px;
}

a.map_profile_name, a.map_profle_name:visited {
    font-family:arial;
    font-size:12px;
    color:#2242b8;
    font-weight:bold;
    text-decoration:none;
}

.map_profile_place {
    font-family:arial;
    font-size:10px;
    color:#4c4c4c;
}

.map_profile_weather {
    font-family:arial;
    font-size:12px;
}

#feed_error {
    font-size:12px;
    text-align:center;
    display:none;
}

#err_dialog {
    background:#fff;
    position:absolute;
    width:400px;
    height:140px;
    border:2px solid #213FB7;
    text-align:center;
    top:68px;
    display:none;
}

#err_dialog_close_left {
    float:right;
    cursor:pointer;
    padding-left:17px;
    margin-right:20px;
}

#err_dialog_close {
    float:left;
    color:#fff;
    font-size:11px;
    height:15px;
    line-height:15px;
    padding-right:7px;

}
</style>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>

<!-- PUT THIS TAG IN THE head SECTION -->
<script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js">
</script>
<script type="text/javascript">
  GS_googleAddAdSenseService("ca-pub-8123415297019784");
  GS_googleEnableAllServices();
</script>
<script type="text/javascript">
	GA_googleAddSlot("ca-pub-8123415297019784", "weather_box");
    GA_googleAddSlot("ca-pub-8123415297019784", "weather_custom_1");
    GA_googleAddSlot("ca-pub-8123415297019784", "weather_custom_2");
	GA_googleAddSlot("ca-pub-8123415297019784", "weather_leaderboard_top");
</script>
<script type="text/javascript">
  GA_googleFetchAds();
</script>
<!-- END OF TAG FOR head SECTION -->

<script type="text/javascript">
	
	var _gadgetID = 49;
    var $lp = jQuery.noConflict();
	var lp_pageTracker = _gat._getTracker("UA-345375-1");
    lp_pageTracker._initData();

var ver;
var VER_A = "A";
var VER_B = "B";
var g_prefs = new _IG_Prefs();

  /* page tracker for regular reporting*/
  var lp_pageTracker = _gat._getTracker("UA-345375-1");
  lp_pageTracker._initData();
  
  /* page tracker for A/B testing reports*/
  var lp_pageTrackerTest = _gat._getTracker("UA-345375-3");
  lp_pageTrackerTest._initData();

function lp_trackEvent(eventName,eventLable,eventVar) {
    try {
	   lp_pageTracker._trackEvent('Weather - Canvas',eventName,eventLable,eventVar);
	   lp_pageTrackerTest._trackEvent('Weather - Canvas_'+ver,eventName,eventLable,eventVar);
    }
    catch(ee) {

    }
}

    var platform;

	try{
	    var domain = opensocial.getEnvironment().getDomain();
	    if( domain.indexOf('google.com/ig') >= 0 ) {
		platform = 'igoogle';
	    }
	    else if ( domain.indexOf('orkut.com') >= 0 ) {
		platform = 'orkut';
	    }
	    else if ( domain.indexOf('myspace.com') >= 0 ) {
		platform = 'myspace';
	    }
	    else if ( domain.indexOf('hi5.com') >= 0 ) {
		platform = 'hi5';
	    }
	    else if ( domain.indexOf('shindig') >= 0 ) {
		platform = 'shindig';
	    }
	    else {
			platform = 'igoogle';
	    }
	}
	catch (ee) {
	    if( document.location.hostname == 'os.labpixies.com' )
		platform = 'shindig';
	    else
		platform = 'igoogle';//the value should have been "not-os". changing it to "igoogle" will allow to try loading the igoogle key for the map.
		
	}

	var apikeys = { 
	    igoogle: "ABQIAAAAZnZdzRcDBizyBEPH4MDuLxTZqGWfQErE9pT-IucjscazSdFnjBR0pJPAuGajKG2-0RpnSxJBm6BilQ", 
	    orkut: "ABQIAAAAZnZdzRcDBizyBEPH4MDuLxTZqGWfQErE9pT-IucjscazSdFnjBR0pJPAuGajKG2-0RpnSxJBm6BilQ", 
	    myspace: "ABQIAAAATcial5GD1zI7Wkyd02u5CBTnoafGCtz1NECmAcUYLJSslAPmLhSo5sk-K5hma2tX2B1HNna6rqM3xA",
	    hi5: "ABQIAAAATcial5GD1zI7Wkyd02u5CBRJwUzEb5stqZCdhItqARrWzouR2RTN54WcGHjzoG4dPOWD7703iR9Gfg",
	    shindig: "ABQIAAAATcial5GD1zI7Wkyd02u5CBTuURy28e5inG-turiJlevqF6eTlRQT1FEgGJBV1OM19HrFOlUKEIboGw"
	};


	var lang = g_prefs.getLang();
	var mMAPS = 'http://maps.google.com/maps?file=api&amp;v=2&amp;hl='+lang+'&amp;key=' + apikeys[platform];
	document.write('<scr'+'ipt type="text/javascript" src="'+mMAPS+'"></scr'+'ipt>');
	
</script>

<script type="text/javascript">
//var mSIDEBAR = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_sidebar.js");
//document.write('<scr'+'ipt type="text/javascript" src="'+mSIDEBAR+'"></scr'+'ipt>');

	var IMAGES_BASE = "http://cdn.labpixies.com/campaigns/weather/images/canvas/";
	var g_partner_id = "BFB7BE81-EF74-4b7b-A9EF-A82D059992EF";
	var g_zip_code = '10001';
	var g_city_code = '';
	var g_degree = 0;
	var g_zcode		 = "z6070";

	var g_locations = []; //an array that holds objects of type { zip_code, city_code }
	var g_location_buttons = []; //an array that holds the location buttons dom elements
	var g_active_location = 0;
	var g_default_index = 0;

	var g_delete_lock = 0; // "semahore" to help synchronize data requests with the rest of the code

	var weekday = new Array(7);
	weekday[0]="__MSG_sunday__";
	weekday[1]="__MSG_monday__";
	weekday[2]="__MSG_tuesday__";
	weekday[3]="__MSG_wednesday__";
	weekday[4]="__MSG_thursday__";
	weekday[5]="__MSG_friday__";
	weekday[6]="__MSG_saturday__";

	var forecastData = [];
	var arrDate = new Array();

	var g_is_os;
	var is_gadget_ready = false;
	var g_params = gadgets.views.getParams();

	_IG_RegisterOnloadHandler(init_module);
	function gadget_ready() {
	    if(is_gadget_ready) return;
	    is_gadget_ready = true;
	    $lp('#loading_block').remove();
	}

	function setVersion(){
		ver = g_prefs.getString("ver");
    //if no version then setting A as temporary (not saving to prefs)
    if ((ver!=VER_A) && (ver!=VER_B)){
      ver = VER_A;
      lp_pageTrackerTest._trackPageview("/weather_canvas_"+ver+"_weird");
    }
    lp_pageTrackerTest._trackPageview("/weather_canvas_"+ver);
   // _IG_Analytics("UA-345375-3", "/weather_canvas_"+ver);

	}
	
	function init_module() {
			setVersion();
	    loadImages();
	    g_is_os = !g_prefs.getInt('disable_os') && lpgadgets.lp.utils.isOpenSocialSupported();

		/*
	    var addSidebarParams = {}; // contains the texts for notification areas
	    var addMenuParams = {}; // contains menu parameters
	    
	    // set notification area titles
	    addSidebarParams.notifications = '__MSG_notifications__';
	    addSidebarParams.friendslist = '__MSG_friends_list__';
	    
	    // set menu area params
	    addMenuParams.textDirection = '__MSG_tdDir__'; // optional, 'ltr' is the default value
	    addMenuParams.lang = '__MSG_lang__';	     // optional, 'en' is the default value							
	    addMenuParams.title = 'More Options';			
	    
	    // deploy sidebar
	    lpgadgets.lp.sidebar.deploy('container', addSidebarParams, addMenuParams);
	     */

	    date = new Date();
	    today = date.getDay();
	    for(var i=1;i<=7;i++) {
			day_img = document.getElementById('day'+i+'_img');
			day_img.index = i;
			day_img.onclick = function() { selectDay(this.index); lp_trackEvent('Day Forecast','Day Forecast button '+this.index); };


			if( i == 1 ) {
			    document.getElementById('day'+i+'_title').innerHTML = "__MSG_today__";
			    day_img.parentNode.style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'icon_background_selected.png')+') no-repeat';
			}
			else {
			    document.getElementById('day'+i+'_title').innerHTML = weekday[ (today-1 + i) % 7 ];
			    day_img.parentNode.style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'icon_background.png')+') no-repeat';
			}

			day_img.src = _IG_GetImageUrl(IMAGES_BASE + 'temp_icon_new.gif');
			document.getElementById('day'+i+'_hi').innerHTML = '__MSG_hi__: --&deg;';
			document.getElementById('day'+i+'_lo').innerHTML = '__MSG_lo__: --&deg;';
	    }
	    
	    
	    g_degree = g_prefs.getInt('degree_unit_type');
	    if(g_degree)
		document.getElementById('degree_c').checked = true;
	    else
		document.getElementById('degree_f').checked = true;

	    loadLocations();
	    


	    initMap();
	    getAwsLinks();
	    gadget_ready();
	}

	var g_bounds;
	var g_mapIcon;
	var g_myIcon;

	function initMap() {
	    map = new GMap2( document.getElementById('friends_map') );
	    map.setCenter( new GLatLng(37.4419, -122.1419), 6);

	    g_geocoder = new GClientGeocoder();
	    g_bounds = new GLatLngBounds();
	    g_mapIcon = new GIcon();
	    g_mapIcon.image = _IG_GetImageUrl( IMAGES_BASE + 'marker.png' );// + '&bla=.png';
	    g_mapIcon.shadow = _IG_GetImageUrl( IMAGES_BASE + 'marker_shadow.png' );// + '&bla=.png';
	    g_mapIcon.iconSize = new GSize(20, 22);
	    g_mapIcon.shadowSize = new GSize(20, 22);
	    g_mapIcon.iconAnchor = new GPoint(10, 22);
	    g_mapIcon.infoWindowAnchor = new GPoint(10, 2);
	    g_mapIcon.infoShadowAnchor = new GPoint(10, 18);

	    g_myIcon = new GIcon( g_mapIcon );
	    g_myIcon.image = _IG_GetImageUrl( IMAGES_BASE + 'my_marker.png' );

	    map.addControl( new GMapTypeControl() );
	    map.addControl( new GLargeMapControl() );

	    if( g_is_os ) {
		var params = {};
		params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [opensocial.Person.Field.PROFILE_URL];

		var req = opensocial.newDataRequest();
		req.add( req.newFetchPersonRequest( opensocial.DataRequest.PersonId.OWNER ), "owner");
		req.add( req.newFetchPeopleRequest( opensocial.DataRequest.Group.OWNER_FRIENDS, params ), 'ownerFriends' );
		req.add( req.newFetchPersonAppDataRequest(opensocial.DataRequest.Group.OWNER_FRIENDS, 'locations'), 'locations' );
		
		req.send(
		    function (data) {
			try {
			    var ownerFriends = data.get('ownerFriends');
			    var ownerFriendsData = data.get('locations');

			    if( typeof(ownerFriends) != 'object' || typeof(ownerFriendsData) != 'object' ) return;

			    ownerFriends = ownerFriends.getData();
			    ownerFriendsData = ownerFriendsData.getData();

			    ownerFriends.each( function(person)
					       {
						   if( !ownerFriendsData) return;
						   var locations = ownerFriendsData[ person.getId() ];

						   if(locations) {
						       if( typeof(locations['locations']) == 'undefined' ) return;
						       var obj = gadgets.util.unescapeString( locations['locations'] );
						       obj = gadgets.json.parse(obj);

						       try {
							   var loc = {};
							   loc.name = obj.name[obj['default']];
							   loc.zip_code = obj.zip_code[obj['default']];
							   loc.city_code = obj.city_code[obj['default']];
							   loc.country = obj.country[obj['default']];

							   findAndAddToMap( loc, person, 0 );
						       }
						       catch(ee) {}
						   }
					       });
			}
			catch(ee) {
			    showErrorDialog('__MSG_data_load_error__');
			}
		    });
	    }
	    else {
		for( i in g_locations ) {
		    findAndAddToMap( g_locations[i], 0, 0 );
		}
	    }

	}
	
	function findAndAddToMap( location, person, me ) {
	    var location_name = location.name;
	    if(location.country) location_name+=', '+location.country;

	    g_geocoder.getLocations( location_name,
				   function (response ) {
				       if( typeof( response.Placemark ) != 'object' ) return; //location not found

				       var place = response.Placemark[0];

				       var point = new GLatLng( place.Point.coordinates[1]+ Math.random()/5.0, place.Point.coordinates[0]+ Math.random()/5.0 );
				       var marker = new GMarker( point, {icon: me?g_myIcon:g_mapIcon} );
				       g_bounds.extend( point );
				       
				       infoDiv = document.createElement('div');
				       
				       if( person && g_is_os ) {
					   profileLink = document.createElement('a');
					   var name = person.getDisplayName();
					   if(!name && me) name = '__MSG_me__';

					   var profile_url = person.getField(opensocial.Person.Field.PROFILE_URL);
					   profileLink.innerHTML = name;
					   if( profile_url ) profileLink.href = profile_url;
					   profileLink.target = '_top';
					   profileLink.className = 'map_profile_name';
				       				       
					   profilePic = document.createElement('img');
					   profilePic.src = person.getField(opensocial.Person.Field.THUMBNAIL_URL);
					   profilePic.className = 'map_profile_pic';

					   infoDiv.appendChild( profilePic );
					   infoDiv.appendChild( profileLink );
				       }
				       else {
					   var weatherImg = document.createElement('img');

					   weatherImg.className = 'map_weather_pic';
					   infoDiv.appendChild( weatherImg );
				       }

				       locationName = document.createElement('div');
				       locationName.innerHTML = location_name;
				       locationName.className = 'map_profile_place';

				       locationWeather = document.createElement('div');
				       locationWeather.className = 'map_profile_weather';
				       	
				       infoDiv.appendChild( locationName );
				       infoDiv.appendChild( locationWeather );
				       
				       marker.bindInfoWindow( infoDiv );
				       marker.infoDiv = infoDiv;
				       marker.loc = location;
				       
				       GEvent.addListener( marker, "infowindowopen",
							   function () {
							       var marker = this;
							       var infoDiv = marker.infoDiv;
							       
							       getLiveWeatherForMap( location, $lp('.map_profile_weather', infoDiv ) );
							       var img =  $lp('img',infoDiv);
							       if( marker.loc == g_locations[g_active_location] && img.attr('class')=='map_weather_pic' ) {
								   var src = document.getElementById('day1_img').src;
								   img.attr('src',src).show();
							       }
							       else {
								   img.hide();
							       }
							   });

				       map.addOverlay( marker );
				       if(location == g_locations[g_default_index]) marker.openInfoWindow( infoDiv );

				       var zoomlevel = map.getBoundsZoomLevel(g_bounds);
				       if( zoomlevel > 3 ) zoomlevel=3;			       
				       
				       map.setCenter(g_bounds.getCenter(), zoomlevel);
				   });
	}

	function getLiveWeatherForMap( location, target_jquery ){
	    var cur_live_url = "";
	    
	    //set url with the correct city code or zip code
	    if (location.zip_code!=0){		
		cur_live_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId="+g_partner_id+"&zipcode=" + location.zip_code + "&unittype=" + g_degree;
	    }
	    else if(location.city_code!=0) {
		cur_live_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId="+g_partner_id+"&citycode=" + location.city_code + "&unittype=" + g_degree;
	    }

	    //fetch data
	    _IG_FetchXmlContent(cur_live_url,
				function(response) {
				    try{
					if (response == null || typeof(response) != "object") {return;}
					if(response.firstChild == null){return;}
					
					var itemList = response.getElementsByTagName("condition");

					if(itemList.item(0)){
					    var out_text = itemList.item(0).getAttribute('text')+', '+itemList.item(0).getAttribute("temp") + "&deg;";

					    target_jquery.html(out_text);
					}
				    }
				    catch(e){}
				});
	}

	function loadLocations() {
	    if( !g_is_os ) { loadLocationsPref(); return; }

	    var json;

	    var req = opensocial.newDataRequest();
	    req.add( req.newFetchPersonRequest( opensocial.DataRequest.PersonId.VIEWER ), "viewer");
	    req.add( req.newFetchPersonRequest( opensocial.DataRequest.PersonId.OWNER), "owner");
	    req.add( req.newFetchPersonAppDataRequest(opensocial.DataRequest.PersonId.OWNER, "locations"), "locations" );
	    req.send( 
		function(data) {
		    var viewer;
		    var me;
		    try {
			viewer = data.get("viewer");
			me = data.get("owner");

			if( typeof(viewer) != 'object' || typeof(me) != 'object' )
			    throw 2; //can't determine owner

			viewer = viewer.getData();
			me = me.getData();

			if( me.getId() == viewer.getId() ) { //display edit location links
			    document.getElementById('edit_locations').style.display = 'inline';
			    //lpgadgets.lp.menu.addMenuItem('__MSG_add_location__', function(){ onAddLocation(); lp_trackEvent('add location - sidebar'); });
			}

			var mydata = data.get("locations");

			mydata = mydata.getData();

			mydata = mydata[me.getId()];

			if( typeof(mydata) == 'object' ) {
			    json = mydata['locations'];

			    json = gadgets.util.unescapeString(json);

			    if(json) {
				obj = gadgets.json.parse(json);

				g_default_index = obj['default'];

				var len = obj.zip_code.length;
				if( obj.city_code.length > len ) len = obj.city_code.length;

				for( var i=0; i< len; i++ ) {				    
				    addLocation( obj.name[i], obj.zip_code[i] || '0', obj.city_code[i] || '0', obj.country[i], 0 );
				}
			    }
			    else {
				throw 1;
			    }
			}
			else {
			    throw 1;
			}

		    }
		    catch(e) {
			addLocation('New York', '10001', '');		

			if( e != 2 && me.isOwner() ) {
			    if( g_prefs.getInt('first_load') ) {
				saveLocations();
			    }			
			    else {
				showErrorDialog('__MSG_data_load_error__');
			    }
			}

			g_default_index = 0;
		    }

		    
		    g_active_location = g_default_index;
		    setActiveButton( g_default_index );
		    show_forecast(g_locations[g_default_index].zip_code, g_locations[g_default_index].city_code);

		    if( typeof(me)=='object' ) findAndAddToMap( g_locations[g_default_index] , me ,1);
		    
	    });
	    

	}

	function loadLocationsPref() {
	    var json;

	    document.getElementById('edit_locations').style.display = 'inline';
	    //lpgadgets.lp.menu.addMenuItem('__MSG_add_location__', function(){ onAddLocation(); lp_trackEvent('add location - sidebar');});

	    json = g_prefs.getString('locations');
	    json = lpgadgets.lp.utils.unescapeString(json);

	    if(json && json != '0') {
			obj = lpgadgets.lp.utils.jsonParse(json);

			g_default_index = obj['default'];
			
			var len = obj.zip_code.length;
			if( obj.city_code.length > len ) len = obj.city_code.length;

			for( var i=0; i< len; i++ ) {
			    if(!obj.zip_code[i]) obj.zip_code[i]='0';
			    if(!obj.city_code[i]) obj.city_code[i]='0';

			    addLocation( obj.name[i], obj.zip_code[i], obj.city_code[i], obj.country[i], 0 );
			}
	    }

	    else {
			addLocation('New York', '10001', '');		
			g_default_index = 0;
	    }
		    
	    g_active_location = g_default_index;
	    setActiveButton( g_default_index );
	    show_forecast(g_locations[g_default_index].zip_code, g_locations[g_default_index].city_code);

	    //if( typeof(me)=='object' ) findAndAddToMap( g_locations[g_default_index] , me ,1);
	}

	function saveLocations() {
	    if( !g_is_os ) { saveLocationsPrefs(); return; }
	    obj = {};

	    locations_zip = [];
	    locations_city = [];
	    locations_name = [];
	    locations_country = [];

	    for( var i=0; i< g_locations.length; i++ ) {
		locations_zip.push( g_locations[i].zip_code );
		locations_city.push( g_locations[i].city_code );
		locations_name.push( g_locations[i].name );
		locations_country.push( g_locations[i].country );
	    }

	    obj.name = locations_name;
	    obj.zip_code = locations_zip;
	    obj.city_code = locations_city;
	    obj.country = locations_country;
	    obj['default'] = g_default_index;

	    json = gadgets.json.stringify(obj);


	    
	    var req = opensocial.newDataRequest();
	    req.add( req.newUpdatePersonAppDataRequest("VIEWER", "locations", json));
	    req.send( function(response) {
		if( !response.hadError() ) {
		    g_prefs.set('first_load','0');
		}
		else {
		    showErrorDialog('__MSG_data_error__');
		}
		if( g_delete_lock > 0 ) g_delete_lock--;
	    } );
	}

	function saveLocationsPrefs() {
	    obj = {};

	    locations_zip = [];
	    locations_city = [];
	    locations_name = [];
	    locations_country = [];

	    for( var i=0; i< g_locations.length; i++ ) {
			locations_zip.push( g_locations[i].zip_code );
			locations_city.push( g_locations[i].city_code );
			locations_name.push( g_locations[i].name );
			locations_country.push( g_locations[i].country );
	    }

	    obj.name = locations_name;
	    obj.zip_code = locations_zip;
	    obj.city_code = locations_city;
	    obj.country = locations_country;
	    obj['default'] = g_default_index;

	    json = lpgadgets.lp.utils.jsonStringify(obj);
	    
	    g_prefs.set('locations', json);
	    if( g_delete_lock > 0 ) g_delete_lock--;
	}

	var g_img_edit;
	var g_img_edit_over;
	var g_img_delete;
	var g_img_delete_over;

	function loadImages() {
	    document.getElementById('weatherbug').src = _IG_GetImageUrl(IMAGES_BASE + 'weatherbug_logo.jpg');
	    
	    document.getElementById('titlebar').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_top.png') +')';
	    
	    document.getElementById('forecast_left').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_forecast_left.jpg')+') top left no-repeat';
	    document.getElementById('forecast_right').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_forecast_right.jpg')+') top right no-repeat';
	    document.getElementById('forecast_outer').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_forecast_middle.jpg')+') repeat-x';
	    
	    document.getElementById('bottom_outer').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_bottom.jpg')+') repeat-x';
	    document.getElementById('bottom_left').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_bottom_left.jpg')+') top left no-repeat';
	    document.getElementById('bottom_right').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_bottom_right.jpg')+') top right no-repeat';
	    //document.getElementById('bottom_left_white_corner').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_bottom_white_left.jpg')+') top left no-repeat';
	    //document.getElementById('bottom_right_white_corner').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_bottom_white_right.jpg')+') top right no-repeat';

	    document.getElementById('whitearea_outer_left').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_white_left.jpg')+') left repeat-y';
	    document.getElementById('whitearea_outer_right').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'blue_white_right.jpg')+') right repeat-y';
	    document.getElementById('whitearea_top_right').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'white_top_left.jpg')+') left no-repeat';
	    document.getElementById('whitearea_top_left').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'white_top_right.jpg')+') right no-repeat';
	    document.getElementById('whitearea_top').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'white_top.jpg')+') repeat-x';

	    document.getElementById('friends_title_left').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'map_title_left.jpg')+') left no-repeat';
	    document.getElementById('friends_title_right').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'map_title_right.jpg')+') right no-repeat';
	    document.getElementById('friends_title').style.background = 'url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'map_title_middle.jpg')+') repeat-x';

	    document.getElementById('locations_editor_close_left').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'close_button_left.png')+') left no-repeat';
	    document.getElementById('locations_editor_close').style.background = '#103671 url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'close_button_right.png')+') right no-repeat';

	    g_img_edit = _IG_GetImageUrl(IMAGES_BASE + 'edit_location.png');
	    g_img_edit_over = _IG_GetImageUrl(IMAGES_BASE + 'edit_location_roll.png');
	    g_img_delete = _IG_GetImageUrl(IMAGES_BASE + 'delete_location.png');
	    g_img_delete_over = _IG_GetImageUrl(IMAGES_BASE + 'delete_location_roll.png');

	    document.getElementById('add_location_left').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'add_location_left.png')+') left no-repeat';
	    document.getElementById('add_location').style.background = '#103671 url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'add_location_right.png')+') right no-repeat';

	    document.getElementById('locations_search_close_left').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'close_button_left.png')+') left no-repeat';
	    document.getElementById('locations_search_close').style.background = '#103671 url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'close_button_right.png')+') right no-repeat';
	    document.getElementById('locations_search_back_left').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'back_button_left.png')+') left no-repeat';
	    document.getElementById('locations_search_back').style.background = '#103671 url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'back_button_right.png')+') right no-repeat';

	    document.getElementById('err_dialog_close_left').style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'close_button_left.png')+') left no-repeat';
	    document.getElementById('err_dialog_close').style.background = '#103671 url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'close_button_right.png')+') right no-repeat';

	}

	function getFeedUrl( zip_code, city_code ) {
		var url ="";
		if(zip_code != '0' && zip_code != ''){
			url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&UnitType="+g_degree+"&ForecastType=1";
			
			//fix bug of 4 digits
			var temp_code = zip_code.toString();
			if(temp_code.length==4){
				url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode=0"+zip_code+"&UnitType="+g_degree+"&ForecastType=1";
			}
		}
		else if(city_code != '0' && city_code != ''){
			url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&CityCode="+city_code+"&UnitType="+g_degree+"&ForecastType=1";
		}
		else{
			if(zip_code != 0){
				url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&UnitType="+g_degree+"&ForecastType=1";
				//fix bug of 4 digits
				if(zip_code.length==4){
					url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode=0"+zip_code+"&UnitType="+g_degree+"&ForecastType=1";
				}
			}
			else{
				url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&CityCode="+city_code+"&UnitType="+g_degree+"&ForecastType=1";
			}
		}
		
		//fix bug of 4 digits
		if(zip_code.length==4 || zip_code.toString().length==4){
			zip_code = "0" + zip_code;
		}
	    
	    return url;
	}

  var forecast_timeout;	
	function show_forecast( zip_code, city_code) {
	    url = getFeedUrl( zip_code, city_code );
	    //update gui with degree type
	    forecast_timeout = setTimeout("setErrorMsg()",10000);
	    _IG_FetchXmlContent(url,parseRSS_Forecast);
	}

	function setErrorMsg() {
	    document.getElementById('forecast').style.display = 'none';
	    document.getElementById('whitearea').style.display = 'none';
	    document.getElementById('feed_error').style.display = 'block';
	    document.getElementById('city_name').innerHTML = '';
	    _IG_AdjustIFrameHeight();
	}

	function unsetErrorMsg() {
	    document.getElementById('forecast').style.display = 'block';
	    document.getElementById('whitearea').style.display = 'block';
	    document.getElementById('feed_error').style.display = 'none';
	}

	function parseRSS_Forecast(response) {
	    clearTimeout(forecast_timeout);
	    forecastData = [];
	    
	    unsetErrorMsg();
	    if (response == null || typeof(response) != "object") {
		setErrorMsg();
		return;
	    }
	    
	    if(response.firstChild == null){
		setErrorMsg();
		return;
	    }
	    
	    //--------------------------------------------
	    // Get Location name - city and state
	    //--------------------------------------------
	    
	    var itemList_2 = response.getElementsByTagName("aws:location");
	    if(itemList_2.length==0){itemList_2 = response.getElementsByTagName("location");}
	    
	    var state_name_str 	= "";
	    var city_name_str 	= "";
	    for (var k=0; k < itemList_2.length; k++) { 
		
		var nodeList_2 = itemList_2.item(k).childNodes;
		
		for (var l=0; l < nodeList_2.length; l++) {
		    
		    var node_2 = nodeList_2.item(l);
		    
		    //city name
		    if(node_2.nodeName=="aws:city" || node_2.nodeName=="city"){
/*			if(node_2.firstChild.nodeValue.length>16){
			    document.getElementById("city_name").innerHTML = node_2.firstChild.nodeValue.substring(0,15);
			}
			else{
			    document.getElementById("city_name").innerHTML = node_2.firstChild.nodeValue;
			}
*/
			city_name_str = node_2.firstChild.nodeValue + ", ";
		    }
		    
		    //state name or country name
		    if(node_2.nodeName=="aws:state" || node_2.nodeName=="state" ||node_2.nodeName=="aws:country" ||node_2.nodeName=="country"){
			state_name_str = node_2.firstChild.nodeValue;
		    }
		}
	    }
	    
	    //update city title
	    document.getElementById("city_name").innerHTML = city_name_str + state_name_str;
	    
	    //--------------------------------------------		
	    // Get Forecast
	    //--------------------------------------------
	    
	    //temp values
	    var tmp_name  	=	"";
	    var tmp_image 	=	"";
	    var tmp_hi 		=	"";
	    var tmp_low 	=	"";
	    var tmp_desc	= 	"";
	    var cursor 		= 0;
	    
	    var itemList = response.getElementsByTagName("aws:forecast");
	    if(itemList.length == 0){itemList = response.getElementsByTagName("forecast");}
	    for (var i=0; i < itemList.length; i++) { 
		
		//for each node	
		var nodeList = itemList.item(i).childNodes;

		for (var j=0; j < nodeList.length; j++) {
		    
		    var node = nodeList.item(j);
		    if (node.firstChild) {
    		    //day name
    		    if(node.nodeName=="aws:title" || node.nodeName=="title"){tmp_name = node.firstChild.nodeValue;}

    		    //day image
    		    if(node.nodeName=="aws:image" || node.nodeName=="image"){tmp_image = node.firstChild.nodeValue;}

    		    //day hi temp
    		    if(node.nodeName=="aws:high" || node.nodeName=="high")	{tmp_hi = node.firstChild.nodeValue;}

    		    //day low temp
    		    if(node.nodeName=="aws:low" || node.nodeName=="low")	{tmp_low = node.firstChild.nodeValue;}

    		    //day forecast text
     		    if(node.nodeName=="aws:prediction" || node.nodeName=="prediction"){
     			tmp_desc = node.firstChild.nodeValue;
     		    }
     		}
		    
		}


		var k;
		if(tmp_low == '--' ) { //day node
		    k = Math.floor( i / 2);
		    forecastData[k] = forecastData[k] || {};
		    forecastData[k].day = {};
		    forecastData[k].day.temp = tmp_hi;
		    forecastData[k].day.image = tmp_image;
		    forecastData[k].day.desc = tmp_desc;
		}
		else if(tmp_hi == '--' ) { //night node
		    k = Math.floor( (i-1) / 2 );
		    forecastData[k] = forecastData[k] || {};
		    forecastData[k].night = {};
		    forecastData[k].night.temp = tmp_low;
		    forecastData[k].night.image = tmp_image;
		    forecastData[k].night.desc = tmp_desc;
		}
		else { //not in the us - single node per day
		    k = i;
		    forecastData[k] = forecastData[k] || {};
		    forecastData[k].single = {};
		    forecastData[k].single.temp = {};
		    forecastData[k].single.temp.hi = tmp_hi;
		    forecastData[k].single.temp.lo = tmp_low;
		    forecastData[k].single.image = tmp_image;
		    forecastData[k].single.desc = tmp_desc;
		}


	    }

	    for (var i=1; i<=7; i++ ) {
		if( typeof(forecastData[i-1]) == 'undefined'  ) {
		    for(var j=i-1; j<=7; j++ ) {
			document.getElementById('day'+i+'_img').src = _IG_GetImageUrl(IMAGES_BASE + 'temp_icon_new.gif');
			document.getElementById('day'+i+'_hi').innerHTML = '__MSG_hi__: --&deg;';
			document.getElementById('day'+i+'_lo').innerHTML = '__MSG_lo__: --&deg;';
		    }
		    break;
		}

		if( typeof(forecastData[i-1].day ) == 'object' ) {
		    document.getElementById('day'+i+'_img').src = forecastData[i-1].day.image;
		    document.getElementById('day'+i+'_hi').innerHTML = '__MSG_hi__: '+forecastData[i-1].day.temp + '&deg;';
		}
		if( typeof(forecastData[i-1].night ) == 'object' ) {
		    document.getElementById('day'+i+'_lo').innerHTML = '__MSG_lo__: '+forecastData[i-1].night.temp + '&deg;';
		}
		if( typeof(forecastData[i-1].single ) == 'object' ) {
		    document.getElementById('day'+i+'_img').src = forecastData[i-1].single.image;
		    document.getElementById('day'+i+'_hi').innerHTML = '__MSG_hi__: '+forecastData[i-1].single.temp.hi + '&deg;';
		    document.getElementById('day'+i+'_lo').innerHTML = '__MSG_lo__: '+forecastData[i-1].single.temp.lo + '&deg;';
		}

	    }

	    if( g_params && g_params.day ) selectDay( parseInt(g_params.day) );
	    else selectDay(1);

	    if( g_params && g_params.edit ) {
		onEditLocations();
		g_params = {};
	    }
	    else if( g_params && g_params.add ) {
		onAddLocation();
		g_params = {};
	    }

	    _IG_AdjustIFrameHeight();
	    
	}

	function selectDay( index ) {
	    if( typeof(forecastData[index-1]) !='object') return;
	    for(var i=1; i<=7; i++ ) {
		if(i != index ) document.getElementById('day'+i+'_img').parentNode.style.background =  'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'icon_background.png')+') no-repeat';
	    }

	    document.getElementById('day'+index+'_img').parentNode.style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'icon_background_selected.png')+') no-repeat';

	    var whiteArea = document.getElementById('whitearea');
	    whiteArea.innerHTML = '';

	    var table = $lp('<table class="details">').appendTo(whiteArea);

	    if( typeof(forecastData[index-1].day ) == 'object' ) {
		var tr = $lp('<tr>').appendTo(table);

		$lp('<td class="dayimg"><img src="'+forecastData[ index-1 ].day.image+'" /></td>').appendTo(tr);
		$lp('<td class="temp daytemp">'+'__MSG_hi__: '+forecastData[ index-1 ].day.temp + '&deg;</td>').appendTo(tr);
		$lp('<td class="textual">'+forecastData[ index-1 ].day.desc+'</td>').appendTo(tr);
		if( typeof(forecastData[index-1].night) != 'object' ) {
		    $lp('td.dayimg',tr).attr('class','');
		}
	    }

	    if( typeof(forecastData[index-1].night ) == 'object' ) {
		var tr = $lp('<tr>').appendTo(table);

		$lp('<td><img src="'+forecastData[ index-1 ].night.image+'" /></td>').appendTo(tr);
		$lp('<td class="temp nighttemp">'+'__MSG_lo__: '+forecastData[ index-1 ].night.temp + '&deg;</td>').appendTo(tr);
		$lp('<td class="textual">'+forecastData[ index-1 ].night.desc+'</td>').appendTo(tr);
	    }

	    if( typeof(forecastData[index-1].single ) == 'object' ) {
		var tr = $lp('<tr>').appendTo(table);

		$lp('<td><img src="'+forecastData[ index-1 ].single.image+'" /></td>').appendTo(tr);
		$lp('<td class="temp daytemp">'+'__MSG_hi__: '+forecastData[ index-1 ].single.temp.hi + '&deg;</td>').appendTo(tr);
		$lp('<td class="textual">'+forecastData[ index-1 ].single.desc+'</td>').appendTo(tr);
	    }
	    

	    _IG_AdjustIFrameHeight();
	}

	function degreeChanged(value) {
	//onclick handler for the degree type radio buttons
	    var degs = "Celsius";
	    if (value==0){
	    	degs = "Fahrenheit";
			}
			lp_trackEvent('Degrees Units',degs);
	    g_degree = value;
	    g_prefs.set('degree_unit_type', g_degree);

	    show_forecast(g_locations[ g_active_location ].zip_code , g_locations[ g_active_location ].city_code);
	}

	function addLocation( name, zip, city, country, save ) {
	    index = g_locations.push( {name: name, zip_code: zip, city_code: city, country: country} ) - 1;
	    if(save) saveLocations();

	    addLocationButton( index, name );

	    //create an entry for the new location in the Edit Locations dialog
	    tr = document.createElement('tr');
	    tdRadio = document.createElement('td');
	    tdRadio.className = 'radio';
	    //inputRadio = document.createElement('input');
	    inputRadio = $lp('<input type="radio" name="default_location" value="'+index+'" />');
	    inputRadio.click( function (ee) { //save new default location
	    lp_trackEvent('Edit Locations - Change Default Location','Radio button');
		g_default_index = this.value;
		//lpgadgets.lp.notifications.setAlert('__MSG_note_changed_location__ ' + g_locations[g_default_index].name );
		//lpgadgets.lp.notifications.addTagLine(g_locations[g_default_index].name);
		saveLocations();
		return true;
	    }) ;
	    //tdRadio.appendChild(inputRadio);
	    $lp(tdRadio).append(inputRadio);
	    
	    tdLocation = document.createElement('td');
	    tdLocation.innerHTML = name;
	    
	    tdEdit = document.createElement('td');
	    tdEdit.className = 'edit';
	    imgEdit = document.createElement('img');
	    imgEdit.src = g_img_edit;
	    imgEdit.onmouseover = function () { this.src = g_img_edit_over; };
	    imgEdit.onmouseout = function () { this.src = g_img_edit; };
	    imgEdit.index = index;
	    imgEdit.onclick = editButtonHandler;
	    tdEdit.appendChild(imgEdit);

	    tdDelete = document.createElement('td');
	    tdDelete.className = 'delete';
	    imgDelete = document.createElement('img');
	    imgDelete.src = g_img_delete;
	    imgDelete.onmouseover = function () { this.src = g_img_delete_over; };
	    imgDelete.onmouseout = function () { this.src = g_img_delete; };
	    imgDelete.index = index;
	    imgDelete.onclick = deleteButtonHandler;
	    tdDelete.appendChild(imgDelete);
	    
	    tdLast = document.createElement('td');
	    tdLast.innerHTML = '&nbsp;';

	    tr.appendChild(tdRadio);
	    tr.appendChild(tdLocation);
	    tr.appendChild(tdEdit);
	    tr.appendChild(tdDelete);
	    tr.appendChild(tdLast);

	    document.getElementById('locations_editor_tbody').appendChild(tr);

	    if( g_default_index == index ) inputRadio.attr('checked',true); //this has to be done here for IE

	    if( g_locations.length > 1 ) showDelete();
	    else {
		hideDelete();
	    }
	}

	function addLocationButton( index, name ) {
	//this function is used to create the location buttons
	    
	    leftDiv = document.createElement('div'); //this is the outer div - it creates the left part of the button
	    leftDiv.style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'location_left.png')+') left no-repeat';
	    leftDiv.className = 'location_button_outer';
	    leftDiv.location_index = index;
	    leftDiv.onclick = locationHandler;
	    
	    rightDiv = document.createElement('div');
	    rightDiv.className = 'location_button';
	    rightDiv.style.background = '#97d5fc url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'location_right.png')+') right no-repeat';

	    if( name.length > 10 ) name = name.substring(0, 8) + '...';
	    rightDiv.appendChild( document.createTextNode( name ) );
	    leftDiv.appendChild(rightDiv);
	    
	    document.getElementById('locations').appendChild(leftDiv);
	    g_location_buttons.push( leftDiv );
	}

	function setActiveButton( index ) {

	    for( var j=0; j<g_location_buttons.length; j++ ) {
		g_location_buttons[j].style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'location_left.png')+') left no-repeat';
		g_location_buttons[j].firstChild.style.background = '#97d5fc url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'location_right.png')+') right no-repeat';
	    }
	    g_location_buttons[index].style.background = 'transparent url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'location_current_left.png')+') left no-repeat';
	    g_location_buttons[index].firstChild.style.background = '#ef8a14 url'+'('+_IG_GetImageUrl(IMAGES_BASE + 'location_current_right.png')+') right no-repeat';
	}

	function locationHandler() {
	//this is the onclick handler for the location buttons
	    i = this.location_index;
	    setActiveButton( i );

	    g_active_location = i;
	    lp_trackEvent('Show Location',''+i+' '+g_locations[i].name);
	    show_forecast( g_locations[i].zip_code, g_locations[i].city_code );
	    getAwsLinks();
	}

	function searchLocationByString(str){
	    //search for locations
	    str				= escape(str);
	    cur_url 			= "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId="+g_partner_id+"&SearchString=" + str;
		
	    _IG_FetchXmlContent(cur_url,parseRSS_Locations);
	}

	function parseRSS_Locations( response ) {
	    resultsDiv = document.getElementById('locations_results');
	    resultsDiv.innerHTML = '';

	    if( response == null || typeof(response) != 'object' ) {
		resultsDiv.innerHTML = '<i style="padding-left:10px">__MSG_invalid_result__</i>';
		return;
	    }

	    locationTags = response.getElementsByTagName('location');
	    if( locationTags.length == 0 ) {
		resultsDiv.innerHTML = '<i style="padding-left:10px">__MSG_invalid_result__</i>';
		return;
	    }

	    ul = document.createElement('ul');
	    
	    for(var i=0; i< locationTags.length; i++ ) {
		li = document.createElement('li');
		a = document.createElement('a');
		
		city = locationTags[i].getAttribute('city');
		state = locationTags[i].getAttribute('state');
		country = locationTags[i].getAttribute('country');
		state = locationTags[i].getAttribute('state');
		if( state ) country = state+', '+country;

		a.innerHTML = '&bull; '+city+' ('+country+')';
		a.href="#";
		if(state) a.innerHTML += ', '+state;

		a.location = { name: city, zipcode: locationTags[i].getAttribute('zipcode'), citycode: locationTags[i].getAttribute('citycode'), country:country };
		a.onclick = locationLinkHandler;

		li.appendChild(a);
		ul.appendChild(li);
	    }

	    resultsDiv.appendChild(ul);

	    resultsDiv.style.height = '';
	    if( resultsDiv.offsetHeight > 145 ) resultsDiv.style.height = '145px';
	    
	}

	var g_replacing_location = -1; /* if this var is set to anything other than -1, the following function 
					will use it as the index of the location that it should replace */

	function locationLinkHandler() {
	    if( g_replacing_location < 0 ) {
		var index = g_locations.length;

		g_default_index = index;
		addLocation( this.location.name, this.location.zipcode, this.location.citycode, this.location.country, 1 );
		
		setActiveButton( index );

		g_active_location = index;
		show_forecast( g_locations[index].zip_code, g_locations[index].city_code );
	    }
	    else {
		g_locations[g_replacing_location].name = this.location.name;
		g_locations[g_replacing_location].zip_code = this.location.zipcode;
		g_locations[g_replacing_location].city_code = this.location.citycode;
		g_locations[g_replacing_location].country = this.location.country;
		
		//replace the entry in the locations editor table
		$lp('tr:eq('+ (g_replacing_location+1) + ') >td:eq(1)', document.getElementById('locations_editor_tbody')).html( this.location.name );

		//rewrite the locatin button
		var name = this.location.name;
		if( name.length > 10 ) name = name.substring(0, 8) + '...';
		g_location_buttons[g_replacing_location].firstChild.innerHTML = name;
		g_location_buttons[g_replacing_location].onclick();

		setActiveButton( g_replacing_location );

		g_active_location = g_replacing_location;
		show_forecast( g_locations[g_replacing_location].zip_code, g_locations[g_replacing_location].city_code );

		g_replacing_location = -1;

		saveLocations();		
	    }

	    onLocationSearchClose();
	    return false;
	}

	function onLocationSearch() {
	    str  = document.getElementById('search_box').value;

	    searchLocationByString(str);
	}

	function onEditLocations() {
	    document.getElementById('locations_editor').style.display = 'block';
	    document.getElementById('locations_search').style.display = 'none';
	    
	    _IG_AdjustIFrameHeight();
	}

	function onEditLocation() {
	    var location = g_locations[ g_active_location ];
	    g_replacing_location = g_active_location;

	    document.getElementById('search_box').value = location.name;
	    showLocationSearch();
	    onLocationSearch();
	}

	function onLocationsEditorClose() {
	    document.getElementById('locations_editor').style.display = 'none';

	    _IG_AdjustIFrameHeight();
	}

	function editButtonHandler() {
			lp_trackEvent('Edit Locations - Edit Location','Edit button');
	    var location = g_locations[ this.index ];
	    g_replacing_location = this.index;

	    document.getElementById('search_box').value = location.name;
	    showLocationSearch();
	    onLocationSearch();   
	}


	function deleteButtonHandler() {
	    if( g_delete_lock > 0 ) return;
	    else g_delete_lock++;
			
			lp_trackEvent('Edit Locations - Delete Location','Delete button');
	    try {

		// remove the location from the global array
		g_locations.splice( this.index, 1 );
		
		// remove the location button
		g_location_buttons[ this.index ].parentNode.removeChild( g_location_buttons[ this.index ] );
		g_location_buttons.splice( this.index, 1 );
		
		// update button indices
		for( var i=this.index; i<g_location_buttons.length; i++ ) {
		    g_location_buttons[i].location_index--;
		}

		// remove the table entry
		this.parentNode.parentNode.parentNode.removeChild( this.parentNode.parentNode );

		// update radio button values
		$lp('#locations_editor_tbody input:radio').each( function( n, el) {
		    el.value = n;
		});

		// update delete button indices
		$lp('#locations_editor_tbody td.delete img').each( function( n, el) {
		    el.index = n;
		});

		// update edit button indices
		$lp('#locations_editor_tbody td.edit img').each( function( n, el) {
		    el.index = n;
		});
		
		// if the default location was removed
		if( g_default_index == this.index ) {
		  $lp('#locations_editor_tbody input[@value=0]').attr('checked',true);
		    g_default_index = 0;
		} 
		else if ( g_default_index > this.index ) {
		    g_default_index--;
		    
		}

		setActiveButton( g_default_index );
		g_active_location = g_default_index;
		show_forecast( g_locations[g_default_index].zip_code, g_locations[g_default_index].city_code );
		
		if( g_locations.length == 1 ) hideDelete();
		// save changes
		saveLocations();

	    }
	    catch (ee) { g_delete_lock--; }

	}

	function hideDelete() {
	    $lp('td.delete>img').css('visibility','hidden');
	    $lp('th.delete').html('');
	}

	function showDelete() {
	    $lp('td.delete>img').css('visibility','visible');
	    $lp('th.delete').html('__MSG_delete__');
	}

	function showLocationSearch() {
	    document.getElementById('locations_editor').style.display = 'none';
	    document.getElementById('locations_search').style.display = 'block';

	    _IG_AdjustIFrameHeight();
	}

	function onAddLocation() {
	    if( g_locations.length >= 5 ) {
		showErrorDialog( '__MSG_too_many_locations__' );
				     
		return;
	    }

	    showLocationSearch();
	}

	function onLocationSearchBack() {
	    document.getElementById('locations_editor').style.display = 'block';
	    document.getElementById('locations_search').style.display = 'none';

	    _IG_AdjustIFrameHeight();
	}

	function onLocationSearchClose() {
	    document.getElementById('locations_search').style.display = 'none';
	    
	    _IG_AdjustIFrameHeight();
	}

	function getAwsLinks() {
	    var cur_url = "";
	    
	    //set url with the correct city code or zip code

	    var zip_code = g_locations[ g_active_location ].zip_code;
	    var city_code = g_locations[ g_active_location ].city_code;

	    if (zip_code!=0){
		cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&LinkName=forecast_hourly,maps_infrared,severeweather_localalerts,hurricanes_commandcenter,cameras_local,traffic_local,video_local,health_airquality,travel_forecast&Zcode="+g_zcode;
	    }
	    else if(city_code!=0){
		cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&CityCode="+city_code+"&LinkName=forecast_hourly,maps_infrared,severeweather_localalerts,hurricanes_commandcenter,cameras_local,traffic_local,video_local,health_airquality,travel_forecast&Zcode="+g_zcode;
	    }

	    //fetch data
	    _IG_FetchXmlContent(cur_url,parseRSS_AWS_LINKS);
	}

	var g_links_set = false;
	var g_link_titles = {'forecast_hourly':'Hourly Forecast', 'maps_infrared':'Radar & Maps', 'severeweather_localalerts':'Severe Weather', 'hurricanes_commandcenter':'Hurricanes', 'cameras_local':'Weather Cameras', 'traffic_local':'Traffic Cameras', 'video_local':'Video Forecast','health_airquality':'Health & Fitness', 'travel_forecast':'Travel'};
	var g_link_urls = {};

	function sidebarLink(t) {
	    window.open(g_link_urls[t],'_blank');
	}

	function parseRSS_AWS_LINKS(response) {
	    
	    if(!g_links_set) {
		for(t in g_link_titles ) {
		    g_link_urls[t] = "http://www.weatherbug.com/?zcode="+g_zcode;
		    //eval("var func = function() {sidebarLink('"+t+"');}");
		    //lpgadgets.lp.menu.addLongMenuItem( g_link_titles[t], g_link_titles[t],IMAGES_BASE + 'weatherbug_icon', func);
		}
		g_links_set = true;

	    }

	    try{
		if (response == null || typeof(response) != "object") {return;}
		if(response.firstChild == null){return;}
		
		var itemList = response.getElementsByTagName("aws:Link");
		if(itemList.length==0){itemList = response.getElementsByTagName("Link");}
		

		//check if we have any items
		for( i=0;i<itemList.length;i++ ) {
		    var t = itemList[i].getAttribute('linkname');
		    var title = g_link_titles[t];
		    if(typeof(title)!='undefined') {
			g_link_urls[t] = itemList[i].getAttribute('url');
		    }
		}
				
	    }
	    catch(e){}
	}

	function showErrorDialog(errmsg) {
	    dialog = document.getElementById('err_dialog');
	    document.getElementById('err_dialog_inner').innerHTML = errmsg;

	    parent_left = dialog.parentNode.offsetLeft;
	    dialog.style.left = (parent_left+70) + 'px';
	    dialog.style.display = 'block';
	}
	
	lp_pageTracker._trackPageview("/Weather_" + gadgets.views.getCurrentView().getName());
	//_IG_Analytics("UA-345375-1", "/Weather_" + gadgets.views.getCurrentView().getName());
	_IG_Analytics("UA-335767-2", "/WeatherBug");

</script>

<center>
<table cellpadding="0" cellspacing="0" border="0"  width="760">
	<tr>
		<td colspan="2">
			<div id="gadget_ad" style="margin-top:10px;margin-bottom:10px;background:url(http://cdn.labpixies.com/infra/images/ad_unit_bg_760.png);width:760px;height:106px;">
				<div id="canvas_mode_ad_div" style="text-align:left; margin-left:22px; padding-top:9px;">
				<script type="text/javascript">
					GA_googleFillSlot("weather_leaderboard_top");		
				</script>
				</div>
			</div>
		</td>	
	</tr>
    <tr>
        <td style="width:520px;padding-left:15px;">
			<div id="container">
<div>
	<div id="locations"></div>
	<div style="float:left"><a id="edit_locations" href="#" onclick="onEditLocations(); lp_trackEvent('Edit Locations','Edit locations button'); return false;">__MSG_edit_locations__</a></div>
</div>
<div class="clear"></div>

<div id="locations_editor_outer">
<div id="err_dialog">
	<table>
		<tr><td id="err_dialog_inner" style="width:400px;height:100px;text-align:center;vertical-align:middle;"></td></tr>
		<tr><td><div onclick="document.getElementById('err_dialog').style.display='none';" id="err_dialog_close_left">
			<div id="err_dialog_close">__MSG_close__</div></div></td></tr>
	</table>
</div>

<div id="locations_editor">

<table id="locations_editor_table" border="0" cellpadding="0" cellspacing="0">
<form id="default_form">
	<tbody id="locations_editor_tbody">
	<tr class="header">
		<th>__MSG_default__</th>
		<th class="location"></th>
		<th class="edit">__MSG_Edit__</th>
		<th class="delete">__MSG_delete__</th>
		<th class="last">
			<div onclick="onLocationsEditorClose();" id="locations_editor_close_left">
				<div id="locations_editor_close">__MSG_close__</div>
			</div>
		</th>
	</tr>
	</tbody>
</form>
</table>
	<div onclick="onAddLocation(); lp_trackEvent('Edit Locations - Add Location','+ Add Location button');" id="add_location_left"><div id="add_location">__MSG_add_location__</div></div>
	<div class="clear"></div>
</div> <!-- locations_editor -->
</div> <!-- locations_editor_outer -->
<div id="locations_search">
	<div class="header">
		<div onclick="onLocationSearchBack(); lp_trackEvent('Add New Location - Cancel ','Back button'); return false;" id="locations_search_back_left"><div id="locations_search_back">__MSG_back__</div></div>
		<div onclick="onLocationSearchClose(); lp_trackEvent('Add New Location - Close','Close button'); return false;" id="locations_search_close_left"><div id="locations_search_close">__MSG_close__</div></div>
		<div></div>
		<div class="clear"></div>
	</div>
	<div></div>
	<div id="search_area">
	<form onsubmit="onLocationSearch(); lp_trackEvent('Add New Location - Search','Enter'); return false;">
		<div id="search_title">__MSG_search_title__</div>
		<div><input id="search_box" /><a id="search_link" href="#" onclick="onLocationSearch(); lp_trackEvent('Add New Location - Search','Search button'); return false;" >&raquo; __MSG_search__</a></div>
	</form>
	</div>
	<div id="locations_results">
		
	</div>
</div>
<div class="clear"></div>
<div id="titlebar">
	<span id="titlebar_text">
		<span id="city_name">__MSG_loading__</span>
	
	</span>
	<a href="http://www.weatherbug.com/?zcode=z6070" target="_new"><img id="weatherbug" /></a>
</div>
<div id="forecast_outer" class="gainlayout">
	<div id="forecast_left" class="gainlayout">
	<div id="forecast_right" class="gainlayout">
	<div id="forecast">
		<table>
			<tr>
				<td>
					<div id="day1">
						<div class="icon_background"><img id="day1_img"/></div>
						<div class="day_title" id="day1_title"></div>
						<div class="day_hi" id="day1_hi"></div>
						<div class="day_lo" id="day1_lo"></div>
					</div>
				</td>
				<td>
					<div id="day2">
						<div class="icon_background"><img id="day2_img"/></div>
						<div class="day_title" id="day2_title"></div>
						<div class="day_hi" id="day2_hi"></div>
						<div class="day_lo" id="day2_lo"></div>
					</div>
				</td>
				<td>
					<div id="day3">
						<div class="icon_background"><img id="day3_img"/></div>
						<div class="day_title" id="day3_title"></div>
						<div class="day_hi" id="day3_hi"></div>
						<div class="day_lo" id="day3_lo"></div>
					</div>
				</td>
				<td>
					<div id="day4">
						<div class="icon_background"><img id="day4_img"/></div>
						<div class="day_title" id="day4_title"></div>
						<div class="day_hi" id="day4_hi"></div>
						<div class="day_lo" id="day4_lo"></div>
					</div>
				</td>
				<td>
					<div id="day5">
						<div class="icon_background"><img id="day5_img"/></div>
						<div class="day_title" id="day5_title"></div>
						<div class="day_hi" id="day5_hi"></div>
						<div class="day_lo" id="day5_lo"></div>
					</div>
				</td>
				<td>
					<div id="day6">
						<div class="icon_background"><img id="day6_img"/></div>
						<div class="day_title" id="day6_title"></div>
						<div class="day_hi" id="day6_hi"></div>
						<div class="day_lo" id="day6_lo"></div>
					</div>
				</td>
				<td>
					<div id="day7">
						<div class="icon_background"><img id="day7_img"/></div>
						<div class="day_title" id="day7_title"></div>
						<div class="day_hi" id="day7_hi"></div>
						<div class="day_lo" id="day7_lo"></div>
					</div>
				</td>
			</tr>
		</table>
	</div>
	</div>
	</div>
</div>

<div id="whitearea_outer" class="gainlayout">
<div id="whitearea_outer_left" class="gainlayout">
<div id="whitearea_outer_right" class="gainlayout">
<div id="whitearea_left">
<div id="whitearea_right">
	<div id="whitearea_top">
	<div id="whitearea_top_left">
	<div id="whitearea_top_right">
	<div></div> <!-- IE fix empty div -->
	</div>
	</div>
	</div>
	<div id="feed_error">__MSG_unavailable__</div>
	<div id="whitearea">

	</div>
</div>
</div>
</div>
</div>
</div>

<div id="bottom_outer">
	<div id="bottom_left">
	<div id="bottom_left_white_corner">
	<div id="bottom_right">
	<div id="bottom_right_white_corner">
	</div>
	</div>
	</div>
	</div>
</div>


<input type="radio" name="degree" id="degree_f" onclick="degreeChanged(0);" />
<label class="degree_radio" for="degree">__MSG_fahrenheit__</label>
<input type="radio" name="degree" id="degree_c" onclick="degreeChanged(1);"/>
<label class="degree_radio" for="degree">__MSG_celsius__</label>


<!--<table>
	<tr>
		<td style="vertical-align:middle;">
			<input type="radio" name="degree" id="degree_f" onclick="degreeChanged(0);" />
		</td>
		<td class="degree_radio">
			__MSG_fahrenheit__
		</td>

		<td style="vertical-align:middle;">
			<input type="radio" name="degree" id="degree_c" onclick="degreeChanged(1);"/>
		</td>
		<td class="degree_radio">
			__MSG_celsius__
		</td>
	</tr>
</table> -->

<div id="friends_title_left">
<div id="friends_title_right">
<div id="friends_title">
__MSG_friends_title__
</div>
</div>
</div>

<div id="friends_map">
</div>
</div> <!-- container -->
</td>
		<td style="width:240px;padding-right:15px;" align="right" valign="top">
			<div style="width:200px; margin-bottom:10px;">
				<script type="text/javascript">
				  GA_googleFillSlot("weather_custom_1");
				</script>
			</div>
			<div style="width:200px; margin-bottom:10px;">
				<script type="text/javascript">
				  GA_googleFillSlot("weather_custom_2");
				</script>
			</div>
			<div style="width:200px;">
				<script type="text/javascript">
				  GA_googleFillSlot("weather_box");
				</script>
			</div>
		</td>
	</tr>
 </table>
 


<div style="height:10px;font-size:1px;clear:both;">&nbsp;</div>
<div style="text-align:center;width:728px;">

<script type="text/javascript">

google_ad_client = "pub-8123415297019784";

/* Weather - Links Unit - Bottom */

google_ad_slot = "6688256128";

google_ad_width = 728;

google_ad_height = 15;

</script>

<script type="text/javascript"

src="http://pagead2.googlesyndication.com/pagead/show_ads.js">

</script>

</div>

<div>
	<script type="text/javascript">
        var mMENU = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_footer.js");
	    document.write('<scr'+'ipt type="text/javascript" src="'+mMENU+'"></scr'+'ipt>');
     </script>
</div>

</center>
<iframe width="1" height="1" style="width:1px; height:1px; overflow:hidden; position:absolute; visibility:hidden;" src="http://static.labpixies.com/campaigns/weather/analytics.html"></iframe>
]]>
</Content>
<Content type="html">
  <![CDATA[
<title>Weather</title>
<!-- PUT THIS TAG IN THE head SECTION -->
<script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js">
</script>
<script type="text/javascript">
  GS_googleAddAdSenseService("ca-pub-8123415297019784");
  GS_googleEnableAllServices();
</script>
<script type="text/javascript">
  GA_googleAddSlot("ca-pub-8123415297019784", "live_weather_txt");
</script>
<script type="text/javascript">
  GA_googleFetchAds();
</script>
<!-- END OF TAG FOR head SECTION -->

<style type="text/css">
.style1 {font-size: 1px}
.style3 {
	font-size: 14px;
	font-family: Arial, Helvetica, sans-serif;
	color: #fbe317;
	font-weight: bold;
}
.style4 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #13265d;
	font-weight: bold;
}
.style5 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #bac1dd;
	font-weight: bold;
}
.style6 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 24px;
	font-weight: bold;
	color: #FFFFFF;
}
.style7 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #FFFFFF;
}
.style7_gray {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #999999;
}

.style_aws_alert {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	font-weight: bold;
	color: #DF4E00;
}
a.style_aws_alert:link{text-decoration:none;color:#DF4E00;}
a.style_aws_alert:visited{text-decoration:none;color:#DF4E00;}
a.style_aws_alert:active{text-decoration:underline;color:#DF4E00;}
a.style_aws_alert:hover{text-decoration:underline;color:#DF4E00;}

.style_aws_link {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #5ea3e3;
	line-height:11px;
	font-weight:bold;	
}
a.style_aws_link:link{text-decoration:none;color:#5ea3e3;}
a.style_aws_link:visited{text-decoration:none;color:#5ea3e3;}
a.style_aws_link:active{text-decoration:underline;color:#fbe317;}
a.style_aws_link:hover{text-decoration:underline;color:#fbe317;}

.style7_a {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #FFFFFF;
	cursor: pointer;
}

.style8 {
	color: #fbe317;
	font-weight: bold;
	font-size: 10px;
	font-family: Arial, Helvetica, sans-serif;
	text-decoration:none;
}

a.style8:visited{text-decoration:none;color:#fbe317;}
a.style8:active{text-decoration:underline;color:#fbe317;}
a.style8:hover{text-decoration:underline;color:#fbe317;}

.style9 {
	color: #5ea3e3;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
	font-weight: bold;
}

.style10 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	font-weight: bold;
	color: #f49e19;
}

.style11 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	font-weight: bold;
	color: #5ea3e3;
}

.whitebordertable {
	border: 1px solid #FFFFFF;
	background-color: #0b1641;
}

.style12 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #13265d; font-weight: bold; }

.style13 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	font-weight: bold;
	color: #fbe317;
}

.table_div {
	height: 75px;
}

.style17 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #f49e19; }

.style19 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; color: #5ea3e3; }

#no_line a:link    {text-decoration:none;}
#no_line a:visited {text-decoration:none;}
#no_line a:hover   {text-decoration:none;}
#no_line a:active  {text-decoration:none;}

#tdad_title {
	font-size:11px;
	font-family: Verdana, Arial, sans-serif;
	color:#1c47b8;
}

</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
<script type="text/javascript">
	var $lp=jQuery.noConflict();
	var images_url = "http://cdn.labpixies.com/campaigns/weather/images/";

	var _gadgetID = 49;
	var lp_pageTracker = _gat._getTracker("UA-345375-1");
    lp_pageTracker._initData();
    function lp_trackEvent(eventName,eventLable,eventVar) {
        try {
    	   lp_pageTracker._trackEvent('Weather V1',eventName,eventLable,eventVar);
        }
        catch(ee) {

        }
    }
    
    //var mMENU = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_menu.js");
	//document.write('<scr'+'ipt type="text/javascript" src="'+mMENU+'"></scr'+'ipt>');
    
	var mAll = _IG_GetCachedUrl("http://www.labpixies.com/lib/lp_utils_all_cookie.js");
	document.write('<scr'+'ipt type="text/javascript" src="'+mAll+'"></scr'+'ipt>');
  
</script>

<script type="text/javascript">
	//current loaction
	var city_name			= "";
	var state_name			= "";
	var country_name		= "";
	var zip_code			= "";
	var city_code			= "";
	var cur_url				= "none";
	
	//actions
	var cur_action			= "FORECAST"; //FORECAST , SEARCH_CITY 
	
	//loading cities message
	var stop_loading		=	0;
	var is_loading			=	0;
	var h_timeout;
	var cur_loading_str		=	"";
	var live_stop_loading	=	0;
	var live_is_loading		=	0;
	
	//degree values
	var degree 		= 0;
	
	//forecast array
	var forecastText = new Array();
	var arrDate		 = new Array();
	arrDate[0]		 = "Today";
	
	//timeout handle
	var hTime = 0;
	
	//globals
	var g_partner_id = "BFB7BE81-EF74-4b7b-A9EF-A82D059992EF";
	var g_zcode		 = "z6070";
	var g_link_str = "http://www.weatherbug.com/?zcode="+g_zcode;
	
	//---------------------------------------------
	//init module
	//---------------------------------------------
	
	function init_module__MODULE_ID__(){
		
		// Get user preferences
		prefs__MODULE_ID__ = new _IG_Prefs(__MODULE_ID__);
		
		//get prefs
		degree 		= prefs__MODULE_ID__.getString("degree_unit_type");
		city_code 	= prefs__MODULE_ID__.getString("city_code");
		zip_code 	= prefs__MODULE_ID__.getString("zip_code");
		
		if(degree=='1') document.getElementById('radio_c').checked = true;
		else document.getElementById('radio_f').checked = true;

		if(zip_code == 'none') prefs__MODULE_ID__.set('zip_code','0');
	    	if(city_code == 'none') prefs__MODULE_ID__.set('city_code','0');

		//look for zip code
		if(zip_code != "0"){
			show_forecast(1,zip_code,'0',0);
		}
		//if not - look for city code
		else{
			if(city_code != "0"){
				show_forecast(1,'0',city_code,0);
			}
			//no settings - use NYC as a default city
			else{
				if(city_code=="0" && zip_code=="0"){
					zip_code="10001";
					show_forecast(1,zip_code,'0',1);
				}
			}
		}
	}
	
	//---------------------------------------------
	//show forecast
	//---------------------------------------------
	
	var close_setting_flag = 1; //tells us if the settings win should be closed now - 1 means close it , 0 means keep  it open , this parametes is checked while parsing the rss
	function show_forecast(close_setttings_flag_arg,	
							zip_code_arg,
							city_code_arg,
							save_location_flag){
		//prepare the url 					
		var url ="";
		if(zip_code_arg != '0'){
			
			url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode="+zip_code_arg+"&UnitType="+degree+"&ForecastType=1";
			
			//fix bug of 4 digits
			var temp_code = zip_code_arg.toString();
			if(temp_code.length==4){
				url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode=0"+zip_code_arg+"&UnitType="+degree+"&ForecastType=1";
			}
		}
		else if(city_code_arg != '0'){
			url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&CityCode="+city_code_arg+"&UnitType="+degree+"&ForecastType=1";
		}
		else{
			if(zip_code != "0"){
				url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&UnitType="+degree+"&ForecastType=1";
				//fix bug of 4 digits
				if(zip_code.length==4){
					url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&ZipCode=0"+zip_code+"&UnitType="+degree+"&ForecastType=1";
				}
			}
			else{
				url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=4&PartnerId="+g_partner_id+"&CityCode="+city_code+"&UnitType="+degree+"&ForecastType=1";
			}
		}
		
		//save location codes
		if(save_location_flag){
			if(zip_code_arg != '0'){
				zip_code = zip_code_arg;
				city_code = "0";
				prefs__MODULE_ID__.set("zip_code", zip_code);
				prefs__MODULE_ID__.set("city_code", "0");
			
			}
			else if (city_code_arg != '0'){
				city_code = city_code_arg;
				zip_code = "0";
				prefs__MODULE_ID__.set("city_code", city_code);
				prefs__MODULE_ID__.set("zip_code", "0");
			}
		}
							
		//setting window close flag
		close_setting_flag = close_setttings_flag_arg;
		
		//show loading forecast message
		cur_loading_str 	= 	"weather details";
		stop_loading		=	0;
		showLoadingMessage();
				
		//fetch forecast
		cur_action 			= "FORECAST";
		cur_url 			= url;
		
		//fix bug of 4 digits
		if(zip_code_arg.length==4 || zip_code_arg.toString().length==4){
			zip_code = "0" + zip_code_arg;
		}
			
		//update gui with degree type
		_IG_FetchXmlContent(url,parseRSS_Forecast);
	}
	
	//---------------------------------------------
	//search for location - user enters his city name or zip code
	//---------------------------------------------
	
	function search_city_click(){
		
		//check if input box is empty
		if(_gel("city_name").value==""){
		    _gel("city_search_result").innerHTML = "Please enter a city name or zip code";
			return false;
		}
		
		//disable search button		
		_gel("search_button").innerHTML = '<a style="cursor:default; color: #999999;"  title="Please wait for search to end...">Search&raquo;</a>';
		
		//show loading message
		stop_loading		=	0;
		cur_loading_str 	= 	"locations";
		showLoadingMessage();
		
		//clear paging arrows
		_gel("city_search_result_paging").innerHTML = "&nbsp;";
		
		//get cities
		searchLocationByString(_gel("city_name").value);
		
		return false;
	}
		
	//handle enter key press - users pressed enter key while typing his location name
	function onKeyHandle(e,origin){
		
		var keynum;
		
		if(window.event){keynum = e.keyCode;}
		else if(e.which){keynum = e.which;}
		
		//enter key = 13
		if(keynum == 13){
			
			if(_gel("city_name").value==""){return false;}
			
			//check if already loading - if yes quit
			if(stop_loading==0){return false;}
			
			//disable search 
			//before starting a new search we disable the search option 
			//so the user will not be able to start a new search before the current one ends
			_gel("search_button").innerHTML = '<a style="cursor:default; color: #999999;"  title="Please wait for search to end...">Search&raquo;</a>';
			
			//clear paging arrows
			_gel("city_search_result_paging").innerHTML = "&nbsp;";
		
			//show loading message
			stop_loading		=	0;
			cur_loading_str 	= 	"locations";
			showLoadingMessage();
			
			//get cities
			searchLocationByString(_gel("city_name").value);
			
			return false;
		}
		
		return true;
	}
	
	//---------------------------------------------
	// Loading text animation
	//---------------------------------------------
	
	//loading cities message - this is just a simple text  animation
	function liveWeatherLoadingMessage(){
		var temp_str = "";
		if(live_stop_loading==0){
			if(live_is_loading==0) temp_str = "&nbsp;" + ".";
			if(live_is_loading==1) temp_str = "&nbsp;" + "..";
			if(live_is_loading==2) temp_str = "&nbsp;" + "...";
			if(live_is_loading==3) temp_str = "&nbsp;" + "";
			live_is_loading++;
			live_is_loading = live_is_loading%4;
			_gel("day_1_temperature_live").innerHTML = temp_str;
			setTimeout(liveWeatherLoadingMessage,300);
		}
		else
			live_is_loading=0;
	}
	
	//loading cities message - this is just a simple text  animation
	function showLoadingMessage(){
		
		if(stop_loading==0){
			if(is_loading==0) my_str = "&nbsp;" + cur_loading_str + ".";
			if(is_loading==1) my_str = "&nbsp;" + cur_loading_str + "..";
			if(is_loading==2) my_str = "&nbsp;" + cur_loading_str + "...";
			if(is_loading==3) my_str = "&nbsp;" + cur_loading_str + "";
			is_loading++;
			is_loading = is_loading%4;
			_gel("city_search_result").innerHTML = "Loading" + my_str;
			h_timeout = setTimeout(showLoadingMessage,500);
		}
		else
			is_loading=0;
	}
	
	//---------------------------------------------
	// settings screen (edit)
	//---------------------------------------------
	
	//opens the settings screen
	function edit_button_click(){
		_gel("city_search_result").innerHTML 		= "";
		_gel("settings_window").style.display 		= "";
		_gel("search_button").innerHTML 			= '<a style="cursor:pointer; color: #fbe317;"  onclick="search_city_click()">Search&raquo;</a>';
	}

	//closes the settings screen
	function settings_close_button_click(){
		_gel("settings_window").style.display = "none";
		
		//clear paging arrows
		_gel("city_search_result_paging").innerHTML = "&nbsp;";
		
		//clear input box
		_gel("city_name").value="";
	}
	
	//more info show
	function more_info(num){
	
		//show fade in
		fadeImage();
		
		//show  info
		_gel("more_info_text").innerHTML 		=  forecastText[num-1] + '<br /><br />' +
		'<a onmouseout="this.style.color=\'#5ea3e3\';" onmouseover="this.style.color=\'#fbe317\';"  class="style_aws_link" href="'+g_link_str+'" target="_blank" onclick="lp_trackEvent(\'forecast link\')" >Forecast</a>&nbsp;&nbsp;' +
		'<a onmouseout="this.style.color=\'#5ea3e3\';" onmouseover="this.style.color=\'#fbe317\';"  class="style_aws_link" href="'+g_link_radar+'" target="_blank" onclick="lp_trackEvent(\'radar link\')">'+g_radar_title+'</a>&nbsp;&nbsp;' +
		'<a onmouseout="this.style.color=\'#5ea3e3\';" onmouseover="this.style.color=\'#fbe317\';"  class="style_aws_link" href="'+g_link_news+'" target="_blank" onclick="lp_trackEvent(\'news link\')">News</a>&nbsp;&nbsp;' +
		'<a onmouseout="this.style.color=\'#5ea3e3\';" onmouseover="this.style.color=\'#fbe317\';"  class="style_aws_link" href="'+g_link_cameras+'" target="_blank" onclick="lp_trackEvent(\'cameras link\')">Cameras</a>';
		_gel("more_info_img").src 				= _gel("day_"+(num)+"_img").src;
		_gel("more_info_hi").innerHTML 			= "&nbsp;" + _gel("day_"+ num +"_temperature_hi").innerHTML + "&deg;&nbsp;/&nbsp;";
		_gel("more_info_lo").innerHTML 			= _gel("day_"+ num +"_temperature_lo").innerHTML + "&deg;";
		_gel("more_info_date").innerHTML 		= arrDate[num-1]; 
		
		_gel("more_info_window").style.left = lp_getAbsoluteLeft("mainBackground")+15+"px";
		_gel("more_info_window").style.top 	= lp_getAbsoluteTop("mainBackground")+15+"px";
		_gel("more_info_window").style.display 	= "";
		
	}
	
	function more_info_close_button_click(){
		_gel("more_info_window").style.display = "none";
	}
	
	//---------------------------------------------
	//fade images in & out 
	//---------------------------------------------
	
	var fade_steps = 0;
	var is_inside  = 0;
	
	function enableFadeAgain(){
		fade_steps=0;
	}
	
	function fadeImage(){
		
		if(fade_steps<0){
			setTimeout(enableFadeAgain,1000);
			return;
		}
		
		//semaphore
		if(is_inside==1)
			setTimeout(fadeImage,50);
		else
			is_inside=1;
	
		//fade out
		if(fade_steps<=10){
			
			//main table
			var cur_image = _gel("main_table");
			var object = cur_image.style;
			
			object.opacity			= 0;
			object.MozOpacity		= 0;
			object.KhtmlOpacity		= 0;
			object.filter = "alpha(opacity=0)";
			
			//more info window
			cur_image = _gel("more_info_window");
			object = cur_image.style;
						
			object.opacity			= 0;
			object.MozOpacity		= 0;
			object.KhtmlOpacity		= 0;
			object.filter = "alpha(opacity=0)";

			fade_steps=11;
			setTimeout(fadeImage,70);
		}
		
		//fade in
		if(fade_steps>10 && fade_steps!=20){
			
			var cur_image = _gel("more_info_window");
			var object = cur_image.style;
			var temp_opacity		= (fade_steps-10)*10;
			
			object.opacity			= temp_opacity/100;
			object.MozOpacity		= temp_opacity/100;
			object.KhtmlOpacity		= temp_opacity/100;
			object.filter = "alpha(opacity=" + temp_opacity + ")";
			
			fade_steps=fade_steps+1;
			setTimeout(fadeImage,90);
		}
		
		//exit fade
		if(fade_steps==20){
			//more info
			var cur_image = _gel("more_info_window");
			var object = cur_image.style;
			object.opacity			= 100;
			object.MozOpacity		= 100;
			object.KhtmlOpacity		= 100;
			object.filter = "alpha(opacity=100)";
			
			//main table
			cur_image = _gel("main_table");
			object = cur_image.style;
			object.opacity			= 100;
			object.MozOpacity		= 100;
			object.KhtmlOpacity		= 100;
			object.filter = "alpha(opacity=100)";
			
			//reset
			fade_steps=-1;
		}
		
		//semaphore
		is_inside=0;
	}
	
	//---------------------------------------------
	// degree type Fer or Cel 
	//---------------------------------------------
	
	function degree_change(type){
	
		var old_deg = degree;
		if(type=='c') degree = 1;
		if(type=='f') degree = 0;
		
		//save current value
		prefs__MODULE_ID__.set("degree_unit_type", degree);
		
		if(cur_action=="SEARCH_CITY" && _gel("city_name").value!=""){
			
			//show loading message
			stop_loading		= 0;
			cur_loading_str 	= "locations";
			showLoadingMessage();
			
			//clear paging arrows
			_gel("city_search_result_paging").innerHTML = "&nbsp;";
		
			//get cities
			searchLocationByString(_gel("city_name").value);
		}
		else{
			show_forecast(0,"0","0",0);
		}
		
		//update gui with degree type
		if(degree==0){
			_gel("set_deg_type_1").innerHTML = "&deg;&nbsp;F";
			_gel("set_deg_type_2").innerHTML = "&deg;&nbsp;F";
		}
		if(degree==1){
			_gel("set_deg_type_1").innerHTML = "&deg;&nbsp;C";
			_gel("set_deg_type_2").innerHTML = "&deg;&nbsp;C";
		}
	} 

	//---------------------------------------------
	// search for locations
	//---------------------------------------------
	
	var temp_str = "";
	function searchLocationByString(str){
		
		//clear pagin cursor on new search
		if(temp_str!=str){list_cursor = 0;}
		temp_str = str;
		
		//search for locations
		str 				= escape(str);
		cur_url 			= "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId="+g_partner_id+"&SearchString=" + str;
		cur_action 			= "SEARCH_CITY";
		
		_IG_FetchXmlContent(cur_url,parseRSS_Locations);
	}
	
	
	
	//---------------------------------------------
	// Live weather - get current temperature
	//---------------------------------------------
	
	function getLiveWeather(){
		
		var cur_live_url = "";
			
		//set url with the correct city code or zip code
		if(city_code!="0"){
			cur_live_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId="+g_partner_id+"&citycode=" + city_code + "&unittype=" + degree;
		}
		else if (zip_code!="0"){
			cur_live_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=103&PartnerId="+g_partner_id+"&zipcode=" + zip_code + "&unittype=" + degree;
		}
		
		//start the loading text animation
		live_stop_loading = 0;
		liveWeatherLoadingMessage();
		
		//fetch data
		_IG_FetchXmlContent(cur_live_url,parseRSS_LiveWeather);
	}

	function parseRSS_LiveWeather(response) {
		
		try{
			//clear loading message
			live_stop_loading=1;
			
			if (response == null || typeof(response) != "object") {return;}
			if(response.firstChild == null){return;}
			
			var itemList = response.getElementsByTagName("condition");
			
			if(itemList.item(0)){
				_gel("day_1_temperature_live").innerHTML = itemList.item(0).getAttribute("temp") + "&deg;";
			}
		}
		catch(e){}
	}	
	
	//---------------------------------------------
	//aws new links - prepare
	//---------------------------------------------
	
	var links_fetching_flag = 0; //this var is a semafore that make sure we do no override the fetch operations
	var g_radar_title = "Radar";
	
	function getAwsLinks(){
	
		if(city_code!="0"){g_radar_title = "Satellite";}
		else{g_radar_title = "Radar";}
	
	    _gel("aws_link_forecast").innerHTML = '<span id="aws_link_forecast_dot"><b>&bull;</b></span>&nbsp;<a onmouseout="_gel(\'aws_link_forecast_dot\').style.color=\'#5ea3e3\';" onmouseover="_gel(\'aws_link_forecast_dot\').style.color=\'#fbe317\';" class="style_aws_link" href="http://www.weatherbug.com/?zcode='+g_zcode+'" target="_blank" onclick="lp_trackEvent(\'forecast link\')">Forecast</a><br />';
	    _gel("aws_link_radar").innerHTML 	= '<span id="aws_link_radar_dot"><b>&bull;</b></span>&nbsp;<a onmouseout="_gel(\'aws_link_radar_dot\').style.color=\'#5ea3e3\';" onmouseover="_gel(\'aws_link_radar_dot\').style.color=\'#fbe317\';" class="style_aws_link" href="http://www.weatherbug.com/?zcode='+g_zcode+'" target="_blank" onclick="lp_trackEvent(\'radar link\')">'+g_radar_title+'</a><br />';
	    _gel("aws_link_news").innerHTML 	= '<span id="aws_link_news_dot"><b>&bull;</b></span>&nbsp;<a onmouseout="_gel(\'aws_link_news_dot\').style.color=\'#5ea3e3\';" onmouseover="_gel(\'aws_link_news_dot\').style.color=\'#fbe317\';"  class="style_aws_link" href="http://www.weatherbug.com/?zcode='+g_zcode+'" target="_blank" onclick="lp_trackEvent(\'news link\')">News</a><br/>';
	    _gel("aws_link_cameras").innerHTML 	= '<span id="aws_link_cameras_dot"><b>&bull;</b></span>&nbsp;<a onmouseout="_gel(\'aws_link_cameras_dot\').style.color=\'#5ea3e3\';" onmouseover="_gel(\'aws_link_cameras_dot\').style.color=\'#fbe317\';" class="style_aws_link" href="http://www.weatherbug.com/?zcode='+g_zcode+'" target="_blank" onclick="lp_trackEvent(\'cameras link\')">Cameras</a>';
		_gel("alert_td").innerHTML 			= '&nbsp;';
		
		getAwsLinks_Forecast();
		getAwsLinks_Cameras();
		getAwsLinks_Radar();
		getAwsLinks_News();
		getAwsWeatherAlerts();
	}
	
	//---------------------------------------------
	//aws new links - forecast 
	//---------------------------------------------
	
	function getAwsLinks_Forecast(){
		
		var cur_url = "";
		
		//set url with the correct city code or zip code
		if(city_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&CityCode="+city_code+"&LinkName=forecast_sevenday&Zcode="+g_zcode;
		}
		else if (zip_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&LinkName=forecast_sevenday&Zcode="+g_zcode;
		}
		
		//fetch data
		_IG_FetchXmlContent(cur_url,parseRSS_AWS_FORECASTS);
	}
	
	function parseRSS_AWS_FORECASTS(response) {
		
		try{
			if (response == null || typeof(response) != "object") {return;}
			if(response.firstChild == null){return;}
			
			var itemList = response.getElementsByTagName("aws:Link");
			if(itemList.length==0){itemList = response.getElementsByTagName("Link");}
			
			//check if we have any items
			if(itemList.length!=0){
				if(itemList[0].getAttribute("linkname")=="forecast_sevenday"){
					//update the link on the main screen
					_gel("aws_link_forecast").innerHTML = '<span id="aws_link_forecast_dot"><b>&bull;</b></span>&nbsp;<a onmouseout="_gel(\'aws_link_forecast_dot\').style.color=\'#5ea3e3\';" onmouseover="_gel(\'aws_link_forecast_dot\').style.color=\'#fbe317\';" class="style_aws_link" href="' + itemList[0].getAttribute("url") + '" target="_blank">Forecast</a><br />';
					
					//update the more link on the main screen
					_gel("more_info_1").innerHTML = '<a class="style8" target="_blank" href="' + itemList[0].getAttribute("url") + '" style="cursor:pointer; color:#fbe317;">more...</a>';
					g_link_str = itemList[0].getAttribute("url");
				}
			}
		}
		catch(e){}
	}

	//---------------------------------------------
	//aws new links - cameras
	//---------------------------------------------
	
	function getAwsLinks_Cameras(){
		
		var cur_url = "";
		
		//set url with the correct city code or zip code
		if(city_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&CityCode="+city_code+"&LinkName=cameras_local&Zcode="+g_zcode;
		}
		else if (zip_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&LinkName=cameras_local&Zcode="+g_zcode;
		}
		
		_IG_FetchXmlContent(cur_url,parseRSS_AWS_CAMERAS);
	}
	
	var g_link_cameras="http://www.weatherbug.com/?zcode="+g_zcode;
	function parseRSS_AWS_CAMERAS(response) {
		
		try{
			if (response == null || typeof(response) != "object") {return;}
			if(response.firstChild == null){return;}
			
			var itemList = response.getElementsByTagName("aws:Link");
			if(itemList.length==0){itemList = response.getElementsByTagName("Link");}
			
			//check if we have any items
			if(itemList.length!=0){
				if(itemList[0].getAttribute("linkname")=="cameras_local"){
					_gel("aws_link_cameras").innerHTML = '<span id="aws_link_cameras_dot"><b>&bull;</b></span>&nbsp;<a onmouseout="_gel(\'aws_link_cameras_dot\').style.color=\'#5ea3e3\';" onmouseover="_gel(\'aws_link_cameras_dot\').style.color=\'#fbe317\';" class="style_aws_link" href="' + itemList[0].getAttribute("url") + '" target="_blank">Cameras</a><br />';
					g_link_cameras = itemList[0].getAttribute("url");
				}
			}
		}
		catch(e){}
	}
	
	//---------------------------------------------
	//aws new links - Radar
	//---------------------------------------------
	
	function getAwsLinks_Radar(){
		
		var cur_url = "";
		
		//set url with the correct city code or zip code
		if(city_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&CityCode="+city_code+"&LinkName=maps_doppler&Zcode="+g_zcode;
		}
		else if (zip_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&LinkName=maps_doppler&Zcode="+g_zcode;
		}
		
		//fetch data
		_IG_FetchXmlContent(cur_url,parseRSS_AWS_RADAR);
	}
	
	var g_link_radar="http://www.weatherbug.com/?zcode="+g_zcode;
	function parseRSS_AWS_RADAR(response) {
		
		try{
			if (response == null || typeof(response) != "object") {return;}
			if(response.firstChild == null){return;}
			
			var itemList = response.getElementsByTagName("aws:Link");
			if(itemList.length==0){itemList = response.getElementsByTagName("Link");}
			
			//check if we have any items
			if(itemList.length!=0){
				if(itemList[0].getAttribute("linkname")=="maps_doppler"){
					_gel("aws_link_radar").innerHTML = '<span id="aws_link_radar_dot"><b>&bull;</b></span>&nbsp;<a onmouseout="_gel(\'aws_link_radar_dot\').style.color=\'#5ea3e3\';" onmouseover="_gel(\'aws_link_radar_dot\').style.color=\'#fbe317\';" class="style_aws_link" href="' + itemList[0].getAttribute("url") + '" target="_blank">'+g_radar_title+'</a><br />';
					g_link_radar=itemList[0].getAttribute("url");
				}
			}
		}
		catch(e){}
	}

	//---------------------------------------------
	//aws new links - News
	//---------------------------------------------	

	function getAwsLinks_News(){
		
		var cur_url = "";
		
		//set url with the correct city code or zip code
		if(city_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&CityCode="+city_code+"&LinkName=news_topstories&Zcode="+g_zcode;
		}
		else if (zip_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&LinkName=news_topstories&Zcode="+g_zcode;
		}
		
		//fetch data
		_IG_FetchXmlContent(cur_url,parseRSS_AWS_NEWS);
	}
	
	var g_link_news="http://www.weatherbug.com/?zcode="+g_zcode;
	function parseRSS_AWS_NEWS(response) {
		
		try{
			if (response == null || typeof(response) != "object") {return;}
			if(response.firstChild == null){return;}
			
			var itemList = response.getElementsByTagName("aws:Link");
			if(itemList.length==0){itemList = response.getElementsByTagName("Link");}
			
			//check if we have any items
			if(itemList.length!=0){
				if(itemList[0].getAttribute("linkname")=="news_topstories"){
					_gel("aws_link_news").innerHTML = '<span id="aws_link_news_dot"><b>&bull;</b></span>&nbsp;<a onmouseout="_gel(\'aws_link_news_dot\').style.color=\'#5ea3e3\';" onmouseover="_gel(\'aws_link_news_dot\').style.color=\'#fbe317\';"  class="style_aws_link" href="' + itemList[0].getAttribute("url") + '" target="_blank">News</a><br />';
					g_link_news = itemList[0].getAttribute("url");
				}
			}
		}
		catch(e){}
	}
		
	//---------------------------------------------
	//aws new links - WEATHER ALERTS
	//---------------------------------------------
	function getAwsWeatherAlerts(){
		
		var cur_url = "";
		
		//set url with the correct  zip code - US ONLY
		if (zip_code!="0"){
			cur_url = "http://datafeed.weatherbug.com/getxml.aspx?RequestType=6&PartnerId="+g_partner_id+"&ZipCode="+ zip_code;
			_IG_FetchXmlContent(cur_url,parseRSS_AWS_ALERTS);
		}
	}
	
	function parseRSS_AWS_ALERTS(response) {
		
		if (response == null || typeof(response) != "object") {return;}
		if(response.firstChild == null){return;}
		
		var itemList = response.getElementsByTagName("aws:alert");
		if(itemList.length==0){itemList = response.getElementsByTagName("alert");}
		
		//check if we have any items
		if(itemList.length!=0){
			//we have alerts for this place - fetch link
			var cur_url = "http://datafeed.weatherbug.com/GetXml.aspx?RequestType=23&PartnerId="+g_partner_id+"&ZipCode="+zip_code+"&LinkName=severeweather_localalerts&Zcode="+g_zcode;
			//fetch data
			_IG_FetchXmlContent(cur_url,parseRSS_AWS_ALERTS_LINK);
		}
	}
	
	function parseRSS_AWS_ALERTS_LINK(response) {
		
		if (response == null || typeof(response) != "object") {return;}
		if(response.firstChild == null){return;}
		
		var itemList = response.getElementsByTagName("aws:Link");
		if(itemList.length==0){itemList = response.getElementsByTagName("Link");}
		
		//check if we have any items
		if(itemList.length!=0){
			if(itemList[0].getAttribute("linkname")=="severeweather_localalerts"){
				//_gel("alert_td").innerHTML = '<a class="style_aws_alert" href="' + itemList[0].getAttribute("url") + '" title="Weather alert - click for more details" target="_top">WEATHER ALERT!</a>';
				_gel("alert_td").innerHTML = '<div style="background-color:#FF0000; text-align:center;"><a class="style_aws_alert" style="color:#FFFFFF;" href="' + itemList[0].getAttribute("url") + '" title="Weather alert - click for more details" target="_top">WEATHER ALERT! - CLICK HERE</a></div>';
			}
		}
	}	
	
	//Error handling
	function setErrorMsg(){
		
		if(cur_action=="SEARCH_CITY"){
			stop_loading=1;
		    _gel("city_search_result").innerHTML = "Search ended with no results, or an error has occurred, please check your input and try again.";
			_gel("search_button").innerHTML = '<a style="cursor:pointer; color: #fbe317;"  onclick="search_city_click()">Search&raquo;</a>';
			return;
		}
			
		stop_loading=1;
		settings_close_button_click();
		
		forecastText[0] = "&nbsp;";
		forecastText[1] = "&nbsp;";
		forecastText[2] = "&nbsp;";
		forecastText[3] = "&nbsp;";
		forecastText[4] = "&nbsp;";
		forecastText[5] = "&nbsp;";
		 
		_gel("city_name_text").innerHTML 	= "Unavailable";
	    _gel("city_name_text").title 		= "Error Fetching Data";
	    _gel("day_1_forecast").innerHTML 	= "Please Try again later";
		
		_gel("day_1_img").src = _IG_GetImageUrl(images_url+"temp_icon_new.gif");
		_gel("day_2_img").src = _IG_GetImageUrl(images_url+"temp_icon_new.gif");
	    _gel("day_3_img").src = _IG_GetImageUrl(images_url+"temp_icon_new.gif");
	    _gel("day_4_img").src = _IG_GetImageUrl(images_url+"temp_icon_new.gif");
		_gel("more_info_img").src = _IG_GetImageUrl(images_url+"temp_icon_new.gif");
		
		_gel("day_1_temperature_live").innerHTML 	= "&nbsp;";
		_gel("day_1_temperature_hi").innerHTML 		= "&nbsp;";
		_gel("day_1_temperature_lo").innerHTML 		= "&nbsp;";
		
		_gel("day_2_temperature_hi").innerHTML = "&nbsp;";
		_gel("day_2_temperature_lo").innerHTML = "&nbsp;";
		_gel("day_3_temperature_hi").innerHTML = "&nbsp;";
		_gel("day_3_temperature_lo").innerHTML = "&nbsp;";
		_gel("day_4_temperature_hi").innerHTML = "&nbsp;";
		_gel("day_4_temperature_lo").innerHTML = "&nbsp;";
		
		_gel("day_2_name").innerHTML = "--";
		_gel("day_3_name").innerHTML = "--";
		_gel("day_4_name").innerHTML = "--";
		
	    	_gel("more_info_text").innerHTML 	=  "Data unavailable, plesae Try again later";
		_gel("more_info_img").src 			= _IG_GetImageUrl(images_url+"temp_icon_new.gif");
		_gel("more_info_hi").innerHTML 		= "&nbsp;";
		_gel("more_info_lo").innerHTML 		= "&nbsp;";
		_gel("more_info_date").innerHTML 	= "&nbsp;";
		
		_gel("more_info_1").innerHTML = "<a class='style8' target='_blank' href='http://www.weatherbug.com/?zcode="+g_zcode+"' style='cursor:pointer; color:#fbe317;'>more...</a>";
	}	
	
	//---------------------------------------------
	// parse RSS Locations
	//---------------------------------------------
	var list_cursor=0;
	var current_m=0;
	function parseRSS_Locations (response){
		
		if (response == null || typeof(response) != "object") {
			setErrorMsg();
			return;
		}
		
		if(response.firstChild == null){
			setErrorMsg();
			return;
		}
		
		//clear loading message
		stop_loading=1;
		
		// Get Location
		var itemList = response.getElementsByTagName("aws:location");
		if(itemList.length==0){itemList = response.getElementsByTagName("location");}
		
		var html_str = "";
		
		for (var m=0; m < itemList.length; m++) { 
			//up to 5 cities in results page
			if(m<5+(5*list_cursor) && m>=(5*list_cursor)){
				var node_4 = itemList.item(m);
				
				var cur_city_str 	= "&bull;&nbsp;";
				var cur_city_code 	= "";
				var cur_zip_code 	= "";
				
				//city name
				if(node_4.getAttribute("city")!=""){
					if(node_4.getAttribute("city").length>34){
						cur_city_str = cur_city_str + node_4.getAttribute("city").substring(0,33) + ".";
						cur_city_name = cur_city_str + node_4.getAttribute("city").substring(0,33);
					}
					else{
						cur_city_str = cur_city_str + node_4.getAttribute("city");
						cur_city_name = cur_city_str + node_4.getAttribute("city");
					}
				}
				
				//country name
				if(node_4.getAttribute("country")!=""){
					cur_city_str = cur_city_str + "&nbsp;&nbsp;("+node_4.getAttribute("country")+ ")";
				}
				
				//state name
				if(node_4.getAttribute("state")!=""){
					cur_city_str = cur_city_str + "&nbsp;," + node_4.getAttribute("state");
				}
				
				//zip code
				if(node_4.getAttribute("zipcode")!=""){
					cur_zip_code = node_4.getAttribute("zipcode");
				}
				
				//city code
				if(node_4.getAttribute("citycode")!=""){
					cur_city_code = node_4.getAttribute("citycode");
				}
				
				var my_link = "";
				if(cur_zip_code!=""){
					cur_city_str = "<a id='city_link_" + m + "' onMouseOut=city_mouse_out(" + m + "); onMouseOver=city_mouse_over(" + m + "); onclick=show_forecast(1,'"+cur_zip_code+"','0',1); class='style7_a' >" + cur_city_str + "</a>";
				}
				else if(cur_city_code!=""){
					cur_city_str = "<a id='city_link_" + m + "' onMouseOut=city_mouse_out(" + m + "); onMouseOver=city_mouse_over(" + m + "); onclick=show_forecast(1,'0','"+cur_city_code+"',1); class='style7_a'>" + cur_city_str + "</a>";
				}
				
				//update the inner html code
				html_str = html_str + cur_city_str + "<br />";
				
				//update cursor for paging
				current_m = m;
			}
		}
		
		//paging 
		var str_paging = "";
		if(current_m>=5 && current_m+1<itemList.length){
			str_paging = "<span style='cursor:pointer;' class='style7_a' onmouseover='this.style.color=\"#fbe317\";' onmouseout='this.style.color=\"#ffffff\";'  onclick='locationPage(0);'>&laquo;back</span>&nbsp;|&nbsp;<span style='cursor:pointer;' onmouseover='this.style.color=\"#fbe317\";' onmouseout='this.style.color=\"#ffffff\";' class='style7_a' onclick='locationPage(1);'>next&raquo;</span>";
		}
		else if(current_m>=5){
			str_paging = "<span style='cursor:pointer;' class='style7_a' onmouseover='this.style.color=\"#fbe317\";' onmouseout='this.style.color=\"#ffffff\";' style='cursor:pointer;' onclick='locationPage(0);'>&laquo;back</span>&nbsp;|&nbsp;<span style='cursor:pointer;' class='style7_gray'>next&raquo;</span>";
		}
		else if(current_m+1<itemList.length){
			str_paging = "<span style='cursor:pointer;' class='style7_gray'>&laquo;back</span>&nbsp;|&nbsp;<span class='style7_a' onmouseover='this.style.color=\"#fbe317\";' onmouseout='this.style.color=\"#ffffff\";' style='cursor:pointer;' onclick='locationPage(1);'>next&raquo;</span>";
		}
		
		//update html
		_gel("city_search_result").innerHTML 		= html_str;
		_gel("city_search_result_paging").innerHTML = str_paging;
		
		//enable search button again
		_gel("search_button").innerHTML = '<a style="cursor:pointer; color: #fbe317;"  onclick="search_city_click()">Search&raquo;</a>';
		
		//test - load the single location found -  AUTOMATICALLY
		if(itemList.length==1){
			_gel("city_link_0").onclick();
		}
		
	}
	
	//paging
	function locationPage(num){
	
		if(num){
			list_cursor++;
		}
		else{
			list_cursor--;
		}
		
		//clear paging arrows
		_gel("city_search_result_paging").innerHTML = "&nbsp;";
		
		search_city_click();
	}
	
	//---------------------------------------------
	// parse RSS Forecast
	//---------------------------------------------
	
	function parseRSS_Forecast(response) {
		
		if (response == null || typeof(response) != "object") {
			setErrorMsg();
			return;
		}
		
		if(response.firstChild == null){
			setErrorMsg();
			return;
		}
		
		//clear loading message
		stop_loading=1;
		
		//close edit screen
		if(close_setting_flag==1)
			settings_close_button_click();
		else
		    _gel("city_search_result").innerHTML = "Data Loaded Successfully";
		
		//--------------------------------------------
		// Get Location name - city and state
		//--------------------------------------------
		
		var itemList_2 = response.getElementsByTagName("aws:location");
		if(itemList_2.length==0){itemList_2 = response.getElementsByTagName("location");}
		
		var state_name_str 	= "";
		var city_name_str 	= "";
		for (var k=0; k < itemList_2.length; k++) { 
			
			var nodeList_2 = itemList_2.item(k).childNodes;
			
			for (var l=0; l < nodeList_2.length; l++) {
				
				var node_2 = nodeList_2.item(l);
				
				//city name
				if(node_2.nodeName=="aws:city" || node_2.nodeName=="city"){
					if(node_2.firstChild.nodeValue.length>16){
						_gel("city_name_text").innerHTML = node_2.firstChild.nodeValue.substring(0,15);
					}
					else{
						_gel("city_name_text").innerHTML = node_2.firstChild.nodeValue;
					}
					city_name_str = node_2.firstChild.nodeValue + ", ";
				}
				
				//state name or country name
				if(node_2.nodeName=="aws:state" || node_2.nodeName=="state" ||node_2.nodeName=="aws:country" ||node_2.nodeName=="country"){
					state_name_str = node_2.firstChild.nodeValue;
				}
			}
		}
		
		//update city title
		_gel("city_name_text").title = 	city_name_str + state_name_str;
		
		//--------------------------------------------		
		// Get Forecast
		//--------------------------------------------
		
		//temp values
		var tmp_name  	=	"";
		var tmp_image 	=	"";
		var tmp_hi 		=	"";
		var tmp_low 	=	"";
		var tmp_desc	= 	""
		var cursor 		= 0;
			
		var itemList = response.getElementsByTagName("aws:forecast");
		if(itemList.length == 0){itemList = response.getElementsByTagName("forecast");}
		for (var i=0; i < itemList.length; i++) { 
			
			//for each node	
			var nodeList = itemList.item(i).childNodes;
			for (var j=0; j < nodeList.length; j++) {
				
				var node = nodeList.item(j);
				if (node.firstChild) {
    				//day name
    				if(node.nodeName=="aws:title" || node.nodeName=="title"){tmp_name = node.firstChild.nodeValue;}

    				//day image
    				if(node.nodeName=="aws:image" || node.nodeName=="image"){tmp_image = node.firstChild.nodeValue;}

    				//day hi temp
    				if(node.nodeName=="aws:high" || node.nodeName=="high")	{tmp_hi = node.firstChild.nodeValue;}

    				//day low temp
    				if(node.nodeName=="aws:low" || node.nodeName=="low")	{tmp_low = node.firstChild.nodeValue;}

    				//day forecast text
    				if(node.nodeName=="aws:prediction" || node.nodeName=="prediction"){
    					tmp_desc = node.firstChild.nodeValue;
    					if(i==0){
    						if(tmp_desc.length>56)
    							_gel("day_1_forecast").innerHTML = tmp_desc.substring(0,56) + ".";
    						else
    							_gel("day_1_forecast").innerHTML = tmp_desc;
    					}
    				}
    			}
				
			}
			
			//update gui - there are differences between us location and rest of the world
			if(tmp_hi != "--" && tmp_low!="--"){
				if(_gel("day_"+(i+1-cursor)+"_name"))				_gel("day_"+(i+1-cursor)+"_name").innerHTML 			= tmp_name.substring(0,3);
				if(_gel("day_"+(i+1-cursor)+"_img")) 				_gel("day_"+(i+1-cursor)+"_img").src 					= tmp_image;
				if(_gel("day_"+(i+1-cursor)+"_temperature_hi")) 	_gel("day_"+(i+1-cursor)+"_temperature_hi").innerHTML	= tmp_hi;
				if(_gel("day_"+(i+1-cursor)+"_temperature_lo")) 	_gel("day_"+(i+1-cursor)+"_temperature_lo").innerHTML 	= tmp_low;
				forecastText[i-cursor] 	= tmp_desc;
				arrDate[i-cursor] 		= tmp_name;
			}
			else if(tmp_hi == "--" && tmp_low!="--"){
				if(i==0){
					_gel("day_1_img").src 					= tmp_image;
					_gel("day_1_temperature_hi").innerHTML	= tmp_hi;
					_gel("day_1_temperature_lo").innerHTML 	= tmp_low;
					forecastText[0] = tmp_desc;
					arrDate[0] 		= tmp_name;
				}
				else{
					cursor++;
					if(_gel("day_"+(i+1-cursor)+"_temperature_lo")) _gel("day_"+(i+1-cursor)+"_temperature_lo").innerHTML 	= tmp_low;
				}
			}
			else if(tmp_hi != "--" && tmp_low=="--"){
				if(_gel("day_"+(i+1-cursor)+"_name"))				_gel("day_"+(i+1-cursor)+"_name").innerHTML 			= tmp_name.substring(0,3);
				if(_gel("day_"+(i+1-cursor)+"_img")) 				_gel("day_"+(i+1-cursor)+"_img").src 					= tmp_image;
				if(_gel("day_"+(i+1-cursor)+"_temperature_hi")) 	_gel("day_"+(i+1-cursor)+"_temperature_hi").innerHTML	= tmp_hi;
				if(_gel("day_"+(i+1-cursor)+"_temperature_lo")) 	_gel("day_"+(i+1-cursor)+"_temperature_lo").innerHTML 	= tmp_low;
				forecastText[i-cursor]  = tmp_desc;
				arrDate[i-cursor] 		= tmp_name;
			}
		}
		
		//update gui with degree type
		if(degree==0){
			_gel("set_deg_type_1").innerHTML = "&deg;&nbsp;F";
			_gel("set_deg_type_2").innerHTML = "&deg;&nbsp;F";
		}
		if(degree==1){
			_gel("set_deg_type_1").innerHTML = "&deg;&nbsp;C";
			_gel("set_deg_type_2").innerHTML = "&deg;&nbsp;C";
		}
		
		//enable search button again (on the settings screen)
		_gel("search_button").innerHTML = '<a style="cursor:pointer; color: #fbe317;"  onclick="search_city_click()">Search&raquo;</a>';
	
		//call live weather - > try catch 
		try{getLiveWeather();}
		catch(e){}
		
		//get links
		getAwsLinks();
	}

	//link mouse over - makes the hover link yellowed
	function city_mouse_over(num){
		_gel("city_link_"+num).style.color = "#fbe317";
	}

	//link mouse out
	function city_mouse_out(num){
		_gel("city_link_"+num).style.color = "#FFFFFF";
	}

</script>
<div id="menu_div">
</div>
<center>
<div id="all_other_elements">
<table id="mainBackground" width="270" height="207" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td width="19">&nbsp;</td>
		<td width="230">
			<table id="main_table" width="230" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td height="13"><span class="style1">&nbsp;</span></td>
				</tr>
				<tr>
					<td height="17">
						<table width="230" border="0" cellpadding="0" cellspacing="0">
							<tr>
<td width="165" align="left"><span class="style3" style="cursor:default" id="city_name_text">&nbsp;Loading...</span><span align="left" class="style3" id="state_name_text">&nbsp;</span><span align="left" class="style3">&nbsp;</span><span align="left" class="style4" id="edit_button" onclick="javascript:edit_button_click(); lp_trackEvent('edit location');" style="cursor:pointer;">edit</span></td>
								<td width="65" style="font-size:12px" id="no_line"><a href="http://www.weatherbug.com/?zcode=z6070" target="_blank">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a></td>
							</tr>
						</table>
					</td>	
				</tr>
				<tr>
					<td height="17" class="style_aws_alert" id="alert_td" valign="top">&nbsp;</td>
				</tr>
				<tr>
					<td height="57">
						<table  width="230" height="57" border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td width="50" valign="top" onclick="more_info(1); lp_trackEvent('today icon');" style="cursor:pointer;"><img id="day_1_img" width="50" height="42" /></td>
								<td width="10">&nbsp;</td>
<td width="70" valign="top"><span class="style5">Hi:&nbsp;</span><span class="style5" id="day_1_temperature_hi">&nbsp;</span><span class="style5" id="set_deg_type_1">&deg; F</span><br /><span class="style6" id="day_1_temperature_live">&nbsp;</span><br /><span class="style5">Lo:&nbsp;<span class="style5" id="day_1_temperature_lo">&nbsp;</span><span class="style5" id="set_deg_type_2">&deg;&nbsp;F</span></td>
								<td width="100" valign="top"><div style="width:100px; height:57px; overflow:hidden;"><span class="style7" id="day_1_forecast">Loading...</span><span class="style8">&nbsp;</span><span class="style8" id="more_info_1"><a class='style8' target='_blank' href='http://www.weatherbug.com/?zcode=z6070' style='cursor:pointer; color:#fbe317;' onclick="lp_trackEvent('today more link');">more...</a></span></div></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr><td height="12"><span class="style1">&nbsp;</span></td></tr>
				<tr>
					<td height="78">
						<table width="230" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="50" height="18"><span class="style9" id="day_2_name">--</span></td>
								<td width="10" height="18" class="style1">&nbsp;</td>
								<td width="50" height="18"><span class="style9" id="day_3_name">--</span></td>
								<td width="10" height="18" class="style1">&nbsp;</td>
								<td width="50" height="18"><span class="style9" id="day_4_name">--</span></td>
								<td width="9" height="18" class="style1">&nbsp;</td>
								<td width="51" height="18" class="style1">&nbsp;</td>
							</tr>
							<tr>
								<td width="50" height="42" onclick="more_info(2); lp_trackEvent('day 2 icon');" style="cursor:pointer;"><img id="day_2_img" width="50" height="42" /></td>
								<td width="10" height="42" class="style1">&nbsp;</td>
								<td width="50" height="42" onclick="more_info(3); lp_trackEvent('day 3 icon');" style="cursor:pointer;"><img id="day_3_img" width="50" height="42" /></td>
								<td width="10" height="42" class="style1">&nbsp;</td>
								<td width="50" height="42" onclick="more_info(4); lp_trackEvent('day 4 icon');" style="cursor:pointer;"><img id="day_4_img" width="50" height="42" /></td>
								<td width="9" height="42" class="style1">&nbsp;</td>
								<td width="51" rowspan="2" valign="top" xbgcolor=pink class="style_aws_link"><span class="style_aws_link" id="aws_link_forecast"></span><span class="style_aws_link" id="aws_link_radar"></span><span class="style_aws_link" id="aws_link_news"></span><span class="style_aws_link" id="aws_link_cameras"></span></td>
							</tr>
							<tr>
								<td width="50" height="18"><div align="center"><span class="style10" id="day_2_temperature_hi">&nbsp;</span><span class="style10">&deg;&nbsp;/&nbsp;</span><span class="style11" id="day_2_temperature_lo">&nbsp;</span><span class="style11">&deg;</span></div></td>
								<td width="10" height="18" class="style1">&nbsp;</td>
								<td width="50" height="18"><div align="center"><span class="style10" id="day_3_temperature_hi">&nbsp;</span><span class="style10">&deg;&nbsp;/&nbsp;</span><span class="style11" id="day_3_temperature_lo">&nbsp;</span><span class="style11">&deg;</span></div></td>
								<td width="10" height="18" class="style1">&nbsp;</td>
								<td width="50" height="18"><div align="center"><span class="style10" id="day_4_temperature_hi">&nbsp;</span><span class="style10">&deg;&nbsp;/&nbsp;</span><span class="style11" id="day_4_temperature_lo">&nbsp;</span><span class="style11">&deg;</span></div></td>
								<td width="9" height="18" class="style1">&nbsp;</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr><td height="13"><span class="style1">&nbsp;</span></td></tr>
			</table>
		</td>
		<td width="21">&nbsp;</td>
	</tr>
</table>

<div>
	<script type="text/javascript">
	  GA_googleFillSlot("live_weather_txt");
	</script>
</div>
<!-- settings window -->
<table id="settings_window" style="display:none; position:relative; top:-209px; left:0px;" width="240" height="180" border="0" cellpadding="0" cellspacing="0" class="whitebordertable">
	<tr>
		<td class="style1" width="5">&nbsp;</td>
		<td valign="middle">
			<table width="230" height="170" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td height="15" class="style3">Settings</td>
					<td class="style3"><div align="right"><a style="cursor:pointer;" onclick="javascript:settings_close_button_click();"><img id="btnCloseSettings" border="0" width="31" height="9" /></a></div></td>
				</tr>
				<tr>
					<td colspan="2">
						<table width="230" border="0" cellspacing="0" cellpadding="0">
							<tr>
								<td width="180" height="18" class="style7">Zip code (US only) or City (worldwide)</td>
							</tr>
							<tr>
<td width="180"><input  id="city_name" type="text" class="style12" size="16" onkeypress="onKeyHandle(event,'city_name');" /><span class="style13">&nbsp;&nbsp;</span><span class="style13" id="search_button"><a style="cursor:pointer; color: #fbe317;"  onclick="search_city_click()">Search&raquo;</a></span></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td height="12" colspan="2"><img id="imgVDiv" width="230" height="12" /></td>
				</tr>
				<tr>
					<td height="64" colspan="2" class="style7" id="city_search_result" valign="top" style="line-height:12px;">&nbsp;</td>
				</tr>
				<tr>
					<td height="14" colspan="2" class="style7" id="city_search_result_paging" align="center" valign="bottom" style="line-height:12px;">&nbsp;</td>
				</tr>
				<tr>
					<td height="12" colspan="2"><img id="imgVDiv2" width="230" height="12" /></td>
				</tr>
				<tr>
<td height="15" colspan="2" valign="top"><span class="style13">Units: </span><span class="style7"><input onclick="degree_change('f');" id="radio_f" name="radiobutton" type="radio" checked=true class="style7"/>Fahrenheit&nbsp;&nbsp;<input onclick="degree_change('c');"  name="radiobutton" id="radio_c" type="radio" class="style7" />Celsius</span></td>

				</tr>
			</table>
		</td>
		<td class="style1" width="5">&nbsp;</td>
	</tr>
</table>
<!-- more info window -->
<table id="more_info_window" style="display:none; position:absolute;" width="240" height="180" border="0" cellpadding="0" cellspacing="0" class="whitebordertable">
	<tr>
		<td class="style1" width="5">&nbsp;</td>
		<td valign="middle">
			<table width="230" height="170" border="0" align="center" cellpadding="0" cellspacing="0">
				<tr>
					<td width="230" height="1" colspan="2" class="style1">&nbsp;</td>
				</tr>
				<tr>
					<td width="199" height="26" valign="top" class="style3" id="more_info_date">&nbsp;</td>
					<td width="31" height="26" valign="top" class="style3"><div align="right"><a style="cursor:pointer;" onclick="more_info_close_button_click();"><img id="btnCloseInfo" width="31" height="9" /></a></div></td>
				</tr>
				<tr>
					<td width="230" height="140" colspan="2" valign="top">
						<table width="230" border="0" height="140" cellpadding="0" cellspacing="0" xbgcolor=red>
							<tr>
								<td width="50" valign="top"><div align="center"><img id="more_info_img" onclick="more_info_close_button_click();" style="cursor:pointer;" border=1 width="50" height="42" /><br /><span class="style17" id="more_info_hi">--&deg;</span><span id="more_info_lo" class="style19">--&deg;</span></div></td>
								<td width="10">&nbsp;</td>
								<td width="170" valign="top" class="style7" id="more_info_text">&nbsp;</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
		<td class="style1" width="5">&nbsp;</td>
	</tr>
</table>
</div>



									
</center>

<div>
	<script type="text/javascript">
        var mMENU = _IG_GetCachedUrl("http://cdn.labpixies.com/infra/js/lp_footer.js");
	    document.write('<scr'+'ipt type="text/javascript" src="'+mMENU+'"></scr'+'ipt>');
     </script>
</div>

<script type="text/javascript">
	function setImages() {
		
		_gel("mainBackground").style.background = 'transparent url'+'('+_IG_GetImageUrl("http://cdn.labpixies.com/campaigns/weather/images/background_nir.jpg")+') 0px 0px no-repeat';
		_gel("day_1_img").src 			= _IG_GetImageUrl(images_url+"temp_icon_new.gif");
		_gel("day_2_img").src 			= _IG_GetImageUrl(images_url+"temp_icon_new.gif");
		_gel("day_3_img").src 			= _IG_GetImageUrl(images_url+"temp_icon_new.gif");
		_gel("day_4_img").src 			= _IG_GetImageUrl(images_url+"temp_icon_new.gif");
		_gel("btnCloseSettings").src 	= _IG_GetImageUrl(images_url+"close.gif");
		_gel("imgVDiv").src 			= _IG_GetImageUrl(images_url+"vertical_div.gif");
		_gel("imgVDiv2").src 			= _IG_GetImageUrl(images_url+"vertical_div.gif");
		_gel("btnCloseInfo").src 		= _IG_GetImageUrl(images_url+"close.gif");
		_gel("more_info_img").src 		= _IG_GetImageUrl(images_url+"temp_icon_new.gif");
	}
   
	setImages();
	_IG_RegisterOnloadHandler(function () {
		init_module__MODULE_ID__();
		//lpgadgets.lp.menu.deploy("menu_div",{"textDirection":"ltr","lang":"en"});
		
		_IG_AdjustIFrameHeight();
	});
</script>

<!-- google analytics -->
<script type="text/javascript">
	_IG_Analytics("UA-345375-1", "/Weather");
	_IG_Analytics("UA-335767-2", "/WeatherBug");
</script>
<iframe width="1" height="1" style="width:1px; height:1px; overflow:hidden; position:absolute; visibility:hidden;" src="http://static.labpixies.com/campaigns/weather/analytics.html"></iframe>	
]]> 
</Content>
</Module>
