
//cookie=PageFontSize
//Undefined = 0
//Smallest = 1
//Small = 2
//Medium = 3
//Large = 4
//Largest = 5


function PageFontSizeObject(strFormName)
{
	this.mstrFormName = strFormName;

    //saves the page font size to a cookie
    this.savesize = function(intSize)  
    {
        if(typeof(intSize) == 'undefined' || intSize==null)
        {
            intSize = this.mintDefaultSize;
        }
        //alert('saving cookie: ' + intSize);
        Cookie.set(this.mstrCookie, intSize, 365);
    }
    
	//loads the font size from the cookie
    this.loadsize = function()        
    {
        var intSize = Cookie.get(this.mstrCookie);
        //alert('loaded from cookie: ' + intSize);
        if(typeof(intSize) == 'undefined' || intSize==null)
        {
            intSize = this.mintDefaultSize;
        }   
        return parseInt(intSize);
    }
	
	//returns the class name as a string
    this.cssclass =  function(intSize) 
    {
        switch(parseInt(intSize))
        {
            case 1:
                return this.mstrClassPre + this.mstrSize1;    
                break;
            case 2:
                return this.mstrClassPre + this.mstrSize2;    
                break;
            case 3:
                return this.mstrClassPre + this.mstrSize3;    
                break;
            case 4:
                return this.mstrClassPre + this.mstrSize4;    
                break;
            case 5:
                return this.mstrClassPre + this.mstrSize5;    
                break;
            default:
                return this.cssclass(this.mintDefaultSize);   
        }
    }
    
    //sets the font size class name
    this.setsizeclass = function(strClass)
    {
        for(var i=1;i<=this.mintMaxSize;i++)
        {
            this.removesizeclass(this.cssclass(i));
        }
        $(this.mstrFormName).addClassName(strClass);  
    }

    //removes the specified class name
    this.removesizeclass = function(strClass)
    {
        $(this.mstrFormName).removeClassName(strClass);
    }
    
	//increase the font size
	this.setSizeUp = function() 
	{
	    var intSize = this.loadsize();
	    intSize++;
	    if(intSize>this.mintMaxSize)
	    {
	        return false;
	    }
	    else
	    {
	        var strClass = this.cssclass(intSize);
	        this.setsizeclass(strClass);
	        this.savesize(intSize);
	    }
	}
	
	//decrease the font size
	this.setSizeDown = function()
	{
	    var intSize = this.loadsize(); 
	    intSize--;
	    if(intSize<=0)
	    {
	        return false;
	    }
	    else
	    {
	        var strClass = this.cssclass(intSize);
	        this.setsizeclass(strClass);
	        this.savesize(intSize);
	    }
	}
	
    this.init = function() 
    {
        var intSize = this.loadsize();
        var strClass = this.cssclass(intSize);
        this.setsizeclass(strClass);
    }
}

PageFontSizeObject.prototype.mstrFormName;
PageFontSizeObject.prototype.mintDefaultSize = 3;
PageFontSizeObject.prototype.mintMaxSize = 5;
PageFontSizeObject.prototype.mstrClassPre = 'body-';
PageFontSizeObject.prototype.mstrCookie = 'PageFontSize';
PageFontSizeObject.prototype.mstrSize1 = 'Smallest';
PageFontSizeObject.prototype.mstrSize2 = 'Small';
PageFontSizeObject.prototype.mstrSize3 = 'Medium';
PageFontSizeObject.prototype.mstrSize4 = 'Large';
PageFontSizeObject.prototype.mstrSize5 = 'Largest';

