var Agente=navigator.userAgent.toUpperCase();
if(1+Agente.indexOf('MSIE'))var sBrowser='IE';
else if(1+Agente.indexOf('FIREFOX'))var sBrowser='FF';
else if(1+Agente.indexOf('CHROME'))var sBrowser='CH';
else if(1+Agente.indexOf('SAFARI'))var sBrowser='SA';
else if(1+Agente.indexOf('OPERA'))var sBrowser='OP';
else var sBrowser='NS';

var IDCategoriaAtualFC=0;

ImgOnError="nd";

function MostraImgOnError(este,iIdioma){
  if(ImgOnError==undefined)ImgOnError="nd";
  este.src="/sistema/images/"+ImgOnError+iIdioma+".gif";
}

function PutObject(IDMenu,IDPos){
  var oPos=getPos(document.getElementById(IDPos));
  var oMenu=document.getElementById(IDMenu);
  oMenu.style.visibility='visible';
  oMenu.style.left=oPos.x;
  oMenu.style.top=oPos.y;
}

function getPos(obj){
  var output=new Object();var mytop=0,myleft=0;
  while(obj){mytop+=obj.offsetTop;myleft+=obj.offsetLeft;obj=obj.offsetParent;}
  output.x=myleft;output.y=mytop;
  return output;
}

function CatToggle(id){
  ul="ul_"+id;
  img="img_"+id;
  ulElement=document.getElementById(ul);
  imgElement=document.getElementById(img);
  if(ulElement){
    if (ulElement.className=="CatClosed"){
      ulElement.className="CatOpened";
      imgElement.className="ImgOpened";
    }
    else{
      ulElement.className="CatClosed";
      imgElement.className="ImgClosed";
    }
  }
}

function OpenCat(id){
  if(document.getElementById(id))OpenCat(document.getElementById(id).parentNode.id.substring(3));
  ul="ul_"+id;
  img="img_"+id;
  ulElement=document.getElementById(ul);
  imgElement=document.getElementById(img);
  if(ulElement){
      ulElement.className="CatOpened";
      imgElement.className="ImgOpened";
  }
}

function DefineCatDefault(IDCategoriaAtualFC){
  //Define defaults &IDCategoria=
  if(IDCategoriaAtualFC==0){
    var sPag=document.location.href.toUpperCase();
    var sParamCat='IDCATEGORIA';
    var PosIDCatIni=sPag.indexOf(sParamCat+"=");
    if(PosIDCatIni<0){var sParamCat='IDCATEGORY';var PosIDCatIni=sPag.indexOf(sParamCat+'=');}
    if(PosIDCatIni>=0){
      PosIDCatIni=PosIDCatIni+sParamCat.length+1;
      var IDCategoriaAtualFC=sPag.substring(PosIDCatIni);
      var PosIDCatFim=IDCategoriaAtualFC.indexOf("&");
      if(PosIDCatFim>=0)IDCategoriaAtualFC=IDCategoriaAtualFC.substr(0,PosIDCatFim);
    }
  }
  if(IDCategoriaAtualFC>0){
    //define defaults tag <select>
    var SelectsFC=document.getElementsByTagName('select');
    for(var i=0;i<SelectsFC.length;i++){
      if(SelectsFC[i].name.substr(0,9).toUpperCase()=='IDCATEGOR'){
        var j=0;
        var AcheiCat=false;
        while(j<SelectsFC[i].length && !AcheiCat){
          if(SelectsFC[i].options[j].value==IDCategoriaAtualFC){
            AcheiCat=true;
            SelectsFC[i].options[j].selected=true;
          }
          else{j++;}
        }
      }
    }
    //define defaults tag <ul>
    var ULsFC=document.getElementsByTagName('ul');
    for(var i=0;i<ULsFC.length;i++){
      if(ULsFC[i].className.toUpperCase()=='CATCLOSED'||ULsFC[i].className.toUpperCase()=='CATOPENED'){
        var LIsFC=ULsFC[i].getElementsByTagName('li');
        var j=0;
        var AcheiCat=false;
        while(j<LIsFC.length && !AcheiCat){
          if(LIsFC[j].id.indexOf('_'+IDCategoriaAtualFC)>0){
            AcheiCat=true;
            ULsFC[i].className='CatOpened';
            //LIsFC[j].className='PathCatActive';

            //var oNomeCat=document.getElementById('idPathCat'+IDCategoriaAtualFC);
            //oNomeCat.className=oNomeCat.className+' PathCatActive';

            var AsFC=LIsFC[j].getElementsByTagName('a')[0];
            AsFC.className='PathCatActive';
            OpenCat(LIsFC[j].id);
          }
          else{j++;}
        }
      }
    }
  }
}

function AddURLServices(){
  var sPag=document.location.href;
  document.write("<style>.BookmarkSites{font-size:9px;font-family:verdana;}.BookmarkSites a:link{color:#000000;text-decoration:none}.BookmarkSites a:hover{color:#FF0000;text-decoration:none}.BookmarkSites ul{list-style:none;margin-top:0px;margin-left:0px;padding:0}.BookmarkSites ul li{display:inline;margin-left:10px}.BookmarkSites img{width:12px;height:12px;position:relative;top:2px;left:2px;margin: 0px 5px 0px 0px;padding:2px 2px 0px 5px;border-style:none}</style>");
  document.write("<div class=BookmarkSites><ul>");
  document.write("<li><a target=_blank href=http://digg.com/submit?phase=2&url="+ sPag +"><img src=images/IcDigg.gif>Digg it</a></li>");
  document.write("<li><a target=_blank href=http://delicious.com/post?url="+ sPag +"><img src=images/IcDelicious.gif>Delicious</a></li>");
  document.write("<li><a target=_blank href=http://twitter.com/home?status="+ escape(document.title) +"+"+ sPag +"><img src=images/IcTwitter.gif>Twitter</a></li>");
  document.write("<li><a target=_blank href=http://reddit.com/submit?url="+ sPag +"><img src=images/IcReddit.gif>Reddit</a></li>");
  document.write("<li><a target=_blank href=http://google.com/bookmarks/mark?op=edit&amp;bkmk="+ sPag +"><img src=images/IcGoogleBook.gif>Google bookmarks</a></li>");
  document.write("<li><a target=_blank href=http://furl.net/storeIt.jsp?u="+ sPag +"><img src=images/IcFurl.gif>Furl</a></li>");
  document.write("</ul></div>");
}

function ChangeCBIncMult(este,QTField){
  if(este.checked && QTField.value=='0'){try{QTField.value='1';QTField.focus();QTField.select();}catch(e){}}
  if(!este.checked){QTField.value='0';}
}

function ChangeQTIncMult(este,CBField){
  if(este.value=='0'){CBField.checked=false;}
  else{CBField.checked=true;}
}

function FocusQTIncMult(este,CBField){
  CBField.checked=true;
  if(este.value=='0')este.select();
}

function NumFilt(evt){
  if(sBrowser=='IE'){var charCode=event.keyCode;}else{var charCode=evt.which;}
  if(charCode!=0 && charCode!=8 && (charCode<48||charCode>57)){return false;}else{return true;}
}

function ValidaOpcao(oCombo,sCombo,iIdioma){
  if(oCombo.selectedIndex==0){
    if(iIdioma==0)alert("Selecione "+sCombo+".");
    else if(iIdioma==1)alert("Select "+sCombo+".");
    else if(iIdioma==2)alert("Seleccione "+sCombo+".");
    else if(iIdioma==3)alert("Seleccione "+sCombo+".");
    oCombo.focus();
    return false;
    }
  else{return true;}
}

function ValidaMult(oQT,oCombo,sCombo,iIdioma){
  try{
    if(oQT.value=='0')return true;
    if(oCombo.selectedIndex==0){
      if(iIdioma==0)alert("Selecione "+sCombo+".");
      else if(iIdioma==1)alert("Select "+sCombo+".");
      else if(iIdioma==2)alert("Seleccione "+sCombo+".");
      else if(iIdioma==3)alert("Seleccione "+sCombo+".");
      oCombo.focus();
      return false;
      }
    else{return true;}
  }catch(e){return true;}
}

function MostraDisp(IDLoja,IDProduto){
  popup=window.open("AvisaDispProduto.asp?IDLoja="+IDLoja+"&IDProduto="+IDProduto,"Disp","top=10,left=10,height=320,width=400,scrollbars=no");
  popup.focus();
  return void(0);
}
function MostraDispCaptcha(IDLoja,IDProduto){
  popup=window.open("AvisaDispProduto.asp?IDLoja="+IDLoja+"&IDProduto="+IDProduto,"Disp","top=10,left=10,height=370,width=400,scrollbars=no");
  popup.focus();
  return void(0);
}

function MostraDispIf(IDLoja,IDProduto,NomeLoja){
  windowopen(NomeLoja,'AvisaDispProduto.asp?if=1&IDLoja='+IDLoja+'&IDProduto='+IDProduto,10,10,400,320);
}
function MostraDispIfCaptcha(IDLoja,IDProduto,NomeLoja){
  windowopen(NomeLoja,'AvisaDispProduto.asp?if=1&IDLoja='+IDLoja+'&IDProduto='+IDProduto,10,10,400,370);
}

function MostraIndique(IDLoja,IDProduto){
  popup=window.open("IndiqueProduto.asp?IDLoja="+IDLoja+"&IDProduto="+IDProduto,"Indique","top=10,left=10,height=370,width=423,scrollbars=no");
  popup.focus();
  return void(0);
}
function MostraIndiqueCaptcha(IDLoja,IDProduto){
  popup=window.open("IndiqueProduto.asp?IDLoja="+IDLoja+"&IDProduto="+IDProduto,"Indique","top=10,left=10,height=420,width=423,scrollbars=no");
  popup.focus();
  return void(0);
}

function MostraIndiqueIf(IDLoja,IDProduto,NomeLoja){
  windowopen(NomeLoja,'IndiqueProduto.asp?if=1&IDLoja='+IDLoja+'&IDProduto='+IDProduto,10,10,423,370);
}
function MostraIndiqueIfCaptcha(IDLoja,IDProduto,NomeLoja){
  windowopen(NomeLoja,'IndiqueProduto.asp?if=1&IDLoja='+IDLoja+'&IDProduto='+IDProduto,10,10,423,420);
}

function ValidaEmail(sEmail) {
  var regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,6}$/;
  return regex.test(sEmail);
}

function ValidaCEP(campo) {
  var validos="0123456789-";
  var NumHifens=0;
  if (campo.length<8)return false;
  for (var i=0;i<campo.length;i++) {
    temp=""+campo.substring(i,i+1);
    if(temp=="-") NumHifens++;
    if(validos.indexOf(temp)=="-1")return false;
    if(NumHifens>0 && ""+campo.charAt(5)!="-")return false;
  }
  return true;
}

function LimitaTexto(CampoTexto,MaxChars,iIdioma){
  if(CampoTexto.value.length>MaxChars){
    CampoTexto.value=CampoTexto.value.substring(0,MaxChars);
    if(iIdioma==0)alert('Este campo pode conter até '+MaxChars+' caracteres.');
    else if(iIdioma==1)alert('Maximum capacity is '+MaxChars+' characters.');
    else if(iIdioma==2)alert('Este campo puede contener hasta '+MaxChars+' caracteres.');
    else if(iIdioma==3)alert('Este campo pode conter até '+MaxChars+' caracteres.');
    CampoTexto.focus();
    }
}

function FormatPrecoReais(num){
  num=num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))num="0";
  sign=(num==(num=Math.abs(num)));
  num=Math.floor(num*100+0.50000000001);
  cents=num%100;
  num=Math.floor(num/100).toString();
  if(cents<10)cents="0"+cents;
  for(var i=0;i<Math.floor((num.length-(1+i))/3);i++)num=num.substring(0,num.length-(4*i+3))+'.'+num.substring(num.length-(4*i+3));
  return ((sign)?'':'-')+'R$&nbsp;'+num+','+cents;
}

function FormatPrice(num,symbol){
  num=num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))num="0";
  sign=(num==(num=Math.abs(num)));
  num=Math.floor(num*100+0.50000000001);
  cents=num%100;
  num=Math.floor(num/100).toString();
  if(cents<10)cents="0"+cents;
  for(var i=0;i<Math.floor((num.length-(1+i))/3);i++)num=num.substring(0,num.length-(4*i+3))+'.'+num.substring(num.length-(4*i+3));
  return ((sign)?'':'-')+symbol+'&nbsp;'+num+','+cents;
}

function CalculaParcelaJurosCompostos(Preco,Parcelas){
  if(Juros[Parcelas-1]==0)return Preco/Parcelas;
  else return Math.round(Preco*(Math.pow(1+Juros[Parcelas-1]/100,Parcelas)*Juros[Parcelas-1]/100)/(Math.pow(1+Juros[Parcelas-1]/100,Parcelas)-1)*100)/100;
}

function MostraPesquisaCEP(){popup=window.open('http://www.correios.com.br/servicos/cep/default.cfm','PesquisaCEP','top=30,left=1,height=550,width=790,menubar=yes,location=yes,toolbar=yes,scrollbars=yes,resizable=yes');popup.focus();return void(0);}


var DIF_dragging=false;
var DIF_iframeBeingDragged="";
var DIF_iframeObjects=new Object();
var DIF_iframeWindows=new Object();
var DIF_iframeMouseDownLeft=new Object();
var DIF_iframeMouseDownTop=new Object();
var DIF_pageMouseDownLeft=new Object();
var DIF_pageMouseDownTop=new Object();
var DIF_handles=new Object();
var DIF_highestZIndex=210;
var DIF_raiseSelectedIframe=false;
var DIF_allowDragOffScreen=false;

bringSelectedIframeToTop(true);

function bringSelectedIframeToTop(val){DIF_raiseSelectedIframe=val;}

function allowDragOffScreen(val){DIF_allowDragOffScreen=val;}

function addHandle(o,win){
  if(arguments.length==2 && win==window){
    var p=win;
    while(p=p.parent){
      if(p.addHandle){p.addHandle(o,win,true);return;}
      if(p==win.top){return;}
      }
    return;
  }
  var topRef=win;
  var topRefStr="window";
  while(topRef.parent && topRef.parent!=window){
    topRef=topRef.parent;
    topRefStr=topRefStr + ".parent";
  }
  if (typeof(win.DIF_mainHandlersAdded)=="undefined" || !win.DIF_mainHandlersAdded){
    with (win){ 
      eval("function OnMouseDownHandler(evt){ if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.DIF_begindrag(evt, "+topRefStr+") }");
      eval("document.onmousedown=OnMouseDownHandler;");
      eval("function OnMouseUpHandler(evt){ if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.DIF_enddrag(evt, "+topRefStr+") }");
      eval("document.onmouseup=OnMouseUpHandler;");
      eval("function OnMouseMoveHandler(evt){ if(typeof(evt)=='undefined'){evt=event;}"+topRefStr+".parent.DIF_iframemove(evt, "+topRefStr+") }");
      eval("document.onmousemove=OnMouseMoveHandler;");
      win.DIF_handlersAdded=true;
      win.DIF_mainHandlersAdded=true;
      }
    }
  if (typeof(window.DIF_handlersAdded)!="undefined" || !window.DIF_handlersAdded){
    eval("function OnMouseMoveHandler(evt){ if(typeof(evt)=='undefined'){evt=event;}DIF_mouseMove(evt, window) }");
    eval("document.onmousemove=OnMouseMoveHandler;");
    window.DIF_handlersAdded=true;
    }
  o.style.cursor="arrow";
  var name=DIF_getIframeId(topRef);
  if (DIF_handles[name]==null){
    DIF_handles[name]=new Array();
    DIF_iframeMouseDownLeft[name]=0;
    DIF_iframeMouseDownTop[name]=0;
    DIF_pageMouseDownLeft[name]=0;
    DIF_pageMouseDownTop[name]=0;
    }
  DIF_handles[name][DIF_handles[name].length]=o;
  }

function DIF_getEventPosition(evt){
  var pos=new Object();
  pos.x=0;
  pos.y=0;
  if (!evt){
    evt=window.event;
    }
  if (typeof(evt.pageX) == 'number'){
    pos.x=evt.pageX;
    pos.y=evt.pageY;
  }
  else {
    pos.x=evt.clientX;
    pos.y=evt.clientY;
    if (!top.opera){
      if ((!window.document.compatMode) || (window.document.compatMode == 'BackCompat')){
        pos.x += window.document.body.scrollLeft;
        pos.y += window.document.body.scrollTop;
      }
      else {
        pos.x += window.document.documentElement.scrollLeft;
        pos.y += window.document.documentElement.scrollTop;
      }
    }
  }
  return pos;
}

function DIF_getIframeId(win){
  var iframes=document.getElementsByTagName("IFRAME");
  for (var i=0; i<iframes.length; i++){
    var o=iframes.item(i);
    var w=null;
    if (o.contentWindow){
      w=o.contentWindow;
      }
    else if (window.frames && window.frames[o.id].window){
      w=window.frames[o.id];
      }
    if (w == win){
      DIF_iframeWindows[o.id]=win;
      DIF_iframeObjects[o.id]=o;
      return o.id; 
      }
    }
  return null;
  }

function DIF_getObjectXY(o){
  var res=new Object();
  res.x=0; res.y=0;
  if (o != null){
    res.x=o.style.left.substring(0,o.style.left.indexOf("px"));
    res.y=o.style.top.substring(0,o.style.top.indexOf("px"));
    }
  return res;
  }

function getSrcElement(e){
  var tgt=e.target;
  while (tgt.nodeType != 1){ tgt=tgt.parentNode;}
  return tgt;
  }

function isHandleClicked(handle, objectClicked){
  if (handle==objectClicked){ return true;}
  while (objectClicked.parentNode != null){
    if (objectClicked==handle){
      return true;
      }
    objectClicked=objectClicked.parentNode;
    }
  return false;
  }
  
function DIF_begindrag(e, win){
  var iframename=DIF_getIframeId(win);
  if (iframename==null){ return;}
  if (DIF_handles[iframename]==null || DIF_handles[iframename].length<1)return;
  var isHandle=false;
  var t=e.srcElement || getSrcElement(e);
  for(var i=0; i<DIF_handles[iframename].length; i++){
    if(isHandleClicked(DIF_handles[iframename][i],t)){
      isHandle=true;
      break;
      }
    }
  if(!isHandle)return false;
  DIF_iframeBeingDragged=iframename;
  if (DIF_raiseSelectedIframe)DIF_iframeObjects[DIF_iframeBeingDragged].style.zIndex=DIF_highestZIndex++;
  DIF_dragging=true;
  var pos=DIF_getEventPosition(e);
  DIF_iframeMouseDownLeft[DIF_iframeBeingDragged]=pos.x;
  DIF_iframeMouseDownTop[DIF_iframeBeingDragged]=pos.y;
  var o=DIF_getObjectXY(DIF_iframeObjects[DIF_iframeBeingDragged]);
  DIF_pageMouseDownLeft[DIF_iframeBeingDragged]=o.x - 0 + pos.x;
  DIF_pageMouseDownTop[DIF_iframeBeingDragged]=o.y -0 + pos.y;
  }

function DIF_enddrag(e){
  DIF_dragging=false;
  DIF_iframeBeingDragged="";
  }

function DIF_mouseMove(e){
  if (DIF_dragging){
    var pos=DIF_getEventPosition(e);
    DIF_drag(pos.x - DIF_pageMouseDownLeft[DIF_iframeBeingDragged] , pos.y - DIF_pageMouseDownTop[DIF_iframeBeingDragged]);
    }
  }

function DIF_iframemove(e){
  if (DIF_dragging){
    var pos=DIF_getEventPosition(e);
    DIF_drag(pos.x - DIF_iframeMouseDownLeft[DIF_iframeBeingDragged] , pos.y - DIF_iframeMouseDownTop[DIF_iframeBeingDragged]);
    }
  }

function DIF_drag(x,y){
  var o=DIF_getObjectXY(DIF_iframeObjects[DIF_iframeBeingDragged]);
  var newPositionX=o.x-0+x;
  var newPositionY=o.y-0+y;
  if (!DIF_allowDragOffScreen){
    if (newPositionX < 0){ newPositionX=0;}
    if (newPositionY < 0){ newPositionY=0;}
    }
  DIF_iframeObjects[DIF_iframeBeingDragged].style.left=newPositionX + "px";
  DIF_iframeObjects[DIF_iframeBeingDragged].style.top =newPositionY + "px";
  DIF_pageMouseDownLeft[DIF_iframeBeingDragged] += x;
  DIF_pageMouseDownTop[DIF_iframeBeingDragged] += y;
  }


try{document.write("<div id=overlay name=overlay></div>");}catch(e){}

var overlay=null;
function findOverlayRef(){
  if( document.layers ){ //Netscape layers
    return document.layers["overlay"];}
  if( document.getElementById ){ //DOM; IE5, NS6, Mozilla, Opera
    return document.getElementById("overlay");}
  if( document.all ){ //Proprietary DOM; IE4
    return document.all["overlay"];}
  if( document["overlay"] ){ //Netscape alternative
    return document["overlay"];}
  return false;
}
function setupOverlay(){
  if((obj=findOverlayRef())){
    overlay=new Object();
    overlay.div=obj;
    overlay.px=document.childNodes?'px':0;
    overlay.style=obj.style?obj.style:obj;
    return true;
  }
  return false;
}
function rewriteOverlayDiv( s ){
  if( typeof( overlay.div.innerHTML )!='undefined' ){
    overlay.div.innerHTML=s;
  } else {
    if( overlay.div.document && overlay.div.document!=window.document ){
      overlay.div.document.open();
      overlay.div.document.write(s);
      overlay.div.document.close();
    }
  }
}

function windowopen(title,src,left,top,tamx,tamy){
  if(!overlay){if(!setupOverlay()) return false;}
  rewriteOverlayDiv("");
  var v=navigator.userAgent.toUpperCase();
  if(1+v.indexOf('MSIE')){var Xadic=10;var Yadic=29;}	//IE
  else{var Xadic=18;var Yadic=37;}	//Netscape e outros Mozilla
  left+=document.body.scrollLeft;top+=document.body.scrollTop;	//compensa scroll X/Y
  var s='<iframe scrolling=no frameborder=0 name=iframePOP ID=iframePOP style=z-index:210;position:absolute;left:'+left+';top:'+top+';width:'+(tamx+Xadic)+'px;height:'+(tamy+Yadic)+'px src=PopupIF.asp?src='+escape(src)+'&title='+escape(title)+'&tamy='+(tamy+Yadic)+'><\/iframe>';
  rewriteOverlayDiv(s);
  return void(0);
}

function fechaIf(){
  if(sBrowser=='NS')window.parent.parent.document.getElementById("iframePOP").style.visibility='hidden';
  else window.parent.parent.document.all.iframePOP.style.visibility='hidden';
  window.parent.document.getElementById("iframeInt").src='ChatVazio.htm';
}

function moveOverlay(t,l){
  if(!overlay){ if(!setupOverlay()) return false;}
  overlay.style.left=l + overlay.px;
  overlay.style.top=t + overlay.px;
  return false;
}
function sizeOverlay(h,w){
  if(!overlay){ if(!setupOverlay()) return false;}
  if( overlay.style.resizeTo ) overlay.style.resizeTo( w, h );
  overlay.style.width=w + overlay.px;
  overlay.style.pixelWidth=w;
  overlay.style.height=h + overlay.px;
  overlay.style.pixelHeight=h;
  return false;
}

function getRandomNum(lbound,ubound){return(Math.floor(Math.random()*(ubound-lbound))+lbound);}
function getRandomChar(){
  var sChars="0123456789abcdefghijklmnopqrstuvwxyz";
  return sChars.charAt(getRandomNum(0,sChars.length));
}
function getRandomID(pos){
  var rc="";
  rc=rc+getRandomChar();
  for(var idx=1;idx<pos;++idx)rc=rc+getRandomChar();
  return rc;
}

function hideLayerFC(DisappearFlash){
  if(document.getElementById){document.getElementById(DisappearFlash).style.visibility="hidden";}
  else if(document.all){document.all[DisappearFlash].style.visibility="hidden";}
  else if(document.layers){document.layers[DisappearFlash].visibility="hidden";}
}

function FlashSemBorda(Arquivo,Largura,Altura,BGcolor,Base){
  AC_FL_RunContent('codebase','https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0','width',Largura,'height',Altura,'src',Arquivo,'quality','high','pluginspage','https://www.macromedia.com/go/getflashplayer','movie',Arquivo,'wmode','transparent','bgcolor',BGcolor,'base',Base);
}

function AC_AddExtension(src, ext){
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs,params,embedAttrs){
  var sRandomID='f'+getRandomID(7);
  var str = '<object id='+sRandomID+' ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed name='+sRandomID+' ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    
    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
