$(document).ready( function(){
		$('#request').show()
		$('#hidden_form').hide()
		$('#seo_request').show()
		$('#seo_request').click(function () {
			$(this).animate(
				{
					opacity: 0,
					top: '+=280'
				}, 1000, function () {
					$('#hidden_form').slideDown(200)
				}
			)
			//$(this).css('display', 'none')
			$('#seo_img').css('display', 'block')
		})
		
		$('.checkbox').click(function (){
			$(this).toggleClass('checkbox_checked');
		})
		
		$('#slider').slider({
			min: 0,
			max: 150000,
			values: [20000,50000],
			range: true
		});	

	$(function() {
		$( "#slider" ).slider({
			range: true,
			min: 0,
			max: 300000,
			values: [20000, 50000 ],
			slide: function( event, ui ) {
				$( "input.fromAmount" ).val(ui.values[ 0 ] - ui.values[ 0 ] % 100);
				$( "div.fromAmount" ).text(ui.values[ 0 ] - ui.values[ 0 ] % 100);
				$( "input.toAmount" ).val(ui.values[ 1 ] - ui.values[ 1 ] % 100);
				$( "div.toAmount" ).text(ui.values[ 1 ] - ui.values[ 1 ] % 100);
			}
		});
		/*$( "input.fromAmount" ).val( $( "#slider-range" ).slider( "values", 0 ));
		$( "div.fromAmount" ).text( $( "#slider-range" ).slider( "values", 0 ));
		$( "input.toAmount" ).val( $( "#slider-range" ).slider( "values", 1 ));
		$( "div.toAmount" ).text( $( "#slider-range" ).slider( "values", 1 ));*/
	});
		
		if (document.location.pathname === "/netcat/add.php") {
			$('#request').hide()
			$('#seo_request').hide()
			$('#hidden_form').show()
			$('#seo_img').show()
		}

		$('#request').click(function () {
			$(this).animate(
				{
					opacity: 0,
					top: '+=280'
				}, 1000, function () {
					$('#hidden_form').slideDown(200)
				}
			)
		})
		
		
		$('.slideblock:not(:first)').css('display', 'none')
		//$('.slide:first').addClass('activeslide')
		
		$('.slide').click(function () {
			var el = $(this).parent().next()
			if ($(el).css('display') === 'none') {
				$(el).css('display', 'block')
				//$(this).addClass('activeslide')
			} else {
				$(el).css('display', 'none')
				//$(this).removeClass('activeslide')			
			}
		})
		
		//$('.clients_list li img').eq(0).css('opacity', '1.0').css('filter', 'alpha(opacity=100)');
		
		$('.clients_list li a').click(function(){
		$('.seo_statistics_tringle').fadeOut(0);
		$('.seo_statistics_table').hide(0);
		
		var numb = $('.clients_list li a').index(this);		

		$('.clients_list li').find('a').removeClass('active')
		$('.clients_list li a').eq(numb).addClass('active')		
		
		$('.clients_list li').find('img:first').css('display', 'none').next().css('display', 'block');	
		$('.clients_list li').eq(numb).find('img:first').css('display', 'block').next().css('display', 'none');
		$('.seo_statistics_tringle').eq(numb).fadeIn(230);
		$('.seo_statistics_table').eq(numb).fadeIn(230);
		return false;
		});

		$('.portolio_item').hover(		
		function (){
		$(this).find('.portolio_item_title').stop(true, true).slideDown(200);
		},
		function (){
		$(this).find('.portolio_item_title').stop(true, true).slideUp(400);		
		}
		);
		
		$('.scroll-content-port').css('margin-left', '0')





/*
$('.grey_line_ruler').bind('mousedown', function(e){
$('.logo').html('d');
$('.grey_line').unbind('mouseup');
$('.grey_line').bind('mousemove', function(e){
fromleft = e.clientX-880;
$('.grey_line_ruler').css('left', fromleft);  
});
});


$('.grey_line_ruler').bind('mouseup', function(){
$('.logo').html('u');
$('.grey_line_ruler').unbind('click');
$('.grey_line').unbind('mousemove');
});
*/


var scrollPane = $( ".scroll-pane" ),
	scrollContent = $( ".scroll-content" );
if (scrollPane)
{
//задаем высоту для  scrollContent
num2 = $('.clients_list li').size();
panelwidth = 0
$('.clients_list li').each(function () {
	widthli = $(this).width()
	if ($.browser.msie && ($.browser.version == 6 || $.browser.version == 7)) {
	   widthli = widthli+2;
	}	
	widthli += parseInt($(this).css('margin-left'));
	widthli += parseInt($(this).css('margin-right'));
	panelwidth += widthli
});
//widthliright2 = parseInt($('.port_list li').css('margin-left'));
//widthlileft2 = parseInt($('.port_list li').css('margin-right'));
//widthli2 = widthli2+widthliright2+widthlileft2;
//panelwidth2 = widthli2*num2;

scrollContent.css( "width", panelwidth );
//end


var scrollbar = $( ".scroll-bar" ).slider({
			slide: function( event, 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 );
				}
			}
});

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();
		
		//change overflow to hidden now that slider handles the scrolling
		scrollPane.css( "overflow", "hidden" );
		
		/*
		//size scrollbar and handle proportionally to scroll distance
		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 );
		}
		*/
		//reset slider value based on scroll content position
		function resetValue() {
			var remainder = scrollPane.width() - scrollContent.width();
			var leftVal = scrollContent.css( "margin-left" ) === "auto" ? 0 :
				parseInt( scrollContent.css( "margin-left" ) );
			var percentage = Math.round( leftVal / remainder * 100 );
			scrollbar.slider( "value", percentage );
		}
		
		//if the slider is 100% and window gets larger, reveal content
		function reflowContent() {
				var showing = scrollContent.width() + parseInt( scrollContent.css( "margin-left" ), 10 );
				var gap = scrollPane.width() - showing;
				if ( gap > 0 ) {
					scrollContent.css( "margin-left", parseInt( scrollContent.css( "margin-left" ), 10 ) + gap );
				}
		}
		
		//change handle position on window resize
		$( window ).resize(function() {
			//resetValue();
			//sizeScrollbar();
			//reflowContent();
		});
		//init scrollbar size
		
		/*setTimeout( sizeScrollbar, 10 );*/
}



//-----------------------------------------------------//
//-----------------------------------------------------//
//-----------------------------------------------------//


var scrollPane2 = $( ".scroll-pane-port" ),
	scrollContent2 = $( ".scroll-content-port" );
if (scrollPane2)
{
//задаем высоту для  scrollContent2
num2 = $('.port_list li').size();
panelwidth2 = 0
$('.port_list li').each(function () {
	widthli2 = $(this).width()
	if ($.browser.msie && ($.browser.version == 6 || $.browser.version == 7)) {
	   widthli2 = widthli2+2;
	}
	
	widthli2 += parseInt($(this).css('margin-left'));
	widthli2 += parseInt($(this).css('margin-right'));

	panelwidth2 += widthli2
});

//widthliright2 = parseInt($('.port_list li').css('margin-left'));
//widthlileft2 = parseInt($('.port_list li').css('margin-right'));
//widthli2 = widthli2+widthliright2+widthlileft2;
//panelwidth2 = widthli2*num2;
scrollContent2.css( "width", panelwidth2 );
//end


var scrollbar2 = $( ".scroll-bar-port" ).slider({
			slide: function( event, ui ) {
				if ( scrollContent2.width() > scrollPane2.width() ) {
					scrollContent2.css( "margin-left", Math.round(
						ui.value / 100 * ( scrollPane2.width() - scrollContent2.width() )
					) + "px" );
				} else {
					scrollContent2.css( "margin-left", 0 );
				}
			}
});

var handleHelper2 = scrollbar2.find( ".ui-slider-handle" )
		.mousedown(function() {
			scrollbar2.width( handleHelper2.width() );
		})
		.mouseup(function() {
			scrollbar2.width( "100%" );
		})
		.append( "<span class='ui-icon ui-icon-grip-dotted-vertical'></span>" )
		.wrap( "<div class='ui-handle-helper-parent'></div>" ).parent();
		
		//change overflow to hidden now that slider handles the scrolling
		scrollPane2.css( "overflow", "hidden" );
		
		//reset slider value based on scroll content position
		function resetValue2() {
			var remainder = scrollPane2.width() - scrollContent2.width();
			var leftVal = scrollContent2.css( "margin-left" ) === "auto" ? 0 :
				parseInt( scrollContent2.css( "margin-left" ) );
			var percentage = Math.round( leftVal / remainder * 100 );
			scrollbar2.slider( "value", percentage );
		}
		
		//if the slider is 100% and window gets larger, reveal content
		function reflowContent2() {
				var showing = scrollContent2.width() + parseInt( scrollContent2.css( "margin-left" ), 10 );
				var gap = scrollPane2.width() - showing;
				if ( gap > 0 ) {
					scrollContent2.css( "margin-left", parseInt( scrollContent2.css( "margin-left" ), 10 ) + gap );
				}
		}
		
		//change handle position on window resize
		$( window ).resize(function() {
			resetValue2();
			sizeScrollbar();
			reflowContent2();
		});
		//init scrollbar size
		
		/*setTimeout( sizeScrollbar, 10 );*/
}
		
});


