var rdm=Math.random();
rdm=Math.floor(rdm*3)+1;
document.getElementById("img51").src="img/ad/ad_"+rdm+".jpg";
document.getElementById("linkl1").href=document.getElementById("linkl"+rdm+"").href;
document.getElementById("img5"+rdm+"").src="img/ad/ad_1.jpg";
document.getElementById("linkl"+rdm+"").href="#"
document.getElementById("link5pic").href=document.getElementById("linkl1").href;
document.getElementById("btnimg1").href=document.getElementById("linkl1").href;
document.getElementById("btnimg"+rdm+"").href="#"
var layeri=0;
var stopshow=0;
var timeout=0;

function moveformat(id){
if(stopshow==0){
picswin(id);
var browser=navigator.appName;
if(browser!="Microsoft Internet Explorer"){
layeri++;
document.getElementById(id).style.zIndex = layeri;
document.getElementById(id).style.left=(0+"px");
var linkid="link"+id;
document.getElementById("link5pic").href=document.getElementById(linkid).href;
}
else{
document.getElementById(id).style.posLeft = 360;
layeri++;
document.getElementById(id).style.zIndex = layeri;
movestart(id);
}
}
}

function movestart(id){
if(document.getElementById(id).style.posLeft!=0){
var mnum=document.getElementById(id).style.posLeft*0.2;
var x=document.getElementById(id).style.posLeft-mnum;
document.getElementById(id).style.posLeft=x;
moveid=id;
setTimeout("movestart(moveid);",30);
}
else{
var linkid="link"+id;
document.getElementById("link5pic").href=document.getElementById(linkid).href;
}
}

var i=1;

function showindexad(){
if (i<3 && stopshow==0){
  i++;
  var picid="l";
  picid=picid+i;
  setTimeout("moveformat('"+picid+"');showindexad();",5000);
  }
else if(stopshow==0){
  i=1;
  var picid="l";
  picid=picid+i;
  setTimeout("moveformat('"+picid+"');showindexad();",5000);
  }
else{
timeout=1;
}
}

showindexad();

function picsw(id) {
if(document.getElementById("pn"+id+"").src!="img/p"+id+".gif"){
picswin(id);
showindexad2(id);
}
}

function picswin(id){
document.getElementById("pnl1").src="img/pl1a.gif";
document.getElementById("pnl2").src="img/pl2a.gif";
document.getElementById("pnl3").src="img/pl3a.gif";
document.getElementById("pn"+id+"").src="img/p"+id+".gif";
}

function showindexad2(id){
  stopshow=1;
  var browser=navigator.appName;
  if(browser!="Microsoft Internet Explorer"){
  layeri++;
  document.getElementById(id).style.zIndex = layeri;
  document.getElementById(id).style.left=(0+"px");
  var linkid="link"+id;
  document.getElementById("link5pic").href=document.getElementById("link"+id).href;
  }
else{
  document.getElementById(id).style.posLeft = 360;
  layeri++;
  document.getElementById(id).style.zIndex = layeri;
  movestart(id);
  }
}
function startauto(){
  stopshow=0;
  if(timeout==1){
  showindexad();
  timeout=0;
  }
}