﻿var Step3LicenseView = (function() {
    function fnStep3LicenseViewConstructor() {
        /****************************************************/
		/*                                                  */
		/*                                                  */
		/*           Class Level Priveleged Methods         */
		/*                                                  */
		/*                                                  */
		/****************************************************/
		
		this.addLicenseItem = function(iQuantity, sDescription, sAmount, sSubtotal) {
		    $("tblSummary").down("tbody").insert(new Template("<tr><td>#{quantity}</td><td class=\"licenseDescription\">#{description}</td><td class=\"licenseNumericColumn\">#{amount}</td><td class=\"licenseNumericColumn\">#{subtotal}</td></tr>").evaluate({quantity: iQuantity.toString(), description: sDescription, amount: sAmount, subtotal: sSubtotal}), "bottom");
		}
		
		this.addPromotion = function(sPromotion, sAmount) {
		    $("tblSummary").select("tfoot > tr.Total").first().insert({before: new Template("<tr class=\"Promotion\"><td colspan=\"3\">#{message}</td><td class=\"Left\">#{amount}</td></tr>").evaluate({message: sPromotion, amount: sAmount})});
		}
		
		this.clearLicenseItemList = function() {
		    $("tblSummary").down("tbody").update("");
		}		
		
		this.clearMSRPPrice = function() {
		    $("tblSummary").select("tfoot > tr.MSRPTotal > td").last().update("");
		}
		
		this.clearPromotionList = function() {
		    var aPromotionRows = $("tblSummary").select("tfoot > tr.Promotion");
		    aPromotionRows.each(function(oPromotionRow, iIndex) {
		        oPromotionRow.remove();
		    });
		}
		
		this.clearTotalPrice = function() {
		    $("tblSummary").select("tfoot > tr.Total > td").last().update("");
		}
		
		this.hideTotalPrice = function() {
		    $("tblSummary").select("tfoot > tr.Total").first().addClassName("Hidden");
		}
		
		this.setMSRPPrice = function(sPrice) {
		    $("tblSummary").select("tfoot > tr.MSRPTotal > td").last().update(sPrice);
		}
		
		this.setTotalPrice = function(sPrice) {
		    $("tblSummary").select("tfoot > tr.Total > td").last().update(sPrice);
		}
		
		this.showTotalPrice = function() {
		    $("tblSummary").select("tfoot > tr.Total").first().removeClassName("Hidden");
		}
    }
    
    return fnStep3LicenseViewConstructor;
})();