		
         j.easing.easeOutQuart = function (x, t, b, c, d) {
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		}; 

j().ready(function(){



			j("#screen_top").serialScroll({
				target:"#slideshow_top",
				items:"li", //selector to the items ( relative to the matched elements, "#sections" in this case )
				prev:"img.prev",//selector to the "prev" button (absolute!, meaning it"s relative to the document)
				next:"img.next",//selector to the "next" button (absolute too)
				axis:"xy",//the default is "y"
				queue:false,//we scroll on both axes, scroll both at the same time.
				event:"click",//on which event to react (click is the default, you probably won"t need to specify it)
				stop:false,//each click will stop any previous animations of the target. (false by default)
				lock:true, //ignore events if already animating (true by default)
				duration:700,//length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
				start: 0, //on which element (index) to begin ( 0 is the default, redundant in this case )
				force:true, //force a scroll to the element specified by "start" (some browsers don"t reset on refreshes)
				cycle:false,//cycle endlessly ( constant velocity, true is the default )
				step:1, //how many items to scroll each time ( 1 is the default, no need to specify )
				jump:false, //if true, items become clickable (or w/e "event" is, and when activated, the pane scrolls to them)
				lazy:false,//(default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
				interval:false, //it"s the number of milliseconds to automatically go to the next
				//navigation:"#navigation li",
				constant:true,
				onBefore:function( e, elem, $pane, $items, pos ){
					/**
					 * "this" is the triggered element
					 * e is the event object
					 * elem is the element we"ll be scrolling to
					 * $pane is the element being scrolled
					 * $items is the items collection at this moment
					 * pos is the position of elem in the collection
					 * if it returns false, the event will be ignored
					 */
					 //those arguments with a $ are jqueryfied, elem isn"t.
					e.preventDefault();
					if( this.blur )
						this.blur();
				},
				onAfter:function( elem ){
					//"this" is the element being scrolled ($pane) not jqueryfied
				}
			});
            

				j("#slideshow_gal").serialScroll({
				items:"li",
				prev:"#imgprev_gal",
				next:"#imgnext_gal",
				axis:"xy",
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //dont pull back once you reach the end
				step:2,
				easing:"easeOutQuart", //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
			});
				j("#slideshow_gal2").serialScroll({
				items:"li",
				prev:"#imgprev_gal2",
				next:"#imgnext_gal2",
				axis:"xy",
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //dont pull back once you reach the end
				step:2,
				easing:"easeOutQuart", //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
			});

				j("#slideshow_gal3").serialScroll({
				items:"li",
				prev:"#imgprev_gal3",
				next:"#imgnext_gal3",
				axis:"xy",
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //dont pull back once you reach the end
				step:2,
				easing:"easeOutQuart", //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
			});
				j("#slideshow_gal4").serialScroll({
				items:"li",
				prev:"#imgprev_gal4",
				next:"#imgnext_gal4",
				axis:"xy",
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //dont pull back once you reach the end
				step:2,
				easing:"easeOutQuart", //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
			});
            
            	j("#slideshow_shop_jgames").serialScroll({
				items:"li",
				prev:"#screen_shop_jgames a.prev, #imgprev_shop_jgames",
				next:"#screen_shop_jgames a.next, #imgnext_shop_jgames",
				axis:"xy",
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //dont pull back once you reach the end
				step:1,
				easing:"easeOutQuart", //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
			});
            
            	j("#slideshow_shop_images").serialScroll({
				items:"li",
				prev:"#screen_shop_images a.prev, #imgprev_shop_images",
				next:"#screen_shop_images a.next, #imgnext_shop_images",
				axis:"xy",
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //dont pull back once you reach the end
				step:1,
				easing:"easeOutQuart", //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
			});
            
            	j("#slideshow_shop_ringtones").serialScroll({
				items:"li",
				prev:"#screen_shop_ringtones a.prev, #imgprev_shop_ringtones",
				next:"#screen_shop_ringtones a.next, #imgnext_shop_ringtones",
				axis:"xy",
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //dont pull back once you reach the end
				step:1,
				easing:"easeOutQuart", //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
			});


			j("#screen_bottom_bus1").serialScroll({
				target:"#slideshow_bottom_bus1",
				items:"li", //selector to the items ( relative to the matched elements, "#sections" in this case )
				prev:"img.prev",//selector to the "prev" button (absolute!, meaning it"s relative to the document)
				next:"img.next",//selector to the "next" button (absolute too)
				axis:"xy",//the default is "y"
				queue:false,//we scroll on both axes, scroll both at the same time.
				event:"click",//on which event to react (click is the default, you probably won"t need to specify it)
				stop:false,//each click will stop any previous animations of the target. (false by default)
				lock:true, //ignore events if already animating (true by default)
				duration:700,//length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
				start: 0, //on which element (index) to begin ( 0 is the default, redundant in this case )
				force:true, //force a scroll to the element specified by "start" (some browsers don"t reset on refreshes)
				cycle:false,//cycle endlessly ( constant velocity, true is the default )
				step:1, //how many items to scroll each time ( 1 is the default, no need to specify )
				jump:false, //if true, items become clickable (or w/e "event" is, and when activated, the pane scrolls to them)
				lazy:false,//(default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
				interval:false, //it"s the number of milliseconds to automatically go to the next
				//navigation:"#navigation li",
				constant:true,
				onBefore:function( e, elem, $pane, $items, pos ){

					 //those arguments with a $ are jqueryfied, elem isn"t.
					e.preventDefault();
					if( this.blur )
						this.blur();
				},
				onAfter:function( elem ){
					//"this" is the element being scrolled ($pane) not jqueryfied
				}
			});
            
			j("#screen_bottom_bus2").serialScroll({
				target:"#slideshow_bottom_bus2",
				items:"li", //selector to the items ( relative to the matched elements, "#sections" in this case )
				prev:"img.prev",//selector to the "prev" button (absolute!, meaning it"s relative to the document)
				next:"img.next",//selector to the "next" button (absolute too)
				axis:"xy",//the default is "y"
				queue:false,//we scroll on both axes, scroll both at the same time.
				event:"click",//on which event to react (click is the default, you probably won"t need to specify it)
				stop:false,//each click will stop any previous animations of the target. (false by default)
				lock:true, //ignore events if already animating (true by default)
				duration:700,//length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
				start: 0, //on which element (index) to begin ( 0 is the default, redundant in this case )
				force:true, //force a scroll to the element specified by "start" (some browsers don"t reset on refreshes)
				cycle:false,//cycle endlessly ( constant velocity, true is the default )
				step:1, //how many items to scroll each time ( 1 is the default, no need to specify )
				jump:false, //if true, items become clickable (or w/e "event" is, and when activated, the pane scrolls to them)
				lazy:false,//(default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
				interval:false, //it"s the number of milliseconds to automatically go to the next
				//navigation:"#navigation li",
				constant:true,
				onBefore:function( e, elem, $pane, $items, pos ){

					 //those arguments with a $ are jqueryfied, elem isn"t.
					e.preventDefault();
					if( this.blur )
						this.blur();
				},
				onAfter:function( elem ){
					//"this" is the element being scrolled ($pane) not jqueryfied
				}
			});
            
			j("#screen_bottom_bus3").serialScroll({
				target:"#slideshow_bottom_bus3",
				items:"li", //selector to the items ( relative to the matched elements, "#sections" in this case )
				prev:"img.prev",//selector to the "prev" button (absolute!, meaning it"s relative to the document)
				next:"img.next",//selector to the "next" button (absolute too)
				axis:"xy",//the default is "y"
				queue:false,//we scroll on both axes, scroll both at the same time.
				event:"click",//on which event to react (click is the default, you probably won"t need to specify it)
				stop:false,//each click will stop any previous animations of the target. (false by default)
				lock:true, //ignore events if already animating (true by default)
				duration:700,//length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
				start: 0, //on which element (index) to begin ( 0 is the default, redundant in this case )
				force:true, //force a scroll to the element specified by "start" (some browsers don"t reset on refreshes)
				cycle:false,//cycle endlessly ( constant velocity, true is the default )
				step:1, //how many items to scroll each time ( 1 is the default, no need to specify )
				jump:false, //if true, items become clickable (or w/e "event" is, and when activated, the pane scrolls to them)
				lazy:false,//(default) if true, the plugin looks for the items on each event(allows AJAX or JS content, or reordering)
				interval:false, //it"s the number of milliseconds to automatically go to the next
				//navigation:"#navigation li",
				constant:true,
				onBefore:function( e, elem, $pane, $items, pos ){

					 //those arguments with a $ are jqueryfied, elem isn"t.
					e.preventDefault();
					if( this.blur )
						this.blur();
				},
				onAfter:function( elem ){
					//"this" is the element being scrolled ($pane) not jqueryfied
				}
			});


// ---- Форма -----
  var options = {
    // элемент, который будет обновлен по ответу сервера
  	target: "#output",
    //beforeSubmit: showRequest, // функция, вызываемая перед передачей
    success: showResponse, // функция, вызываемая при получении ответа
    timeout: 3000 // тайм-аут
  };

 j("#reg_new_user").validate({
    focusInvalid: false,
    focusCleanup: true,
rules : {
			login : {required : true, minlength: 2, remote: "ajax/check_login.php"},
			password : {required : true, minlength: 4},
            password2: {equalTo : "#password"},
            mail: {email : true},
            chk: {required: true}

		},
		messages : {
			login : {
				required : "Введите ваше имя",
				minlength : "Введите не менее 2 символов.",
				remote : "Это имя занято"
			},
			password : "Введите пароль",
            password2: "пароли не совпадают",
            mail : {
                required: "Нужно указать email адрес",
                email: "email адрес неверный"
            },
            chk: "!"
		}

        /* ,
    errorPlacement: function(error, element) {
      var er = element.attr("name");
      //error.appendTo( element.parent().find("label[@for=\'" + er + "\']").find("em") );
      error.appendTo( element.parent().find("label[@for=\'" + er + "\']").find("em") );
    } */


	});


  function showResponse(responseText, statusText)  {
                //j("#reg_form").hide();
                //alert(responseText);
  }


    j("#screen_shop_images").addClass("screen__hide"); // скрываем вторую
    j("#screen_shop_ringtones").addClass("screen__hide"); // скрываем третью
    
    j("#screen_gal").removeClass("screen__hide"); // скрываем вторую галерею
    //j("#screen_gal3").addClass("screen__hide"); // скрываем третью галерею
    
    
	j("#show_jgames").click( function(){
    j("#screen_shop_jgames").show(); //покажем первую
    j("#screen_shop_images").addClass("screen__hide"); //скроем вторую
    j("#screen_shop_ringtones").addClass("screen__hide"); // скрываем третью
    
    j(this).removeClass("shop_button_disabled"); //
    j(this).addClass("shop_button_enabled"); //
    j("#show_images").removeClass("shop_button_enabled"); //    
    j("#show_images").addClass("shop_button_disabled"); //

    
    j("#show_ringtones").addClass("shop_button_disabled"); //
    j("#show_ringtones").removeClass("shop_button_enabled"); //
    });
    
    
    j("#show_images").click( function(){
    j("#screen_shop_jgames").hide(); //скроем первую
    j("#screen_shop_ringtones").addClass("screen__hide"); // скрываем третью
    j("#screen_shop_images").removeClass("screen__hide"); //покажем вторую
    
    j(this).removeClass("shop_button_disabled"); //
    j(this).addClass("shop_button_enabled"); //
    j("#show_jgames").removeClass("shop_button_enabled"); //    
    j("#show_jgames").addClass("shop_button_disabled"); //

    j("#show_ringtones").addClass("shop_button_disabled"); //
    j("#show_ringtones").removeClass("shop_button_enabled"); //    
	});
    
	j("#show_ringtones").click( function(){
    j("#screen_shop_jgames").hide(); //скроем первую
    j("#screen_shop_images").addClass("screen__hide"); //скроем вторую
    j("#screen_shop_ringtones").removeClass("screen__hide"); //покажем третью
    
    j(this).removeClass("shop_button_disabled"); //
    j(this).addClass("shop_button_enabled"); //
    j("#show_images").removeClass("shop_button_enabled"); //    
    j("#show_images").addClass("shop_button_disabled"); //
    
    j("#show_jgames").addClass("shop_button_disabled"); //
    j("#show_jgames").removeClass("shop_button_enabled"); //
    });
    
    /*ГАЛЕРЕИ*/
    
    j("#show_gal").click( function(){
    j("#screen_gal").show(); //скроем первую
    j("#screen_gal2").addClass("screen__hide"); //скроем вторую
    j("#screen_gal3").addClass("screen__hide"); //покажем третью
    j("#screen_gal4").addClass("screen__hide"); //покажем третью
    j(this).removeClass("gal_button_disabled"); //
    j(this).addClass("gal_button_enabled"); //
    j("#show_gal2").removeClass("gal_button_enabled"); //    
    j("#show_gal2").addClass("gal_button_disabled"); //
    j("#show_gal3").removeClass("gal_button_enabled"); //
    j("#show_gal3").addClass("gal_button_disabled"); //
    j("#show_gal4").removeClass("gal_button_enabled"); //
    j("#show_gal4").addClass("gal_button_disabled"); //
    });
    
    j("#show_gal2").click( function(){
    j("#screen_gal").hide(); //скроем первую
    j("#screen_gal3").addClass("screen__hide"); //скроем вторую
    j("#screen_gal2").removeClass("screen__hide"); //покажем третью
    j("#screen_gal4").addClass("screen__hide"); //скроем вторую
    j(this).removeClass("gal_button_disabled"); //
    j(this).addClass("gal_button_enabled"); //
    j("#show_gal").removeClass("gal_button_enabled"); //    
    j("#show_gal").addClass("gal_button_disabled"); //
    j("#show_gal3").addClass("gal_button_disabled"); //
    j("#show_gal3").removeClass("gal_button_enabled"); //
    j("#show_gal4").removeClass("gal_button_enabled"); //
    j("#show_gal4").addClass("gal_button_disabled"); //
    });

    j("#show_gal3").click( function(){
    j("#screen_gal").hide(); //скроем первую
    j("#screen_gal2").addClass("screen__hide"); //скроем вторую
    j("#screen_gal3").removeClass("screen__hide"); //покажем третью
    j("#screen_gal4").addClass("screen__hide"); //скроем вторую
    j(this).removeClass("gal_button_disabled"); //
    j(this).addClass("gal_button_enabled"); //
    j("#show_gal").removeClass("gal_button_enabled"); //    
    j("#show_gal").addClass("gal_button_disabled"); //
    j("#show_gal2").addClass("gal_button_disabled"); //
    j("#show_gal2").removeClass("gal_button_enabled"); //
    j("#show_gal4").removeClass("gal_button_enabled"); //
    j("#show_gal4").addClass("gal_button_disabled"); //
    });
    
    j("#show_gal4").click( function(){
    j("#screen_gal").hide(); //скроем первую
    j("#screen_gal2").addClass("screen__hide"); //скроем вторую
    j("#screen_gal3").addClass("screen__hide"); //скроем вторую
    j("#screen_gal4").removeClass("screen__hide"); //покажем третью
    j(this).removeClass("gal_button_disabled"); //
    j(this).addClass("gal_button_enabled"); //
    j("#show_gal").removeClass("gal_button_enabled"); //    
    j("#show_gal").addClass("gal_button_disabled"); //
    j("#show_gal2").addClass("gal_button_disabled"); //
    j("#show_gal2").removeClass("gal_button_enabled"); //
    j("#show_gal3").removeClass("gal_button_enabled"); //
    j("#show_gal3").addClass("gal_button_disabled"); //
    });

    /**/
    /* BUSINESS SLIDERS*/
    j("#screen_bottom_bus2").addClass("screen__hide"); // скрываем вторую
    j("#screen_bottom_bus3").addClass("screen__hide"); // скрываем третью
    
    j("#show_bus1").click( function(){
    j("#screen_bottom_bus1").show(); //скроем первую
    j("#screen_bottom_bus2").addClass("screen__hide"); //скроем вторую
    j("#screen_bottom_bus3").addClass("screen__hide"); //покажем третью
    j(this).removeClass("bus_button_disabled"); //
    j(this).addClass("bus_button_enabled"); //
    j("#show_bus2").removeClass("bus_button_enabled"); //    
    j("#show_bus2").addClass("bus_button_disabled"); //
    j("#show_bus3").removeClass("bus_button_enabled"); //
    j("#show_bus3").addClass("bus_button_disabled"); //
    });
    
    j("#show_bus2").click( function(){
    j("#screen_bottom_bus1").hide(); //скроем первую
    j("#screen_bottom_bus3").addClass("screen__hide"); //скроем вторую
    j("#screen_bottom_bus2").removeClass("screen__hide"); //покажем третью
    j(this).removeClass("bus_button_disabled"); //
    j(this).addClass("bus_button_enabled"); //
    j("#show_bus1").removeClass("bus_button_enabled"); //    
    j("#show_bus1").addClass("bus_button_disabled"); //
    j("#show_bus3").addClass("bus_button_disabled"); //
    j("#show_bus3").removeClass("bus_button_enabled"); //
    });
    
    j("#show_bus3").click( function(){
    j("#screen_bottom_bus1").hide(); //скроем первую
    j("#screen_bottom_bus2").addClass("screen__hide"); //скроем вторую
    j("#screen_bottom_bus3").removeClass("screen__hide"); //покажем третью
    j(this).removeClass("bus_button_disabled"); //
    j(this).addClass("bus_button_enabled"); //
    j("#show_bus1").removeClass("gal_button_enabled"); //    
    j("#show_bus1").addClass("bus_button_disabled"); //
    j("#show_bus2").addClass("bus_button_disabled"); //
    j("#show_bus2").removeClass("bus_button_enabled"); //
    });
    /* //BUSINESS SLIDERS*/
    
    
    
j("#reg_form").hide(); //скрыть форму регистрации при загрузке
j("#load_pic_form").hide(); //скрыть форму добавления фото при загрузке
j("#login_form_popup").hide();

	j("#reg_form_close").click( function(){
	j("#reg_form").fadeOut("slow");
	});

	j("#show_reg_form").click( function(){
	j("#reg_form").slideDown("slow");
    j("#login_form_popup").fadeOut("slow");
	});
    
    j("#login_form_popup_close").click( function(){
    //j("#reg_form").hide();
	j("#login_form_popup").fadeOut("slow");
	});
    

	j("#load_pic_form_close").click( function(){
	j("#load_pic_form").fadeOut("slow");
	});

    j("#show_load_pic_form").click( function(){
	j("#load_pic_form").slideDown("slow");
	});

    j("#voiti").click( function(){
	j("#reg_form").fadeOut("slow");
    j("#login_form_popup").slideDown("slow");
	});
    
j("#check_username").click( function(){
  j("#check_username_status").load("/../ajax/check_login.php", {name:"j(“#my-id”)"} );
  });



});