function loadShopsDeals(nb, last, shop_id, type, instance_id, country, language){
	url = "/media/js/get_deals.php?action=getDealsFromShop&nb="+nb+"&shop_id="+shop_id+"&type="+type+"&view=shop&instance_id="+instance_id+"&country="+country+"&lang="+language;
	
	loadDeals(url, last);
}

function lastDealFunc_search(nb, last, keywords, type, view, instance_id, country)
{
	url = "/media/js/get_deals.php?action=getLastDeals&nb="+nb+"&keywords="+keywords+"&type="+type+"&view=search_result&instance_id="+instance_id+"&country="+country;
	
	loadDeals(url, last);
}

function loadDeals(url, last){
	url += "&last="+last;
	var canRequest = new Array();
	
	callDeals(url);
	
	div = $('<div>', {text: "View more", id: "view_more"}).addClass("more");
	$('#all_deals').append(div);
	
	$('#view_more').click(function(){

		last = getNbDeals();
		
		if(canRequest[last] != false){
		
			url += "&last="+last;
			callDeals(url);
			canRequest[last] = false;
			
			img = $('<img>', {src: "/media/images/site_images/loader.gif"});
			
			$(this).html(img);
	
		}
	});
}

function getNbDeals(){
	return $('.deal').length;
}


function callDeals(url){
	$.ajax({
		  url: url,
		  success: function(data){
				
					if (data != "") {
						
						$('iframe').remove();
						
			        	$(".deal:last").after(data);
			        		        	
			        	$('#view_more').html('View more');
			        	
			        } else {
			        	$('#view_more').fadeOut('slow', function(){
			        		$(this).remove();
			        	});
			        }
				}
		});
};
