var IE = jQuery.browser.msie;
var IE6 = jQuery.browser.msie && jQuery.browser.version == 6;
var _ext = IE6 ? 'gif' : 'png';


$(document).ready(function() { 
    //$("#contentTochno").jScrollPane({showArrows : true});
	//$("#textGlwrapper").jScrollPane({showArrows : true});
	var button=$('#bigKnopka');
	if(button){
		var overlay=$('<div class="overlay"></div>').css('opacity', 0.8);
		$(document.body).append(overlay);

		var text=$('#textGl').css('opacity', 0).css('display', 'none');
		button.append(text);

		if(IE6){
			overlay.css({
				position: 'absolute'
			});
			$(window).scroll(function(){
				overlay.css('top', $(this).scrollTop());
				button.css('top', $(this).scrollTop()+$(this).height()/2);
			});
			$(window).scroll();
			button.css({
				position: 'absolute',
				zIndex: 1000
			});
			text.css({
				position: 'absolute',
				top: parseInt(button.css('height'))/2
			});
			$(window).resize(function(){
				text.css('height', $(this).height()/2-parseInt(text.css('bottom'))-parseInt(button.css('height'))/2);
				overlay.css('top', $(this).scrollTop());
				button.css('top', $(this).scrollTop()+$(this).height()/2);
			});
			$(window).resize();
		}

		text.mousewheel(function(event, delta){
			text.scrollTop(text.scrollTop()-delta*10);
			event.preventDefault();
		});

		button.mouseover(function(){
			$.each([text], function(){
				this.stop();
				this.animate({
					opacity: 1
				},{ 
					duration: 1000
				});
				this.css('display', 'block')
			});
		}).mouseleave(function(event){
			$.each([text], function(){
				this.stop();
				this.animate({
					opacity: 0
				},{
					duration: 1000,
					complete: function(){
						$(this).css('display', 'none')
					}
				});
			});
		});

	}	
	
	
    $('.cc_header img').hover(
	function(){
		$(this).attr('src', "http://tamarin.ru/design/images/logo.jpg");
	},
    function(){
		$(this).attr('src', IE6 ? "http://tamarin.ru/design/images/logo_passiv.gif" : "http://tamarin.ru/design/images/logo_passiv.png"); 
	});
    $('.leftMenuLink a').hover(function(){ 
	    var img = $('img', this)[0];
	    var ext = img.src.substr(img.src.lastIndexOf('.') + 1);
	    img.src = img.src.replace('_passiv.' + ext, '.' + ext);
    }, function(){
	    var img = $('img', this)[0];
	    var ext = img.src.substr(img.src.lastIndexOf('.') + 1);
	    img.src = img.src.replace('.' + ext, '_passiv.' + ext);
    });   
    $('.uslugiInner').appendTo('.apend');

    $('#pochta').hover(function(){
		$(this).attr('src', "http://tamarin.ru//design/images/pochta_orang." + _ext)},
        function(){$(this).attr('src', "http://tamarin.ru//design/images/pochta_siniy." + _ext);});
    $('#telephon').hover(function(){
		$(this).attr('src', "http://tamarin.ru//design/images/telephon_orang." + _ext )},
        function(){$(this).attr('src', "http://tamarin.ru//design/images/telephon_siniy." + _ext);});

		if(IE6){
			$('img.png').each(function(){
				$(this).attr('src', $(this).attr('src').replace(/\.png$/, '.gif'));
			});
			$('#pochta, #telephon').each(function(){
				$(this).attr('src', $(this).attr('src').replace(/\.png$/, '.gif'));
			});
			$('#mcvl, #mcvr').css('position', 'relative');
			$('#mcvl').css('margin-left', 0).css('left', -2);
			$('#content').css('height', 550);
			$('#mainContent').css('width', $('#mainContent').width())
				.css('position', 'absolute')
				.css('left', 0)
				.css('top', 100);
		}
		if(IE6 || window.opera){
			var minus = window.opera ? 0 : 3;
			var left = 0;
			var len = $('#uslugi .uslugi').length;
			$('#uslugi .uslugi').each(function(index){
				$(this).css('position', 'absolute').css('left', left);
				if(index == len - 1){
					$(this).css('width', $(this).parent().width() - left - minus);
				}
				left += this.offsetWidth;				
			});	
		}
		correctBtns();
		
		
		
 });
 function resizeBoxJSPane() {
    var ww = $(".cc_cc").width();
    if (IE6) {
        ww = ww - 15;
    }
    $(".jScrollPaneContainer").css("width", ww+"px");
    $("#contentTochno").css("width", (ww-15)+"px");
    correctBtns();
 }
 function correctBtns() {
     var cc = $(".cc_box").width() + 220 - 20;
    $(".jScrollArrowUp").css("left", cc+"px");
    $(".jScrollArrowDown").css("left", cc+"px");
	$(".dot").css("left", cc+"px"); 
 }