/*################################################################################
##################################################################################
####  Page Scripts                                                            ####
####  Requires: jQuery                                                        ##*/


/*################################################################################
##################################################################################
####  FUNCTION: SetFontSizeClass                                              ####
####  Takes the given class name and assigns it to the document body          ####
####  Updates the SESSION value so the font size transfers between pages      ##*/
function SetFontSizeClass(ClassName, ID){
    jQuery.get(         '/services/set-font-size.php',
                        {'FontClass': ClassName},
                        function(data, textStatus){
                            jQuery("body").removeClass()
                                .addClass(ClassName);
                            jQuery("span#SelectorSize1").removeClass();
                            jQuery("span#SelectorSize2").removeClass();
                            jQuery("span#SelectorSize3").removeClass();
                            jQuery("span#" + ID).addClass("FontSizeActive");
                        }
        );
}


/*################################################################################
##################################################################################
####  Assigns the click events to the font selectors                          ####
####                                                                          ##*/
jQuery("window").ready(
    function(){
        jQuery("span#SelectorSize1").click(
            function(){
                SetFontSizeClass("Size1", "SelectorSize1");
            }
        );
        
        jQuery("span#SelectorSize2").click(
            function(){
                SetFontSizeClass("Size2", "SelectorSize2");
            }
        );
        
        jQuery("span#SelectorSize3").click(
            function(){
                SetFontSizeClass("Size3", "SelectorSize3");
            }
        );
    }
);



/*################################################################################
##################################################################################
####  Applying rounded corners                                                ####
####                                                                          ##*/
function RoundCorners(CSSSelector, Color){
    if(!Color){
        Color = "#ffffff";
    }
    jQuery.each(
        jQuery(CSSSelector),
        function(){
            var Width = jQuery(this).width(), Height = jQuery(this).height();
            jQuery(this)
                .css("position", "relative")
                .html(
                //TL
                    '<div class="Rounded50" style="left: 0px; top: 1px; background-color: ' + Color + '" />' +
                    '<div class="Rounded100" style="left: 0px; top: 0px; background-color: ' + Color + '" />' +
                    '<div class="Rounded50" style="left: 1px; top: 0px; background-color: ' + Color + '" />' +
                //TR
                    '<div class="Rounded50" style="left: ' + (Width - 2) + 'px; top: 0px; background-color: ' + Color + '" />' +
                    '<div class="Rounded100" style="left: ' + (Width - 1) + 'px; top: 0px; background-color: ' + Color + '" />' +
                    '<div class="Rounded50" style="left: ' + (Width - 1) + 'px; top: 1px; background-color: ' + Color + '" />' +
                //BR
                    '<div class="Rounded50" style="left: ' + (Width - 1) + 'px; top: ' + (Height - 2) + 'px; background-color: ' + Color + '" />' +
                    '<div class="Rounded100" style="left: ' + (Width - 1) + 'px; top: ' + (Height - 1) + 'px; background-color: ' + Color + '" />' +
                    '<div class="Rounded50" style="left: ' + (Width - 2) + 'px; top: ' + (Height - 1) + 'px; background-color: ' + Color + '" />' +
                //BL
                    '<div class="Rounded50" style="left: 1px; top: ' + (Height - 1) + 'px; background-color: ' + Color + '" />' +
                    '<div class="Rounded100" style="left: 0px; top: ' + (Height - 1) + 'px; background-color: ' + Color + '" />' +
                    '<div class="Rounded50" style="left: 0px; top: ' + (Height - 2) + 'px; background-color: ' + Color + '" />'
                );
        }
    );
}
