var count, p;

   function MoveLight(obj, mouse) {
		count = 0;
		p = document.getElementById(''+obj+'');
		
		if(mouse == "over"){
			p.style.filter="none";
			p.style.filter="light";
			p.filters[0].addPoint(100,100,400,500,500,500,100);
			ChangePoint(100/5,100/5,100/5);
		} else if(mouse == "out"){
			p.style.filter="none";
			p.style.filter="light";
			p.filters[0].addPoint(100,100,400,255,255,255,100);
			ChangePoint(10/5,10/5,10/5);
		}
   }

   function ChangePoint(xstep, ystep, zstep) {
	if (count < 10) {
		p.filters[0].MoveLight(0,xstep,ystep,zstep,false);
		setTimeout("ChangePoint("+xstep+","+ystep+","+zstep+"); 100");
		count++
	}
   }



function GeraSWF($arquivo,$altura,$largura,$id,$transparent){
	incTransp = '';
    document.writeln('    <object align="middle" id="globalnav-object" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + $largura + '" height="' + $altura + '" id="' + $id + '" name="' + $id + '">');
	if($transparent == "yes"){
		document.writeln('        <param name="wmode" value="transparent" />');
		incTransp = 'wmode="transparent"';
	}
    document.writeln('        <param name="allowScriptAccess" value="sameDomain" />');
    document.writeln('        <param name="quality" value="high" />');
    document.writeln('        <param name="scaleMode" value="noScale" />');
    document.writeln('        <param name="menu" value="false" />');
    document.writeln('        <param name="movie" value="' + $arquivo + '" />');
    document.writeln('        <param name="FlashVars" value="loc=en_US&htmlApp=false&gatewayURL=gwurl" />');
    document.writeln('        <embed id="globalnav-embed" src="' + $arquivo + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="loc=en_US&htmlApp=false&gatewayURL=gwurl" menu="false" align="middle" quality="high" scale="noscale" id="' + $id + '" width="' + $largura + '" height="' + $altura + '" '+incTransp+'></embed>');
    document.writeln('    </object>');
}



var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input, len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		input.form[(getIndex(input)+1) % input.form.length].focus();
	}

	function containsElement(arr, ele) {
		var found = false, index = 0;
		
		while(!found && index < arr.length)
			if(arr[index] == ele)
				found = true;
			else
				index++;
				
		return found;
	}
	
	function getIndex(input) {
		var index = -1, i = 0, found = false;
		
		while (i < input.form.length && index == -1)
			if (input.form[i] == input)index = i;
			else i++;
		return index;
	}

return true;

}


//Created by Arthur Paredes
function hideLayer(obj, timeOut){
	setTimeout("showHideLayers('" + obj + "','','hide')", timeOut);
}

//========================================================================

//Created by Arthur Paredes
function divAdjust(obj, objWidth, offSet){
  
	var winl = (screen.width - (objWidth - offSet)) / 2;
	var obj,args=divAdjust.arguments;
	if ((obj=MM_findObj(args[0]))!=null) { 
		if (obj.style) { 
			obj=obj.style;
		}
		obj.left=winl; 
	}
	
};

//========================================================================

var flg1 = true;
var flg2 = true;
var txtorig1; 
var txtorig2;

function inn(txt,i) {
	 if (eval('flg'+i)){
		  eval('txtorig'+i+'=txt.value;');
		  eval('flg'+i+'=false;');
	 }
	
	 if (txt.value == eval('txtorig'+i)) txt.value = '';
}

function out(txt,i) {
	if (txt.value == '') txt.value = eval('txtorig'+i);
}


//========================================================================


function newWindow(mypage, 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+',status=yes, resizable'
	win = window.open(mypage, '', winprops)
	
		if (parseInt(navigator.appVersion) >= 4) { 
			win.window.focus(); 
		}
}


//========================================================================


function flashGoTo(frame) {
	
        var IE = navigator.appName.indexOf("Microsoft") != -1;
        var filme = IE ? window.mainMovie : window.document.mainMovie;
        filme.GotoFrame(frame - 1);
}


//========================================================================


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


//========================================================================


function showHideLayers() { //v6.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  	if ((obj=MM_findObj(args[i]))!=null) { 
		v=args[i+2];
    	if (obj.style) { 
			obj=obj.style;
			v=(v=='show')?'visible':(v=='hide')?'hidden':v;
		}
    	obj.visibility=v; 
	}
}

//============================================================================


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


//============================================================================

function placeFocus() {
	if (document.forms.length > 0) {
		var field = document.forms[0];
		for (i = 0; i < field.length; i++) {
			if ((field.elements[i].type == "text") || (field.elements[i].type == "textarea") || (field.elements[i].type.toString().charAt(0) == "s")) {
				document.forms[0].elements[i].focus();
				break;
         }
      }
   }
}


function Mascara(objeto, evt, mask) {
 
var LetrasU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
var LetrasL = 'abcdefghijklmnopqrstuvwxyz';
var Letras  = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var Numeros = '0123456789';
var Fixos  = '().-:/ '; 
var Charset = " !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_/`abcdefghijklmnopqrstuvwxyz{|}~";

evt = (evt) ? evt : (window.event) ? window.event : "";
var value = objeto.value;
if (evt) {
 var ntecla = (evt.which) ? evt.which : evt.keyCode;
 tecla = Charset.substr(ntecla - 32, 1);
 if (ntecla < 32) return true;

 var tamanho = value.length;
 if (tamanho >= mask.length) return false;

 var pos = mask.substr(tamanho,1); 
 while (Fixos.indexOf(pos) != -1) {
  value += pos;
  tamanho = value.length;
  if (tamanho >= mask.length) return false;
  pos = mask.substr(tamanho,1);
 }

 switch (pos) {
   case '#' : if (Numeros.indexOf(tecla) == -1) return false; break;
   case 'A' : if (LetrasU.indexOf(tecla) == -1) return false; break;
   case 'a' : if (LetrasL.indexOf(tecla) == -1) return false; break;
   case 'Z' : if (Letras.indexOf(tecla) == -1) return false; break;
   case '*' : objeto.value = value; return true; break;
   default : return false; break;
 }
}
objeto.value = value; 
return true;
}

function MaskDateTime(objeto, evt) { 
	return Mascara(objeto, evt, '##/##/## ##:##');
}

function MaskDate(objeto, evt) {
	return Mascara(objeto, evt, '##/##/####');
}

function move_i(what) { what.style.background='#FFFFFF'; }
function move_o(what) { what.style.background='#E9E9E9'; }

function abrirJanela(url) { //v2.0
  window.open(url,'as','status=yes,scrollbars=yes,width=660,height=600');
}

var slideShowSpeed = 3500;
var crossFadeDuration = 3;
var Pic = new Array();

Pic[0] = '_imagens/destaques/d2008.gif'
Pic[1] = '_imagens/destaques/s_brasil.jpg'

var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
preLoad[i] = new Image();
preLoad[i].src = Pic[i];
}
function runSlideShow() {
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout('runSlideShow()', slideShowSpeed);
}