var RatingsHistory = {
        
        notCached:true,
 
		init: function(clientId, clickEvent) {
		  
		    if($("ajaxreturnwindow")) {
		     return;
		    }
		    var leftStyle = 0;
		    var topStyle = 0;
		      
			if (clickEvent.y || clickEvent.pageY) {
				if (clickEvent.pageY) {
					tv = clickEvent.pageY;
					lv = clickEvent.pageX + 65;
				} else {
					tv = clickEvent.y + document.documentElement.scrollTop; 
					lv = clickEvent.x + 65 +  document.documentElement.scrollLeft;
				} 
				
				leftStyle = lv; 
				topStyle = tv;
			 }
		  
			  RatingsHistory.openFloatingPane(leftStyle, topStyle);

             if(this.notCached){
			  DWREngine.beginBatch();    

				RatingsHistory.doSellersRatingAjaxCall(clientId, 1);
				RatingsHistory.doSellersRatingAjaxCall(clientId, 3);
				RatingsHistory.doSellersRatingAjaxCall(clientId, 12);

			  DWREngine.endBatch();
			  this.notCached = false;
			 }
		},

	    doSellersRatingAjaxCall: function(clientId, dateRange) {
	  
	  		SellerRatingService.getSellerRatingData(clientId, dateRange, true, {
	  		   callback:function(dataFromServer) {
	  			 RatingsHistory.callbackFunc(dataFromServer, dateRange);
	  		   },
	  		   errorHandler:function(errorString, exception) {
	  			 RatingsHistory.errorHandlerFunc(errorString, exception);
	  		   }
	  
	  		}); 
	  },
		
		callbackFunc: function(dataFromServer, therange) {
		  
          $("ajaxLoaingImage").style.display = "none";

		  
		  var dateRange = therange;

		  var imagePath = dataFromServer.sellerRatingImagePath;
		  var sucessResponse = dataFromServer.success;	
		  var percentage = dataFromServer.sellerRatingPercentage;
		 
		  RatingsHistory.setContent(imagePath, dateRange, percentage);  
		
		},				
		
		 errorHandlerFunc: function(errorString, exception) {
		    
		 
		 },
	    openFloatingPane: function(x, y) {
	   
				
			var FloatingPaneProperties = {
				xOffset: x,
				yOffset: y,
				panePosition: "absolute",
				paneWidth: 310,
				paneHeight: 290,
				paneWindowID: "ajaxreturnwindow",
				panezIndex: 1,
				contentWindowID:"popUpWidget",
				loadingImageLocation:"popUptitle",
				titleBarText: $("localizedCloseWindow")
			};
              

			 //Launch Floating Pane window
			 FloatingPane.OpenPane(FloatingPaneProperties);
			 
			 var MainContent = $(FloatingPaneProperties.contentWindowID);
			 $(FloatingPaneProperties.paneWindowID).appendChild(MainContent);
			 
	  },
	  	  	  	  
	  setContent: function(callBackData, theRange, thepercentage){
	  

		   var imageLoc = "history" + theRange;
		   var imgElement = document.createElement('IMG');

		   var imageSrc = "/images/Shared/sellerRatings/" + callBackData;
		   var imgID = "image" + theRange;

		   imgElement.setAttribute("id", imgID);
		   imgElement.setAttribute("src", imageSrc);		   
		   
           $(imageLoc).innerHTML = " ";
		   $(imageLoc).appendChild(imgElement);

      }, 
	  	  	  
	  
	  errorHandler: function(errorString, exception){
	  
	  }
	  

	  
}


/*

*/    
