var urls=['http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=cat%20chow%20colchonete&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2','http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=capa%20equi&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2'];
var imagens=["tv/p5.jpg","tv/p3.jpg"]
myPix=new Array("tv/p5.jpg","tv/p3.jpg")
var total = imagens.length;
rando = Math.floor((Math.random() * total)) 
var atual = rando;
c=0;
d=0;
k=0;
j=0; 

function choosePic(){ 
if (document.images){ 
randomNum = Math.floor((Math.random() * total)) 
document.inicial.src = myPix[rando]
atual++; 
} 
} 

function mudaImagensComFrescura() {

  window.setTimeout ("alteraOpacidade('90')", 100);

  window.setTimeout ("alteraOpacidade('80')", 200);

  window.setTimeout ("alteraOpacidade('70')", 300);

  window.setTimeout ("alteraOpacidade('60')", 400);

  window.setTimeout ("alteraOpacidade('70')", 500);

  window.setTimeout ("alteraOpacidade('80')", 600);

  window.setTimeout ("alteraOpacidade('90')", 700);

}

function alteraOpacidade (quanto) {

  document.getElementById("pikachu").className = ("opacidade" + quanto);

  if (quanto == 60) {

  if (atual == total) {
    atual = 0;
  }

  document.getElementById("pikachu").src = imagens[atual];
  atual++;
  }

}

function linkUrl(){
if(atual>0&&atual<total&&d==0)
document.location.href=urls[atual-1];
else if(atual==0&&d==0)
document.location.href=urls[total-1];
else if(atual==total&&d==0)
document.location.href=urls[total-1];
else if(atual<total&&d==1)
document.location.href=urls[atual];
else if(atual==total&&d==1)
document.location.href=urls[total-1];
}

function im(){
if(c==1){
document.getElementById("play").src="4_b.png"
document.getElementById("pause").src="5.png"
}
else{
document.getElementById("play").src="4.png"
document.getElementById("pause").src="5_b.png"
}
if(j==1){
document.getElementById("prox").src="8_b.png"
window.setTimeout(function(){document.getElementById("prox").src='8.png'},200)
}
if(k==1){
document.getElementById("anter").src="7_b.png"
window.setTimeout(function(){document.getElementById("anter").src='7.png'},200)
}
}

function i(){
if(k==1||j==1){
atual++;
}
if(c==0){
intervalo=window.setInterval ("mudaImagensComFrescura()", 4000);
c=1;
d=0;
k=0;
}
k=0;
j=0;
return im();
}

function z(){
if(c==1){
clearInterval(intervalo);
c=0;
return im();
}
}


function ja(){
clearInterval(intervalo);
c=0;
k=0;
j=1;
if(atual<total-1&&d==0){
atual=atual;
d=1;
}
else if(atual==total-1&&d==0){
atual=2;
d=1;
}
else if(atual==total&&d==0){
atual=0;
d=1;
}
else if(atual<total-1&&d==1){
atual++;
}
else if(atual==total-1&&d==1){
atual=0;
}

document.getElementById("pikachu").src = imagens[atual];
return im();
}

function ka(){
clearInterval(intervalo);
c=0;
j=0;
k=1;
if(atual>1&&d==0){
atual=atual-2;
d=1;
}
else if(atual==1&&d==0){
atual=total-1;
d=1;
}
else if(atual==0&&d==0){
atual=total-1;
d=1;
}
else if(atual>0&&d==1){
atual--;
}
else if(atual==0&&d==1){
atual=total-1;
}

document.getElementById("pikachu").src = imagens[atual];
return im();
}

Anunciante1=new Array("i1.jpg","i3.jpg")
Go1=new Array("http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=sera&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2","http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=frontline&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2")
Anunciante2=new Array("i4.jpg","i5.jpg")
Go2=new Array("http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=sanol%20dog&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2","http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=dr.%20pet&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2")
Anunciante3=new Array("i7.jpg","i8.jpg")
Go3=new Array("http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=cat%20chow&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2","http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=dog%20chow&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2")
Anunciante4=new Array("i6.jpg","i2.jpg")
Go4=new Array("http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=butox&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2","http://www.petcentermarginal.com.br/searchresults.aspx?dskeyword=du%20chef&idproducttype=0&idproductcolor=0&nupricerangestart=1&nupricerangeend=9999999&type=2")
var anunciantes1 = Anunciante1.length;
aleat1 = Math.floor((Math.random() * anunciantes1))
var anunciantes2 = Anunciante2.length;
aleat2 = Math.floor((Math.random() * anunciantes2))
var anunciantes3 = Anunciante3.length;
aleat3 = Math.floor((Math.random() * anunciantes3))
var anunciantes4 = Anunciante4.length;
aleat4 = Math.floor((Math.random() * anunciantes4))

function ins(){ 
document.anunc1.src = Anunciante1[aleat1]
document.anunc2.src = Anunciante2[aleat2]
document.anunc3.src = Anunciante3[aleat3]
document.anunc4.src = Anunciante4[aleat4]
}

function go1(){
document.location.href=Go1[aleat1]
}

function go2(){
document.location.href=Go2[aleat2]
}

function go3(){
document.location.href=Go3[aleat3]
}

function go4(){
document.location.href=Go4[aleat4]
}
