function changeContWidth(ww) {
	if (ww<1024) {
		$('#container').css('width',971);
		$('#top-panel').css('width',971);
		$('.mc-article-title').css('width',415);
        $('.mc-article-subtitle-press').css('width',415);
	} else if (ww>1280) {
		$('#container').css('width',1227);
		$('#top-panel').css('width',1227);
		$('.mc-article-title').css('width',655);
        $('.mc-article-subtitle-press').css('width',655);
	} else {
		$('#container').css('width',ww-53);
		$('#top-panel').css('width',ww-53);
		$('.mc-article-title').css('width',ww-625);
        $('.mc-article-subtitle-press').css('width',ww-625);
	}
	if (ww<1147) {
		$('.phone').css('height','31px');
		$('.hr-left').css('width','72%');

	} else {
		$('.phone').css('height','62px');
		$('.hr-left').css('width','68%');
	}
}

$(document).ready(function(){
	changeContWidth($(window).width());
	$(window).resize(function(){
		changeContWidth($(window).width());
	})
	$('#langs .lang-active').click(function() {
		$('#langs ul').toggle();
	});
	$('#langs ul>li>a').click(function() {
		$('#langs ul').toggle();
	});
	$('#langs ul').mouseleave(function() {
		setTimeout("$('#langs ul').hide();",300);
	})
	$('#langs').mouseleave(function() {
		setTimeout("$('#langs ul').hide();",300);
	})
	$('.sselect ul').mouseleave(function() {
		setTimeout("$('.sselect ul').hide();",300);
	})
	$('.sselect').mouseleave(function() {
		setTimeout("$('.sselect ul').hide();",300);
	})
	$('.sselect ul>li').bind("mouseenter mouseleave", function() {
		$(this).toggleClass('hover');
	})
	$('.sselect .s-active').click(function() {
		$('.sselect ul').hide();
		$(this).parent().find('ul').toggle();
		$(this).parent().find('ul>li').removeClass('hover');
	});
	$('.sselect ul>li>a').click(function() {
		$(this).parent().parent().parent().find('.s-active').text($(this).text().length<21 ? $(this).text() : $(this).text().substr(0,21)+'...');
		$(this).parent().parent().toggle();
		$(this).parent().removeClass('hover');
	});
	$('.lmore-but').click(function() {
//		$(this).removeClass('lb-under');
		$(this).parent().toggleClass('lmore');
		if ( $(this).parent().hasClass('lmore') ) {
			$(this).text('свернуть');
		} else {
			$(this).text('развернуть');
		}
	});
//	$('.lmore-but').mouseenter(function(){
//		$(this).addClass('lb-under');
//	});
//	$('.lmore-but').mouseleave(function(){
//		$(this).removeClass('lb-under');
//	});
	////////////////////////////////
	//$('input.checkbox').removeAttr('checked');
	$('img.checkbox').click(function(){
		var elem = $('input.checkbox[name = '+$(this).attr('rel')+']');
		if (!elem.attr('checked')) {
			elem.attr('checked','checked');
			$(this).attr('src','/img/check-a.gif');
		} else {
			elem.removeAttr('checked');
			$(this).attr('src','/img/check.gif');
		}
	})
	jQuery.each(jQuery.browser, function(i, val) {
		if(i=="msie" && (jQuery.browser.version.substr(0,1)=="6" || jQuery.browser.version.substr(0,1)=="7") )
			if ($('.second .mt-right .ask-doctor span').width() <= 120 && $('.second .mt-right .ask-doctor span').height() <= 20) {
				$('.second .mt-right .ask-doctor').width(120)
			} else { $('.second .mt-right .ask-doctor').width(150) }
		});
        


    
        
    $("a[rel=img_group]").fancybox({     
        'transitionIn'      : 'elastic',
        'transitionOut'     : 'elastic',
        'titlePosition'     : 'over',
        'titleFormat'       : function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-over">Image ' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
            }
    });

   
        
        
        
})
