﻿// parameters（have to be a number except iconRatio.）
iconWidth = 100;        // Initial value of icon width (must be equal a value in css.)
iconHeight = 93;        // Initial value of icon height (must be equal a value in css.)
iconWidthMax = 162;     // Maximum value of icon width (must be equal a value in css.)
iconHeightMax = 150;    // Maximum value of icon height (must be equal a value in css.)
iconStep = 3;           // Step count of icon spread.
interval = 50;          // Interval of icon spread. 
frontZIndex = 100;      // Z index of spreading icon.

function spreadIcon(iconID, mode) {
    if (!document.getElementById) return;

    var icon = document.getElementById('promoicon' + iconID);
    if (!icon) return;

    if (!icon.step) {
        icon.step = 0;
    }

    clearInterval(icon.timer);

    icon.style.zIndex = frontZIndex;

    icon.timer = setInterval(function() { resizeIcon(icon, mode); }, interval);
}
    function ShowAddressDiv(pDiv, pLink, pTotalDivs)
    {
        for(intCnt=1;intCnt<=pTotalDivs; intCnt++)
        {
            var vDiv = document.getElementById('Div'+intCnt.toString());
            vDiv.style.display='none';
            document.getElementById("tab"+intCnt.toString()).className = "ContactUsCustomLinkBlue";
        }
        var vDiv1 = document.getElementById(pDiv);
        vDiv1.style.display="block";
        var vItem = document.getElementById(pLink);
        vItem.className="ContactUsCustomLinkBlack";
        var vTitle = document.getElementById('divTitle');
        vTitle.innerHTML = vItem.text;
    }
function resizeIcon(icon, mode) {
    if (!icon) return;

    icon.step += mode;

    if (icon.step <= 0 || icon.step >= iconStep) {
        clearInterval(icon.timer);
        if (icon.step < 0) {
            icon.step = 0;
        }
        else if (icon.step > iconStep) {
            icon.step = iconStep;
        }
        if (icon.step <= 0) {
            icon.style.zIndex = '';
        }
    }

    icon.style.width = iconWidth + Math.round((iconWidthMax - iconWidth) / iconStep) * icon.step + 'px';
    icon.style.height = iconHeight + Math.round((iconHeightMax - iconHeight) / iconStep) * icon.step + 'px';
}

var tabs = new Array("tab01", "tab02", "tab03", "tab04", "tab05");

function selectTab(selected) {
    if (!document.getElementById) return;
    for (i = 0; i <= tabs.length - 1; i++) {
        if (!document.getElementById(tabs[i])) continue;
        if (tabs[i] == selected) {
            document.getElementById("tab" + tabs[i]).className = "tabnameselected";
            document.getElementById(tabs[i]).style.display = "block";
            if (document.getElementById("hfTab"))
            document.getElementById("hfTab").value = selected;
            
        } else {
            document.getElementById("tab" + tabs[i]).className = "tabname";
            document.getElementById(tabs[i]).style.display = "none";
        }
        document.getElementById(tabs[i]).style.borderBottom = "none";
    }
}

function load() {
    if (!document.getElementById) return;

    for (i = 0; i <= tabs.length - 1; i++) {
        if (!document.getElementById(tabs[i])) continue;

        var nodes = document.getElementById(tabs[i]).childNodes;
        for (var j = 0; j < nodes.length; j++) {
            if (nodes[j].className == "tabtitle") {
                nodes[j].style.display = "none";
            }
        }

        var linkButton = document.getElementById(tabs[i] + "button");
        if (linkButton) {
            linkButton.style.display = "none";
        }
    }
}

function changeButton(selected) {
    if (!document.getElementById) return;

    var body = document.getElementById("tabwindowitems");
    var buttonArea = document.getElementById("tabwindowbuttonarea");
    var button = document.getElementById("tabwindowbutton");
    var footer = document.getElementById("tabwindowfooter");
    var link = document.getElementById("tabwindowbuttonlink");
    if (!body || !buttonArea || !button || !footer) return;

    var visible = (selected == "tab03" || selected == "tab04" || selected == "tab05") ? true : false;

    buttonArea.style.display = (visible) ? "block" : "none";

    body.style.height = (visible) ? "151px" : "181px";
    
    /* button name changes against the bugid-19 
       Date of Change:- Mar 19 2009
    */
    
    var buttonText = "";
    switch (selected) {
        case "tab03":
            buttonText = "Go To MediaRoom";
            break;
        case "tab04":
            buttonText = "News Archives";
            break;
        case "tab05":
            buttonText = "More Information";
            break;
        default:
            break;
    }
    link.firstChild.nodeValue = buttonText;
    link.setAttribute("title", buttonText);
}

function loadTabs()
{
    load();
    selectTab('tab01');
    changeButton('tab01');
}
