// JavaScript Document

//States swithcing plug in needs a web service set up
//The web service takes a variable as the last url parameter
//Recueves an Id of a cuinty and returns the states of
//That country

(function($){
	$.fn.extend({
	getGraph: function(ajaxUrl, type, hotel, date, divSelector, loader, realtime){
        if(date == null){
            date = "";
        }
        if(realtime == null){
            realtime = "";
        }

        $.ajax({
						type: "POST",
						url: ajaxUrl +"/index/"+type+"/"+hotel+"/"+date+"/"+realtime,
						beforeSend: function(){
                            if(realtime == ""){
                                $(divSelector).html("<center><img src='"+loader+"'></img></center>");
                            }else{
					            $(divSelector).html("<center><img src='"+loader+"'></img><br/>Fetching updated data.</center>");
                            }
   						},
						success: function(html){
							$(divSelector).html(html);
						}});
	}
	});
})(jQuery);
