 /**
  * Main javascript file for observer wordpress theme
  * @author Kenlie C. Browne
  */
 
 var _megaConfig = {interval: 250, sensitivity: 4, over: addMega, timeout: 500, out: removeMega};
 
 function addMega()
 { 
	$(this).addClass("hovering"); 
 } 
	 
 function removeMega()
 { 
    $(this).removeClass("hovering"); 
 } 

/*
 * Main load function for the web page
 */
 $('document').ready(function(){
 	
	$("li.mega").hoverIntent(_megaConfig); // load the menu..
 	
	InitInputFields(); // initialize text fields
	InitEvents();

	
	if($('#cnt_media_bar').length)
	{
		RetrieveLatestMedia();
	}
	
	if($('#cnt_embeded').length)
	{
		$('#lnk_currency_converter').click(function(){
			$('#cnt_embeded').attr('src', 'http://finance.yahoo.com/currency-converter');
		});
		
		$('#lnk_eccb').click(function(){
			$('#cnt_embeded').attr('src', 'http://www.eccb-centralbank.org/');
		});
	}
	
	if($('#cnt_location_chnge').length)
	{
		$('#cnt_location_chnge').hide('fast');
	}
	
	if($('#ele_weather_body').length)
	{
		GetWeatherForcast('Antigua and Barbuda');
	}
	
	if($('#btn_forcast').length)
	{
		GetWeatherForcast($(document).getUrlParam("location").replace(/%20/g,' '));
		GetExtendedForcast($(document).getUrlParam("location").replace(/%20/g,' '));
	}
	
	if($('#cnt_news_ticker').length)
		GetNewsAggregation();
 	
	
	InitializeAdsSpaces();
 	
	
	if($('#cnt_observer_radio_current_program').length)
		GetRadioProgramming();
	
	// check to see if were on the home page..
	// by checking to see if.. the stocks table exist
	if($('#tbl_stock_quotes').length) 
	{
		GetStockQuotes(); 
		setInterval('GetStockQuotes()',15000);
	}
		
	/* Binding click events for menu links */
	BindLinkEvents();
	
	if($('#cnt_photo_gallery').length)
	{
		InitializeDailyPhotoViewer($(document).getUrlParam("display"));
		RetrieveAlbums('*');
	}
	
	if($('#post_audio_player').length)
	{
		InitPostAudioPlayer(false, null);
	}
	
 });
 
/*
 * Initialize the audio player for posts
 * @param {string} pAutoStart auto start flag
 * @param {string} pFile to be played
 */
 function InitPostAudioPlayer(pAutoStart, pFile)
 {
 	_flashvars = {skin:"./wp-content/observer_components/modieus.swf",bufferlength:20,autostart:pAutoStart,
	file:pFile,stretching:'exactfit'};
	_params = {wmode:'transparent',allowscriptaccess:'always', allowfullscreen:true};
	_attributes = {};
 	swfobject.embedSWF('./wp-content/observer_components/player.swf', "cnt_audio_player", "350", "30", "9.0.0", false, _flashvars, _params, _attributes);
	swfobject.registerObject("audio_player_inst");

 }
 
/*
 * Play the selected video
 * @param pVideoName
 */
 function PlayVideo(pVideoName)
 {
 	
	$('#spnGallery').text(pVideoName.replace(/%20/g,' '));
	
 	_flashvars = {skin:"./wp-content/observer_components/modieus.swf",bufferlength:20,
	file:'../../wp-content/uploads/media/videos/2009/10/alp_white_march_03.flv',stretching:'exactfit'};
	_params = {wmode:'transparent',allowscriptaccess:'always', allowfullscreen:true};
	_attributes = {};
 	swfobject.embedSWF('./wp-content/observer_components/player.swf', "cnt_video_player", "720", "423", "9.0.0", false, _flashvars, _params, _attributes);
 	
 }
 
/*
 * Retrieve the latest media
 * for the photo galleries, videos, and audio
 */
 function RetrieveLatestMedia()
 {
 	$.post('../../../util_scripts/ajax_main.php', {opr:'RetriveLatestMedia'}, function(data){
			
			if(data.opr_result)
			{
				for(var idx = 0; idx < data.latest_galleries.length; idx++)
				{
					var lVal = data.latest_galleries[idx];
		
					$('#drp_latestGalleries').append(
                                                 $('<option></option>').val(lVal).html(lVal)
                                        );
				}
                                
                for(var idx = 0; idx < data.latest_audio.length; idx++)
				{
					var lVal = data.latest_audio[idx];
		
					$('#drp_latestAudio').append(
                                                 $('<option></option>').val(lVal.id).html(lVal.title)
                                        );
				}
			}
			
		}, 'json');
 }
 
/*
 * Initialize text fields, insert watermarks etc.
 */
 function InitInputFields()
 {
 	if ($(".search-field").length)
		$(".search-field").Watermark("search...", "#999");
		
	if($("#city_name").length)
		$("#city_name").Watermark("city or country name...", "#999");
			
	if ($('#username').length) {
		$("#username").Watermark("enter you email address here", "#999");
	}
 }
 
/*
 * Initialize the events..
 */
 function InitEvents()
 {
 	$('#drp_latestGalleries').change(function(){
		
		if($('#drp_latestGalleries').get(0).selectedIndex == 0)
			return;
		
		document.location = 'http://antiguaobserver.com/?page_id=3584' + '&display=' + $(this).val();
	});
	
	$('#drp_latestAudio').change(function(){
		
		if($('#drp_latestAudio').get(0).selectedIndex == 0)
			return;
		
		//alert($(this).val());
		window.open($(this).val());
	});
	
	$('#drp_latestVideos').change(function(){
		
		if($('#drp_latestVideos').get(0).selectedIndex == 0)
			return;
		
		alert('play videos');
	});
	
	$('#audio_ply_lst').change(function(){
		
		if($('#audio_ply_lst').get(0).selectedIndex == 0)
			return;
		
		InitPostAudioPlayer(true, $('#audio_ply_lst :selected').val());
	});
 }
 
 function BindLinkEvents()
 {
 	$('#lnk_obradio_listen').click(function(){
		//window.open('http://www.live365.com/stations/observerradio?site=observerradio','Observer Radio 91.1 FM');
		window.open('http://www.live365.com/stations/observerradio?site=pro','Observer Radio 91.1 FM');
		return false;
	});
	
	/*
	$('#lnk_hitz_fm').click(function(){
		window.open('http://hitz919fm.antiguaobserver.com/home_page.aspx','Hitz 91.9 FM');
		return false;
	});
	*/
	
	$('#lnk_tune_in').click(function(){
		//window.open('http://www.live365.com/stations/observerradio?site=observerradio','Observer Radio 91.1 FM');
		window.open('http://www.live365.com/stations/observerradio?site=pro','Observer Radio 91.1 FM');
		return false;
	});
	
	$('#btn_subscribe').click(function(){
		//window.open('./wp-content/data/subscribe_form.pdf','Newspaper soft copy subscription');
		//return false;
	});
	
	$('#btn_forcast').click(function(){
		
		if($('#city_name').val() != '')
		{
			$('#loader_img').show();
			GetWeatherForcast($('#city_name').val());
			GetExtendedForcast($('#city_name').val());
		}
		
	});
	
	$('#lnk_weather_detail').click(function(){
		document.location = $('#lnk_weather_detail').attr('href') + '&location=' +$('#location').text();
		return false;
	});
	
	$('#btn_get_forcast').click(function(){
		
		if($('#city_name').val() != '') 
		{
			$('#loader_img').show();
			GetWeatherForcast($('#city_name').val());
		}
			
	});
	
	$('#change_location').click(function(){
		$('#cnt_location_chnge').show('fast');
		return false;
	});
	
	$('#eccb_lnk').click(function(){
		window.open('http://www.eccb-centralbank.org/');
		return false;
	});
	
	$('#escec_lnk').click(function(){
		window.open('http://www.ecseonline.com/');
		return false;
	});
	
	$('.paper-link').click(function(){	
		window.open($(this).attr("href")+ '&id=' +$(this).attr("id"));
		return false;
	});
	
	$('.btn_readnow').click(function(){
		window.open('http://www.antiguaobserver.com/?page_id=2349' + '&id=' + $(this).attr("id"));
		return false;
	});
	
	$('#drp_blog_arrow').click(function(){
		$('#cnt_blog_listing').show('fade');
		return false;
	});
	
	$('#lnk_listing').click(function(){
		$('#cnt_blog_listing').show('fade');
		return false;
	});
	
	$('#listing_close').click(function(){
		$('#cnt_blog_listing').hide('fade');
		return false;
	});
	
	$('#stream_link').click(function(){
		//window.open("http://www.stormpulse.com/fullscreen/atlantic","Storm Tracker","menubar=no,width=800,height=700,toolbar=no");
		window.open('http://www.ustream.tv/channel-popup/iobserve',null,"height=450,width=450,status=yes,toolbar=no,menubar=no,location=no");
	});
	
	// account logout.. action 
	$('#account_logout').click(function(){
		
		$(this).text('logging out...');
		
		$.post('./util_scripts/ajax_main.php', {opr:'logout'}, function(data){
			
			if(data.opr_result)
			{
				document.location = 'http://www.antiguaobserver.com';
			}
			
		}, 'json');

		return false;
	});
	
	$('#lnk_make_home_page').click(SetHomePage);
	
	$('#btn_findalbum').click(function(){
		
		FindPhotoAlbums();
	});
	
	$('.ads-link').click(function(){
		window.open($(this).attr('href'));
		return false;
	});
 }
 
/*
 * Retrieve albums based on the title
 * @param pTitle Title of the album to retrieve
 */
 function RetrieveAlbums(pTitle)
 {
 	$.post('./util_scripts/ajax_main.php', {opr:'ListPhotoGalleries',gtitle:pTitle}, function(data){
			
			if(data.rslt)
			{
				DisplayAlbumList(data);
			}
			
		}, 'json');
 }
 
/*
 * Find a photo album by title
 */
 function FindPhotoAlbums()
 {
 	// display processing message
	$('#loader_img').show('fast');
	$('#loading_label').show('fast');
	
	// run the query
 	$.post('./util_scripts/ajax_main.php', {opr:'ListPhotoGalleries',gtitle:$('#txtQuery').val(), filter:$('#qryType :selected').val()}, function(data){
			
			if(data.rslt)
			{
				// remove the processing message
				$('#loader_img').hide('fast');
				$('#loading_label').hide('fast');
				
				//display the items
				DisplayAlbumList(data);
			} else {
				$('#loader_img').hide('fast');
				$('#loading_label').hide('fast');
				$('#lst_albums').empty();
				$('#lst_albums').append('<p class="search-msg">No galleries were found from the previous search, please try another search with different parameters</p>');
			}
			
		}, 'json');
 }
 
/*
 * Initialize the photo gallery based on the gallery Name
 * @param pGalleryName Gallery to initialize
 */
 function InitializeDailyPhotoViewer(pGalleryName)
 {
	_flashvars = {xmlfile:'./util_scripts/images.php?gtitle=' + pGalleryName};
	_params = {wmode:'transparent', allowfullscreen: "true"};
	_attributes = {};
	swfobject.embedSWF("./wp-content/observer_components/observer_lens.swf", "cnt_photo_gallery", "720", "500", "9.0.0", false, _flashvars, _params, _attributes);
	
	$.scrollTo('#cnt_main',300);
	
	$('#spnGallery').text(pGalleryName.replace(/%20/g,' '));
 }
 
/*
 * Display the list of albums retrieve from the server
 * @param pAlbumData album data returned
 */
 function DisplayAlbumList(pAlbumData)
 {
 	//clear the present list..
	$('#lst_albums').empty();
	
	for(var idx = 0; idx < pAlbumData.list.length; idx++)
	{
		_template = BuildTemplate('ALBUM_LISTING_TMPL');
		
		_template = _template.replace(':id', pAlbumData.list[idx].gid);
		_template = _template.replace(':alt', pAlbumData.list[idx].name);
		_template = _template.replace(':title', pAlbumData.list[idx].title);
		_template = _template.replace(':item_title', pAlbumData.list[idx].title);
		_template = _template.replace(':src', pAlbumData.list[idx].path + '/thumbs/thumbs_' + pAlbumData.list[idx].pic);
		_template = _template.replace(':desc', pAlbumData.list[idx].galdesc);
		
		$('#lst_albums').append(_template);
	}
	
	// bind the click event.. for album selection
	$('.cnt-album-listitem').click(function(){
		DisplaySelectedGallery($(this).attr('name'));
	});
 }
 
/*
 * Build the template.. for dynamic content
 * @param pTemplateName Name of the template to build
 * @return String template string
 */
 function BuildTemplate(pTemplateName)
 {
 	// album listing template
 	var _template = '<li id=":id" class="album-list-item">' +
					'<div class="cnt-album-listitem" name=":item_title">' +
						'<img alt=":alt" src=":src"/>' +
						'<h2 class="album-title">:title</h2>' +
						'<p class="album-desc">:desc<p>' +
					'</div>' +
					'</li>';
	
 	switch(pTemplateName)
	{
		case 'ALBUM_LISTING_TMPL':
			return _template;
		break;
	}
 }
 
/*
 * Display the selected photo gallery
 * @param pTitle Title of the gallery to display
 */
 function DisplaySelectedGallery(pTitle)
 {
 	// clear the current gallery container
	$('#ele_gallery_player').remove();
	$('#cnt_gallery_player').append('<div id="ele_gallery_player"></div>');
	
	// load the photo gallery
	InitializeDailyPhotoViewer(pTitle);
	
 }
 
 // Set the home page (I.E browsers)
 function SetHomePage()
 {
 	if (document.all)
    {
        document.body.style.behavior='url(#default#homepage)';
  		document.body.setHomePage(App_Config.domain_url);
    }
 }
 
/*
 * Return the printable name for the stock symbol
 * @return Synbol printable name
 */
 function StockSymbolName(pSymbol)
 {
 	var _name = null;
 	switch(pSymbol)
	{
		case '"DOW"':
		_name = 'Dow';
		break;
		
		case '"MSFT"':
		_name = 'MSFT';
		break;
		
		case '"GE"':
		_name = 'GE';
		break;
		
		case '"^IXID"':
		_name = '^IXID';
		break;
		
		case '"GOOG"':
		_name = 'GOOG';
		break;
		
		case '"^DJI"':
		_name = "^DJI"
		break;
	}
	
	return _name;
 }
 
/*
 * Remove the quote from a string
 * @String pValue
 */
 function RemoveQuote(pValue)
 {
 	return pValue.substring(1, pValue.length - 2);
 }
 
 function GetStockQuotes()
 {
 	//var stock = 'DOW,MSFT,GE,RHT,NOVL,NYX,GOOG,^IXIC';
	var stock = '^DJI,^IXID,GOOG,MSFT';
		
		$.get('./util_scripts/stock_quotes.php?tickers=' + stock, function(data){
			
			var linesOfData = data.split('\n');
			$('#tbl_stocks_body').empty(); // clear the box..
			
			for(i=0; i < linesOfData.length-1; i++)
			{
				var lineOfData = linesOfData[i].split(',');
				var lRowId = 'tbl_stock_row_' + i.toString();
				
				if((i % 2) != 0)
				{
					$('#tbl_stocks_body').append('<tr id="'+lRowId+'" class="stock-odd">');
				} else {
					$('#tbl_stocks_body').append('<tr id="'+lRowId+'">');
				}
				
				$("#" + lRowId).append('<td class="stock-symb"><a class="symbol-link" href="#">' + StockSymbolName(lineOfData[0]) + '</a></td>'); 
								
				if(lineOfData[2].indexOf('-') != -1)
				{
					$("#" + lRowId).append('<td class="stock-down"></td>');
					$("#" + lRowId).append('<td class="end-col-red">' + RemoveQuote(lineOfData[2]) + '</td>');
					$("#" + lRowId).append('<td class="end-col-red col-perc">' + RemoveQuote(lineOfData[3]) + '</td>');
					$('#tbl_stocks_body').append('</tr>');
					continue;
				}
				
				if(lineOfData[2].indexOf('+') != -1)
				{
					
					$("#" + lRowId).append('<td class="stock-up"></td>');
					$("#" + lRowId).append('<td class="end-col-green">' + RemoveQuote(lineOfData[2]) + '</td>');
					$("#" + lRowId).append('<td class="end-col-green col-perc">' + RemoveQuote(lineOfData[3]) + '</td>');
					$('#tbl_stocks_body').append('</tr>');
					continue;
				}
				
				$("#" + lRowId).append('<td class="stock-neutral">-</td>');
				$("#" + lRowId).append('<td class="end-col">' + RemoveQuote(lineOfData[2]) + '</td>');
				$("#" + lRowId).append('<td class="trade-percent-neutral col-perc">' + RemoveQuote(lineOfData[2]) +'</td>');
			}
			
			// remove the bottom border for the last row
			$('#tbl_stocks_body td:gt(11)').addClass('last-stock-item'); 			
		});
 }
 
 function InitializeAdsSpaces()
 {
 	_flashvars = {xmlfile:"./wp-content/ads/images.xml"};
	_params = {wmode:'transparent'};
	_attributes = {};
 	swfobject.embedSWF("./wp-content/ads/observer_radio_ad.swf", "cnt_observer_radio_ad", "358", "200", "9.0.0", false, _flashvars, _params, _attributes);
 }
 
/*
 * Retrieve the current programming
 * for obsever radio;
 */
 function GetRadioProgramming()
 {
 	$.get("./util_scripts/o_radio_current_program.php", function(data)
	{
		
		if(data.length != 4) // if there was no programming returned
		{
			var _pro = eval('('+data+')');
		} else {
			$('.loading-txt').text('broadcasting.');
			return;
		}
			
		$('#ele_program_loading').remove();
		$('#program_name').text(_pro.Name);
		$('#program_hosts').text(_pro.Hosts);
		$('#program_time').text(_pro.Time);
		$('.div_programming_panel').show('slow');	
 	});
 }
 
/*
 * Retrieve a list of news stories from the top news sites
 */
 function GetNewsAggregation()
 {
 	$.get("./util_scripts/ticker_tape_agregator.php", function(data)
	{
		if(data != null || data != '' || data.length != 4)
		{
			var _feeds = eval('('+data+')');
			$('#feeds_load_msg').fadeOut('slow', function(){
				$('#feeds_load_msg').remove();
				DisplayFeeds(_feeds);
			});
		}
	});
 }
 
/*
 * Display the list of feeds returned
 */
 function DisplayFeeds(pFeeds)
 {
 	$('#cnt_news_ticker').append('<ul id="ticker"></ul>');
	for(var idx = 0; idx < pFeeds.length; idx++)
	{
		$('ul#ticker').append('<li><span>'+pFeeds[idx].Agency+'</span><a href="'+pFeeds[idx].Premalink+'">'+pFeeds[idx].Name+'</a></li>');
	}
	
	$("#ticker").liScroll({travelocity: 0.03});
	
 }
 
/*
 * Get the current weather for the given location
 * @param pLocation Location to retrieve weather information for
 */
 function GetWeatherForcast(pLocation)
 {
 	$.post("./util_scripts/weather_forcaster.php", {location:pLocation, action:'getCurrentForcast'}, function(data){
		
		$('#loader_img').hide();
			
		var _weather = eval(data);
		
		if(_weather.city == undefined)
		{
			//alert('no conditions found for the location entered');
			$('#location').text('no conditions found for the location entered');
			$('#temperature').text('0\u00B0');
			$('#wind').text('--');
			$('#condition').text('--');
			$('#weather_icon').attr('src', '#');
			return;
		}
		
		$('#weather_header').text("Weather Forecast for: " + _weather.city.replace(/\+/g,' '));
	    $('#location').text(_weather.city);
		$('#temperature').text(_weather.temp_f+'\u00B0');
		$('#wind').text(_weather.wind_condition);
		$('#condition').text(_weather.condition);
		
		var _icon = '';
		if(_weather.TimeOfDay == 'Day')
		{
			switch(_weather.condition)
			{
				
				case 'Clear':
				  _icon = 'clear.png';
				break;
				
				case "Cloudy":
				  _icon = 'mostly_cloudy.png';
				break;
				
				case "Haze":
				  _icon = 'haze.png';
				break;
				
				case "Partly Sunny":
				  _icon = 'partly_cloudy.png';
				break;
				
				case "Mostly Sunny":
				  _icon = 'partly_cloudy.png'
				break;
				
				case "Partly Cloudy":
				   _icon = 'partly_cloudy.png';
				break;
				
				case "Mostly Cloudy":
				   _icon = 'mostly_cloudy.png';
				break;
				
				case 'Rain':
				  _icon = 'shower.png';
				break;
				
				case "Light rain":
				   _icon = 'light_rain.png';
				break;
				
				case "Chance of Rain":
				   _icon = 'chance_of_rain_day.png';
				break;
				
				case "Chance of Storm":
				   _icon = 'chance_of_thunderstorm.png';
				break;
				
			}
		} else {
			
			switch(_weather.condition)
			{
				case 'Clear':
				  _icon = 'clear_night.png';
				break;
				
				case "Cloudy":
				   _icon = 'mostly_cloudy_night.png';
				break;
				
				case "Haze":
				   _icon = 'haze.png';
				break;
				
				case "Partly Sunny":
				  _icon = "partly_sunny_night.png";
				  $('#condition').text('Partly Clear');
				break;
				
				case "Mostly Sunny":
				  _icon = 'partly_sunny_night.png';
				  $('#condition').text('Mostly Clear');
				break;
				
				case "Partly Cloudy":
				   _icon = 'partly_cloudy_night.png';
				break;
				
				case "Mostly Cloudy":
				   _icon = 'mostly_cloudy_night.png';
				break;
				
				case "Light rain":
				   _icon = 'light_rain.png';
				break;
				
				case 'Rain':
				  _icon = 'shower.png';
				break;
				
				case "Chance of Rain":
				   _icon = 'chance_of_rain_night.png';
				break;
				
				case "Chance of Storm":
				   _icon = 'chance_of_storm_night.png';
				break;
				
				case "Thunderstorm":
					_icon = 'storm.png';
				break;
				
			}
		}
		$('#weather_icon').attr('src', $('#_templatedir').val() +'/images/weather/' + _icon);
			
	}, 'json'); 
 }
 
/*
 * Get the extended weather forcast for the given location.
 * @param pLocation Location to retrieve forcast for.
 */
 function GetExtendedForcast(pLocation)
 {
 	$.post("./util_scripts/weather_forcaster.php", {location:pLocation, action:'getExtendedForcast'}, function(data){
		var _weather = eval(data);
		
		_tonights_forcast = _weather[0]; // first item is the forcast for later..
		$('#location_night').text(_tonights_forcast.city);
		$('#temperature_night').text(_tonights_forcast.high+'\u00B0');
		$('#wind_night').text(_tonights_forcast.wind_condition);
		$('#condition_night').text(_tonights_forcast.condition);
		$('.forcast-information .highs').text('Hi '+_tonights_forcast.high+'\u00B0');
		$('.forcast-information .lo').text('Lo '+_tonights_forcast.low+'\u00B0');
		
		var night_icon = '';
		switch(_tonights_forcast.condition)
		{
			case 'Clear':
			  night_icon = 'clear_night.png';
			break;
			
			case "Cloudy":
			   night_icon = 'mostly_cloudy_night.png';
			break;
			
			case "Haze":
			   night_icon = 'haze.png';
			break;
			
			case "Partly Sunny":
			  night_icon = "partly_sunny_night.png";
			  $('#condition_night').text('Partly Clear');
			break;
				
			case "Mostly Sunny":
			  night_icon = 'partly_sunny_night.png';
			  $('#condition_night').text('Mostly Clear');
			break;
			
			case "Partly Cloudy":
			   night_icon = 'partly_cloudy_night.png';
			break;
			
			case "Mostly Cloudy":
			   night_icon = 'partly_sunny_night.png';
			break;
			
			case "Light rain":
			   night_icon = 'light_rain.png';
			break;
			
			case 'Rain':
			  night_icon = 'shower.png';
			break;
			
			case "Chance of Rain":
			   night_icon = 'chance_of_rain_night.png';
			break;
			
			case "Chance of Storm":
			   night_icon = 'chance_of_storm_night.png';
			break;
			
			case "Thunderstorm":
				night_icon = 'storm.png';
			break;
		}
		$('#weather_icon_night').attr('src', $('#_templatedir').val() +'/images/weather/' + night_icon);
		
		$('#ext-forecast1 .day-header').text(_weather[1].day_of_week);
		
		for(var idx = 1; idx < _weather.length; idx++)
		{
			_extended_icon = '';
			$('#ext-forecast'+idx+' .day-header').text(_weather[idx].day_of_week);
			$('#ext-forecast'+idx+' .condition').text(_weather[idx].condition);
			$('#ext-forecast'+idx+' .highs-lo .highs').text('Hi '+_weather[idx].high+'\u00B0');
			$('#ext-forecast'+idx+' .highs-lo .lo').text('Lo '+_weather[idx].low+'\u00B0');
			
			switch(_weather[idx].condition)
			{
				
				case 'Clear':
				  _extended_icon = 'clear.png';
				break;
				
				case "Cloudy":
				  _extended_icon = 'mostly_cloudy.png';
				break;
				
				case "Haze":
				  _extended_icon = 'haze.png';
				break;
				
				case "Partly Sunny":
				  _extended_icon = 'partly_cloudy.png'
				break;
				
				case "Partly Cloudy":
				   _extended_icon = 'partly_cloudy.png';
				break;
				
				case "Mostly Cloudy":
				   _extended_icon = 'mostly_cloudy.png';
				break;
				
				case "Mostly Sunny":
				   _extended_icon = 'partly_cloudy.png';
				break;
				
				case "Light rain":
				   _extended_icon = 'light_rain.png';
				break;
				
				case "Chance of Rain":
				   _extended_icon = 'chance_of_rain_day.png';
				break;
				
				case "Rain":
				   _extended_icon = 'shower.png';
				break;
				
				case "Chance of Storm":
				   _extended_icon = 'chance_of_thunderstorm.png';
				break;
				
				case "Thunderstorm":
				   _extended_icon = 'storm.png';
				break;
				
			}
			$('#ext-forecast'+idx+' .extended-forcast-img').attr('src', $('#_templatedir').val() +'/images/weather/'+ _extended_icon);
		}
		
	}, 'json');
 }
