﻿//Text resizing function
var sitefunctions = {
    textresize : function(){
        // show text resizing links
        $("#textsize").show();
        //set a cookie to remember user preference
        var $cookie_name = "serviceNS-textSize";
        var originalFontSize = $("html").css("font-size");
        // if exists load saved value, otherwise store it
        if($.cookie($cookie_name)) {
            var $getSize = $.cookie($cookie_name);
            $("html").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")}); // IE fix for double "pxpx" error
        } else {
            $.cookie($cookie_name, originalFontSize);
        }
        //decrease link
        $(".decreaseFont").bind("click", function() {
            var currentFontSize = $("html").css("font-size");
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var currentDivHeight = $(".spotlight,  .taskbox").css("height");
            var currentDivHeightNum = parseFloat(currentDivHeight, 10);
            var currentHomeDivHeight = $(".spotlightHome").css("height");
            var currentHomeDivHeightNum = parseFloat(currentHomeDivHeight, 10);
            var currentServicesDivHeight = $(".spotlightServices").css("height");
            var currentServicesDivHeightNum = parseFloat(currentServicesDivHeight, 10);
            var newFontSize = currentFontSizeNum*0.9;
            var newDivSize = currentDivHeightNum*0.9;
            var newHomeDivSize = currentHomeDivHeightNum*0.86;
            var newServicesDivSize = currentServicesDivHeightNum*0.9;
            if (newFontSize > 15) {
                $("html").css("font-size", newFontSize);
                $('.spotlight, .taskbox').css("height",newDivSize); 
                $('.spotlightHome').css("height",newHomeDivSize); 
                $('.spotlightServices').css("height",newServicesDivSize); 
                $.cookie($cookie_name, newFontSize);
  }
  return false;
});
        // increase link
        $(".increaseFont").bind("click", function() {
            var currentFontSize = $("html").css("font-size");
            var currentFontSizeNum = parseFloat(currentFontSize, 10);
            var currentDivHeight = $(".spotlight,  .taskbox").css("height");
            var currentDivHeightNum = parseFloat(currentDivHeight, 10);
            var currentHomeDivHeight = $(".spotlightHome").css("height");
            var currentHomeDivHeightNum = parseFloat(currentHomeDivHeight, 10);
            var currentServicesDivHeight = $(".spotlightServices").css("height");
            var currentServicesDivHeightNum = parseFloat(currentServicesDivHeight, 10);
            var newFontSize = currentFontSizeNum*1.1;
            var newDivSize = currentDivHeightNum*1.1;
            var newHomeDivSize = currentHomeDivHeightNum*1.14;
            var newServicesDivSize = currentServicesDivHeightNum*1.1;
            if (newFontSize < 20) {
                $("html").css("font-size", newFontSize);
                $('.spotlight,.taskbox').css("height",newDivSize); 
                $('.spotlightHome').css("height",newHomeDivSize); 
                $('.spotlightHome').css("padding-bottom","13px"); 
                $('.spotlightServices').css("height",newServicesDivSize); 
                $.cookie($cookie_name, newFontSize);
                    
            }
            return false;    
        });
    }
}
$(function(){
        sitefunctions.textresize();    
})

//Striped tables funtion
$(function(){
//Add the alt class to even rows
$(".stripe tr:even").addClass("alt");
});
//Searchbox opacity - IE
$(function() {
    $('#search').css({opacity: .8});                                  
});
//Create equal height boxes for spotlight/taskbox divs
function equalHeight(group) {
    tallest = 0;
    //Find out which box is the tallest
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

//Create equal height boxes for the top three AccessNS spotlight divs
function homeHeight(group) {
    tallest = 0;
    //Find out which box is the tallest
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}

//Create equal height boxes for the top three AccessNS spotlight divs
function servicesHeight(group) {
    tallest = 0;
    //Find out which box is the tallest
    group.each(function() {
        thisHeight = $(this).height();
        if(thisHeight > tallest) {
            tallest = thisHeight;
        }
    });
    group.height(tallest);
}
