/***@title:Vibrate@version:2.0@author:Andreas Lagerkvist@date:2008-08-31@url:http://andreaslagerkvist.com/jquery/vibrate/@license:http://creativecommons.org/licenses/by/3.0/@copyright:2008 Andreas Lagerkvist (andreaslagerkvist.com)@requires:jquery@does:This plug-in makes any element you want "vibrate" every now and then. Can be used in conjunction with blink for maximum annoyance!@howto:jQuery('#ad-area').vibrate(); would make #ad-area vibrate every now and then, options are available, please check the source.Vibrate currently only works with elements positioned 'static'.@exampleHTML:I should vibrate every now and then@exampleJS:jQuery('#jquery-vibrate-example').vibrate();***/
$.fn.vibrate=function(conf){var config=$.extend({speed:30,duration:2000,frequency:5000,spread:3},conf);return this.each(function(){var t=$(this);var vibrate=function(){var topPos=Math.floor(Math.random()*config.spread)-((config.spread-1)/2);var leftPos=Math.floor(Math.random()*config.spread)-((config.spread-1)/2);/*var rotate=Math.floor(Math.random()*config.spread)-((config.spread-1)/2);*/rotate=0;var matginleft=parseInt(parseInt(t.css('left')));if(matginleft=='5'){matginleft=4;}else{matginleft=5;}var matgintop=parseInt(parseInt(t.css('top')));if(matgintop=='1'){rotate=-15;matgintop=0;}else{matgintop=1;rotate=15;}t.css({position:'absolute',left:matginleft+'px',top:matgintop+'px',WebkitTransform:'rotate('+rotate+'deg)'/*cheers to erik@birdy.nu for the rotation-idea*/});};var doVibration=function(){var vibrationInterval=setInterval(vibrate,config.speed);var stopVibration=function(){clearInterval(vibrationInterval);t.css({position:'absolute',WebkitTransform:'rotate(0deg)'});};setTimeout(stopVibration,config.duration);};setInterval(doVibration,config.frequency);});};
