count = parseInt(0);
endCounter = 0;
endBlick = 0;
function showTrust()
{
	$("#hello_trust").animate({opacity: '1'}, 2000, 0, setTimeout('showGroup()', 200));
	$("#hello_noblesse").animate({opacity: '1'}, 2000);
}
function showGroup()
{
	$("#hello_group").animate({opacity: '1'}, 2000, 0, setTimeout('gotoMainPage()', 4000));
}
function gotoMainPage()
{
//	alert(44);
	var lft = document.body.offsetWidth;
	$("table.hello_table").css('position','absolute').animate({left: -lft+'px'}, 1000, 0,
							setTimeout('showPageTable()', 1000));
//	$("table.page_table").animate({left: '0px'}, 1000);
}
function showPageTable()
{
	$("table.page_table").css('display','block').animate({left: '0px'}, 1000, 0, setTimeout('endBlick()', 1000));
	$.post('/Index/mainpage');
}
function startCounter()
{
	var txt = count+'%';
	$("span.counter").text(txt);
	count += 1;
	if (count <= 100)
		endCounter = setTimeout('startCounter()', 50);
	else
	{
		clearTimeout(endCounter);
		blickCounter();
	}
}
var HexLookup = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
function RGB2Hex(rgb) 
{
    var Hex = "";
    while (rgb > 0) 
    {
        Hex = HexLookup[rgb % 16] + Hex;
        rgb -= (rgb % 16);
        rgb /= 16;
    }
    return Hex;
}
function RGBcss2Hex(str) 
{
    var vals = str.match(/\d+/g);
    var hex = "";
    for (var i = 0; i < vals.length; i++) 
    {
        hex += RGB2Hex(vals[i]);
    }
    return hex;
}
function blickCounter()
{
	var clr = $("span.counter").css('color');
	clr = RGBcss2Hex(clr);
	if (clr == '777777')
		clr = '#aaaaaa';
	else
		clr = '#777777';
	$("span.counter").css('color',clr);
	endBlick = setTimeout('blickCounter()', 50);
}
function endBlick()
{
	clearTimeout(endBlick);
}
$(function(){
	if (!$.browser.msie)
	{
		$("td.hello_group").css('vertical-align','bottom');
	}
//	startCounter();
	var lft = document.body.offsetWidth;
//	$("table.page_table").css({left: -lft+'px', display: 'none'});
	$("div.hello_companies").css('opacity','0.6');
	$("img.hide").css('opacity','0');
//	$("#hello_logo").animate({opacity: '1'}, 2000, 0, setTimeout('showTrust()', 2000));
//	$("div.hello_blick").animate({opacity: '1'}, 2000);

	$("img.wb_color").hover(function()
		{
			var id = $(this).attr('id');
			id = '/design/imgs/' + id + 'color.png';
			$("div.hello_companies").css('opacity','1');
			$(this).attr('src', id);
			var tp = parseInt($(this).css('top')) - 3;
			var lf = parseInt($(this).css('left')) - 3;
			$(this).css('top',tp+'px');
			$(this).css('left',lf+'px');
		},
		function()
		{
			var id = $(this).attr('id');
			id = '/design/imgs/' + id + 'wb.png';
			$(this).attr('src', id);
			var tp = parseInt($(this).css('top')) + 3;
			var lf = parseInt($(this).css('left')) + 3;
			$(this).css('top',tp+'px');
			$(this).css('left',lf+'px');
		}
	);
	$("div.hello_companies").hover(function()
		{
			$(this).animate({'opacity': '1'}, 1000);
		}, 
		function()
		{
			$(this).animate({'opacity': '0.4'}, 1000);
		}
	);

});
