
//-Begin Section -cookie.js-\\
/**
 * @author Ryan Johnson <ryan@livepipe.net>
 * @copyright 2007 LivePipe LLC
 * @package Prototype.Tidbits
 * @license MIT
 * @url http://livepipe.net/projects/prototype_tidbits/
 * @version 1.7.0
 * 
 * Note that each tidbit is independent, and is meant to be copied and pasted as you see fit into your application rather than used as a whole.
 */

/**
 * Tidbit : Cookie
 */

var Cookie = {
	set: function(name,value,intDays)
	    {
		    if(intDays)
		    {
			    d = new Date();
			    d.setTime(d.getTime() + (intDays * 24 * 60 * 60 * 1000));
			    expiry = '; expires=' + d.toGMTString();
		    }
		    else 
		    {
			    expiry = '';
		    }
		    //alert('SET: ' + new Date() + ' - ' + name + '=' + value + expiry + '; path=/');
		    document.cookie = name + "=" + value + expiry + "; path=/";
	    },
	get: function(name)
	    {
		    nameEQ = name + "=";
		    ca = document.cookie.split(';');
		    for(i = 0; i < ca.length; i++)
		    {
			    c = ca[i];
			    //alert('got: ' + c);
			    while(c.charAt(0) == ' ') 
			    {
				    c = c.substring(1,c.length);
				}
			    if(c.indexOf(nameEQ) == 0) 
			    {
			        //alert('GET: ' + new Date() + ' - ' + c.substring(nameEQ.length,c.length));
				    return c.substring(nameEQ.length,c.length);
				}
		    }
		    return null
	    },
	unset: function(name)
	    {
		    Cookie.set(name,'',-1);
	    }
}

 
//-End Section -cookie.js-\\


//-Begin Section -pagefontsize.js-\\

//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';


//-End Section -pagefontsize.js-\\

//-End File