
function closeLigthWindow(){

	$('#ligthWindow-overlay').hide();
	$('.ligthWindow-container').hide();
	if($.browser.msie && $.browser.version < 7) $('select').css({'visibility' : 'visible'});
	if($.browser.msie && $.browser.version <= 7) $('.jCarouselLite li').css({'display' : 'block'});
    if(iframe = $('.ligthWindow-container').find('iframe')) {
        iframe.attr('src', iframe.attr('oldsrc'));
        iframe.removeAttr('oldsrc');
    }
}

$(function (){
	$('#login-form').appendTo('body');

	//Открывалка меню сервисов
	$('#header .nl').hover(function (){
		box = $(this).addClass('selected');
		if($.browser.msie && $.browser.version < 7) $('select').css({'visibility' : 'hidden'});
	},function (){
		box = $(this).removeClass('selected');
		if($.browser.msie && $.browser.version < 7) $('select').css({'visibility' : 'visible'});
	});
	$('#show-account-menu').click(function (){
		$('#account-menu').toggle();
		return false;
	});
	//Закрывался меню сервисов
	$(document).click(function (){
		$('#account-menu').hide();
	});

	//А-ля лайтбокс
	$('<div id="ligthWindow-overlay"></div>').appendTo('body').hide().click(closeLigthWindow);
	$('.ligthWindow-container .close').live('click', closeLigthWindow);
	$(document).keydown(function(event){
		if(event.keyCode == 27) closeLigthWindow();
	});

	$('.ligthWindow').live('click', function (){
		if($.browser.msie && $.browser.version < 7) $('select').css({'visibility' : 'hidden'});
		if($.browser.msie && $.browser.version <= 7) $('.jCarouselLite li').css({'display' : 'none'});

		var box = $('#' + this.id.replace('show-',''));
		box.put = function (){
			t = (self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop)) + ((self.innerHeight && self.innerHeight) || (document.documentElement && document.documentElement.clientHeight) || (document.body && document.body.clientHeight))/2 - box.height()/2;
			this.css({'margin' : t + 'px 0 0 -' + Math.ceil(this.width()/2) + 'px'}).show();
		}
		box.put();
        
		$('#ligthWindow-overlay').show();
		return false;
	});



	//Подсказка для input[text]
	$('#footer input.hint').each(function (){
		if(this.value == '' || this.value == this.title) $(this).css('color','#999').val(this.title);
	}).bind('focus', function (){
		if(this.value == this.title) $(this).css('color','#000').val('');
	}).bind('blur', function (){
		if(this.value == '') $(this).css('color','#999').val(this.title);
	});


	//Фокус на поле логин в форме авторизации
	$('#show-login-form').click(function (){
		setTimeout(function (){
			$('#login').eq(0).focus();
		},100);
	});

	//Упрощенная группа радио-баттонов
	$('.radio-string label').live("click", function (){
		box = $(this).parent().parent().find('li').removeClass('checked');
		$(this).parent().addClass('checked').find('input').attr('checked', 'checked');
	});
    //$('#show-region-list').html(getRegionName());
});
