//jquery used
//(function($){
//banner tabs
var tab='li a';
var content='#bannerContents div';
var cc='current';
var dft=0;
var $this=$('#bannerTabs');
var $contents=$(content);
var $tabs=$this.find(tab);
var $currentContent=$(content).eq(dft);
var $currentTab=$tabs.eq(dft);
var currentId=dft;
tabImg();
var interval;
function tabImg(){
	$tabs.each(function(i){
						$(this).attr('rel',i).mouseover(function(){
															 clearInterval(interval);
															 if($(this).attr('rel')!=currentId) swapTab($(this).attr('rel'));
															 });
						});
	interval = setInterval('swapTab(-1)',7000);
}
function swapTab(i){
	i<0?currentId++:currentId=i;
	currentId>2?currentId=0:currentId=currentId;
	$eachTab=$tabs.eq(currentId);
	if(navigator.userAgent.indexOf("MSIE")>=0){
		$currentContent.hide();
		$currentTab.removeClass(cc);
		$currentTab=$eachTab.addClass(cc);
		$currentContent=$($eachTab.attr('href'));
		$currentContent.show();
	}else{
	$currentContent.fadeOut('normal',function(){
											  $currentTab.removeClass(cc);
											  $currentTab=$eachTab.addClass(cc);
											  $currentContent=$($eachTab.attr('href'));
											  $currentContent.fadeIn();
											  });
	}
	$eachTab.blur();
	return false;
}
//dom ready
$(function(){
//banner light
/*
var $light=$('<div id="light"><q></q></div>').hide();
$('#banner').append($light);
var $img=$('<img src="styles/p/light.png"/>').hide();
$('body').append($img);
$img.load(function(){($.browser.msie&&$.browser.version>6)?$light.show():$light.fadeIn('slow');});
*/
//awards
//$("#awardsContainer").css("overflow","hidden").toggleHeight(90,355,"查看更多奖项","隐藏更多奖项","#viewAwards");
$viewAwards=$("<a href='#awards' id='viewAwards' style='float:right;margin-top:-3px'>查看更多奖项</a>").click(function(){$("#awards .bd").toggleHeight(190,455,"查看更多奖项","隐藏更多奖项","#viewAwards");$(this).blur();return false;});
$("#awards .hd").prepend($viewAwards);
//products
//$("#productsContainer").css("overflow","hidden").toggleHeight(140,210,"查看更多产品","隐藏更多产品","#viewProducts");
$viewProducts=$("<a href='#products' id='viewProducts' style='float:right;margin-top:10px;'>查看更多产品</a>").click(function(){$("#productsContainer").toggleHeight(140,280,"查看更多产品","隐藏更多产品","#viewProducts");$(this).blur();return false;});
$("#productsContainer").after($viewProducts);


});

/* functions */
$.fn.extend({
	toggleHeight:function(hMin,hMax,ts,th,btn){
		$btn=$(btn);
		if($(this).height()>hMin){
			$(this).animate({height:hMin},function(){$btn.text(ts)});
		}else{
			$(this).animate({height:hMax},function(){$btn.text(th)});
		}
		return $(this);
	}
});
//})(jQuery);
