	$(document).ready(function(){
		$('#showformenter').click(function(){
			$(".showformenter").animate({top:"-44"}, 300, "easeInCubic", function(){
				$(".formenter").animate({top:"0"}, 500, "easeOutCubic" );
			});
		});
		$('#hideformenter').click(function(){
			$(".formenter").animate({top: "-176"}, 300, "easeInCubic", function(){
				$(".showformenter").animate({top: "0"}, 500, "easeOutCubic" );
			});
		});
		
	    $(".gallery a.gallery-block").hover(
	      function () {
				$(this).find(".divhint").css({"display":"block"});
	      },
	      function () {
				$(this).find(".divhint").css({"display":"none"});
	      }
	    );
		
		$('.tkopis-more a').click(function(){
			$(this).parent().parent().find("table").slideDown(300);
		});
		
		
		
		
		$(".menu ul:first-child").addClass('ul1');
		$(".ul1").children('li').addClass('li1');
		$(".li1:last-child").addClass('li1last');
		$(".li1").children('a').addClass('a1');
		$(".li1").children('ul').addClass('ul2');
		$(".ul2").children('li').addClass('li2');
		$(".li2:last-child").addClass('li2last');
		$(".li2:first-child").addClass('li2first');
		$(".li2").children('a').addClass('a2');
		$(".li2").children('ul').addClass('ul3');
		$(".ul3").children('li').addClass('li3');
		$(".li3:last-child").addClass('li3last');
		$(".li3:first-child").addClass('li3first');
		$(".li3").children('a').addClass('a3');		
		$(".menu .a1").append('<span class="s1"></span><span class="s2"></span>');
		$(".menu").append('<div class="gsl1"></div><div class="gsl2"></div>');


	    $(".menu .li1").hover(
	      function () {
				$(this).find(".ul2").addClass('ul2dislay');
				$(this).find(".a1").addClass('active');
	      },
	      function () {
				$(this).find(".ul2").removeClass('ul2dislay');
				$(this).find(".a1").removeClass('active');
	      }
	    );
		
	    $(".menu .li1 .li2").hover(
	      function () {
				$(this).find(".ul3").addClass('ul3dislay');
				$(this).find(".a2").addClass('a2active');
	      },
	      function () {
				$(this).find(".ul3").removeClass('ul3dislay');
				$(this).find(".a2").removeClass('a2active');
	      }
	    );
		
		
		var autoPlayTime=10000;
		autoPlayTimer = setInterval( autoPlay, autoPlayTime);
		function autoPlay(){
			Slidebox('next');
		}
		$('.next').click(function () {
			Slidebox('next','stop');
		});
		$('.previous').click(function () {
			Slidebox('previous','stop');
		});

		$("#slidebox .content").each(function(i){
			slideboxTotalContent=i*$('#slidebox').width();	
			$('#slidebox .container').css("width",slideboxTotalContent+$('#slidebox').width());
		});
		
		
	});
	
	
	
	function Slidebox(slideTo,autoPlay){
	    var animSpeed=1000; //animation speed
	    var easeType='easeInOutExpo'; //easing type
		var sliderWidth=$('#slidebox').width();
		var leftPosition=$('#slidebox .container').css("left").replace("px", "");
		if( !$("#slidebox .container").is(":animated")){
			if(slideTo=='next'){ //next
				if(autoPlay=='stop'){
					clearInterval(autoPlayTimer);
				}
				if(leftPosition==-slideboxTotalContent){
					$('#slidebox .container').animate({left: 0}, animSpeed, easeType); //reset
				} else {
					$('#slidebox .container').animate({left: '-='+sliderWidth}, animSpeed, easeType); //next
				}
			} else if(slideTo=='previous'){ //previous
				if(autoPlay=='stop'){
					clearInterval(autoPlayTimer);
				}
				if(leftPosition=='0'){
					$('#slidebox .container').animate({left: '-'+slideboxTotalContent}, animSpeed, easeType); //reset
				} else {
					$('#slidebox .container').animate({left: '+='+sliderWidth}, animSpeed, easeType); //previous
				}
			} else {
				var slide2=(slideTo-1)*sliderWidth;
				if(leftPosition!=-slide2){
					clearInterval(autoPlayTimer);
					$('#slidebox .container').animate({left: -slide2}, animSpeed, easeType); //go to number
				}
			}
			
		}
	}
	
	
function getXmlHttp(){
  var xmlhttp;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e2) {
		try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP.4.0");
		} catch (e2) {
		xmlhttp = false;
		}
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}


function ajaddtovarincart(filename, contayner)
{
filename=filename+'&rnd='+Math.random();
alert("Вы добавили в корзину!");
var xmlhttp = getXmlHttp()
xmlhttp.open('GET', filename, true);
xmlhttp.onreadystatechange = function() {
  if (xmlhttp.readyState == 4) {
     if(xmlhttp.status == 200) {

	 document.getElementById(contayner).innerHTML = xmlhttp.responseText;
	 
     }
  }
}
xmlhttp.send(null);
}
