/*!
 * Earthlogic, Inc. Sequential Image Rotator
 * http://www.earthlogic.com/
 *
 * Copyright 2010, Earthlogic, Inc.
 * Developer: William Charlton
 * 
 * Requires jQuery.js
 * http://jquery.com/
 *
 * Date: Thur Sept 9 14:33:48 2010
 * 
 * To ease implementation for non javascript developers the properties for this plug-in are extracted from custom
 * attributes on a div tcontainer tag. This div element is also the element to bind the plugin too. Place a default
 * image in the div. If the image is to initially be random you can pass the random option as a custom attribute as well.
 * 
 * It is important to set the WIDTH and HEIGHT of the image as the plug-in reads the size to set the size of the DIV tag.
 * This helps in eliminating unwanted padding. It is also acceptable to apply css class or styles to the DIV element as well.
 * 
 * Custom tag attributes are:
 * - imgpath | Path to image directory. Can ommit and use absolute path on each image
 * - delay | The amount of time in milliseconds to wait before displaying a new image. 5000 = 5 seconds
 * - fadeout | Speed of the image fadeout animation
 * - fadein | Speed of the image fadein. This animation is not visible but is used to restore the overlay image. Set to a very fast speed like 100
 * - imgs | comma delimited string of images. If using imgpath do not use complete image urls. The image element is to be "^" delimited with the first
 *          element being the image source and the second element a href url. This allows each random image to link to a unique location. A href value 
 *          of false will result in a non linking image
 * 
 * EXAMPLE:
 *    <div id="home_image1" class="random_image"imgpath='./other/' 
 *     imgs="home-01.gif^false,other-02.gif^false,other-03.gif^false,other-04.gif^false" 
 *     delay="2500" fadeout="2000" fadein="100"
 *    >
 *       <img width="940" height="139" class="test" name="test1" id="test1" src="./other/other-01.gif" border="0"  />
 *   </div>
 */
jQuery.fn.elsequentialimage=function(){this.each(function(){var a=jQuery(this),c=a.attr("imgs").split(","),k=a.attr("preload")&&jQuery.trim(a.attr("preload"))!=""?jQuery.trim(a.attr("preload")):true,l=a.attr("delay")&&jQuery.trim(a.attr("delay"))!=""?jQuery.trim(a.attr("delay")):5E3,m=a.attr("fadeout")&&jQuery.trim(a.attr("fadeout"))!=""?jQuery.trim(a.attr("fadeout")):1200,n=a.attr("fadein")&&jQuery.trim(a.attr("fadein"))!=""?jQuery.trim(a.attr("fadein")):100,f=jQuery("img",a),o=a.attr("imgpath")&& jQuery.trim(a.attr("imgpath"))!=""?jQuery.trim(a.attr("imgpath")):"",b=f.width(),d=f.height();f.attr("src");a.css({padding:"0px",width:b+"px",height:d+"px","background-repeat":"no-repeat"});var e=false,h=0,i=true;for(b=0;b<c.length;b++){d=c[b].split("^");c[b]={image:o+d[0],href:d[1]}}if(k){d=false;for(b=0;b<c.length;b++){d=new Image;d.src=c[b].image}}var j=function(){if(i){i=false;g=c[0]}else{var g;++h;if(h>=c.length)h=0;g=c[h]}a.css({"background-image":"url("+g.image+")"});e=g.href;setTimeout(function(){f.fadeOut(m, function(){f.attr("src",g.image).fadeIn(n,function(){j()})})},l)};a.mouseover(function(){e&&e!="false"?a.css("cursor","pointer"):a.css("cursor","default")}).mouseout(function(){a.css("cursor","default")}).click(function(){if(e&&e!="false")document.location=e});j()});return this};
