/**
 * Creator: pramod_g
 * Date: Jun 08, 2009
 * Time: 1:53:33 PM
 * Contents are property of Cappex.com LLC, and strictly confidential.
 */

/** 
 * CLASS: 	ReviewProcessor
 * DESCR:	
 * USAGE:
 * EXMPL:	
 */
var ReviewProcessor = new Class({

	options : {
		ajaxProcessorUrl : null
	},

	// ajax members
	ajaxProcessor : null,
	fieldsetIndex : null,
	voteOrFlag : null,
	
	initialize : function (options) {

		this.setOptions(options);

		window.addEvent('domready', function () {
			this.domReady();
		}.bind(this));

		this.initializeAjax();

	},

	domReady : function () {

	},

	initializeAjax : function () {

		this.ajaxProcessor = new AjaxCpx(this.options.ajaxProcessorUrl, {

			onSuccess : function() {
				var responseA = this.ajaxProcessor.transport.responseText;
				$('voteAndFlag'+this.fieldsetIndex).innerHTML = responseA;
				
				if(this.voteOrFlag == 'f'){
					
					var aId = $('castVoteOrFlagParams').value;
					var params = aId.split('_');
					var idx = params[3];
					$('voteAndFlagReason_'+idx).setStyle('display','none');
				}
			}.bind(this)
		});
	},
	
	storeFlagReviewOption : function(collegeReviewID, accountID, vote, flag, index, flagReason, collegeID, reviewerAccountID) {
		if(vote == 0){
			this.voteOrFlag = 'f';
			vote = '';
		}
		
		if(flag == 0){
			this.voteOrFlag = 'v';
			flag = '';
		}
		
		this.fieldsetIndex = index;
		var data = 'vote='+vote+'&flag='+flag+'&collegeReviewID='+collegeReviewID+'&accountID='+accountID+'&flagReason='+flagReason+'&collegeID='+collegeID+'&index='+index+'&reviewerAccountID='+reviewerAccountID;		 
		this.ajaxProcessor.request(data);
	}

});

ReviewProcessor.implement(new Options);