//(function( $ ){
//	jQuery.fn.getWeather = function(loc, options){
//		var settings = {
//			'location'         : 'top',
//			'background-color' : 'blue'
//		};
//	
//		if ( options ) { 
//			jQuery.extend( settings, options );
//		};
//		
//		var _this = jQuery(this);
//		
//		if(loc){
//			_this.html("Fetching Weather Conditions...");
//			var wurl = "http://www.worldweatheronline.com/feed/weather.ashx?q=84067&format=json&num_of_days=3&key=387d3401a3182909102709&callback=?";
//			//var wurl = "http://localhost:57631/JsonTest/json.ashx";

//			function makeAjaxCall(ajaxUrl, functionSuccess, functionFailure){
//				$.ajax(
//				{
//					type: "GET",
//					url: ajaxUrl,
//					contentType: "application/json; charset=utf-8",
//					data: {},
//					dataType: "json",
//					success: functionSuccess,
//					error: functionFailure
//				});
//			}
//			
//			function loadWeather(data, textStatus, XMLHttpRequest){
//				if(data){
//					setWeather(data)
//				} else {
//					_this.html("Cannot load weather conditions.");
//				};
//			}
//			function loadWeatherFail(data){
//				_this.html("Cannot load weather.");
//			}
//			
//			makeAjaxCall(wurl, loadWeather, loadWeatherFail);
//		} else {
//			_this.html("No location provided - cannot fetch weather");	
//		}
//		
//		function setWeather(weather){		
//			var current = weather.data.current_condition;
//			var upcoming = weather.data.weather;
//			
//			var days = new Array("Mon", "Tues", "Wed", "Thur", "Fri", "Sat", "Sun");
//			
//			var spot1datestamp = upcoming[0].date.replace("-", "/").replace("-", "/");
//			var spot2datestamp = upcoming[1].date.replace("-", "/").replace("-", "/");
//			var spot3datestamp = upcoming[2].date.replace("-", "/").replace("-", "/");
//			
//			var spot1date = new Date(spot1datestamp);
//			var spot2date = new Date(spot2datestamp);
//			var spot3date = new Date(spot3datestamp);
//			
//			var content = " <div id=\"current-weather\">";
//			content += "		<span class=\"location\">Roy, Utah</span> <br />";
//			content += "		<span class=\"temperature\">" + current[0].temp_F + "&deg;</span>  <br />";
//			content += "		<span class=\"wind\">Wind: " + current[0].windspeedMiles + " mph " + current[0].winddir16Point + "</span> <br />";
//			content += "		<span class=\"humidity\">Humidity: " + current[0].humidity + "%</span> <br />";
//			content += "	</div>";
//			content += "	<div id=\"weather-spot1\" class=\"weather-spot\">";
//			content += "		<span class=\"title\">" + days[spot1date.getDay()] + "</span>";
//			content += "		<img src=\"" + upcoming[0].weatherIconUrl[0].value + "\" alt=\"\" width=\"50\" height=\"50\" />";
//			content += "		<span class=\"temp-range\">" + upcoming[0].tempMaxF + "&deg; / " + upcoming[0].tempMinF + "&deg;</span>";
//			content += "	</div>";
//			content += "	<div id=\"weather-spot2\" class=\"weather-spot\">";
//			content += "		<span class=\"title\">" + days[spot2date.getDay()] + "</span>";
//			content += "		<img src=\"" + upcoming[1].weatherIconUrl[0].value + "\" alt=\"\" width=\"50\" height=\"50\" />";
//			content += "		<span class=\"temp-range\">" + upcoming[1].tempMaxF + "&deg; / " + upcoming[1].tempMinF + "&deg;</span>";
//			content += "	</div>";
//			content += "	<div id=\"weather-spot3\" class=\"weather-spot\">";
//			content += "		<span class=\"title\">" + days[spot3date.getDay()] + "</span>";
//			content += "		<img src=\"" + upcoming[2].weatherIconUrl[0].value + "\" alt=\"\" width=\"50\" height=\"50\" />";
//			content += "		<span class=\"temp-range\">" + upcoming[2].tempMaxF + "&deg; / " + upcoming[2].tempMinF + "&deg;</span>";
//			content += "	</div>";
//			
//			_this.html(content);
//		};
//	}
//})( jQuery );
function mycarousel_initCallback(carousel) {
    jQuery('#carousel-overlay a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
		carousel.auto = 0;
		stopCarousel();
        return false;
    });
};
function stopCarousel() {
	var carousel = jQuery('#carousel-content').data('jcarousel');
	carousel.stopAuto();
}
function mycarousel_beforeAnimation(carousel, item, idx, state) {
	jQuery('#carousel-overlay a').removeClass("active");
	jQuery('#carousel-overlay li a').eq(idx-1).addClass("active");
	//if (!$.browser.msie) {
	//	$("#carousel-content img").css({ display: "none" });
	//}
};
function mycarousel_afterAnimation(carousel, item, idx, state) {
	//if (!$.browser.msie) {
	//	$("#carousel-content img").fadeIn(400);
	//}
};

jQuery(document).ready(function(){
	var size = $("#carousel-overlay li").length;
	var leftPos = 915 - (size*31);
	$("#carousel-overlay li").css({left: leftPos});
	
	jQuery("#carousel-content").jcarousel({
		scroll: 1,
		auto: 5,
        animation: 0,
        wrap: "both",
        easing: "swing",
		initCallback: mycarousel_initCallback,
		itemVisibleInCallback: {
            onBeforeAnimation: mycarousel_beforeAnimation,
            onAfterAnimation: mycarousel_afterAnimation
        },
		buttonNextHTML: null,
        buttonPrevHTML: null
	});		
	
	jQuery("#weather").getWeather("84067");
});
