var lcol = 0;
$(document).ready(function(){

//прячем/показываем картинку
    a=0;
	var a = $.cookie("pos");
	
	if (a==0) {
	  $("#pic").css( {display: 'none'} );
	  $('div.show').css( {backgroundPosition: '0 -13px'} );
	  a=1;
	}else{
	  $("#pic").css( {display: 'block'} );
	  $('div.show').css( {backgroundPosition: '0 0'} );		
	  a=0;
	};
		
	$("div.show").click(function () {
    $('div.show').css( {backgroundPosition: '0 0'} );
	if (a==0) {
      $("#pic").hide("slow");
	  $('div.show').css( {backgroundPosition: '0 -13px'} );
	  $.cookie("pos", 0);
	  a=1;
	}else{
	  $("#pic").show("slow");
	  $('div.show').css( {backgroundPosition: '0 0'} );
	  $.cookie("pos", 1);
	  a=0;
	};
    });
	
	
	//закрытие формы логина
    $(".login .ccv").click(function(){
      $(".login").animate( { marginTop:"-100%" }, 800 );
      $("#overlay") .animate( { opacity:".0" }, 500 )
	  				.hide("slow");
		$("a.open-login").removeAttr('href');
		$("a.open-login").attr({ 
          href: "login.html",
          title: "Login"
        });
	});
	
	//закрытие формы регистрации
	$(".login2 .ccv").click(function(){
    $(".login2").animate( { marginTop:"-100%" }, 800 );
    $("#overlay") .animate( { opacity:".0" }, 500 )
				  .hide("slow");
	$("a.open-registration").removeAttr('href');
	$("a.open-registration").attr({ 
        href: "register.html",
        title: "Register"
		});
	});
	
	//закрытие камента
	$(".comment .ccv").click(function(){
    $(".comment").animate( { marginTop:"-100%" }, 800 );
    $("#overlay") .animate( { opacity:".0" }, 500 )
				  .hide("slow");
	$("a.open-comment").removeAttr('href');
	$("a.open-comment").attr({ 
        href: "comment.html",
        title: "Register"
		});
	});
	
	//раскраска табличек в #content с классом .zebra
	$("#content table.zebra tr").each(colorize); // передаем в each функцию colorize
	function colorize(index)
	{
	  if(index % 2 == 1)       // index является индексом текущего элемента в коллекции
	    $(this).toggleClass("odd");
	}


	// уроки
//	heigh_scroll=$("#parent2 img:first").height() + 10;//
//	width_scroll=$("#parent2 img:first").width() + 5;
//	$("#parent2").wslide({
//		width: width_scroll,
//		height: heigh_scroll,
//		horiz: true
//	});
	

	$("#parent2-menu a").click(function(){
		var col = $("#parent2-menu a").index($(this));
		$("#blocks div").eq(lcol).hide("fast");
		$("#blocks div").eq(col).show("fast");
		lcol=col;
	});


});

//показываем форму логина и прячем ссылку href="login.html"
$(document).ready(function(){
    $(".open-login").click(function(e){
	$(".open-login a").removeAttr('href');
	$(".open-login a").attr({href: "#", title: "Enter"});
	  $("#overlay").show()
	  			   .animate( { opacity:".8" }, 500 );
	  $(".login").css( {display: "block"} );
      $(".login")
	  			.animate( { marginTop:"50px" }, 800 )
				.animate( { marginTop:"30px" }, 100 )
				.animate( { marginTop:"50px" }, 80 );

	e.preventDefault();
    });

});

//показываем форму регистрации и прячем ссылку href="register.html"
$(document).ready(function(){
    $(".open-registration").click(function(e){
	$(".open-registration a").removeAttr('href');
	$(".open-registration a").attr({href: "#", title: "Enter"});
	  $("#overlay").show()
	  			   .animate( { opacity:".8" }, 500 );
	  $(".login2").css( {display: "block"} );
      $(".login2")
	  			.animate( { marginTop:"50px" }, 800 )
				.animate( { marginTop:"30px" }, 100 )
				.animate( { marginTop:"50px" }, 80 );

	e.preventDefault();
    });

});

//показываем фому камента
function anichange (objName) {
  if ( $(".comment-form").css('display') == 'none' ) {
    $(".comment-form").animate({height: 'show'}, 300);
  } else {
    $(".comment-form").animate({height: 'hide'}, 300);
  }
}


//крутим картинку
n=0;
$(document).ready(function(){
	$('#pic').css( {backgroundPosition: '-8px 0'} );
	$('a.close').click(function(){ 
		n=n+500;
		$('#pic').animate({backgroundPosition: '('+n+'px 0px)'},
			function(){
			$('#pic').animate({backgroundPosition: '('+(n-10)+'px 0px)'}); 
   	}); 
	});
});


//крутим картинку 2
 step=n;
 step_size=0;
 min_step=0;
 max_step=8;
 flag=0;
function sp_up(){
 if (flag&&step_size<=max_step) {
 step_size=step_size+1;
 setTimeout("sp_up();", 200);
 }
 if (!flag&&step_size>min_step) {
 step_size=step_size-1;
 setTimeout("sp_up();", 200);
 }
}
function s_roll(){
flag=1;
sp_up();
if (step_size<=min_step+1) rolled();
}
function stop_roll(){
flag=0;
sp_up();
}
function rolled()
{
if (step_size>min_step){
	setTimeout("rolled();", 3);
	document.getElementById('pic').style.background='url(images/header-1.jpg) '+step+'px 0 repeat-x';
	step=step+step_size;
}
}
