$.fn.tabs		= function(options){
	var setting	= $.extend({
		
	},options);
	this.each(function(i,n){
		var _this		= $(this);
		var tab_header	= _this.find('>.tab-header>div');
		var tab_body	= _this.find('>.tab-body>div');
		tab_header.click(function(){
			tab_header.removeClass('on').css({'cursor':'pointer'});
			$(this).addClass('on').css({'cursor':'default'});
			tab_body.hide();
			tab_body.eq(tab_header.index(this)).show();
		}).filter(':first').click();
	});
}
$.fn.SubmitAjax			= function(options){
	var setting			= $.extend({
		'dataType'		: 'json',
		'type'			: 'post',
		'readerTo'		: null,
		'success'		: null
	},options);
	return this.bind('submit',function(){
		var _this		= $(this);
		var _mask		= $(setting['readerTo']||this);
		var _overlay	= $('<div class="overlay" />');
		var _loading	= $('<div class="overlay-loading" />');
		var _dialog		= $('<div class="overlay-dialog"><div class="content" /><div class="buttons"><button>OK</button></div></div>');
		var _pos		= {
			top			: _mask.outerHeight()/2-144/2,
			left		: _mask.outerWidth()/2-246/2
		};
		_dialog.show	= function($value,$cls){
			_dialog.find('.content').addClass($cls).html($value);
			_dialog.css(_pos).appendTo(_mask);
		}
		_dialog.hide	= function(){
			_overlay.remove();
			_dialog.remove();
		}
		_dialog.find('button').click(function(){
			_dialog.hide();
		});
		$.ajax({
			cache 		: false,
			url			: _this.attr('action'),
			dataType 	: setting['dataType'],
			type		: setting['type'],
			data 		: _this.serializeArray(),
			beforeSend 	: function(){
				_overlay.css({opacity:0.4}).appendTo(_mask);
				_loading.appendTo(_mask);
			},
			success		: function(data){
				if($.isFunction(setting['success'])){
					setting['success'].call(this,data);
				}else{
					if(data.success){
						_dialog.show(null,'img');
					}else{
						_dialog.show(data.msg);
					}
				}
			},
			complete	: function(){
				_loading.remove();
			}
		});
		return false;
	});
}
jQuery(function(){
	$('.branch-gallery-left ul li a').click(function(){
		$('.branch-gallery-right img').attr('src',this.href);
		return false;
	}).filter(':first').click();
	$('.slide ul').innerfade({
		speed			: 1000,
		timeout			: 3000,
		type			: 'sequence',
		containerheight	: '222px'
	});
	$('.left-content.branch select').change(function(){
		if(this.value)
			location.href=this.value;
	});
	$('.tabs').tabs();
//	$('a.gallery1').lightBox();
//	$('a.gallery2').lightBox();
	$('.submit_email').SubmitAjax({
		'readerTo'		: 'body'
	});
	
hs.graphicsDir = 'highslide/graphics/';
hs.align = 'center';
hs.transitions = ['expand', 'crossfade'];
hs.outlineType = 'rounded-white';
hs.fadeInOut = true;
hs.numberPosition = 'caption';
hs.dimmingOpacity = 0.4;
// Add the controlbar
if (hs.addSlideshow) hs.addSlideshow({
	//slideshowGroup: 'group1',
	interval: 5000,
	repeat: false,
	useControls: true,
	fixedControls: 'fit',
	overlayOptions: {
		opacity: 0.75,
		position: 'bottom center',
		hideOnMouseOut: true
	}
});

})
