﻿//returns true is it is an array
function isArray(obj) {
    if (typeof obj == "undefined") return false;
    return (obj.constructor.toString().indexOf("Array") != -1);
}
function arrayIndexOf(a, v) {
    if (isArray(a)) {
        for (i = 0; i < a.length; i++) {
            if (a[i] == v) return i;
        }
    }
    return -1;
}
function FP_preloadImgs() {//v1.0
    var d = document, a = arguments; if (!d.FP_imgs) d.FP_imgs = new Array();
    for (var i = 0; i < a.length; i++) { d.FP_imgs[i] = new Image; d.FP_imgs[i].src = a[i]; }
}

function markAsSelected(selectedBoxes) {
    for (var sb in selectedBoxes) {
        $(selectedBoxes[sb]).css({
            'background-color': '#616A5A',
            'cursor': 'hand'
        }).click(function() {
            var href = $(this).find("a").attr("href");
            window.location = href;
        });
    }
}
function setup_round_box_1_hover() {
    $(".round-box-1").css("cursor", "hand").hover(
        function() {
            $(this).find(".round-box-1-top").andSelf().css("background-image", "url(./images/img_SelectedTop.gif)")
            $(this).find(".round-box-1-bottom").andSelf().css("background-image", "url(./images/img_SelectedBottom.gif)")
            $(this).css("background-image", "url(./images/img_SelectedMiddle.gif)");
        },
        function() {
            $(this).find(".round-box-1-top").andSelf().css("background-image", "url(./images/img_TestimonialsTop.gif)")
            $(this).find(".round-box-1-bottom").andSelf().css("background-image", "url(./images/img_TestimonialsBottom.gif)")
            $(this).css("background-image", "url(./images/img_TestimonialsBkg.gif)");
        }
    ).click(function() {
        var href = $(this).find("a").attr("href");
        window.location = href;
    });
}
function setup_round_box_2_hover(boxNames) {
    for (i in boxNames) {
        $(boxNames[i]).css("cursor", "hand").hover(
            function() {
        $(this).find(".round-box-2-top").andSelf().css("background-image", "url(./images/img_SmallRoundBoxSelectedTopGray.gif)")
        $(this).find(".round-box-2-bottom").andSelf().css("background-image", "url(./images/img_SmallRoundBoxSelectedBottomGray.gif)")
                $(this).css("background-image", "url(./images/img_SmallRoundBoxSelectedMiddle.gif)");
                if ($(this).find("img").attr("src").indexOf("img_PdfIcon") > 0) {
                    $(this).find("img").attr({ src: "images/img_PdfIconSelected.gif" });
                };
            },
            function() {
            $(this).find(".round-box-2-top").andSelf().css("background-image", "url(./images/img_SmallRoundBoxTopGray.gif)")
            $(this).find(".round-box-2-bottom").andSelf().css("background-image", "url(./images/img_SmallRoundBoxBottomGray.gif)")
                $(this).css("background-image", "url(./images/img_SmallRoundBoxMiddle.gif)");
                if ($(this).find("img").attr("src").indexOf("img_PdfIcon") > 0) {
                    $(this).find("img").attr({ src: "images/img_PdfIcon.gif" });
                }
            }
        ).click(function() {
            var a = $(this).find("a");
            if (a.attr("target") == "_blank")
                window.open(a.attr("href"));
            else
                window.location = a.attr("href");
        });
    }
}
function FP_jumpMenu(el, frm, sel) {//v1.0
    var href = el.options[el.selectedIndex].value;
    if (sel) el.selectedIndex = 0;
    if (href.substring(0, 1) == "-") {
        href = href.substring(1);
    }
    if ('_new' == frm) open(href);
    else eval(frm + ".location='" + href + "'");
}

function returnDocument() {
    var file_name = document.location.href;
    var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
    return file_name.substring(file_name.lastIndexOf("/") + 1, end);
}

