﻿MasterTemplate = function(contentDivID) { 
    this.contentDiv = document.getElementById(contentDivID);    
    this.maxZoom = 2;
    this.minZoom = 1;
}

MasterTemplate.prototype = {
    content_zoomIn: function() {        
        var zoom;
        var cssClass;
        
        if (this.contentDiv)                    
        {
            zoom = this.getZoomFactor(this.contentDiv.className)
            cssClass = this.getClassNameWithoutZoomFactor(this.contentDiv.className);
                        
            if (zoom < this.maxZoom)
                this.contentDiv.className = (cssClass + "x" + zoom*2).toString();
        }
    },
    
    content_zoomOut: function() {
        var zoom;
        var cssClass;
        
        if (this.contentDiv)                    
        {
            zoom = this.getZoomFactor(this.contentDiv.className)
            cssClass = this.getClassNameWithoutZoomFactor(this.contentDiv.className);
                        
            if (zoom > this.minZoom)
                this.contentDiv.className = (cssClass + "x" + zoom/2).toString();
        }
    },    
    
    getZoomFactor: function(cssClass) {
        return cssClass.substring(cssClass.length - 1, cssClass.length);
    },
    
    getClassNameWithoutZoomFactor: function(cssClass) {
        return cssClass.substring(0, cssClass.length - 2);
    }
}