function Download(id, tfid, key) {
    $('table').children('tr[class=sleep]').hide();
    $("#list_item_"+key).css('height', '60px');
    $("#download_"+key).hide();
    $("#preloader_"+key).show();
    $("#frame_"+key).show();
    $("#Iframe_"+key).attr('src', 'http://tfile.ru/forum/viewtopic.php?t='+id);
    setTimeout("getFile('"+tfid+"','"+key+"')", 1000);

}
function getFile(tfid, key){
    $("#download_"+key).show();
    $("#preloader_"+key).hide();

    //Если ссылка не на файл - пересылаем на эту страницу
    if (tfid.indexOf('tfile') != -1) {
        $("#Iframe_"+key).attr('src', tfid);
        $("#frame_"+key).show();
        $("#warning_"+key).show();
    } else {
        window.open( tfid, "_blank" );
    }
}
function getView(id, key) {
    $("#list_item_"+key).css('height', '660px');
    $("#Iframe_"+key).css("height", "600px");
    $("#Iframe_"+key).attr('src', 'http://tfile.ru/forum/viewtopic.php?t='+id);
    $("#warning_"+key).hide();
}




$(document).ready(function() {
	
	/*
	if (typeof payment_link !== 'undefined') {
		$('#payment_number .payment_submit').addClass('button_register');
		$('#payment_sms .payment_submit').addClass('button_access');
		if (payment_link) {
			$('#payment_psubscribe .payment_submit').addClass('button_enter');
			$('#payment_subscribe_activate_mts .payment_submit').addClass('button_enter');
		} else {
			$('#payment_psubscribe .payment_submit').addClass('button_subscribe');
			$('#payment_subscribe_activate_mts .payment_submit').addClass('button_subscribe');
		}
	}
	*/
	$(".bookmark").click(function(event) {
		event.preventDefault();
		var url = document.location.href;
		var title = document.title;
		if ($.browser.mozilla == true) {
			window.sidebar.addPanel(title, url, '');
			return false;
		}
		else if($.browser.msie == true)	{
			window.external.AddFavorite(url, title);
			return false;
		} else {
			alert('Чтобы добавить страницу в избранное, нажмите сочетание клавиш CTRL + D.');
		}
	});
	
	setTimeout('update_music_counter()', rand(2000, 6000));
	setTimeout('update_movie_counter()', rand(2000, 6000));
	setTimeout('update_games_counter()', rand(2000, 6000));
	setTimeout('update_soft_counter()', rand(2000, 6000));
});
function rand(m, n)
{
	m = parseInt(m);
	n = parseInt(n);
	return Math.floor(Math.random() * (n - m + 1)) + m;
}
function update_music_counter()
{
	value = parseInt($('#music_counter').html());
	value = value + rand(0, 3);
	$('#music_counter').html(value);
	setTimeout('update_music_counter()', rand(2000, 6000));
}
function update_movie_counter()
{
	value = parseInt($('#movie_counter').html());
	value = value + rand(0, 3);
	$('#movie_counter').html(value);
	setTimeout('update_movie_counter()', rand(2000, 6000));
}
function update_games_counter()
{
	value = parseInt($('#games_counter').html());
	value = value + rand(0, 3);
	$('#games_counter').html(value);
	setTimeout('update_games_counter()', rand(2000, 6000));
}
function update_soft_counter()
{
	value = parseInt($('#soft_counter').html());
	value = value + rand(0, 3);
	$('#soft_counter').html(value);
	setTimeout('update_soft_counter()', rand(2000, 6000));
}
