/** * coin slider - unique jquery image slider * @version: 1.0 - (2010/04/04) * @requires jquery v1.2.2 or later * @author ivan lazarevic * examples and documentation at: http://workshop.rs/projects/coin-slider/ * licensed under mit licence: * http://www.opensource.org/licenses/mit-license.php **/ (function($){var params=new array;var order=new array;var images=new array;var links=new array;var linkstarget=new array;var titles=new array;var interval=new array;var imagepos=new array;var appinterval=new array;var squarepos=new array;var reverse=new array;$.fn.coinslider=$.fn.coinslider=function(options){init=function(el){order[el.id]=new array();images[el.id]=new array();links[el.id]=new array();linkstarget[el.id]=new array();titles[el.id]=new array();imagepos[el.id]=0;squarepos[el.id]=0;reverse[el.id]=1;params[el.id]=$.extend({},$.fn.coinslider.defaults,options);$.each($('#'+el.id+' img'),function(i,item){images[el.id][i]=$(item).attr('src');links[el.id][i]=$(item).parent().is('a')?$(item).parent().attr('href'):'';linkstarget[el.id][i]=$(item).parent().is('a')?$(item).parent().attr('target'):'';titles[el.id][i]=$(item).next().is('span')?$(item).next().html():'';$(item).hide();$(item).next().hide();});$(el).css({'background-image':'url('+images[el.id][0]+')','width':params[el.id].width,'height':params[el.id].height,'position':'relative','background-position':'top left'}).wrap("
");$('#'+el.id).append("");$.setfields(el);if(params[el.id].navigation) $.setnavigation(el);$.transition(el,0);$.transitioncall(el);} $.setfields=function(el){twidth=swidth=parseint(params[el.id].width/params[el.id].spw);theight=sheight=parseint(params[el.id].height/params[el.id].sph);counter=sleft=stop=0;tgapx=gapx=params[el.id].width-params[el.id].spw*swidth;tgapy=gapy=params[el.id].height-params[el.id].sph*sheight;for(i=1;i<=params[el.id].sph;i++){gapx=tgapx;if(gapy>0){gapy--;sheight=theight+1;}else{sheight=theight;} for(j=1;j<=params[el.id].spw;j++){if(gapx>0){gapx--;swidth=twidth+1;}else{swidth=twidth;} order[el.id][counter]=i+''+j;counter++;if(params[el.id].links) $('#'+el.id).append("");else $('#'+el.id).append("");$("#cs-"+el.id+i+j).css({'background-position':-sleft+'px '+(-stop+'px'),'left':sleft,'top':stop});sleft+=swidth;} stop+=sheight;sleft=0;} $('.cs-'+el.id).mouseover(function(){$('#cs-navigation-'+el.id).show();});$('.cs-'+el.id).mouseout(function(){$('#cs-navigation-'+el.id).hide();});$('#cs-title-'+el.id).mouseover(function(){$('#cs-navigation-'+el.id).show();});$('#cs-title-'+el.id).mouseout(function(){$('#cs-navigation-'+el.id).hide();});if(params[el.id].hoverpause){$('.cs-'+el.id).mouseover(function(){params[el.id].pause=true;});$('.cs-'+el.id).mouseout(function(){params[el.id].pause=false;});$('#cs-title-'+el.id).mouseover(function(){params[el.id].pause=true;});$('#cs-title-'+el.id).mouseout(function(){params[el.id].pause=false;});}};$.transitioncall=function(el){clearinterval(interval[el.id]);delay=params[el.id].delay+params[el.id].spw*params[el.id].sph*params[el.id].sdelay;interval[el.id]=setinterval(function(){$.transition(el)},delay);} $.transition=function(el,direction){if(params[el.id].pause==true)return;$.effect(el);squarepos[el.id]=0;appinterval[el.id]=setinterval(function(){$.appereance(el,order[el.id][squarepos[el.id]])},params[el.id].sdelay);$(el).css({'background-image':'url('+images[el.id][imagepos[el.id]]+')'});if(typeof(direction)=="undefined") imagepos[el.id]++;else if(direction=='prev') imagepos[el.id]--;else imagepos[el.id]=direction;if(imagepos[el.id]==images[el.id].length){imagepos[el.id]=0;} if(imagepos[el.id]==-1){imagepos[el.id]=images[el.id].length-1;} $('.cs-button-'+el.id).removeclass('cs-active');$('#cs-button-'+el.id+"-"+(imagepos[el.id]+1)).addclass('cs-active');if(titles[el.id][imagepos[el.id]]){$('#cs-title-'+el.id).css({'opacity':0}).animate({'opacity':params[el.id].opacity},params[el.id].titlespeed);$('#cs-title-'+el.id).html(titles[el.id][imagepos[el.id]]);}else{$('#cs-title-'+el.id).css('opacity',0);}};$.appereance=function(el,sid){$('.cs-'+el.id).attr('href',links[el.id][imagepos[el.id]]).attr('target',linkstarget[el.id][imagepos[el.id]]);if(squarepos[el.id]==params[el.id].spw*params[el.id].sph){clearinterval(appinterval[el.id]);return;} $('#cs-'+el.id+sid).css({opacity:0,'background-image':'url('+images[el.id][imagepos[el.id]]+')'});$('#cs-'+el.id+sid).animate({opacity:1},300);squarepos[el.id]++;};$.setnavigation=function(el){$(el).append("");$('#cs-navigation-'+el.id).hide();$('#cs-navigation-'+el.id).append("<<");$('#cs-navigation-'+el.id).append(">>");$('#cs-prev-'+el.id).css({'position':'absolute','top':params[el.id].height/2-15,'left':0,'z-index':1001,'line-height':'30px','opacity':params[el.id].opacity}).click(function(e){e.preventdefault();$.transition(el,'prev');$.transitioncall(el);}).mouseover(function(){$('#cs-navigation-'+el.id).show()});$('#cs-next-'+el.id).css({'position':'absolute','top':params[el.id].height/2-15,'right':0,'z-index':1001,'line-height':'30px','opacity':params[el.id].opacity}).click(function(e){e.preventdefault();$.transition(el);$.transitioncall(el);}).mouseover(function(){$('#cs-navigation-'+el.id).show()});$("").appendto($('#coin-slider-'+el.id));for(k=1;k