﻿function init() {
    var timeout = 250;
    
    $("#nav td a").eq(1).corner("left 15px");
    $("#nav td a:last").corner("right 15px");
    
    $("#nav td a:not(.ui-state-hover):not(.bookmark)").hover(function() {
        $(this).css("background-color", "#fdbb31").effect("highlight", { color: "#8c0d05", mode: "show" }, timeout, function() {
            $(this).addClass("ui-state-hover");
        });
    },
    function() {
        $(this).stop(true, true);
        $(this).removeClass("ui-state-hover");
    });
    
    dropDowns();
}

function activateAccordion() {
    $("#leftNav").accordion({ active: 0, autoHeight: false, animated: 'slide', collapsible: true });

}

function makeEOBDialog() {
    $("#eobDialog").dialog({ modal: true, width: 740, height: 420, title: "Explanation Of Benefits" });
    $("#submitEOB").click(function() {
        alert("test");
        $("#eobDialog").dialog("close");
    });
}

function showForm(arg, dest) {
    $(arg).dialog('open');
}

function hideForm(arg) {
    $(arg).dialog("close");
}

function updateURL() {
    document.getElementById('currentURL').innerHTML = location.href + " ";
}

function imgPreLoad() {
    var images = "/images/navbar/navbar-0.gif,/images/navbar/navbar-1.gif,/images/icons/dropUp.gif,/images/icons/dropDown.gif,/images/rbox/tlb.png,/images/rbox/tmb.png,/images/rbox/trb.png,/images/rbox/mlb.png,/images/rbox/mmb.png,/images/rbox/mrb.png,/images/rbox/blb.png,/images/rbox/bmb.png,/images/rbox/brb.png,/images/rbox/bl.png,/images/rbox/bm.png,/images/rbox/br.png"; 
}

function preload(images) {
    if (document.images) 
    {
        var i = 0;
        var imageArray = new Array();
        imageArray = images.split(',');
        var imageObj = new Image();
        for (i = 0; i <= imageArray.length - 1; i++) 
        {
            //document.write('<img src="' + imageArray[i] + '" />');// Write to page (uncomment to check images)
            imageObj.src = images[i];
        }
    }
}

function dropDowns() {
    $(".dropContent").hide();
    $(".dropDownImage").attr('src', "../images/icons/dropUp.gif")

    $(".dropLink").toggle(function() {
        $(this).find(".dropDownImage:first").attr('src', "../images/icons/dropDown.gif");
        $(this).parents(".dropContainer:first").find(".dropContent:first").show('slow');
    }, function() {
        $(this).find(".dropDownImage:first").attr('src', "../images/icons/dropUp.gif");
        $(this).parents(".dropContainer:first").find(".dropContent:first").hide('slow');
    });
}

function checkWidth() {
    if (screen.width <= 1023) {
        document.getElementById("container").style.width = "740px";
    }
}

function CreateBookmarkLink() {
    title = "Southwest Service Administrators, Inc.";
    url = "https://www.southwestservicetpa.com";

    try {
        window.external.AddFavorite(url, title);
    }
    catch (error) {
        alert("Your browser does not support automatic bookmarking. Please navigate to our home page and press CTRL + D to bookmark our site.");
    }
}

function DateTest() {
    $("li[dateCreated]").each(function(i) {
        fileDate = this.attributes.getNamedItem("dateCreated").value;
        if (IsDateRecent(30, fileDate)) {
            var newSpan = document.createElement("span");
            var newSpanClass = document.createAttribute("class");
            newSpanClass.value = "newSpan";
            newSpan.attributes.setNamedItem(newSpanClass);
            newSpan.innerHTML = " New!";
            this.appendChild(newSpan);
        }
    });
}

function openHTP(url)
{
    var w = screen.availWidth - 325;
    var h = screen.availHeight - 140;
    
    var helpMoveToLeft = screen.availWidth - 310;
    var helpHeight = screen.availHeight - 45;
    var helpWidth = 290;
    
    if (navigator.appName != "Microsoft Internet Explorer") {

        w = screen.availWidth - 325;
        h = screen.availHeight;
        
        helpMoveToLeft = screen.availWidth - 260;
        helpHeight = screen.availHeight;
    }

    window.open(url, 'HTP', 'width=' + w + ',location=yes,directories=yes,status=yes,menubar=yes,toolbar=yes,top=0,scrollbars=yes,resizable=yes,height=' + h + ',left=0');
    window.open('htpHelp.html', 'HTPHelp', 'width=' + helpWidth + ',top=0,scrollbars=yes,resizable=yes,height=' + helpHeight + ',left=' + helpMoveToLeft);
}

function IsDateRecent(recentDays, date) {
    var oneDate = 1000 * 60 * 60 * 24;

    if (((new Date()).getTime() - (new Date(date)).getTime()) / oneDate <= recentDays) {
        return true;
    }
    else {
        return false;
    }
}