//Corrige problema com transparencia no ie6
// correctly handle PNG transparency in Win IE 5.5 & 6.
function correctPNG() 
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters))
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
if (window.attachEvent){
    window.attachEvent("onload", correctPNG);
}

//---------------------

var passou=0;

String.prototype.trim = function(){
  return this.replace(/^\s*/, '').replace(/\s*$/, '');
}

String.prototype.haveNo = function(){
  return this.toLowerCase().search(/no/)>-1?true:false;
}

function mailCheck(m){
  return (m.search(/^[a-zA-Z][\.\w-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$/)==-1||m.search(/\.{2,}|\.-|-\.|-{2,}|\._|_\./)>-1)?false:true;
}

function alerta(nC,el){
  window.alert('Por favor, preencha o campo ' +nC.toUpperCase()+ ' corretamente!');
  try{
	// : se type!=radio or type!=checkbox then focus()
	el.focus();
    el.select();
  }
  catch(e){}
}

function isRadio(f,t){
  var fld = f.elements[t];
  var x, len = fld.length;
  for(x=0; x<len; ++x) if(fld[x].checked) break;
  return len<=x?false:true;
}

function validarCampos(f){
  var i,el,nC,vC,totalEl=f.elements.length,al='alerta(nC,el)';

  for(var i=0; i<totalEl; i++){
    el=f.elements[i];
    nC=el.name;
    nClass=el.className;
	vC=el.value;
    if(el.type!='file' && el.type!='password'){
      try{ vC=el.value.trim(); } catch(e){}
      el.value=vC;
	}

    if(vC=='' && el.type!='hidden' && el.type!='submit' && el.type!='radio' && !nClass.haveNo()){
      eval(al);
      return false;
    }

    if(el.type=='radio' && el.type!='hidden' && el.type!='submit' && !nClass.haveNo() && !isRadio(f,nC)){
      eval(al);
      return false;
    }

    if(el.className.toLowerCase().search(/email/)>-1 && el.type!='hidden' && el.type!='submit' && !nClass.haveNo() && !mailCheck(vC)){
      eval(al);
      return false;
    }

	if(passou==1){
      window.alert('Por favor, aguarde. Processo em andamento!');
      return false;
    }
  }
  passou=1;
  return true;
}


function CNWin(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no,toolbar=no,status=no'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

}


var aux = 10;
function alterarFonte(id, acao){
  if(acao == 'maior'){
    if(aux < 16) aux += 1;
  }
  else{
    if(aux > 10) aux -= 1;
  }

 document.getElementById(id).style.fontSize = aux+'px';
}


//--------------------------------------
/*
stepcarousel.setup({
	galleryid: 'mygallery', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:true, moveby:1, pause:3000},
	panelbehavior: {speed:500, wraparound:false, persist:true},
	defaultbuttons: {enable: true, moveby: 1, leftnav: ['../../IMG/gal_nav_back.gif', -15, 20], rightnav: ['../../IMG/gal_nav_fwd.gif', 0, 20]},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})
*/
function chngImg(gimg){
	document.getElementById('L2_INT2').innerHTML = "<img src=../../imagens/slide/"+ gimg +">";
}

function flash(url, largura, altura){
 var aux = '';
 aux += '<object classid="clsid:clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' +largura+ '" height="' +altura+ '" align="middle">';
 aux += '<param name="allowScriptAccess" value="sameDomain" />';
 aux += '<param name="movie" value="' +url+ '">';
 aux += '<param name="loop" value="false" />';
 aux += '<param name="menu" value="false" />';
 aux += '<param name="quality" value="high">';
 aux += '<param name="wmode" value="transparent" />'; // se preciso, habilitar WMODE
 aux += '<embed src="' +url+ '" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' +largura+ '" height="' +altura+ '"></embed>';
 //aux += '<embed src="../../imagens/slide/' +url+ '" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' +largura+ '" height="' +altura+ '"></embed>';
 aux += '</object>';
 document.write (aux);
}

// ----- função para expandir menu
status = 0;
function mostrar(id){
  if (status == 0){
    $(id).show('normal');
    status = 1;
  }
  else{
    $(id).hide('normal');
    status = 0;
  }
}

