$(document).ready(function(){
			
			
			var downloadTxt 	= 'Laadi alla';
			var feedURL			= 'http://feeds.ovi.com/output/xml?group=ET_ee';
			
			
			
			
			
			
			
			
			var $divId			= $('#top-ovi-apps-slider');
			
			var jsonURL			= 'http://188.117.37.112/appcarousel/topapps.php?feedUrl='+escape(feedURL)+'&callback=?&';
			
			$.getJSON(jsonURL, function(data) {
				
				// name, url, price, image[0]
				var numOfItems		= 6;
				var maxItems		= 60;
  				var items			= "";
  				
  				$.each(data.FeedList, function(key, val) {
  					if(key<maxItems){
  						if(key%numOfItems==0) items += '<li class="item-set"><ul>';
  						items += '<li><img src="' + val.image[1] + '" /><p>'+val.name+'</p><a href="'+val.url+'" target="_blank"><div class="app-price-btn" origTxt="'+firstCharUpper(val.price)+'">'+firstCharUpper(val.price)+'</div></a></li>';
    					if(key%numOfItems==numOfItems-1 || key>=data.FeedList.length-1) items += '</ul></li>';
    				}
  				});
  				
  				$(items).appendTo($divId);
  				
  				setSlider();
			});
			
			$('.app-price-btn').live('mouseover mouseout', function(e){
				var origTxt;
				if(e.type == 'mouseover'){
					$(this).text(downloadTxt);
				}else{
					$(this).text($(this).attr('origTxt'));
				}
				
			});
			
			function setSlider(){
				$($divId).anythingSlider({
					autoPlay			: false,
					delay               : 6000,
					pauseOnHover        : true,
					resumeDelay         : 1000,
					animationTime       : 700,
					easing 				: "easeOutQuint",
					hashTags            : false,
					resizeContents      : false, 
					buildNavigation		: false,
					theme				: 'top-ovi-apps'
				});
			}
			
			function firstCharUpper(str){
				
				var firstChar = str.substring( 0, 1 );
				var _str = firstChar.toUpperCase()+str.substring( 1 );
				
				return _str;
				
			}

});
