function at_show_aux(parent, child)
{
    var p = document.getElementById(parent);
    var c = document.getElementById(child );

    var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
    var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

    for (; p; p = p.offsetParent)
    {
        top  += p.offsetTop;
        left += p.offsetLeft;
    }

    c.style.position   = "absolute";
    //c.style.top        = top +'px';
    //c.style.left       = left+'px';
    c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
    var p = document.getElementById(this["at_parent"]);
    var c = document.getElementById(this["at_child" ]);
    document.getElementById(this["at_parent"]).src="/images/"+this["at_parent"]+"_over.jpg";
    at_show_aux(p.id, c.id);
    clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
    var p = document.getElementById(this["at_parent"]);
    var c = document.getElementById(this["at_child" ]);
    document.getElementById(this["at_parent"]).src="/images/"+this["at_parent"]+"_nor.jpg";
    c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_click()
{
    var p = document.getElementById(this["at_parent"]);
    var c = document.getElementById(this["at_child" ]);

    if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
    return false;
}

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function dropdown(parent, child, position, cursor)
{
    var p = document.getElementById(parent);
    var c = document.getElementById(child);

    p["at_parent"]     = p.id;
    c["at_parent"]     = p.id;
    p["at_child"]      = c.id;
    c["at_child"]      = c.id;
    p["at_position"]   = position;
    c["at_position"]   = position;

    c.style.position   = "absolute";
    c.style.visibility = "hidden";

    if (cursor != undefined) p.style.cursor = cursor;

    p.onmouseover = at_show;
    p.onmouseout  = at_hide;
    c.onmouseover = at_show;
    c.onmouseout  = at_hide;
}
function toggle_open(obj)
{
    document.getElementById("upcoming_events").style.display='none';
    document.getElementById("event_sec").style.display='none';
    document.getElementById("event_third").style.display='none';
    
    document.getElementById(obj).style.display='';
}
function viewphoto(path)
{
    document.getElementById('photo_view').innerHTML = "<img style='width:300px;height:250px;' src='"+path+"'>";
}
function detailTabClick(index)
{
    var btn0 = document.getElementById('tabbutton0');
    var btn1 = document.getElementById('tabbutton1');
    var btn2 = document.getElementById('tabbutton2');
    var tab0 = document.getElementById('detailtab0');
    var tab1 = document.getElementById('detailtab1');
    var tab2 = document.getElementById('detailtab2');
    if(btn0 != null)
    {
        if(index == 0)
        {
            btn0.className = "active";
            if (tab0) tab0.style.display = "";
            if (tab1) tab1.style.display = "none";
            if (tab2) tab2.style.display = "none";
        }
        else
        {
            btn0.className = "";
        }
    }
    if(btn1 != null)
    {
        if(index == 1)
        {
            btn1.className = "active";
            if (tab0) tab0.style.display = "none";
            if (tab1) tab1.style.display = "";
            if (tab2) tab2.style.display = "none";
        }
        else
        {
            btn1.className = "";
        }
    }
    if(btn2 != null)
    {
        if(index == 2)
        {
            btn2.className = "active";
            if (tab0) tab0.style.display = "none";
            if (tab1) tab1.style.display = "none";
            if (tab2) tab2.style.display = "";
        }
        else
        {
            btn2.className = "";
        }
    }
}
function settingShowsAndEventsTopStyle()
{
    //className = "active";
    var topbar = document.getElementById("topbar");
    var tools = topbar.getElementsByTagName("a");
    for(var i=0;i<tools.length;i++)
    {
        tools[i].className = "";
    }
    var url = window.location.toString().toLowerCase();

    var flag = 0;
    if(url.indexOf("/shows_and_events") > 0 &&
        (url.indexOf("/shows_and_events/") < 0 ||
         url.lastIndexOf("/") == url.length -1))
    {
        tools[0].className = "active";
        flag = 1;
    }
    if(url.indexOf("/shows_and_events/calendar") > 0)
    {
        tools[1].className = "active";
        flag = 1;
    }
    if(url.indexOf("/shows_and_events/venues") > 0)
    {
        tools[2].className = "active";
        flag = 1;
    }
    if(url.indexOf("/shows_and_events/groups") > 0)
    {
        tools[3].className = "active";
        flag = 1;
    }
    if(url.indexOf("/shows_and_events/at/gift-vouchers") > 0)
    {
        tools[4].className = "active";
        flag = 1;
    }
    if(url.indexOf("/Purchase/ViewShoppingCart.do") > 0)
    {
        tools[5].className = "active";
        flag = 1;
    }
    if(url.indexOf("/shows_and_events/agents_and_outlets") > 0)
    {
        tools[6].className = "active";
        flag = 1;
    }
    if(url.indexOf("/shows_and_events/overseas_shows") > 0)
    {
        tools[7].className = "active";
        flag = 1;
    }
    if(url.indexOf("/shows_and_events/faqs") > 0)
    {
        tools[8].className = "active";
        flag = 1;
    }
    if(flag == 0)
    {
        tools[0].className = "active";
    }
}