SLIDESHOW_isInitialized=0;SLIDESHOW_slideshow_active=0;SLIDESHOW_doShuffle=0;SLIDESHOW_currentPosition=0;SLIDESHOW_imageCounter=0;SLIDESHOW_slideshow_active=0;SLIDESHOW_timer=0;SLIDESHOW_timerID=0;SLIDESHOW_slideshow_interval=6000;SLIDESHOW_fadeouttime=2000;SLIDESHOW_fadeintime=2500;SLIDESHOW_all_images=[];SLIDESHOW_all_w=[];SLIDESHOW_all_h=[];SLIDESHOW_centerImages=1;SLIDESHOW_lastloaded=[];jQuery.ajax({url:'wp-content/themes/TLI1/background.php',cache:false,success:function(result){jQuery('#CONTENT_INNER').html(result);var sl=jQuery('#frontpage_slideshow_images').val();SLIDESHOW_start(sl)}});function SLIDESHOW_resize(){var w=jQuery(window).width();var h=jQuery(window).height();var i;var temp=jQuery('.SLIDESHOW_photodiv');for(i=0;i<temp.length;i++){var e=jQuery(temp[i]).children();e=e[0];var pw=jQuery(e).attr('iW');var ph=jQuery(e).attr('iH');if(pw&&ph){var aspect=pw/ph;var neww=w;var newh=w/aspect;if(newh<h){newh=h;neww=h*aspect}var offsetx=Math.min(0,-1*Math.round((neww-w)/2));var offsety=Math.min(0,-1*Math.round((newh-h)/2));neww=Math.round(neww);newh=Math.round(newh);if(SLIDESHOW_centerImages){offsetx=Math.round(offsetx);offsety=Math.round(offsety)}else{offsetx=0;offsety=0}jQuery(e).attr({'width':neww,'height':newh});jQuery(e).css({'margin-left':offsetx+'px','margin-top':offsety+'px'})}}}function SLIDESHOW_loadVars(sl_arr){var temp=sl_arr.split("[,,]");if(temp.length!=3){return}SLIDESHOW_all_images=temp[0].split("[**]");SLIDESHOW_all_w=temp[1].split(",");SLIDESHOW_all_h=temp[2].split(",");if(SLIDESHOW_doShuffle){var tmp,rand;for(var i=0;i<SLIDESHOW_all_images.length;i++){var rand=Math.floor(Math.random()*SLIDESHOW_all_images.length);var tmp;tmp=SLIDESHOW_all_images[i];SLIDESHOW_all_images[i]=SLIDESHOW_all_images[rand];SLIDESHOW_all_images[rand]=tmp;tmp=SLIDESHOW_all_w[i];SLIDESHOW_all_w[i]=SLIDESHOW_all_w[rand];SLIDESHOW_all_w[rand]=tmp;tmp=SLIDESHOW_all_h[i];SLIDESHOW_all_h[i]=SLIDESHOW_all_h[rand];SLIDESHOW_all_h[rand]=tmp}}}function SLIDESHOW_forget(){jQuery('.SLIDESHOW_pic').unbind();var im=jQuery('.SLIDESHOW_pic');for(var i=0;i<im.length;i++){var e=jQuery(im[i]);e.unbind();if(!e.hasClass('SLIDESHOW_pic_visible')){e.remove()}}SLIDESHOW_imageCounter+=10;SLIDESHOW_slideshow_active=0;SLIDESHOW_currentPosition=0;var currentTime=new Date();var ms=currentTime.getTime();SLIDESHOW_timer=500+ms;SLIDESHOW_lastloaded=new Array();SLIDESHOW_all_w=new Array();SLIDESHOW_all_h=new Array();SLIDESHOW_all_images=new Array();clearTimeout(SLIDESHOW_timerID)}function SLIDESHOW_start(sl_arr){SLIDESHOW_forget();SLIDESHOW_loadVars(sl_arr);if(SLIDESHOW_all_images.length>0){SLIDESHOW_slideshow_active=1;SLIDESHOW_fetchImage()}}function SLIDESHOW_fetchImage(){if(!window.SLIDESHOW_all_images){return}jQuery('#SLIDESHOW_container').append('<div class="SLIDESHOW_photodiv"><img id="SLIDESHOW_img'+SLIDESHOW_imageCounter+'" class="SLIDESHOW_pic" onload="SLIDESHOW_showpic()" src="'+SLIDESHOW_all_images[SLIDESHOW_currentPosition]+'" iW="'+SLIDESHOW_all_w[SLIDESHOW_currentPosition]+'" iH="'+SLIDESHOW_all_h[SLIDESHOW_currentPosition]+'" /></div>')}function SLIDESHOW_showpic(){if(!window.SLIDESHOW_all_images){return}var currentTime=new Date();var ms=currentTime.getTime();var tempImg=jQuery('#SLIDESHOW_img'+SLIDESHOW_imageCounter);if(ms>SLIDESHOW_timer&&SLIDESHOW_slideshow_active==1){if(in_array(SLIDESHOW_imageCounter,SLIDESHOW_lastloaded)){return}SLIDESHOW_lastloaded.push(SLIDESHOW_imageCounter);if(SLIDESHOW_lastloaded.length>2){SLIDESHOW_lastloaded=SLIDESHOW_lastloaded.slice(1)}SLIDESHOW_timer=ms+SLIDESHOW_slideshow_interval;tempImg.fadeOut(0);tempImg.addClass('SLIDESHOW_pic_visible');tempImg.fadeIn(SLIDESHOW_fadeintime,function(){SLIDESHOW_removeOldImages()});if(SLIDESHOW_all_images.length>1){SLIDESHOW_slideshow_active=1;SLIDESHOW_imageCounter++;SLIDESHOW_currentPosition++;if(SLIDESHOW_currentPosition>=SLIDESHOW_all_images.length){SLIDESHOW_currentPosition=0}SLIDESHOW_fetchImage()}else{SLIDESHOW_slideshow_active=0;clearTimeout(SLIDESHOW_timerID)}}else{clearTimeout(SLIDESHOW_timerID);SLIDESHOW_timerID=setTimeout('SLIDESHOW_showpic()',300)}}function SLIDESHOW_removeOldImages(){var temp=jQuery('.SLIDESHOW_photodiv');if(temp.length>4){for(var i=0;i<temp.length-4;i++){jQuery(temp[i]).remove()}}}function SLIDESHOW_setState(act){SLIDESHOW_slideshow_active=act}function in_array(id,arr){var found=0;for(var i=0;i<arr.length;i++){if(arr[i]==id){found=1;break}}return found}
