/**
 * @author playboyko
 */
$(document).ready( function() {
	
	if ($.browser.msie) {
		$(document.documentElement).css('overflow', 'hidden');
		$('.ru, .eng').css('opacity','1');
	} 

	($.browser.msie)?$(document.documentElement).css('overflow', 'hidden'):'';
    resize();	
	
	$('#background img').bind('load readystatechange', function(e) {
	  if (this.complete || (this.readyState == 'complete' && e.type ==
	'readystatechange')) {
			$('.index').find('.logo').css({
				backgroundImage:'url(/shared/i/logo.png)'
			});
			$('.index').fadeIn(1000,function(){
				if ($.browser.msie){
					$('.index').find('.logo').css({
						backgroundImage:'url(/shared/i/logo.png)'
					});
				}
			});
	   }

	});
	var src = $('#background img')[0].src;
    $('#background img')[0].src = '#';
    $('#background img')[0].src = src; 	
	
    $('.logo a').click( function() {
       var lang = $(this).attr('rel');
       Cookie.create( 'lang', lang, 25 ); 
    });
    function resize() {
        var scrHeight = $(window).height();
        var imgHeight = $('.index').height();
//        $('.index').css('background-position','0px ' + (scrHeight - imgHeight) / 2 + 'px');
//        $('.index .wrap').css('padding-top', scrHeight /2 - parseInt($('.index .menu').css('height')) /2 );
    }
    var scrHeight = $(window).height();
    var imgHeight = $('#background').height();
//    alert(imgHeight);
    var top = scrHeight - imgHeight;
    if( top < 0 ) {
    	$('#background img').css('top', top / 2 + 'px');
    }
	
    $(window).bind( 'resize', resize );
    /*
	$(document).keypress( function(e) {
		var keys = new Array( 32, 0 );
		var ye   = false; 
		for( i in keys ) {
			if( e.which == keys[i] ) {
				ye = true;
				break;
			}
		}
		if( ye ) {
			return false;
		}
	});
	*/
});

