(function($) {
// 棣栭〉骞荤伅
$(function() {
var sWidth = $("#slide").width(); //鑾峰彇鐒︾偣鍥剧殑瀹藉害锛堟樉绀洪潰绉級
var len = $("#slide ul li").length; //鑾峰彇鐒︾偣鍥句釜鏁
var index = 0;
var picTimer;
//浠ヤ笅浠g爜娣诲姞鏁板瓧鎸夐挳鍜屾寜閽悗鐨勫崐閫忔槑鏉★紝杩樻湁涓婁竴椤点€佷笅涓€椤典袱涓寜閽
var btn = "
";
$("#slide .info").hide().eq(index).fadeIn( 1000 );
$("#slide").append(btn);
$("#slide .btnBg").css("opacity",0.5);
//鏈緥涓哄乏鍙虫粴鍔紝鍗虫墍鏈塴i鍏冪礌閮芥槸鍦ㄥ悓涓€鎺掑悜宸︽诞鍔紝鎵€浠ヨ繖閲岄渶瑕佽绠楀嚭澶栧洿ul鍏冪礌鐨勫搴
$("#slide ul").css("width",sWidth * (len));
//榧犳爣婊戜笂鐒︾偣鍥炬椂鍋滄鑷姩鎾斁锛屾粦鍑烘椂寮€濮嬭嚜鍔ㄦ挱鏀
$("#slide").hover(function() {
clearInterval(picTimer);
},function() {
picTimer = setInterval(function() {
index++;
if(index == len) {index = 0;}
showPics(index);
},2000); //姝?000浠h〃鑷姩鎾斁鐨勯棿闅旓紝鍗曚綅锛氭绉
}).trigger("mouseleave");
//鏄剧ず鍥剧墖鍑芥暟锛屾牴鎹帴鏀剁殑index鍊兼樉绀虹浉搴旂殑鍐呭
function showPics(index) { //鏅€氬垏鎹
var nowLeft = -index*sWidth; //鏍规嵁index鍊艰绠梪l鍏冪礌鐨刲eft鍊
$("#slide ul").stop(true,false).animate({"margin-left":nowLeft},300); //閫氳繃animate()璋冩暣ul鍏冪礌婊氬姩鍒拌绠楀嚭鐨刾osition
$("#slide .info").hide().eq(index).fadeIn( 1000 );
}
});
// 鏂伴椈涓績棣栭〉骞荤伅
$(function() {
var sWidth = $("#focus").width(); //鑾峰彇鐒︾偣鍥剧殑瀹藉害锛堟樉绀洪潰绉級
var len = $("#focus ul li").length; //鑾峰彇鐒︾偣鍥句釜鏁
var index = 0;
var picTimer;
//浠ヤ笅浠g爜娣诲姞鏁板瓧鎸夐挳鍜屾寜閽悗鐨勫崐閫忔槑鏉★紝杩樻湁涓婁竴椤点€佷笅涓€椤典袱涓寜閽
var btn = "";
for(var i=0; i < len; i++) {
btn += "";
}
// btn += "
";
$("#focus").append(btn);
$("#focus .btnBg").css("opacity",0.5);
//涓哄皬鎸夐挳娣诲姞榧犳爣婊戝叆浜嬩欢锛屼互鏄剧ず鐩稿簲鐨勫唴瀹
$("#focus .btn span").mouseover(function() {
index = $("#focus .btn span").index(this);
showPics(index);
}).eq(0).trigger("mouseover");
//涓婁竴椤点€佷笅涓€椤垫寜閽€忔槑搴﹀鐞
$("#focus .preNext").css("opacity",0.2).hover(function() {
$(this).stop(true,false).animate({"opacity":"0.5"},300);
},function() {
$(this).stop(true,false).animate({"opacity":"0.2"},300);
});
//涓婁竴椤垫寜閽
$("#focus .pre").click(function() {
index -= 1;
if(index == -1) {index = len - 1;}
showPics(index);
});
//涓嬩竴椤垫寜閽
$("#focus .next").click(function() {
index += 1;
if(index == len) {index = 0;}
showPics(index);
});
//鏈緥涓哄乏鍙虫粴鍔紝鍗虫墍鏈塴i鍏冪礌閮芥槸鍦ㄥ悓涓€鎺掑悜宸︽诞鍔紝鎵€浠ヨ繖閲岄渶瑕佽绠楀嚭澶栧洿ul鍏冪礌鐨勫搴
$("#focus ul").css("width",sWidth * (len));
//榧犳爣婊戜笂鐒︾偣鍥炬椂鍋滄鑷姩鎾斁锛屾粦鍑烘椂寮€濮嬭嚜鍔ㄦ挱鏀
$("#focus").hover(function() {
clearInterval(picTimer);
},function() {
picTimer = setInterval(function() {
showPics(index);
index++;
if(index == len) {index = 0;}
},4000); //姝?000浠h〃鑷姩鎾斁鐨勯棿闅旓紝鍗曚綅锛氭绉
}).trigger("mouseleave");
//鏄剧ず鍥剧墖鍑芥暟锛屾牴鎹帴鏀剁殑index鍊兼樉绀虹浉搴旂殑鍐呭
function showPics(index) { //鏅€氬垏鎹
var nowLeft = -index*sWidth; //鏍规嵁index鍊艰绠梪l鍏冪礌鐨刲eft鍊
$("#focus ul").stop(true,false).animate({"left":nowLeft},300); //閫氳繃animate()璋冩暣ul鍏冪礌婊氬姩鍒拌绠楀嚭鐨刾osition
$("#focus .btn span").removeClass("on").eq(index).addClass("on"); //涓哄綋鍓嶇殑鎸夐挳鍒囨崲鍒伴€変腑鐨勬晥鏋
// $("#focus .btn span").stop(true,false).animate({"opacity":"0.4"},300).eq(index).stop(true,false).animate({"opacity":"1"},300); //涓哄綋鍓嶇殑鎸夐挳鍒囨崲鍒伴€変腑鐨勬晥鏋
}
});
$(document).ready(function(){
// 鏂伴椈涓績搴曢儴 tab 鏂伴椈
render_tab( "#tab-news" );
// 瑙嗛鎶ラ亾 tab
render_tab( "#video-tab" );
// 棣栭〉骞荤伅鍙充晶鍥炬爣鐘舵€佸垏鎹
$("#featured .right .left").hover(
function(){
$(this).css('position', 'relative' );
$(this).find("span").fadeOut(800).css({ "display": "block", "opacity": 0.8} );
},
function(){
$(this).find("span").css("display", "none");
$(this).css('position', 'static' );
}
);
// 瀵艰埅鑿滃崟寮瑰嚭浜岀骇鑿滃崟
$("#main-menu div > ul > li").hover(
function(){
$(this).find("ul.sub-menu").slideDown("800").css({"display": "block", "opacity": 0.7});
$("#main-menu li a").css({ "opacity": 1 });
$(this).addClass("hover");
},
function(){
$(this).find("ul.sub-menu").slideUp("fast").css("display", "none");
$(this).removeClass("hover");
}
);
});
function render_tab( wrapper ) {
var $tab_menu = $(wrapper).find(".tab-menu li"),
$item = $(wrapper).find(".tab-items .item");
// first, active first items
$tab_menu.eq(0).addClass("active");
$item.eq(0).addClass("active");
$tab_menu.hover(
function() {
var $active_index = $tab_menu.index(this);
$tab_menu.removeClass("active");
$item.removeClass("active");
$tab_menu.eq($active_index).addClass("active");
$item.eq($active_index).addClass("active");
},
function() {}
);
}
})(jQuery);