(function($){$.fn.adipoli=function(options){var settings=$.extend({'startEffect':'transparent','hoverEffect':'normal','imageOpacity':0.5,'animSpeed':600,'fillColor':'#000','textColor':'#fff','overlayText':'','slices':10,'boxCols':5,'boxRows':3,'popOutMargin':10,'popOutShadow':10},options);$(this).one('load',function(){$(this).wrap(function(){return'
'});$(this).parent().append('');$(this).parent().append('');if(settings.startEffect=="transparent"){$(this).hide();$(this).siblings('.adipoli-before').css({'-ms-filter':'"progid:DXImageTransform.Microsoft.Alpha(Opacity='+settings.imageOpacity*100+')"','filter':'alpha(opacity='+settings.imageOpacity*100+')','-moz-opacity':settings.imageOpacity,'-khtml-opacity':settings.imageOpacity,'opacity':settings.imageOpacity}).show()}else if(settings.startEffect=="grayscale"){var element=$(this);element.hide();element.siblings('.adipoli-before').show();element.siblings('.adipoli-before').children('img').each(function(){this.src=grayscale(this.src)})}else if(settings.startEffect=="normal"){$(this).hide();$(this).siblings('.adipoli-before').show()}else if(settings.startEffect=="overlay"){element=$(this);element.hide();$(this).siblings('.adipoli-before').html(settings.overlayText).css({'-ms-filter':'"progid:DXImageTransform.Microsoft.Alpha(Opacity='+settings.imageOpacity*100+')"','filter':'alpha(opacity='+settings.imageOpacity*100+')','-moz-opacity':settings.imageOpacity,'-khtml-opacity':settings.imageOpacity,'opacity':settings.imageOpacity,'background':settings.fillColor,'color':settings.textColor}).fadeIn();element.show()}$(this).parent().bind('mouseenter',function(){if(settings.hoverEffect=='normal'){var element=$(this);element.children('.adipoli-after').html('').fadeIn(settings.animSpeed)}else if(settings.hoverEffect=='popout'){element=$(this);var curImageWidth=element.children('img').width();var curImageHeight=element.children('img').height();element.children('.adipoli-after').html('');var popOutImage=element.children('.adipoli-after').children('img');popOutImage.width(curImageWidth+2*settings.popOutMargin);popOutImage.height(curImageHeight+2*settings.popOutMargin);element.children('.adipoli-after').width(curImageWidth+2*settings.popOutMargin);element.children('.adipoli-after').height(curImageHeight+2*settings.popOutMargin);element.children('.adipoli-after').css({'left':'-'+settings.popOutMargin+'px','top':'-'+settings.popOutMargin+'px','box-shadow':'0px 0px '+settings.popOutShadow+'px #000'}).show()}else if(settings.hoverEffect=='sliceDown'||settings.hoverEffect=='sliceDownLeft'||settings.hoverEffect=='sliceUp'||settings.hoverEffect=='sliceUpLeft'||settings.hoverEffect=='sliceUpRandom'||settings.hoverEffect=='sliceDownRandom'){$(this).children('.adipoli-after').show();createSlices($(this),settings);var timeBuff=0;var i=0;var slices=$('.adipoli-slice',$(this));if(settings.hoverEffect=='sliceDownLeft'||settings.hoverEffect=='sliceUpLeft')slices=$('.adipoli-slice',$(this))._reverse();if(settings.hoverEffect=='sliceUpRandom'||settings.hoverEffect=='sliceDownRandom')slices=shuffle($('.adipoli-slice',$(this)));slices.each(function(){var slice=$(this);if(settings.hoverEffect=='sliceDown'||settings.hoverEffect=='sliceDownLeft'){slice.css({'top':'0px'})}else if(settings.hoverEffect=='sliceUp'||settings.hoverEffect=='sliceUpLeft'){slice.css({'bottom':'0px'})}if(i==settings.slices-1){setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed,'',function(){})},(100+timeBuff))}else{setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed)},(100+timeBuff))}timeBuff+=50;i++})}else if(settings.hoverEffect=='sliceUpDown'||settings.hoverEffect=='sliceUpDownLeft'){$(this).children('.adipoli-after').show();createSlices($(this),settings);timeBuff=0;i=0;var v=0;slices=$('.adipoli-slice',$(this));if(settings.hoverEffect=='sliceUpDownLeft')slices=$('.adipoli-slice',$(this))._reverse();slices.each(function(){var slice=$(this);if(i==0){slice.css('top','0px');i++}else{slice.css('bottom','0px');i=0}if(v==settings.slices-1){setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed,'',function(){})},(100+timeBuff))}else{setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed)},(100+timeBuff))}timeBuff+=50;v++})}else if(settings.hoverEffect=='fold'||settings.hoverEffect=='foldLeft'){$(this).children('.adipoli-after').show();element=$(this);createSlices(element,settings);timeBuff=0;i=0;slices=$('.adipoli-slice',element);if(settings.hoverEffect=='foldLeft')slices=$('.adipoli-slice',$(this))._reverse();slices.each(function(){var slice=$(this);var origWidth=slice.width();slice.css({top:'0px',height:'100%',width:'0px'});if(i==settings.slices-1){setTimeout(function(){slice.animate({width:origWidth,opacity:'1.0'},settings.animSpeed,'',function(){})},(100+timeBuff))}else{setTimeout(function(){slice.animate({width:origWidth,opacity:'1.0'},settings.animSpeed)},(100+timeBuff))}timeBuff+=50;i++})}else if(settings.hoverEffect=='boxRandom'){$(this).children('.adipoli-after').show();element=$(this);createBoxes(element,settings);var totalBoxes=settings.boxCols*settings.boxRows;i=0;timeBuff=0;var boxes=shuffle($('.adipoli-box',element));boxes.each(function(){var box=$(this);if(i==totalBoxes-1){setTimeout(function(){box.animate({opacity:'1'},settings.animSpeed,'',function(){})},(100+timeBuff))}else{setTimeout(function(){box.animate({opacity:'1'},settings.animSpeed)},(100+timeBuff))}timeBuff+=20;i++})}else if(settings.hoverEffect=='boxRain'||settings.hoverEffect=='boxRainReverse'||settings.hoverEffect=='boxRainGrow'||settings.hoverEffect=='boxRainGrowReverse'){$(this).children('.adipoli-after').show();element=$(this);createBoxes(element,settings);totalBoxes=settings.boxCols*settings.boxRows;i=0;timeBuff=0;var rowIndex=0;var colIndex=0;var box2Darr=new Array();box2Darr[rowIndex]=new Array();boxes=$('.adipoli-box',element);if(settings.hoverEffect=='boxRainReverse'||settings.hoverEffect=='boxRainGrowReverse'){boxes=$('.adipoli-box',element)._reverse()}boxes.each(function(){box2Darr[rowIndex][colIndex]=$(this);colIndex++;if(colIndex==settings.boxCols){rowIndex++;colIndex=0;box2Darr[rowIndex]=new Array()}});for(var cols=0;cols<(settings.boxCols*2);cols++){var prevCol=cols;for(var rows=0;rows=0&&prevCol
').css({left:(sliceWidth*i)+'px',width:(element.width()-(sliceWidth*i))+'px',height:'0px',opacity:'0',background:'url("'+element.children('img').attr('src')+'") no-repeat -'+((sliceWidth+(i*sliceWidth))-sliceWidth)+'px 0%'}))}else{element.children('.adipoli-after').append($('
').css({left:(sliceWidth*i)+'px',width:sliceWidth+'px',height:'0px',opacity:'0',background:'url("'+element.children('img').attr('src')+'") no-repeat -'+((sliceWidth+(i*sliceWidth))-sliceWidth)+'px 0%'}))}}}function createBoxes(element,settings){var boxWidth=Math.round(element.width()/settings.boxCols);var boxHeight=Math.round(element.height()/settings.boxRows);for(var rows=0;rows').css({opacity:0,left:(boxWidth*cols)+'px',top:(boxHeight*rows)+'px',width:(element.width()-(boxWidth*cols))+'px',height:boxHeight+'px',background:'url("'+element.children('img').attr('src')+'") no-repeat -'+((boxWidth+(cols*boxWidth))-boxWidth)+'px -'+((boxHeight+(rows*boxHeight))-boxHeight)+'px'}))}else{element.children('.adipoli-after').append($('
').css({opacity:0,left:(boxWidth*cols)+'px',top:(boxHeight*rows)+'px',width:boxWidth+'px',height:boxHeight+'px',background:'url("'+element.children('img').attr('src')+'") no-repeat -'+((boxWidth+(cols*boxWidth))-boxWidth)+'px -'+((boxHeight+(rows*boxHeight))-boxHeight)+'px'}))}}}}function shuffle(arr){for(var j,x,i=arr.length;i;j=parseInt(Math.random()*i),x=arr[--i],arr[i]=arr[j],arr[j]=x);return arr}function grayscale(src){var canvas=document.createElement('canvas');var ctx=canvas.getContext('2d');var imgObj=new Image();imgObj.src=src;canvas.width=imgObj.width;canvas.height=imgObj.height;ctx.drawImage(imgObj,0,0);var imgPixels=ctx.getImageData(0,0,canvas.width,canvas.height);for(var y=0;y