function advertchange(){var rand;if(typeof(arr) !=='undefined'){rand=1+(arr.length - 1) *(Math.random());rand=Math.round(rand);if(rand !=lasti){document.getElementById('advert_text').innerHTML=arr[rand-1]['text'];document.getElementById('advert_head').src=img_dir+'heads/adverts/'+arr[rand-1]['img'];document.getElementById('advert_img').innerHTML=arr[rand-1]['code'];lasti=rand;window.setTimeout("advertchange()",10000);}else{advertchange();}}}