// JavaScript Document
/*- - - - - -  UTILS - - - - - - - - - - - - */
/*		mousewheel |	Version: 3.0 | minified	*/
(function($){$.event.special.mousewheel={setup:function(){var handler=$.event.special.mousewheel.handler;if($.browser.mozilla)$(this).bind('mousemove.mousewheel',function(event){$.data(this,'mwcursorposdata',{pageX:event.pageX,pageY:event.pageY,clientX:event.clientX,clientY:event.clientY});});if(this.addEventListener)this.addEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
this.onmousewheel=handler;},teardown:function(){var handler=$.event.special.mousewheel.handler;$(this).unbind('mousemove.mousewheel');if(this.removeEventListener)this.removeEventListener(($.browser.mozilla?'DOMMouseScroll':'mousewheel'),handler,false);else
this.onmousewheel=function(){};$.removeData(this,'mwcursorposdata');},handler:function(event){var args=Array.prototype.slice.call(arguments,1);event=$.event.fix(event||window.event);$.extend(event,$.data(this,'mwcursorposdata')||{});var delta=0,returnValue=true;if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;if($.browser.opera)delta=-event.wheelDelta;event.data=event.data||{};event.type="mousewheel";args.unshift(delta);args.unshift(event);return $.event.handle.apply(this,args);}};$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel");},unmousewheel:function(fn){return this.unbind("mousewheel",fn);}});})(jQuery);
/*- - - - - - - - - - - - - - - - - - - - - -*/


$(document).ready(function(){

// описание эффекта для скрола
$.fn.cycle.transitions.scrollHorz = function($cont, $slides, opts) {
    $cont.css('overflow','hidden').width();
//    $slides.show();
    opts.before.push(function(curr, next, opts, fwd) {
        $(this).show();
        var currW = curr.offsetWidth, nextW = next.offsetWidth;
        opts.cssBefore = fwd ? { left: nextW } : { left: -nextW };
        opts.animIn.left = 0;
        opts.animOut.left = fwd ? -currW : currW;
        $slides.not(curr).css(opts.cssBefore);
    });
    opts.cssFirst = { left: 0 };
    opts.cssAfter = { display: 'none' }
	$('#portfolio').css('display', 'block');
};

// старт скрола
$('#scrollBlock').cycle({ 
    fx: 'scrollHorz' // эффект
	 ,speed: '1200'
	 ,timeout: 0
	 ,next: '#toRight'
	 ,prev: '#toLeft'
	 ,nowrap: 0  // неразрвность\закольцованность, булев
});


/*$('#portfolio').mousewheel(function(event, delta) {
	if (delta > 0)
		$('#toLeft').trigger('click');
	else if (delta < 0)
		$('#toRight').trigger('click');
	return false;
});*/

/* эффекты для блока */
/*jQuery.easing['easeOutBounce'] = function (x, t, b, c, d) {
	if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
	return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
};*/

jQuery.easing['easeInBounce'] = function (x, t, b, c, d) {
return c*(t/=d)*t*t*t*t + b;
};
jQuery.easing['easeOutBounce'] = function (x, t, b, c, d) {
	if ((t/=d) < (1/2.75)) {
		return c*(7.5625*t*t) + b;
	} else if (t < (2/2.75)) {
		return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
	} else if (t < (2.5/2.75)) {
		return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
	} else {
		return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
	}
};
/*jQuery.easing['easeInOutBounce'] = function (x, t, b, c, d) {
	if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
	return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
};*/

// определяем кол-во элементов, и отдаём высоту блока
function sizeof () {
	var arrayLength = $('#clients > img').length;
	var elementW = $('#clients').width();
	var blockH = (Math.ceil((arrayLength*180)/elementW))*110;
	return blockH;
}
// триггер блока
$('#arrow').toggle(
	function() {
	var blockH = sizeof();
		$('#clients').animate({height:blockH}, 700, 'easeOutBounce');
		$('#arrow').toggleClass("arrowTop");
	},
	function() {
		$('#clients').animate({height:115}, 500, 'easeOutBounce');
		$('#arrow').toggleClass("arrowTop");
	}
);
});


function openFaq(){
	if($('.contentFaq').css('display')!='block'){
		$('.contentFaq').animate({height:'show'}, 800, 'easeOutBounce');
		$('.titleFaq .arrow').css('display', 'none');
		$('.titleFaq .arrowC').css('display', 'block');
		$('.titleFaq .arrowBottom').css('display', 'block');
	}
	else{
		$('.contentFaq').animate({height:'hide'}, 800, 'easeOutBounce');
		$('.titleFaq .arrowC').hide();
		$('.titleFaq .arrowBottom').css('display', 'none');
		$('.titleFaq .arrow').show();
		}
		return false;
}


function mOv(){
	$('#linkHover').attr('class', 'active');
	}
	
function mOu(){
	$('#linkHover').attr('class', '');
	}

$(function(){
		   $('.openFaq').click(function(){openFaq(); return false;});
		   $('.closeFaq').click(function(){openFaq(); return false;});
		   $('.titleFaq .arrowBottom').click(function(){openFaq(); return false;});
		   $('.strikBlock a').mouseover(mOv);
		   $('.strikBlock a').mouseout(mOu);
		   $('.titleFaq .lFaq a').mouseover(mOv);
		   $('.titleFaq .lFaq a').mouseout(mOu);
		   });




