﻿// TagUnTagReview
Ajax.Commands.TagUnTagReview=function(elementId, ajaxCommand, cmdCounter) {
    this.priority=net.CommandQueue.PRIORITY_IMMEDIATE;
    this.type=net.CommandQueue.TYPE_SINGLEPROCESS;
    this.id=cmdCounter;
    this.ajaxCommand = ajaxCommand;
    this.elementId=elementId;
    
    this.vendorLocationReviewId = elementId;
    this.userId = document.getElementById('userId').value;
    this.vendorLocationReviewTagType = document.getElementById('vendorLocationReviewTagType').value;
}

Ajax.Commands.TagUnTagReview.prototype.QueryStringVariables=function(){
    var commandVariables = new Hashtable();

    commandVariables.put("vendorLocationReviewId", this.vendorLocationReviewId);
    commandVariables.put("userId", this.userId);
    commandVariables.put("vendorLocationReviewTagType", this.vendorLocationReviewTagType);
    
    return commandVariables;
}

Ajax.Commands.TagUnTagReview.prototype.ParseResponse=function(docEl) {
	var attrs = docEl.attributes;
	var status = attrs.getNamedItem('status').value;
	var message = attrs.getNamedItem('message').value;
	var tagupdatestatus = attrs.getNamedItem('tagupdatestatus').value;
	var vendorlocationreviewid = attrs.getNamedItem('vendorlocationreviewid').value;
	var helpfultagcount = attrs.getNamedItem('helpfultagcount').value;
	var nothelpfultagcount = attrs.getNamedItem('nothelpfultagcount').value;
	
	if(status == 'success'){
	
	    document.getElementById('helpfulTagCount' + vendorlocationreviewid).innerHTML = helpfultagcount;
	    document.getElementById('notHelpfulTagCount' + vendorlocationreviewid).innerHTML = nothelpfultagcount;
	    	
	    if(tagupdatestatus == 'Helpful'){
		    document.getElementById('helpfulTag' + vendorlocationreviewid).className = 'helpful tagged';
		    document.getElementById('notHelpfulTag' + vendorlocationreviewid).className = 'nothelpful';
	    }else if(tagupdatestatus == 'Not Helpful'){
		    document.getElementById('notHelpfulTag' + vendorlocationreviewid).className = 'nothelpful tagged';
		    document.getElementById('helpfulTag' + vendorlocationreviewid).className = 'helpful';
	    }else{
		    document.getElementById('notHelpfulTag' + vendorlocationreviewid).className = 'nothelpful';
		    document.getElementById('helpfulTag' + vendorlocationreviewid).className = 'helpful';
	    }	
	}else{
	    //alert(message);
	}
}