﻿//FROM: http://plugins.jquery.com/project/Cookie

/**************************************************

Allows the creation, deletion and reading of cookies on a clients browser.
    
    
Code modified from http://www.quirksmode.org/js/cookies.html

**************************************************/

function CookieManager() {
}
CookieManager.prototype.erase = CookieManager_erase;
CookieManager.prototype.create = CookieManager_create;
CookieManager.prototype.read = CookieManager_read;

function CookieManager_create(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}
function CookieManager_read(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
function CookieManager_erase(name) {
    this.create(name, "", -1);
}

(function($) {
    //****************************************************************/
    //********************* POPUP WINDOW******************************/
    //****************************************************************/
    
    $.fn.popupWindow = function(options) {
        var options = $.extend({}, $.fn.popupWindow.defaults, options);
        return this.each(function() {
            var url = $(this).attr("href");
            $(this).click(function() {
                window.open(
                    url,
                    options.name,
                    options.attributes);
                return false;

            });
        });
    };
    $.fn.popupWindow.defaults = {
        attributes: "width=100, height=100",
        name: ""
    };

    //****************************************************************/
    //********************* ROUNDED CORNERS***************************/
    //****************************************************************/
    
    $.fn.roundQuadrant = function(options) {

        var options = $.extend({}, $.fn.roundQuadrant.defaults, options);

        return this.each(function() {

            var container = $("<div ></div>");

            $(container).html($(this).html());
            $(this).html("");
          

            var topContainer = null;
            var bottomContainer = null;
            
            if (options.imgTopLeft != '' || options.imgTopRight != '') {
                 topContainer = $("<div style=' width:100%; height:0px'></div>");

                if (options.imgTopLeft != '') {
                    $(topContainer).append("<img src='" + options.imgTopLeft + "' style='float:left; position:relative; top:-1px; left:-1px' />");
                }
                if (options.imgTopRight != '') {
                    $(topContainer).append("<img src='" + options.imgTopRight + "' style='float:right; position:relative; top:-1px; left:1px' />");
                }

                $(this).append(topContainer);
            }

            $(this).append(container);

            if (options.imgBottomLeft != '' || options.imgBottomRight != '') {
                bottomContainer = $("<div style='height:0px'></div>");

                if (options.imgBottomLeft != '') {
                    $(bottomContainer).append("<img src='" + options.imgBottomLeft + "' style='float:left; position:relative; top: -9px; left:-1px' />");
                }
                if (options.imgBottomRight != '') {
                    $(bottomContainer).append("<img src='" + options.imgBottomRight + "' style='float:right; position:relative; top:-9px; left:1px' />");
                }

                $(this).append(bottomContainer);
            }

            if (jQuery.browser.version == "6.0" && jQuery.browser.msie) {
                if (topContainer != null) {
                    topContainer.css(
                    {
                        overflow: "hidden"
                    });
                }
                if (bottomContainer != null) {
                    bottomContainer.css(
                    {
                        overflow: "hidden"
                    });
                }
            }
           


        });


    };
    $.fn.roundQuadrant.defaults = {
        leftOffset: 0,
        topOffset: 0,
        imgTopLeft: '',
        imgTopRight: '',
        imgBottomLeft: '',
        imgBottomRight: ''
    };

    //****************************************************************/
    //********************* TEXT RESIZE ******************************/
    //****************************************************************/
    $.fn.textResize = function(options) {

            var cookieMan = new CookieManager();

            var options = $.extend({}, $.fn.textResize.defaults, options);

            return this.each(function() {
                var list = $(this);
                var count = 0;
                options.start = parseFloat($('body').css("font-size"));

                //set text size base on cookie

                if (cookieMan.read(options.cookieName) != '') {
                    var newSize = cookieMan.read(options.cookieName);
                    $.fn.textResize.setSize(newSize);
                }


                list.find("li").each(
                function() {
                    var listItem = $(this);
                    var link = $("<a href='#'></a>");

                    var newSize = options.start + (options.increment * count);
                    listItem.css({
                        "font-size": newSize + "px"
                    });

                    link.click(function() {
                        $.fn.textResize.setSize(newSize);
                        var date = new Date();
                        date.setTime(date.getTime() + (7 * 24 * 60 * 60 * 1000));
                        cookieMan.create(options.cookieName, newSize, { path: '/', expires: date });
                        return false;
                    });

                    link.html(listItem.html());
                    listItem.html("");
                    link.appendTo(listItem);
                    count++;


                });

            });

        }
        $.fn.textResize.defaults = { increment: 0.2, cookieName: "textResize" };
        $.fn.textResize.setSize = function(newSize) {
            if (newSize != null)
                $("body").css("font-size", newSize + 'px');
        }

})(jQuery)





$(function() {

    var quadCorners = {
        imgTopLeft: "/images/roundedcorners/tl.gif",
        imgTopRight: "/images/roundedcorners/tr.gif",
        imgBottomLeft: "/images/roundedcorners/bl.gif",
        imgBottomRight: "/images/roundedcorners/br.gif"
    };

    $("#textResize").textResize({ increment: 2 });
   // $(".content_quadrant_box").roundQuadrant(quadCorners);
   // $(".content_quadrant_box_rhc").roundQuadrant(quadCorners);

    $("#printThis").popupWindow({
        attributes: "status=no,scrollbars=yes,toolbar=yes,resizable=yes,location=no,menubar=yes,width=700,height=445"
    });

    $("#main2 ul li:last ").roundQuadrant({
        imgBottomLeft: "/images/roundedcorners/bl-small-white.gif",
        imgBottomRight: "/images/roundedcorners/br-small-white.gif"
    });

    $("#main2 ul li:first p:first").roundQuadrant({
        imgTopLeft: "/images/roundedcorners/tl.gif",
        imgTopRight: "/images/roundedcorners/tr.gif"
    });

    $("#topNavigation").roundQuadrant({
        imgBottomLeft: "/images/roundedcorners/bl.gif"
    });
});

