<!--
function popitup(url) {
    newwindow = window.open(url, 'ehlspop', 'height=450,width=570,left=50, top=50, scrollbars=yes, status=yes');
    if (window.focus) {
        newwindow.focus()
    }
    return false;
}

function theRotator() {
    //Set the opacity of all images to 0
    $('div#rotator ul li').css({
        opacity: 0.0
    });

    //Get the first image and display it (gets set to full opacity)
    $('div#rotator ul li:first').css({
        opacity: 1.0
    });

    //Call the rotator function to run the slideshow, 12000 = change to next image after 12 seconds
    setInterval('rotate()', 12000);

}

function rotate() {
    //Get the first image
    var current = ($('div#rotator ul li.show') ? $('div#rotator ul li.show') : $('div#rotator ul li:first'));

    //Get next image, when it reaches the end, rotate it back to the first image
    var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') : current.next()) : $('div#rotator ul li:first'));

    //Set the fade in effect for the next image, the show class has higher z-index
    next.css({
        opacity: 0.0
    })
    .addClass('show')
    .animate({
        opacity: 1.0
    },
    1000);

    //Hide the current image
    current.animate({
        opacity: 0.0
    },
    1000)
    .removeClass('show');

};

function validateForm() {

    valid = true;
    msg = '';

    if ( $("#borrower_name_first").val() == "" )
    {
        msg = msg + "- First Name \n";
        valid = false;
    }
    if ( $("#borrower_name_last").val() == "" )
    {
        msg = msg + "- Last Name \n";
        valid = false;
    }
    if ( $("#phone").val() == "" )
    {
        msg = msg + "- Phone \n";
        valid = false;
    }
    if ( $('#state option:selected').val() == "" )
    {
        msg = msg + "- State \n";
        valid = false;
    };
    
    if ( msg != '') {
        alert( 'Please enter a value in the following fields: \n' + msg );
    }

    return valid;
}

$(document).ready(function() {

    // Footer Link Popups
    $("a#link-legal").click(function(event) {
        return popitup(this.href);
    });
    $("a#link-privacy").click(function(event) {
        return popitup(this.href);
    });
    $("a#link-licenses").click(function(event) {
        return popitup(this.href);
    });

    // Font Resizer
    var originalFontSize = $('html').css('font-size');
    $(".resetFont").click(function() {
        $('html').css('font-size', originalFontSize);
    });
    // Increase Font Size
    $("#increaseFont").click(function() {
        var currentFontSize = $('html').css('font-size');
        if (currentFontSize == "small") {
            currentFontSize = '13px';
        }
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 1.2;
        $('html').css('font-size', newFontSize);
        return false;
    });
    // Decrease Font Size
    $("#decreaseFont").click(function() {
        var currentFontSize = $('html').css('font-size');
        if (currentFontSize == "small") {
            currentFontSize = '13px';
        }
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum * 0.8;
        $('html').css('font-size', newFontSize);
        return false;
    });

    //Load the slideshow
    theRotator();

});
// -->

