﻿/*------------------------ 
© 2009 Systen, L.L.C. 
10500 Barkley 
Suite 200 
Overland Park, KS 66212 
-----------------------
Created by: Michael Merrell
Date Created: 3/5/2009
-----------------------
Purpose:
-----------------------
*/
function openWin(childURL, childWidth, childHeight, scrollBars, toolbars, resizable) {
    var childWin;
    var childLeft = (screen.width - childWidth) / 2;
    var childTop = (screen.height - childHeight) / 2;

    childWin = window.open(childURL, '', 'toolbar=' + toolbars + ',location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollBars +
		',resizable=' + resizable + ',width=' + childWidth + ',height=' + childHeight + ',top=' + childTop + ',left=' + childLeft);

    return childWin;
} //function openWin(childURL, childWidth, childHeight, scrollBars, toolbars, resizable) 

function showWin(childURL, childWidth, childHeight) {
    if (document.documentElement.clientWidth <= childWidth || document.documentElement.clientHeight <= childHeight) {
        openWin(childURL, childWidth, childHeight, 'no', 'no', 'no');
    }
    else if (document.getElementById('dvWindowMain') && document.getElementById('iWindow') && document.getElementById('dvWindow')) {
        var dvWindowMain = document.getElementById('dvWindowMain');
        var dvWindow = document.getElementById('dvWindow');
        var iWindow = document.getElementById('iWindow');

        dvWindowMain.style.display = "block";

        dvWindow.style.width = childWidth + 'px';
        dvWindow.style.height = childHeight + 'px';
        dvWindow.style.left = ((document.documentElement.clientWidth - childWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - childHeight) / 2) + 'px';

        iWindow.src = childURL;
        iWindow.height = childHeight + 'px';
        iWindow.width = childWidth + 'px';
    }
    else {
        var dvWindowMain = document.createElement('div');
        var dvBlackOut = document.createElement('div');
        var dvWindow = document.createElement('div');
        var iWindow = document.createElement('iframe');

        dvWindowMain.appendChild(dvBlackOut);
        dvWindowMain.appendChild(dvWindow);
        dvWindow.appendChild(iWindow);

        dvWindowMain.id = "dvWindowMain";
        dvWindowMain.style.width = "100%";
        dvWindowMain.style.height = "100%";
        dvWindowMain.style.display = "block";
        dvWindowMain.style.position = "absolute";
        dvWindowMain.style.left = "0px";
        dvWindowMain.style.top = "0px";

        dvBlackOut.className = "dvBlackOut";

        dvWindow.id = "dvWindow";
        dvWindow.className = "dvWindow";
        dvWindow.style.width = childWidth + 'px';
        dvWindow.style.height = childHeight + 'px';
        dvWindow.style.left = ((document.documentElement.clientWidth - childWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - childHeight) / 2) + 'px';

        iWindow.id = "iWindow"
        iWindow.src = childURL;
        iWindow.height = childHeight + 'px';
        iWindow.width = childWidth + 'px';
        iWindow.frameborder = "0";

        document.forms[0].appendChild(dvWindowMain);
    }
}

function closeWin(bRefresh) {
    if (parent.document.getElementById('dvWindowMain') && bRefresh) {
        parent.document.location = parent.document.location;
    }
    else if (parent.document.getElementById('dvWindowMain') && bRefresh == false) {
        parent.document.getElementById('dvWindowMain').style.display = "none";
        parent.document.getElementById('iWindow').src = "";
    }
    else if (document.getElementById('dvWindowMain') && bRefresh) {
        document.location = document.location;
    }
    else if (document.getElementById('dvWindowMain') && bRefresh == false) {
        document.getElementById('dvWindowMain').style.display = "none";
        document.getElementById('iWindow').src = "";
    }
    else if (self.opener && self.opener.document.getElementById('dvWindowMain') && bRefresh) {
        self.opener.document.location = self.opener.document.location;
        self.close();
    }
    else //if (self.opener && bRefresh == false)
    {
        self.close();
    }
}

function centerWin() {
    var dvWindow = document.getElementById('dvWindow');
    if (dvWindow != null) {
        dvWindow.style.left = ((document.documentElement.clientWidth - dvWindow.clientWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - dvWindow.clientHeight) / 2) + 'px';
    }
}


function setArrow(location) {
    $("#li_" + location).prepend("<img src=\"../images/arrow_orange.gif\" alt=\"Managed Care\" class=\"nav_arrow\" />");
}

function setMarker(location) {
    $("#nav_" + location).addClass("on");
    //setArrow(location);
}

function setSubMarker(location) {
    $("#sub_" + location).addClass("on");
    if (location == "provider_search") {
        setMarker(location);
    }
}

    function randomXToY(minVal, maxVal, floatVal) {
        var randVal = minVal + (Math.random() * (maxVal - minVal));
        return typeof floatVal == 'undefined' ? Math.round(randVal) : randVal.toFixed(floatVal);
    }

    function setHeaderImg() {
    // header images 8-12 are the new images to be used
    var rand = randomXToY(8, 12);  //Math.ceil(Math.random() * 12);
    $("#header_img").attr("src","../images/header_" + rand + ".jpg");
}

/* JQUERY AREA */

    function initMenus() {
        $('ul.menu ul').hide();
        $.each($('ul.menu'), function() {
            $('#' + this.id + '.expandfirst ul:first').show();
        });
        $('ul.menu li a').click(
            function() {
                var checkElement = $(this).next();
                var parent = this.parentNode.parentNode.id;

                if ($('#' + parent).hasClass('noaccordion')) {
                    $(this).next().slideToggle('normal');
                    return false;
                }
                if ((checkElement.is('ul')) && (checkElement.is(':visible'))) {
                    if ($('#' + parent).hasClass('collapsible')) {
                        $('#' + parent + ' ul:visible').slideUp('normal');
                    }
                    return false;
                }
                if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
                    $('#' + parent + ' ul:visible').slideUp('normal');
                    checkElement.slideDown('normal');
                    return false;
                }
            }
        );
    }

    var pathname = window.location.pathname;
    var winLoc1 = window.location.href;
    var winLoc2 = winLoc1.substring(winLoc1.lastIndexOf("?") + 1);
    var winLoc = winLoc2.replace("Cat_ID=", "");
    var page = pathname.substring((pathname.lastIndexOf("/") + 1), pathname.lastIndexOf("."));
    var sub;
    
    if ((page == "index") ||
        (page == "home")) {
        page = "home";
    }
    if ((page == "medical_mgmt") ||
        (page == "cisap") ||
        (page == "billpricing_review")) {
            sub = page;
            page = "services";
    }
    if ((page == "provider_network") ||
        (page == "provider_search") ||
        (page == "provider_signup")) {
            sub = page;
            if (page == "provider_network") {
                sub = page + "1";
            }
            page = "provider_network";
        }
    if (page == "faqs") {
            sub = "faq_"+winLoc;
    }

    $(document).ready(function() {
        setHeaderImg();
        initMenus();
        setMarker(page);
        setSubMarker(sub);
        $("#sub_" + page).show();
    });

/*

* $History: scripts.js $
 * 
 * *****************  Version 13  *****************
 * User: Trye         Date: 3/03/10    Time: 9:36a
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 12  *****************
 * User: Trye         Date: 3/02/10    Time: 4:22p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 11  *****************
 * User: Trye         Date: 3/02/10    Time: 4:11p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 10  *****************
 * User: Trye         Date: 3/02/10    Time: 12:28p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 9  *****************
 * User: Trye         Date: 2/27/10    Time: 1:42p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 8  *****************
 * User: Trye         Date: 2/24/10    Time: 3:43p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 7  *****************
 * User: Trye         Date: 2/19/10    Time: 5:37p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 6  *****************
 * User: Trye         Date: 2/10/10    Time: 2:04p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 5  *****************
 * User: Trye         Date: 1/29/10    Time: 4:28p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 4  *****************
 * User: Trye         Date: 1/29/10    Time: 4:08p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
 * 
 * *****************  Version 3  *****************
 * User: Trye         Date: 1/28/10    Time: 2:54p
 * Updated in $/CompResults/Projects/CompResults/Public/scripts
* 
* *****************  Version 2  *****************
* User: Trye         Date: 12/22/09   Time: 12:03p
* Updated in $/CompResults/Projects/CompResults/Public/scripts
* 
* *****************  Version 1  *****************
* User: Trye         Date: 12/14/09   Time: 5:17p
* Created in $/CompResults/Projects/CompResults/Public/scripts
* 
* *****************  Version 1  *****************
* User: Mmerrell     Date: 12/08/09   Time: 2:08p
* Created in $/CompResults/Projects/CompResults/script
* 
* *****************  Version 1  *****************
* User: Mmerrell     Date: 3/05/09    Time: 9:53a
* Created in $/Systen/Projects/CompResults_08/script
*
*/
