// JScript source code
var need_to_hide_subnav = false;
var current_subnav_active = 0;
var current_timeout = null;
var height_iframe = null;

function hide_all() {
	if (need_to_hide_subnav) {
		current_subnav_active = 0;
		need_to_hide_subnav = false;
		clearTimeout(current_timeout);
		$$('div.subnav').invoke('hide');
		$$('iframe.subnav_bg').invoke('hide');
		//$$('div.subnav').each(function(n){n.setStyle({display: 'none'})});
		//$$('iframe.subnav_bg').each(function(n){n.setStyle({display: 'none'})});
	}
}

function hide_all_immediately() {
	unkeep_subnav(null);
	hide_all();
}

function show_subnav(a) {
	$$('div.subnav').invoke('hide');
	$$('iframe.subnav_bg').invoke('hide');
	//$$('div.subnav').each(function(n){n.setStyle({display: 'none'})});
	//$$('iframe.subnav_bg').each(function(n){n.setStyle({display: 'none'})});
    keep_subnav(a);
    new Effect.Appear("subnav_" + a, {duration: 0.5});
    //$('subnav_' + a).setStyle({display: 'block'});
    //alert(navigator.appName + '-'+ navigator.appVersion);
    if (navigator.appName == 'Opera')
    {
        $('subnav_bg_' + a).setStyle({display: 'none'});
    }
    else
    {
        $('subnav_bg_' + a).setStyle({display: ''});
    }
    height_iframe = $('subnav_' + a).getHeight();
    $('subnav_bg_' + a).setStyle({height: height_iframe + 'px'});
}

function keep_subnav(a) {
	need_to_hide_subnav = false;
	if (a) {
		current_subnav_active = a;
	}
	clearTimeout(current_timeout);
	if($('nav_item_' + a))
	{
	    $('nav_item_' + a).setStyle({background: '#256195'});
	}
	if($('nav_item_r_' + a))
	{
	    $('nav_item_r_' + a).setStyle({background: '#081e2c'});
	}
}

function unkeep_subnav(a) {
	need_to_hide_subnav = true;
	if (a) {
		current_subnav_active = a;
	}
	current_timeout = setTimeout(hide_all, 7000);
	if($('nav_item_' + a))
	{
	    $('nav_item_'+ a).setStyle({background: '#081e2c'});
	}
	if($('nav_item_r_' + a))
	{
	    $('nav_item_r_' + a).setStyle({background: '#256195'});
	}
}