/*--- horisontal accordion ---*/
function initAcc(){
	var _max = 815;
	var _min = 62;
	var _speed = 600;
	var _hold = $('#gallery');
	if(_hold.length){
		var _list = _hold.children();
		var _a = _list.index(_list.filter('.active:eq(0)'));
		if(_a == -1) _a = 0;
		_list.removeClass('active').width(_min).eq(_a).addClass('active').width(_max);
		_list.each(function(_i){
			var _el = $(this);
			var _t;
			_el.mouseenter(function(){
				if(_t) clearTimeout(_t);
				_t = setTimeout(function(){
					if(_a != _i){
						_list.eq(_a).removeClass('active');
						_list.eq(_i).addClass('active');
						_list.stop().animate({width: _min}, _speed);
						_list.eq(_i).stop().animate({width: _max}, _speed);
						_a = _i;
					}
				}, 0);
			}).mouseleave(function(){
				if(_t) clearTimeout(_t);
			});
		});
	}
}

function highlightSubcat(curPath) {
	//alert(curPath);
	// /services/fulfillment.php
	var _hold = $('#subnav');
	if (_hold.length) {
		var _list = _hold.children();
		
		_list.each(function(_i){
			var ahref = $(this).children().attr("href");
			if (ahref == curPath) {
				$(this).addClass('active');
				return false;
			} else {
				$(this).removeClass('active');
			}
		});
		
	}
}

$(document).ready(function(){
	initAcc();
	
	highlightSubcat(window.location.pathname);
	
});