$(document).ready(function(){
    $('.catalog-main-block .item').mouseover(function(){ $(this).addClass('sel'); });
    $('.catalog-main-block .item').mouseout(function(){ $(this).removeClass('sel'); });
    $('.left .price').mouseover(function(){ $(this).addClass('sel'); });
    $('.left .price').mouseout(function(){ $(this).removeClass('sel'); });
    $('.catalog .item').mouseover(function(){ $(this).addClass('sel'); });
    $('.catalog .item').mouseout(function(){ $(this).removeClass('sel'); });        
    $('.tbl table tr:nth-child(even)').addClass('even');
    $('table.tbl tr:nth-child(even)').addClass('even');
    $('ol').each(
        function(){
            i = 0;
            $(this).css('listStyleType', 'none');
            $(this).children('li').each(
            function(){
                i++;
                inner = $(this).html();
                $(this).html('<table class="ol"><tr><td class="li-key"><span>'+i+'</span></td><td class="li-value">' + inner + '</td></tr></table>');
            });            
        }
    );
    $('table.ol .li-key span').corner('10px');  
    $('input.autoclear').autoclear();
    if( $.browser.msie && $.browser.version<8 )
    	$('.project .right .txt').css('overflow-y','scroll');
    else
    	$('.project .right .txt').jScrollPane({ showArrows:true, scrollbarWidth:10, arrowSize:10 });
    
/** ****************** **/

	if( $.browser.msie && $.browser.version<7 ){
		
		$('.project .scroll-pane').css('overflow-x','scroll');		
		$('.project .scroll-bar-wrap').hide();
		$('.scroll-content').width('9999');
		
	}else{
	
		var scrollPane = $('.scroll-pane');
		var scrollContent = $('.scroll-content');
		
		var scrollbar = $(".scroll-bar").slider({
			slide:function(e, ui){
				if( scrollContent.width() > scrollPane.width() ){ scrollContent.css('margin-left', Math.round( ui.value / 100 * ( scrollPane.width() - scrollContent.width() )) + 'px'); }
				else { scrollContent.css('margin-left', 0); }
			},
			change:function(e, ui){
				if( scrollContent.width() > scrollPane.width() ){ scrollContent.css('margin-left', Math.round( ui.value / 100 * ( scrollPane.width() - scrollContent.width() )) + 'px'); }
				else { scrollContent.css('margin-left', 0); }
			},
            animate: true
		});
		
		var handleHelper = scrollbar.find('.ui-slider-handle')
		.mousedown(function(){
			scrollbar.width( handleHelper.width() );
		})
		.mouseup(function(){
			scrollbar.width( '100%' );
		})
		.append('<span class="ui-icon ui-icon-grip-dotted-vertical"></span>')
		.wrap('<div class="ui-handle-helper-parent"></div>').parent();
		
		scrollPane.css('overflow','hidden');
		
		function sizeScrollbar(){
			var remainder = scrollContent.width() - scrollPane.width();
			var proportion = remainder / scrollContent.width();
			var handleSize = scrollPane.width() - (proportion * scrollPane.width());
			scrollbar.find('.ui-slider-handle').css({
				width: handleSize,
				'margin-left': -handleSize/2
			});
			handleHelper.width('').width( scrollbar.width() - handleSize);
		}

		setTimeout(sizeScrollbar,10); 

	}

/** ****************** **/
    $('.project .item').each( function(){
        var cntr = $(this).find('.txt .cntr');
        var txt = $(this).find('.txt'); 
        var imgB = $(this).find('.txt-nav .b img');
        if( cntr.height()<txt.height() )
            imgB.attr('src', '/DESIGN/SITE/images/arr-b-u.png');            
    } );
    
    
    if (screen.width<1225){
    	$('.banner_c').css({'width':'400px'});
    }else{
    	$('.banner_c').css({'width':'600px'});
    }
    
    $('.banner_c').click(function(){document.location.href='/about/contact/'});
    
        
});

function projectScroll(to, toto){
    
    var obj = $('.project .desc .w');
    var nowMarginLeft = parseInt(obj.css('marginLeft'));
    var step = 640;

    if( toto>-1 ){
        obj.animate({ marginLeft: '-'+(step*toto)+'px' }, 1000);
        return false;
    }
        
         
    if( to )
        obj.animate({ marginLeft: (nowMarginLeft+step)+'px' }, 1000);
    else
        obj.animate({ marginLeft: (nowMarginLeft-step)+'px' }, 1000);
        
}
