jQuery.easing['backout'] = function(x, t, b, c, d) {
		var s=1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
};

jQuery(document).ready(function($) {
	$(' .like').socialButton({
		alternativeImage: 'http://www.team-b.ru/imgs/default_logo.png'
	}); 
  
//$('div.tabcontent').load('../blocks/maintabs.php', function() {              
	var tabContainers = $('div.tabs > div.tabcontent > div');
	tabContainers.hide().filter(':first').show();  
			
	$('div.tabs ul.tabNavigation a').click(function () {
		tabContainers.hide();
		tabContainers.filter(this.hash).fadeIn(300);
		$('div.tabs ul.tabNavigation a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').click();
//}); 


$('div.portfolio').load('../blocks/main_portfolio.php', function() {
  $('.portviz').cycle({speed: 1000, timeout: 8000, delay: 0});  
  $('.portkomp').cycle({speed: 1000, timeout: 8000, delay: 2000});  
  $('.portmag').cycle({speed: 1000, timeout: 8000, delay: 4000});  
  $('.portcorp').cycle({speed: 1000, timeout: 8000, delay: 6000});
});  
            
 if ( $('.jCarouselLite').length > 0 ) {
   $(".jCarouselLite").jCarouselLite({
      btnNext: " .next",
      btnPrev: " .prev",
      speed: 500,
      visible: 5,
      easing: "backout"
   });
 }
 
 
	$.validator.methods.equal = function(value, element, param) {
		return value == param;
	};        
    var sum = Math.floor(Math.random()*20); 
    var s1 = Math.floor(Math.random()*sum);
    var s2 = sum - s1;
    $("#exdig").html(s1+' + '+ s2 + '= (*)');
// ---- Форма -----
  // готовим опции для метода
  // ajaxSubmit плагина jquery.form.js
  var options = { 
  	target: "#output",
    timeout: 3000 // тайм-аут
  };
  
  $("#orderform").validate({
  	submitHandler: function(form) {
   	  // вызываем метод ajaxSubmit
   	  // плагина jquery.form.js
  	  $(form).ajaxSubmit(options);
    },
    focusInvalid: false,
    focusCleanup: true,
    rules: {
      name: {
      	required: true,
      	minlength: 2,
      	maxlength: 30
      },
      email: {
      	required: true,
      	email: true
      },
      subject: {
      	required: true,
      	maxlength: 500
      },
      Examine: {
      	required: true,
      	equal: sum
      }
    },
    errorPlacement: function(error, element) {
      element.parent().addClass('error_block');
      error.insertBefore(element);
    }
});     
         
});  
