var features=new Array(); var preload=new Array(); var current_feat=0; var preload_next=1; features[0]="
Breast Cancer Australia
"; preload[0]="/assets/case_study/case_bc.jpg"; features[1]="
Elders Limited
"; preload[1]="/assets/case_study/case_el.jpg"; features[2]="
Kids Cancer
"; preload[2]="/assets/case_study/case_kc.jpg"; features[3]="
National Response Centre
"; preload[3]="/assets/case_study/case_nrc.jpg"; features[4]="
Proper Advice
"; preload[4]="/assets/case_study/case_pa.jpg"; features[5]="
Toro Australia
"; preload[5]="/assets/case_study/case_t.jpg"; function changeFeature(){ var old_elt='feat_'+current_feat; if((current_feat+1)==features.length){ var next_feat=0; } else{ var next_feat=current_feat+1; } var new_elt='feat_'+next_feat; //create the next feature item if it does not exist if(!$(new_elt)){ new Element('div', { 'class': 'feature', 'id': new_elt, 'styles': { 'opacity': '0', 'display': 'none' } }).setHTML(features[next_feat]).injectTop($('header_feature')); } //dont fade the features until we are sure image has loaded if(preload_next>next_feat){ //fade old one out and new one in $(old_elt).effect('opacity', {duration: 1000, transition: Fx.Transitions.linear, onComplete: function(){ $(old_elt).setStyle('display', 'none');}}).start(1,0); $(new_elt).setStyle('display', 'block').effect('opacity', {duration: 1000, transition: Fx.Transitions.linear}).start(0,1); //preload the next image for the first cycle if(preload_next