
$(document).ready(function() {
    $(window).resize(resize);
    resize();

    $(".divtab").mouseover(function() { Menu.show($(this).siblings(".divmenu"));});
    $(".divmenu").mouseover(function(){ Menu.show($(this)); });
    $(".divtab, .divmenu").mouseout(function() { Menu.hide();});   
    $(".tooltip_anchor").hover(
        function() { showtooltip(this.id);  }, 
        function() { hidetooltip(); }); 
});

function resize() {
    $("#tableOuter").css("width", "");
    if($("#tableOuter").width() > 1400)
        $("#tableOuter").width(1400);

    if( $("#banner2 .container, #banner4 .container").height()<200) {
        $("#banner2, #banner4").height(200);
        $("#banner2 .container, #banner4 .container").height(191);
    }
}

Menu = {timer : null, current : null};

Menu.show= function(obj) {
    if(this.timer) clearTimeout(this.timer);
    if (this.current!=null && obj.attr("id")!=this.current.attr("id"))
        this.doHide();
    obj.slideDown(300);
    this.current= obj;
}

Menu.hide= function() {
    this.timer = setTimeout("Menu.doHide()",300);
}

Menu.doHide = function(){
    if(this.current!=null){
	this.current.fadeOut(300);	
	this.current = null;
    }
}


var sshotidx= 0;
var SSHOT_TOUT= 10000;


function fade() {
    $("#random").show(1);
    $("#randomback").show();
    $("#random").fadeOut(2500, function() {
        $("#ss_img").attr("src", $("#bss_img").attr("src"));    
	$("#random").show(1);
	if (++sshotidx>=shots[0].length)
            sshotidx= 0;
        updateSshot(sshotidx);
        $("#randomback").hide();
        setTimeout("fade()", SSHOT_TOUT);
    });
}



function updateSshot(idx) {
    $("#ss_a").attr("href", shots[0][idx]);
    $("#ss_a").attr("title", shots[3][idx]);
    $("#ss_a2").html(shots[2][idx]+" screenshot");
    $("#bss_img").attr("src", shots[1][(idx+1)%shots[0].length]);
    $("#ss_img").attr("src", shots[1][idx]);
    $("#ss_a").lightBox( {imageBtnClose: '/css/lightbox/lightbox-btn-close.gif'});
}

function showtooltip(obj) {    
    tooltipShown = $('#tooltip_'+obj);   
    tooltipShown.css("top", $("#"+obj).offset().top+20 + 'px');
    tooltipShown.css("left", $("#"+obj).offset().left + 'px');
    tooltipShown.fadeIn(300);
}
    
function hidetooltip() {
    if (tooltipShown==null)
        return;
    tooltipShown.fadeOut(500);
    tooltipShown= null;
}
