var maindiv = 'slider'; var mainslide = 'sliderinner'; var itemcount = 0; var itemclass = 'largeimage'; var itemoffclass = 'largeimageoff' var nextb = 'nextbutton'; var backb = 'backbutton'; var nextmode = true; var imgoff = true; var thumbmode = true; var thumbclassmode = true; var thumbul = 'thumbs'; var thumbulcl = 'selected'; var defwidth = 300; var itemar = new Array(); var currentslide = -1; var descmode = true; var descbackmode = true; var descfcl = 'desc'; var descbcl = 'desc_back'; var descspan = 'desc'; function slide_init (inar) { if(inar.item_class != undefined){ itemclass = inar.item_class; } if(inar.primary_div_id != undefined){ maindiv = inar.primary_div_id; } if(inar.inner_div_id != undefined){ mainslide = inar.inner_div_id; } if(inar.nextbutton_id != undefined){ nextb = inar.nextbutton_id; } else { nextmode = false; } if(inar.backbutton_id != undefined){ backb = inar.backbutton_id; } else { nextmode = false; } if(inar.item_off_class != undefined){ itemoffclass = inar.item_off_class; } else { imgoff = false; } if(inar.thumbnail_ul_id != undefined){ thumbul = inar.thumbnail_ul_id; if(inar.thumbnail_ul_sel_class != undefined){ thumbulcl = inar.thumbnail_ul_sel_class; } else { thumbclassmode = false; } } else { thumbmode = false; thumbclassmode = false; } if(inar.description_front_id != undefined){ descfcl = inar.description_front_id; descspan = inar.description_data_span_class; if(inar.description_back_id != undefined){ descbcl = inar.description_back_id; } else { descbackmode = false; } } else { descmode = false; descbackmode = false; } var firstitem = ''; $("." + itemclass).each(function () { if(itemcount == 0){ defwidth = $(this).width(); firstitem = $(this); } else { if(imgoff){ $(this).addClass(itemoffclass); $(this).removeClass(itemclass); } } itemar[itemcount] = $(this); $(this).attr('itemid',itemcount); $(this).click(function () { slide_focus($(this).attr('itemid')); }); itemcount++; }); if(thumbmode){ var thiscount = 0; $("#" + thumbul).find('li').each(function () { $(this).attr('itemid',thiscount); $(this).click(function () { slide_focus($(this).attr('itemid')); }); thiscount++; }); } if(nextmode){ $(document).keydown(function (eve){ if(eve.which == 37){ slide_back(); } if(eve.which == 39 || eve.which == 32){ slide_next(); } }); $("#" + backb).click(function () { slide_back(); }); $("#" + nextb).click(function () { slide_next(); }); $("#" + maindiv).mouseenter(function () { $("#" + nextb).stop(); $("#" + backb).stop(); $("#" + nextb).animate({ 'opacity':1 }); $("#" + backb).animate({ 'opacity':1 }); }); $("#" + maindiv).mouseleave(function () { $("#" + nextb).stop(); $("#" + backb).stop(); $("#" + nextb).animate({ 'opacity':.3 }); $("#" + backb).animate({ 'opacity':.3 }); }); $("#" + nextb).animate({ 'opacity':.3 }); $("#" + backb).animate({ 'opacity':.3 }); } if(inar.firstslide != undefined){ slide_focus(inar.firstslide); } else { slide_focus(0); } } function slide_next () { if(currentslide < (itemcount - 1)){ slide_focus(currentslide + 1); } } function slide_back () { if(currentslide > 0){ slide_focus(currentslide - 1); } } function slide_focus (itemid) { if(itemid != currentslide){ var thisslide = itemar[itemid]; $("#" + mainslide).animate({ 'left': ((($("#"+maindiv).width() / 2) - (defwidth / 2)) - (defwidth * itemid)) + 'px' }); if(imgoff){ $("." + itemclass).addClass(itemoffclass).removeClass(itemclass); $(thisslide).removeClass(itemoffclass); $(thisslide).addClass(itemclass); } slide_buttonupdate(itemid); currentslide = parseInt(itemid); if(thumbmode && thumbclassmode){ $("#" + thumbul).find('li').each(function () { $(this).removeClass(thumbulcl); if(parseInt($(this).attr('itemid')) == currentslide){ $(this).addClass(thumbulcl); } }); } if(descmode){ var pos = $(thisslide).position(); if(descbackmode){ $("#" + descbcl).stop(); $("#" + descbcl).css({'opacity':0, 'left':pos.left+'px'}); $("#" + descbcl).animate({ 'opacity':.85 },600); } $("#" + descfcl).stop(); $("#" + descfcl).css({'opacity':0, 'left':pos.left+'px'}); $("#" + descfcl).html($(thisslide).find('.' + descspan).html()); $("#" + descfcl).animate({ 'opacity':1 },600); } } } function slide_buttonupdate (target) { if(nextmode){ if(target > 0){ $("#" + backb).show(); } else { $("#" + backb).hide(); } if(target < (itemcount - 1)){ $("#" + nextb).show(); } else { $("#" + nextb).hide(); } } }