﻿// JScript File

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) +
	((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

var sitefunctions = {
    textresize: function() {
        // show text resizing links
        var $cookie_name = "SMIFontSize";
        
        var section = new Array('.edcon','.edcon p','.edcon ul','.edcon ul li','.sitemap ul li a','.edcon span');
        section = section.join(',');
               
        // if exists load saved value, otherwise store it
        if (getCookie($cookie_name)) {
            var $getSize = getCookie($cookie_name);            
            $(section).css({ fontSize: $getSize + ($getSize.indexOf("px") != -1 ? "" : "px") }); // IE fix for double "pxpx" error
        } else {
            setCookie($cookie_name, 12);
        }
                                //minus -2px
            $(".FontSizeDec").bind("click", function() {            
            $(section).css('font-size', 10);
            setCookie($cookie_name, 10);
        });
                                
        // reset link
        $(".FontSizeReset").bind("click", function() {
            $(section).css('font-size', 12);
            setCookie($cookie_name, 12);
        });
        
        // +2px
        $(".FontSizeInc").click(function() {
            $(section).css('font-size', 14);
            setCookie($cookie_name, 14);                                                

        });

    }
}


//jQuery(document).ready(function() {
//    sitefunctions.textresize();
//    
//    jQuery("#content").find(".sub_right").each(function() {
//        //getting the image's width
//        w = jQuery(this).width();
//        //getting the image's height
//        h = jQuery(this).height();
//        //To resize the height of the shadow proposionally
//        p = w/349 * 22;
//        
//        //Get the class
//        c = jQuery(this).attr("class");
//        //remove the class from the image
//        jQuery(this).removeAttr("class");
//        
//        //add a wrapper elements as well as the shadow images.
//        jQuery(this).wrap("<div class='"+c+"' style='width:"+w+"px;z-index:1' >").parent()
//        .append("<br><img width='"+w+"' height='"+p+"' src='/DATA/0/images/mot_content/photo_bottomShadow1.jpg' alt='image shadow' />");  
//    })
//    
//    //Add the clear float element at the end of contents to make sure all the floats are cleared.
//    jQuery("#mot_content").append("<div class='clear'>&nbsp;</div>");
//})


//var sitefunctions = {
//    textresize: function() {
//        // show text resizing links
//        var $cookie_name = "SMIFontSize";
//        var originalFontSize = jQuery(".edcon").css("font-size");
//        // if exists load saved value, otherwise store it
//        if (getCookie($cookie_name)) {
//            var $getSize = getCookie($cookie_name);
//            jQuery(".edcon").css({ fontSize: $getSize + ($getSize.indexOf("px") != -1 ? "" : "px") }); // IE fix for double "pxpx" error
//        } else {
//            setCookie($cookie_name, originalFontSize);
//        }
//        // reset link
//        jQuery(".FontSizeReset").bind("click", function() {
//            jQuery(".edcon").css("font-size", originalFontSize);
//            setCookie($cookie_name, originalFontSize);
//        });
//        // text “+” link
//        jQuery(".FontSizeInc").click(function() {

//            var currentFontSize = jQuery(".edcon").css("font-size");
//            var currentFontSizeNum = parseFloat(currentFontSize, 10);
//            if (currentFontSizeNum < 18) {
//                var newFontSize = currentFontSizeNum * 1.1;
//                if (newFontSize, 11) {
//                    jQuery(".edcon").css("font-size", newFontSize);
//                    setCookie($cookie_name, newFontSize);
//                }
//            }
//            return false;
//        });
//        jQuery(".FontSizeDec").bind("click", function() {
//            var currentFontSize = jQuery(".edcon").css("font-size");
//            var currentFontSizeNum = parseFloat(currentFontSize, 10);
//            if (currentFontSizeNum > 9) {
//                var newFontSize = currentFontSizeNum * 0.9;
//                if (newFontSize, 11) {
//                    jQuery(".edcon").css("font-size", newFontSize);
//                    setCookie($cookie_name, newFontSize);
//                }
//            }
//            return false;
//        });
//    }
//}

jQuery(document).ready(function() {
    sitefunctions.textresize();
    
})



