function tick()
{
    var p = [0,0,0,0];
    p[3] = 1235520000 /* zomg! */ - ( new Date().getTime() / 1000 );
    if ( p[3] <= 0 ) {
        $("#tock").hide();
        return;
    }
    p[0] = parseInt( p[3] / 86400 );
    p[3] -= 86400 * p[0];
    p[1] = parseInt( p[3]/ 3600 );
    p[3] -= 3600 * p[1];
    p[2] = parseInt( p[3] / 60 );
    p[3] -= 60 * p[2];
    p[3] = parseInt( p[3] );
    for ( var i = 0; i < p.length; i++ ) {
        if ( p[i] < 10 ) {
            p[i] = "0" + p[i];
		}
    }
    $("#tock").html( p.join( "" ) );
    setTimeout( tick, 1000 );
}

function showOpts() {
	$('#qldl_ctr').unbind("mouseover");
	$('#qldl_active_ctr,#qldl_opts').hover( stopHide, tryHide );

	if ( !$.browser.msie || $.browser.version > 6 ) {
		$('#qldl_active_ctr,#qldl_opts').fadeIn();
	} else {
		$('#qldl_active_ctr').show();
		$('#qldl_opts').fadeIn();
	}
}

function hideOpts() {
	$('#qldl_opts,#qldl_active_ctr').fadeOut(
		function () {
			$('#qldl_ctr').bind( "mouseover", showOpts );
		} );
}

var fadeHandle = null;

function stopHide() {
	if ( fadeHandle ) {
		clearTimeout( fadeHandle );
		fadeHandle = null;
	}
}

function tryHide() {
	stopHide();
	fadeHandle = setTimeout( hideOpts, 60000 );
}

$(function() {
	tick();
	$("#qldl_ctr").bind( "mouseover", showOpts );
});
