// insert JavaScript source code here

// split do form content para o array ////
textareaContent = document.principal.select_cr.value.split(/[\r\n]/i);
Item = new Array();
for(x=0,y=0;x<textareaContent.length;x++) {
  if(textareaContent[x].length>30)
    Item[y++] = textareaContent[x].split('|');
}
function delItem(arr,item) // deleta itens
{
  for (;item<arr.length;item++) arr[item] = arr[item + 1];
    arr.length=arr.length-1;
}

function goURL() // abre url
{
    (Item[atual][3].indexOf('_blank')!=-1) ? window.open(Item[atual][3].substring(0,Item[atual][3].indexOf(' '))) : location.href=Item[atual][3];
}

function changeImg(id) // troca imagens
{
  clearTimeout(timeoutId);
  atual+=parseInt(id);
  if(atual>Item.length-1) atual = 0;
  if(atual<0) atual = Item.length-1;
  if(document.all)
	{
	try {
		document.images.img1.style.filter="blendTrans(duration=1)";
		document.images.img1.filters.blendTrans.Apply();
		document.images.img1.filters.blendTrans.Play();
		} catch(e) {}
	}

    document.img1.src = imgDsp[atual].src;
    document.img1.alt = document.img1.title = Item[atual][0];
    //document.getElementById('titulo1').innerHTML = Item[atual][5];
    document.getElementById('txt1').innerHTML = Item[atual][2];
    //document.icon.src = Item[atual][4];
    //document.getElementById('space').innerHTML = (document.icon.src=="http://img.uol.com.br/x.gif") ? '' : '&nbsp;' ;
    timeoutId = setTimeout("changeImg(1)",6000)
}

function startSlide()
{
  timeoutId = setTimeout("changeImg(1)",6000);
}

for(i=Item.length-1;i>=0;i--) // remove os arrays com informação faltando //
{
//if(Item[i][4].length<3) Item[i][4] = "http://img.uol.com.br/x.gif"; // preenche as chamadas sem icone com x.gif
    if(Item[i][1].length<3||Item[i][3].length<3||Item[i][2].length<3||Item[i][0].length<2) delItem(Item,i);
}

if(Item.length==1)
    document.write("<style>#anterior,#proxima{visibility:hidden}</style>"); // se só tem 1 imagem, some com proximo/anterior

atual = Math.random().toString().substring(2,6) % Item.length; // escolhe uma imagem inicial randomicamente
imgDsp = new Array();
for(n=0;n<Item.length;n++) // pre-load das imagens
{
    imgDsp[n] = new Image();
    imgDsp[n].src = Item[n][1];
}

timeoutId = 0;
onload = startSlide;
// escreve na tela //
//document.write('<div id="v10bb" style="padding:0 0;background-color:#FFC23E;"><span id="titulo1">'+Item[atual][5]+'</span></div><a href=javascript:goURL()><img src='+Item[atual][1]+' width="208" height="146" name=img1 border=0 title="'+Item[atual][0]+'" alt="'+Item[atual][0]+'"></a>');
document.write('<div id="gallery"><a href=javascript:goURL()><img src='+Item[atual][1]+' name=img1 border=0 title="'+Item[atual][0]+'" alt="'+Item[atual][0]+'"></a></div>');
document.write('<div><a href=javascript:goURL() id="a13nw"><div id="legenda_tamanho"><span id="txt1" class="legenda">'+Item[atual][2]+'</span></div></a>');
document.write('<div id="anterior"><a href="javascript:changeImg(-1)"><img src="botao_anterior.gif" border="0"></a></div>');
document.write('<div id="proximo"><a href="javascript:changeImg(1)"><img src="botao_proximo2.gif" border="0"></a></div></div>');

//document.write('<div style="padding:10 0 0 10"><a href=javascript:goURL() id="a13nw"><img src='+Item[atual][4]+' border=0 name=icon><span id=space> </span><span id="txt1">'+Item[atual][2]+'</span></a></div>');

