$(document).ready(function(){
		$('.form-podpiska-ren').submit(function(){
		$.post(
			'/udata/custom/setSubscribe',
			{
				tape: $(this).find('input[name=tape]').val(),
				email: $(this).find('input[name=email]').val()
			},
			function(data){
				alert(data.text);
			},
			'json'
		);

		return false;
	});
});

var f1_in = function () {
 $(this).addClass("hover").children(".under").show();
}

var f2_in = function() {
 $("ul.navBar li.mItem").removeClass('hover');
}

var f1_out = function () {
 $(this).removeClass("hover").find('.under').hide();
}

var sel;
$(document).ready(function(){

 sel = $("ul.navBar li.mItem");
 sel.hover(f1_in, f1_out).addClass('topMenuItem');

 $(document).hover(function (event) {
  $element = $(event.target);
  if ($element.parents('.under').length) {
   return;
  }
	var li = $element.parents('li.topMenuItem').get(0);
  if (li && !$(li).hasClass('click')) {
   sel.unbind('mouseenter mouseleave').hover(f2_in, function () {});
  }
	else
	{
	 sel.unbind('mouseenter mouseleave').hover(f1_in, f1_out)
		.removeClass('hover').find('.under').hide();
  }
  if (li) { $(li).trigger('mouseenter'); }
 });

 /* Resizing header block on main */
 var height = $('.moldelsList UL LI').length*18+10;
 if (height>390) {
	$('.modelsViewBox#kostyl').css('height', height);
	$('.moldelsList').css('height', height);
 }

});


/* Left Model Menu */
function _(t){
	text = t?t:'Heloo world!!!';
	alert(text);
	}

function _p(t){
	text = t?t:'Heloo world!!!';
	$('#panel')[0].innerHTML+= '<li>'+text+'</li>';
	}









var slideTitmer;
//===============================================================================
$(function(){//==================================================================
//===============================================================================
//$('body').append('<ul id="panel"></ul>');
$('#panel').click(function(){
						   this.innerHTML = '';
						   });

var listHeight = $('.modelsViewBox').height();
var ulHeight = $('.moldelsListHr1 ul').height();
$('.moldelsListHr1')
	.css({
		 height:(listHeight-70) +'px'
		 });
$('.arrowBottom')
	.css({
		 top:(listHeight-20)+'px'
		 });

$('.arrowBottom')
	.mousedown(function(){
						slideTitmer = window.setInterval(function(){
																  var el = $('.moldelsListHr1 ul');
																  var top = el.css('top');
																  var numTop = top.replace(/[^0-9]*/g, '');
																  var endPos = el.height() - $('.moldelsListHr1').height();
																  if(numTop <= endPos){
																  	var newTop = Number(numTop)+5;
																  	el.css('top', '-'+newTop+'px')
																  }
																  //_p(numTop + ' / ' + endPos)
																  }, 10)
						})
	.mouseup(function(){
					  clearInterval(slideTitmer);
					  })
	.mouseout(function(){
					  clearInterval(slideTitmer);
					  })
	.click(function(){return false});


$('.arrowTop')
	.mousedown(function(){
						slideTitmer = window.setInterval(function(){
																  var el = $('.moldelsListHr1 ul');
																  var top = el.css('top');
																  var numTop = top.replace(/[^0-9]*/g, '');
																  var endPos = el.height() + $('.moldelsListHr1').height();
																  if(numTop >0){
																  	var newTop = Number(numTop)-5;
																  	el.css('top', '-'+newTop+'px')
																  }
																  //_p(numTop + ' / ' + endPos)
																  }, 10)
						})
	.mouseup(function(){
					  clearInterval(slideTitmer);
					  })
	.mouseout(function(){
					  clearInterval(slideTitmer);
					  })
	.click(function(){return false});
//===============================================================================
});//============================================================================
//===============================================================================

