/***********************************************************************

Global variables for offRamp language

************************************************************************/
var iGlobalEng = 1;
var iThirdPartyEng = 2;

var $j = jQuery;

/***********************************************************************
function FollowURL(iLanguage, sURL, bReturn, sWndName, sOptions)

Description:
Shows the off-ramp language to the user before navigating to a third-
party or global site. 
    
Parameters:
iLanguage: integer value defined above identifying the language to use
Global AZ English = 1
Third Party English = 2
sURL: string value identifying the URL the user is attempting to navigate to
bReturn: optional boolean value identifying whether a return value is required by the caller
sWndName: optional string identifying the name of the target window
sOptions: optional string identifying window.open options
    
Example:
FollowURL(iGlobalEng, "http://www.cnn.com", false, "CNN", "top=10,left=10")

************************************************************************/
function FollowURL(iLanguage, sURL, bReturn, sWndName, sOptions) {
    var sPrompt;
    switch (iLanguage) {
        case 1: // iGlobalEng
            sPrompt = "This link will take you to a global section of this site maintained by ABBOTT.\n Click Cancel to return or OK to continue."
            break;
        case 2: // iThirdPartyEng
            sPrompt = "You are now leaving www.AbbottPointofCare.com.\n\nThis will take you to a site maintained by a third party who is solely responsible for its content.\n\nAbbott Point of Care and Abbott Laboratories provide this link as a service to Web site visitors. Abbott Point of Care and Abbott Laboratories are not responsible for the Privacy Policy of any third-party Web sites. We encourage you to read the privacy policy of every Web site you visit."
            break;
    }

    if (sWndName == null) sWndName = "opener";
    if (sOptions == null) sOptions = "";

    if (!confirm(sPrompt))
        if (bReturn) return false;
    else return;

    var externalWin = window.open(sURL, null, sOptions);
    if (externalWin.opener == null)
        externalWin.opener = window;
    externalWin.opener.name = sWndName;
    if (bReturn) return true;
}

/**********************************************************************/
//Function used to show/hide the accordian sections of the sub pages.
function showAccord(objImgIcon, idAccordSect, accordIconVal) {
    var objAccordSect;
    var accordIconValue;
    var strImgPath;

    objAccordSect = document.getElementById(idAccordSect);
    accordIconValue = document.getElementById(accordIconVal);

    if (accordIconValue.value == 0) {
        objAccordSect.style.display = 'block';
        objImgIcon.src = '/images/istat_contianer_minus.gif';
        accordIconValue.value = '1'
    }
    else if (accordIconValue.value == 1) {
        objAccordSect.style.display = 'none';
        objImgIcon.src = '/images/istat_contianer_plus.gif';
        accordIconValue.value = '0';
    }

    location.href = "#acc1";
}

/**********************************************************************/

// RESIZE TEXT ON SUB PAGES
function resizeText(fontSize) {
    //alert('test');
    //document.getElementById('midSection').getElementsByTagName("p").style.font
    //document.getElementById('midSection').style.fontSize = "15px";
    for (var i = 0; i <= document.getElementById('midSection').getElementsByTagName('p').length; i++) {
        alert(i);
        document.getElementsByTagName('p')[i].className = "size15px";
    }
}

function ChangeFontSize(size) {
    var x = $j("#midSection p").each(function () { $j(this).css("font-size", size); });
    var x = $j("#midSection a").each(function () { $j(this).css("font-size", size); });
    var x = $j("#midSection li").each(function () { if(!($j(this).hasClass("item")))$j(this).css("font-size", size); });
    createCookie("fontSize", size, 7);
}

function displayText(cartridge) {
    var desc = document.getElementById("flashDescriptor");
    if (cartridge == "3") {
        desc.innerHTML = '<span class="clrStyle"><strong>CHEM8+</strong></span>: Fast evaluation of metabolic status and renal function of patients. <span><a href="istat-cartridges.aspx" class="clrAnchorStyle">View all&nbsp;<img src="/images/orange_arrow.gif" width="8" height="9" border="0" /></a></span>';
    }
    else if (cartridge == "0") {
        desc.innerHTML = '<span class="clrStyle"><strong>BNP</strong></span>: For quickly reaching a diagnosis in patients presenting with shortness of breath. <span><a href="istat-cartridges.aspx" class="clrAnchorStyle">View all&nbsp;<img src="/images/orange_arrow.gif" width="8" height="9" border="0" /></a></span>';
    }
    else if (cartridge == "5") {
        desc.innerHTML = '<span class="clrStyle"><strong>cTnl</strong></span>: Rapid triage of chest pain patients, including those with ACS. <span><a href="istat-cartridges.aspx" class="clrAnchorStyle">View all&nbsp;<img src="/images/orange_arrow.gif" width="8" height="9" border="0" /></a></span>';
    }
    else if (cartridge == "1") {
        desc.innerHTML = "<span class='clrStyle'><strong>CG4+</strong></span>: Useful for the diagnosis &amp; treatment of lactic acidosis in conjunction with measurements of blood acid base states and diagnosis of hyperlactatemia.<span><a href='istat-cartridges.aspx' class='clrAnchorStyle'>View all&nbsp;<img src='/images/orange_arrow.gif' width='8' height='9' border='0' /></a></span>";
    }
    else if (cartridge == "6") {
        desc.innerHTML = '<span class="clrStyle"><strong>PT/INR</strong></span>: Applicable for Identifying and monitoring of patients on anticoagulant therapy. <span><a href="istat-cartridges.aspx" class="clrAnchorStyle">View all&nbsp;<img src="/images/orange_arrow.gif" width="8" height="9" border="0" /></a></span>';
    }
    else if (cartridge == "2") {
        desc.innerHTML = '<span class="clrStyle"><strong>CG8+</strong></span>: Blood gas panel plus electrolytes including glucose and ionized calcium measurement. <span><a href="istat-cartridges.aspx" class="clrAnchorStyle">View all&nbsp;<img src="/images/orange_arrow.gif" width="8" height="9" border="0" /></a></span>';
    }
    else if (cartridge == "4") {
        desc.innerHTML = '<span class="clrStyle"><strong>Creatinine</strong></span>: Rapid results for assessing renal function. <span><a href="istat-cartridges.aspx" class="clrAnchorStyle">View all&nbsp;<img src="/images/orange_arrow.gif" width="8" height="9" border="0" /></a></span>';
    }
    else if (cartridge == "7") {
        desc.innerHTML = '<span class="clrStyle"><strong>Other</strong></span>: See our full range of testing cartridges and applications. <span><a href="istat-cartridges.aspx" class="clrAnchorStyle">View all&nbsp;<img src="/images/orange_arrow.gif" width="8" height="9" border="0" /></a></span>';
    }
}

function expandRef() {
    document.getElementById("refs").style.display = "block";
    document.getElementById("expand").style.display = "none";
    document.getElementById("collapse").style.display = "block";
}

function collapseRef() {
    document.getElementById("refs").style.display = "none";
    document.getElementById("expand").style.display = "block";
    document.getElementById("collapse").style.display = "none";
}

function printYear() {
    now = new Date;
    theYear = now.getYear();
    if (theYear < 1900)
        theYear = theYear + 1900;
    document.write(theYear)
}

/* LightBox Functions */
$j(function() {
    // LightBox
    if ($j(".lightBox").length) {
        $j(".lightBox").wrapInner("<div class='lightBoxBody'></div>")
            .prepend("<div class='lightBoxCapper'></div>")
            .append("<div class='lightBoxFooter'></div>")
            .append("<a href='#' class='lightBoxCloseButton'>X</a>")
            .css({ display: "none" });

        $j(".lightBoxLink").live("click", function() {
            if (this != null && $j(this).attr("rel") != null && $j(this).attr("rel") != "") {
                var id = $j(this).attr("rel");
                ShowLightBoxByID(id);
            }
        });

        $j(".lightBoxCloseButton").live("click", function() {
            CloseLightBox($j(this).parent());
            return false;
        });

        $j(window).resize(function() { CenterLightBox($j(".lightBox")) });
        $j(window).scroll(function() { CenterLightBox($j(".lightBox")) });
        
    }
});

function ShowLightBox(lightBox) {
    if (!$j(".lightBoxBackground").length) {
        $j("body").append("<div class='lightBoxBackground'></div>");
        $j(".lightBoxBackground").css({ opacity: 0.75 }).hide();
        $j(".lightBoxBackground").live("click", function() {
            CloseLightBox(lightBox);
            return false;
        });
    }
    if (document.getElementById('flashMovie')) {
        var flashContent = $j('#flashContent').html();
        lightBox.html(flashContent);
    }
    
    CenterLightBox(lightBox);

    lightBox.fadeIn(10);

    $j(".lightBoxBackground").fadeIn(10);
    return true;
}
function ShowLightBoxByID(lightBoxID) {
    return ShowLightBox($j('#' + lightBoxID));
}
function CloseLightBox(lightBox) {
   
    $j("#webinarVideoWrapper").html("<div id='webinarVideoDiv'></div>");
    lightBox.fadeOut(1);
    $j(".lightBoxBackground").fadeOut(10);
    return false;
   
}
function CloseLightBoxByID(lightBoxID) {
    
    CloseLightBox($j('#' + lightBoxID));
}

function CenterLightBox(lightBox) {
    lightBox.css("top", (($j(window).height() - lightBox.outerHeight()) / 2) + $j(window).scrollTop() + "px");
    lightBox.css("left", (($j(window).width() - lightBox.outerWidth()) / 2) + $j(window).scrollLeft() + "px");  
}


$j(document).ready(function() {
    var navTimerHandle = null;

    $j('#pcsDropDown').hover(
        function() {
            //show its submenu
            if ($j(this).children('ul:animated').length === 0) {
                $j(this).children('ul').show(100);
                $j('#fontResize').css('visibility', 'hidden');
                clearTimeout(navTimerHandle);
            }
        },
        function() {
            //hide its submenu
            $this = $j(this);
            navTimerHandle = setTimeout(
                function() {
                    if ($this.children('ul:animated').length === 0) {
                        $this.children('ul').hide(100, function() {
                            $j('#fontResize').css('visibility', 'visible')
                        });
                    }
                },
                250);
        }
    );

    var size = readCookie("fontSize");
    if (size != null)
        ChangeFontSize(size);
});

function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    if (document.cookie != "") {
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}
