/*
*ͼƭ���ų��
*���ߣ�junr
*�˴��벻���լ�ԭ����������ŀ����һ��ҳ���ж��ч�������ծͽ��˴���д���˲����ʽ
*��ӳ���2�ֲ�����ʽ��3����ʾģʽ����һ�η�װ�����ϣ�����ֶ�������
* effect:'', modeϊ��ѡ
* speed : 1000, ͼƭ�ij���ʱ��
* title : false, ����ͼ������ʾч��
* thumb : false, ��������ͼ��ʾч��
* thumbwidth:80, ����ͼ��ȣ���������ͼ��ч
* thumbheight:80 ����ͼ�߶ȣ���������ͼ��ч
*
*
*
*/
$(function() {
$.fn.banner = function(options) {
var defaults = {
effect:'', //modeϊ��ѡ
speed : 2000,
title : false,
thumb : false,
nextpre : false,
onbtn : false,
autoplay : true,
event : 'click',
thumbwidth:80,
thumbheight:80,
onbtns:false
};
var options = $.extend(defaults,options);
var b = $(this),
bw = b.width(),
l = b.find( 'ul li' ).length,
uw = b.find( 'ul' ),
li = b.find( 'ul li' ),
lia = b.find( 'ul li a' ),
img = b.find( 'ul li img' ),
lw = b.find( 'ul li' ).width(),
lh = b.find( 'ul li' ).height();
var index = 0;
var pictimer;
if(options.onbtn){
if(!options.onbtns){
var btn = "
";
if(options.thumb){
img.each(function(){
var img=$(this).attr("src");
btn += '
';
});
}else{
for(var i=0; i < l; i++) {
btn += "
";
}
}
btn += "
";
}
if(options.title){
b.append("");
}
}
b.append(btn);
if(options.title){
var liatitle=img.eq(0).attr("alt");
b.find('.btn_t').text(liatitle);
}
b.find(".btn span").eq(0).addclass("on");
b.find(".btn span").bind(options.event,function() {
index = b.find(".btn span").index(this);
showpics(index);
return false;
}).eq(0).trigger("mouseover");
if(options.effect!='mode'){
uw.css({"width":lw *l,"left":0})
uw.wrapall("")
$(".g-bn-wp").css({"width":lw,"height":lh})
}
if(options.autoplay){
b.hover(function() {
clearinterval(pictimer);
},function() {
pictimer = setinterval(function() {
showpics(index);
var liatitle=img.eq(index).attr("alt");
index++;
if(index == l) {index = 0;}
},options.speed);
}).trigger("mouseleave");
}
if(options.nextpre){
var topcon=img.eq(0).attr("alt");
b.find("#topcon").html(topcon);
li.eq(0).css({"opacity":"1","z-index":10});
}
function showpics(index) {
if(options.effect=='mode'){
li.stop(true,false).animate({"opacity":"0","z-index":1},1500).eq(index).stop(true,false).animate({"opacity":"1","z-index":10},1500);
var topcon=img.eq(index).attr("alt");
b.find("#topcon").html(topcon);
}else{
uw.stop(true,false).animate({"left":-lw},1000,function(){
uw.find("li:first").appendto(uw);
uw.css({"left":"0"});
var liatitle=uw.find("li:first img").attr("alt");
// alert(liatitle);
b.find(".btn_t").html(liatitle);
});
}
b.find(".btn span").removeclass("on").eq(index).addclass("on");
}
$("#next").click(function() {
index += 1;
if(index == l) {index = 0;}
showpics(index);
});
$("#pre").click(function() {
index -= 1;
if(index == -1){index = l- 1;}
showpics(index);
});
}
});