$(function(){
	$('.up','.blockScroll').mousedown(function(){
		status = true
		direct = 2;
		Drive()
	});
	$('.up','.blockScroll').mouseup(function(){
		status = false
	});
	$('.down','.blockScroll').mousedown(function(){
		status = true
		direct = -2;
		Drive()
	});
	$('.down','.blockScroll').mouseup(function(){
		status = false
	});
	
	heightList = $('.list','.blockScroll').height()
	heightBox = $('.ScrollBox','.blockScroll').height()
	
	var counter = 0
	var ie6 = false;
	jQuery.each(jQuery.browser, function(i, val) {
		if(i == "msie" && val == true)
			counter++;
		if(i == "version" && val == "6.0")
			counter++;
		if(counter == 2)
			ie6 = true;
	});
	
	if(ie6){
		CreateLineMenu()
	}
	$(window).resize(function() {
		CreateLineMenu()
	
	});
	
});


function CreateLineMenu(){
	if($(".menuLeft").length == 1){
		var left = $('span', $('li.act', '.menuLeft')).offset().left
		var top = $('span', $('li.act', '.menuLeft')).offset().top
		var height = $('div', $('li.act', '.menuLeft')).height()
		$("#lineMenuActIE").remove()
		$('body > div').last().after('<div id="lineMenuActIE" style="position:absolute;top:'+top+'px;width:'+left+'px;height:'+height+'px;">&nbsp;</div>');
	}
}



var status = false;
var direct = 2;
var Top = 0;
var heightList
var heightBox




function Drive(){
	if(status){
		Top = Top + direct;
		
		if(Top < heightBox - heightList)
			Top = heightBox - heightList
		if(Top > 0)
			Top = 0
		$('.list','.blockScroll').css('top', Top+'px')
		window.setTimeout(Drive, 10)
	}
}


//------------- прокрутка фоток
$(function(){
	var L = $("li",".listFoto").length;
	$("ul",".listFoto").width(L*130)
	
	$("a", $("li",".listFoto")).click(function(){
		$('.ContainerLoad').attr("src", $(this).attr("href"))
		$('.bigFotoNameImage').html($(this).attr("title"))
		Index = $('li',$(this).parent().parent()).index($(this).parent());
		if(L > 5)
			DriveList(Index)
		
		return false;
	});
	
	$(".next", ".listFoto").click(function(){
		if(L > 5)
			DriveList(Index+1)
		return false;
	});
	$(".back", ".listFoto").click(function(){
		if(L > 5)
			DriveList(Index-1)
		return false;
	});
	if(L < 6){
		$(".next", ".listFoto").css("display","none")
		$(".back", ".listFoto").css("display","none")
	}
});
var Index = 2;
var pos = 2;
function DriveList(In){

	if(In < 2)
		In = 2
	if(In > $("li",".listFoto").length-3)
		In = $("li",".listFoto").length-3
	Index = In
	n = pos-In
	if(n != 0){
		if(n == 1)
			delta = '+=130';
		if(n == -1)
			delta = '-=130';
		if(n == 2)
			delta = '+=260';
		if(n == -2)
			delta = '-=260';
		$("ul",".listFoto").animate({
		left: delta
		}, 250, 'swing',  function() {
			pos = Index
		});
	}
	
}

//------------- прокрутка фоток
$(function(){
	var L = $("li",".listConcept").length;
	$("ul",".listConcept").width(L*230)
	

	
	$(".next", ".listConcept").click(function(){
		if(L > 4)
			DriveList(Index+1)
		return false;
	});
	$(".back", ".listConcept").click(function(){
		if(L > 4)
			DriveList(Index-1)
		return false;
	});
	if(L < 5){
		$(".next", ".listConcept").css("display","none")
		$(".back", ".listConcept").css("display","none")
	}
});
var Index = 2;
var pos = 2;
function DriveList(In){

	if(In < 2)
		In = 2
	if(In > $("li",".listConcept").length-3)
		In = $("li",".listConcept").length-3
	Index = In
	n = pos-In
	if(n != 0){
		if(n == 1)
			delta = '+=230';
		if(n == -1)
			delta = '-=230';
		if(n == 2)
			delta = '+=460';
		if(n == -2)
			delta = '-=460';
		$("ul",".listConcept").animate({
		left: delta
		}, 480, 'swing',  function() {
			pos = Index
		});
	}
	
}
