﻿//for master page font sizing
function ConstrainStyling(styleAreaName)
{
    // Reset Font Size
    var originalFontSize = $(styleAreaName).css('font-size');
    $(".resetFont").click(function() {
        $(styleAreaName).css('font-size', originalFontSize);
    });
    // Increase Font Size
    $(".increaseFont").click(function() {
        var currentFontSize = $(styleAreaName).css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 1.2;
        $(styleAreaName).css('font-size', newFontSize);
        return false;
    });
    // Decrease Font Size
    $(".decreaseFont").click(function() {
        var currentFontSize = $(styleAreaName).css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 0.8;

        if (newFontSize >= 5)
            //Cap the font decrease at 5 - IE's font-rounding screws with lower font sizes
            $(styleAreaName).css('font-size', newFontSize);
        return false;
    });
}

var whichImage;

//for master page image selection
function AddHeaders(theImages)
{
    var j = 0
    var p = theImages.length;
    var preBuffer = new Array()
    for (i = 0; i < p; i++)
    {
       preBuffer[i] = new Image()
       preBuffer[i].src = theImages[i]
    }
    
    whichImage = Math.round(Math.random()*(p-1));
}

//for addheaders
function showImage()
{
    
    document.getElementById("headerarea").style.background = "url('" + theImages[whichImage] + "')";
    document.getElementById("headerarea").style.backgroundRepeat = "no-repeat";
    document.getElementById("headerarea").style.backgroundPosition = "right";
}

//for generic master because it is special
function pickimage(backgroundSrcs, logoArea)
{
    //This line picks an image at random from the list you entered above
    var bgimage=backgroundSrcs[(Math.round(Math.random()*(backgroundSrcs.length-1)))]

    var actualLogoArea = document.getElementById(logoArea);
    
    if (actualLogoArea != undefined)
    {
        //This line applies the background image to your masthead
        actualLogoArea.style.background = "url('" + bgimage + "')";
    }
}
