/** * 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"+k+"");} $.each($('.cs-button-'+el.id),function(i,item){$(item).click(function(e){$('.cs-button-'+el.id).removeclass('cs-active');$(this).addclass('cs-active');e.preventdefault();$.transition(el,i);$.transitioncall(el);})});$('#cs-navigation-'+el.id+' a').mouseout(function(){$('#cs-navigation-'+el.id).hide();params[el.id].pause=false;});$("#cs-buttons-"+el.id).css({'left':'50%','margin-left':-images[el.id].length*15/2-5,'position':'relative'});} $.effect=function(el){effa=['random','swirl','rain','straight'];if(params[el.id].effect=='') eff=effa[math.floor(math.random()*(effa.length))];else eff=params[el.id].effect;order[el.id]=new array();if(eff=='random'){counter=0;for(i=1;i<=params[el.id].sph;i++){for(j=1;j<=params[el.id].spw;j++){order[el.id][counter]=i+''+j;counter++;}} $.random(order[el.id]);} if(eff=='rain'){$.rain(el);} if(eff=='swirl') $.swirl(el);if(eff=='straight') $.straight(el);reverse[el.id]*=-1;if(reverse[el.id]>0){order[el.id].reverse();}} $.random=function(arr){var i=arr.length;if(i==0)return false;while(--i){var j=math.floor(math.random()*(i+1));var tempi=arr[i];var tempj=arr[j];arr[i]=tempj;arr[j]=tempi;}} $.swirl=function(el){var n=params[el.id].sph;var m=params[el.id].spw;var x=1;var y=1;var going=0;var num=0;var c=0;var dowhile=true;while(dowhile){num=(going==0||going==2)?m:n;for(i=1;i<=num;i++){order[el.id][c]=x+''+y;c++;if(i!=num){switch(going){case 0:y++;break;case 1:x++;break;case 2:y--;break;case 3:x--;break;}}} going=(going+1)%4;switch(going){case 0:m--;y++;break;case 1:n--;x++;break;case 2:m--;y--;break;case 3:n--;x--;break;} check=$.max(n,m)-$.min(n,m);if(m<=check&&n<=check) dowhile=false;}} $.rain=function(el){var n=params[el.id].sph;var m=params[el.id].spw;var c=0;var to=to2=from=1;var dowhile=true;while(dowhile){for(i=from;i<=to;i++){order[el.id][c]=i+''+parseint(to2-i+1);c++;} to2++;if(to=m){to++;} if(to2>m){from++;} if(from>to)dowhile=false;}} $.straight=function(el){counter=0;for(i=1;i<=params[el.id].sph;i++){for(j=1;j<=params[el.id].spw;j++){order[el.id][counter]=i+''+j;counter++;}}} $.min=function(n,m){if(n>m)return m;else return n;} $.max=function(n,m){if(n