var GAL = null ; if(typeof GAL_ID == "undefined") { var GAL_ID = "#inner-gal" ; } if(typeof GAL_TRANSITION == "undefined") { var GAL_TRANSITION = 1000 ; } if(typeof GAL_SLIDE_TIME == "undefined") { var GAL_SLIDE_TIME = 2000 ; } var GAL_STATUS = 0 ;// 0-not started, 1-started images load listener, 2-ready , 3-running var GAL_TIMER = null ; var GAL_CURRENT = 0 ; var GAL_MODE = "play" ; var GAL_LAST = null ; var GAL_IMAGES = new Array(); //var GAL_TRANSITION = 1000 ; //var GAL_SLIDE_TIME = 2000 ; $(document).ready(function(){ buildGal(); }) ; function buildGal() { gal = $(GAL_ID); var tmp = null ; if( gal.length ) { if( GAL_STATUS == 0 ) // CHECK IMAGES LOAD { jQuery.each( gal.children("img"), function(n,v){ tmp = new Image(); tmp.src = $(v).attr("src") ; GAL_IMAGES[ GAL_IMAGES.length ] = v ; }); GAL_STATUS = 1 ; buildGal(); return; } else if( GAL_STATUS == 1 ) { var complete = true; for( var i=0; i=0 && id 1) { GAL_TIMER = window.setTimeout( function(){ showSlide(++idToLoad) } , GAL_SLIDE_TIME ) ; } else { if( GAL_MODE == "stop_and_go" ) { GAL_TIMER = window.setTimeout( function(){ GAL_MODE ="play"; showSlide(++idToLoad) }, GAL_SLIDE_TIME+2500 ); } else if( GAL_TIMER ) { clearTimeout(GAL_TIMER); } } }) ; } function gotoSlide(id) { if(id>=GAL_IMAGES.length) { id=0; } if(id==GAL_CURRENT) { // STOP RUNNING clearTimeout(GAL_TIMER) ; return ; } if( GAL_STATUS == 3 ) { // STOP RUNNING clearTimeout(GAL_TIMER) ; GAL_MODE = "stop_and_go" ; // STOP ANIMATION var slide = GAL_IMAGES[GAL_CURRENT] ; $(slide).stop() ; // RESET DATA GAL_LAST = slide ; GAL_CURRENT = id ; showSlide(id) } }