function innerTabs(){
	$('ul.image-list').find('a').lightBox();
	var _IE = ((navigator.appName.indexOf('Microsoft Internet Explorer') != -1));
	var _page = $('body > div:eq(0)');
	$('#inner-nav').show();
	var _tabW = 0;
	var _twidth = 0;
	var _width1 = 0;
	var _heightAr = [];
	var _maxH = 0;
	var _innerHold = $('ul.gallery')
	var _bigSlides = _innerHold.children('li');
	_bigSlides.css('padding', 0);
	var _holder = $('li.environment');
	var _innerslide = _holder.find('div.tab');
	var _btn = _holder.find('ul.tabset').find('a');
	var _minWidth = _page.outerWidth();
	var _z = 0;
		if (window.innerHeight) {
			_width = window.innerWidth;
		}
		else {
			_width = document.documentElement.clientWidth;
		}
		_a = _bigSlides.index(_bigSlides.filter('.current:eq(0)'));
		if(_a == -1) _a = 0;
	
	_innerHold.removeClass('active').eq(_a).addClass('current');
	var _Dwidth = _width;
	_bigSlides.css({
		width: _Dwidth
	});
	var _ttt;
	$(window).resize(function(){
		if(_ttt) clearTimeout(_ttt);
		_ttt = setTimeout(function(){
			var _a = _bigSlides.index(_bigSlides.filter('.current:eq(0)'));
			if(_a == -1) _a = 0;
			if (window.innerHeight) _width = window.innerWidth;
			else _width = document.documentElement.clientWidth;
			if(_width != _Dwidth && !_innerHold.is(':animated')){
				_Dwidth = (_width < 980)?(980):(_width);
				_bigSlides.width(_Dwidth);
				if(_z == 0) _innerHold.css({ left: 0});
				else _innerHold.css({ left: -(_Dwidth*(_z))});
				_Margin =_Dwidth;
			}
		}, 200);
	});
	if (_holder.length != 0) {
		var _menu = $('#inner-nav');
		_menu.show();
		var _benefits = _menu.find('li.active a');
		var _slider_hold = _holder.find('div.tab-holder');
		for(var _k=0; _k < _innerslide.length; _k++){
			_slideH = _innerslide.eq(_k).height();
			_heightAr.push(_slideH);
			if(_maxH < _slideH){
				_maxH = _slideH;
			}
		}
		var _firstH = _heightAr[0];
		_innerslide.css('height', _firstH);
		_slideH = _innerslide.eq(0).height();
		_innerslide.css('overflow', 'hidden');
			var _a = _btn.index(_btn.filter('.active:eq(0)'));
			if(_a == -1) _a = 0;
			
		_btn.click(function(){
			var _in = _btn.index(this);
			var _id = this.href.substr(this.href.indexOf("#"));
			var _i = _innerHold.find('div.tab').index(_innerslide.filter(_id)) - 1;
			var _thisH = _heightAr[_i+1];
			if(_in != _a){
				changeTab(_i, _twidth, _Dwidth, _in,_thisH);
			}
			return false;
		});
		_benefits.click(function(){
			_z = 0;
			_a = 3;
			_tabW = 0;
			_innerslide.animate({
					height: _slideH
				}, {
					duration: 1000,
					queue: false
				});
			_innerHold.animate({
				left: -_tabW * 0
			}, {
				duration: 1000,
				queue: false
			});
			_btn.removeClass('active');
			_btn.eq(3).addClass('active');
			return false;
		});
		function changeTab(_ind, _w, _tabW,_in,_thisH){
				_a = _ind;
				_z = _a+1;
				_innerslide.animate({
					height: _thisH
				}, {
					duration: 1000,
					queue: false
				});
				_innerHold.animate({
					left: -_tabW * (_ind+1)
				}, {
					duration: 1000,
					queue: false
				});
				_btn.removeClass('active');
				_bigSlides.removeClass('current');
				_bigSlides.eq(_ind+1).addClass('current');
				var _btnHold = _bigSlides.eq(_ind+1).find('ul.tabset');
				var _Tab = _bigSlides.eq(_ind+1).find('div.tab');
				_idTab = _Tab.attr('id');
				var _num = _bigSlides.index(_bigSlides.eq(_ind+1));
				var _actBtn = _btnHold.find('a');
				_actBtn.each(function(){
					if($(this).attr('href') == '#'+_idTab){
						$(this).addClass('active');
					}
				});
		};
	}
}
function initFooterTabs(){
	_footer = $('#footer');
	_footer.find('ul.tabset').each(function(){
		var btn_h = $(this);
		var _btn = $(this).find('a.tab');
		var _a = _btn.index(_btn.filter('.active:eq(0)'));
		if(_a == -1) _a = 0;
		_btn.removeClass('active').eq(_a).addClass('active');
		_btn.each(function(_i){
			this._box = this.href.substr(this.href.indexOf("#") + 1);
			if(this._box){
				this._box = $('#'+this._box);
				if(_i == _a) this._box.show();
				else this._box.hide();
			}
			this.onclick = function(){
				changeTab(_i);
				return false;
			}
		});
		function changeTab(_ind){
			if(_ind != _a){
				if(_btn.get(_a)._box) _btn.get(_a)._box.hide();
				if(_btn.get(_ind)._box) _btn.get(_ind)._box.fadeIn();
				_btn.eq(_a).removeClass('active');
				_btn.eq(_ind).addClass('active');
				_a = _ind;
			}
		}
	});
}
$(document).ready(function(){
	innerTabs();
	initFooterTabs();
});