/************************************************************************************
General SCRIPTS
Compiler: Gunther W.Seibert
2004 - General Scripts for Web
*************************************************************************************/

//-- Funções Gerais ------------------------------------------------------------------
	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 MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}

	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_preloadImages() { //v3.0
	 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}

function YY_checkform() { //v4.65
//copyright (c)1998,2002 Yaromat.com
  var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
  for (var i=1; i<args.length;i=i+4){
    if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
    var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
    myV=myObj.value;
    if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
      if (myReq&&myObj.value.length==0){addErr=true}
      if ((myV.length>0)&&(args[i+2]==1)){ //fromto
        var myMa=args[i+1].split('_');if(isNaN(parseInt(myV))||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==2)){
          var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
      } else if ((myV.length>0)&&(args[i+2]==3)){ // date
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
        if(myAt){
          var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
          var myDate=new Date(myY,myM,myD);
          if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
        }else{addErr=true}
      } else if ((myV.length>0)&&(args[i+2]==4)){ // time
        var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
      } else if (myV.length>0&&args[i+2]==5){ // check this 2
            var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
            if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!myObj1.checked){addErr=true}
      } else if (myV.length>0&&args[i+2]==6){ // the same
            var myObj1 = MM_findObj(args[i+1]);
            if(myV!=myObj1.value){addErr=true}
      }
    } else
    if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
          var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
          var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
      if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
      if (args[i+2]==2){
        var myDot=false;
        for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
        if(!myDot){myErr+='* ' +args[i+3]+'\n'}
      }
    } else if (myObj.type=='checkbox'){
      if(args[i+2]==1&&myObj.checked==false){addErr=true}
      if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
    } else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
      if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
    }else if (myObj.type=='textarea'){
      if(myV.length<args[i+1]){addErr=true}
    }
    if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
  }
  if (myErr!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+myErr)}
  document.MM_returnValue = (myErr=='');
}


  function MM_validateForm() { //v4.0
	  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
	  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
		if (val) { nm=val.name; if ((val=val.value)!="") {
		  if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
			if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve conter um e-mail válido.\n';
		  } else if (test!='R') { num = parseFloat(val);
			if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
			if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
			  min=test.substring(8,p); max=test.substring(p+1);
			  if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' é obrigatório.\n'; }
	  } if (errors) alert('Por favor, verifique:\n'+errors);
	  document.MM_returnValue = (errors == '');
	}


//-- Cursos ---------------------------------------------------------------------------
	function mudabarra(barra) {
		if (barra=="0")
		{ document.all.dvbarra.innerHTML = ""; }
		else
		{ var txtbarra = "<img src='imagens/" + barra + ".gif' border=0>"; document.all.dvbarra.innerHTML = txtbarra; }
	}

	function movepara(elemento,valor,direcao){
		// valor = distância a mover
		// 0 - esquerda, 1 - direita
		var t = "document.all."+elemento+".style"; var e = eval(t);	var l = e.left;
		if (direcao==0) { if (valor>0) { e.left = parseInt(l)-1; valor-=1; var tx = "movepara('" + elemento + "'," + valor + "," + direcao + ")"; setTimeout(tx,0.001); } }
		if (direcao==1) { if (valor>0) { e.left = parseInt(l)+1; valor-=1; var tx = "movepara('" + elemento + "'," + valor + "," + direcao + ")"; setTimeout(tx,0.001); } }
	}

	function muda(c) {
		var le = document.all.dvc3.style.left; var lp = document.all.dvc2.style.left; var lg = document.all.dvc1.style.left; 
		if (c==1) // Graduação
		{
			if (lp=="30px" && lg=="211px")	{ movepara('dvc1',151,0); } 	
			if (lp=="181px" && lg=="211px")	{ movepara('dvc1',151,0); movepara('dvc2',151,0); } 	
			return true;
		}
		if (c==2) // Pós-Graduação
		{
			if (lp=="30px" && lg=="60px")		{ movepara('dvc1',151,1); } 	
			if (lp=="30px" && lg=="211px")	{ movepara('dvc1',151,0); } 	
			if (lp=="181px" && lg=="211px")	{ movepara('dvc2',151,0); } 	
			return true;
		}
		if (c==3) // Extensão
		{
			if (lp=="30px" && lg=="60px") 	{ movepara('dvc2',151,1); movepara('dvc1',151,1); } 	
			if (lp=="30px" && lg=="211px")	{ movepara('dvc2',151,1); } 
			if (lp=="181px" && lg=="211px")	{ movepara('dvc2',151,0); movepara('dvc1',151,0); } 	
			return true;
		}
	}

	function initdivs() {
		document.all.dvc1.style.left="60px";
		document.all.dvc2.style.left="30px";
		document.all.dvc3.style.left="0px";
		document.all.dvc1.style.top="0px";
		document.all.dvc2.style.top="0px";
		document.all.dvc3.style.top="0px";
		document.all.dvtotal.style.left= (parseInt(document.body.clientWidth)/2)-375;
		document.all.dvtotal.style.top="70px";
		document.all.divUpControl.style.left= (parseInt(document.body.clientWidth)/2)+365;
		document.all.divUpControl.style.top="100px";
		document.all.divDownControl.style.left= (parseInt(document.body.clientWidth)/2)+365;
		document.all.divDownControl.style.top="120px";
		document.all.divContainer.style.left= (parseInt(document.body.clientWidth)/2)+160;
		document.all.divContainer.style.top="100px";
	}
	
	function movetimer() {
	if (document.all.dvc1.style.left=="60px"&&document.all.dvc2.style.left=="30px") {movepara('dvc1',151,1);wa=3;}
	if (document.all.dvc1.style.left=="211px"&&document.all.dvc2.style.left=="30px"&&wa==3) {movepara('dvc2',151,1);wa=2;}
	if (document.all.dvc1.style.left=="211px"&&document.all.dvc2.style.left=="181px") {movepara('dvc2',151,0);wa=1;}
	if (document.all.dvc1.style.left=="211px"&&document.all.dvc2.style.left=="30px"&&wa==1) {movepara('dvc1',151,0);wa=10;}
	}

	function stoptimer() { window.clearInterval(otimer); }

//-- Funções ONLOAD ------------------------------------------------------------------

	function resizing() {
		var WB=screen.Width;
		var LB=screen.Height;
		window.moveTo(0,0);
		window.resizeTo(WB,LB);
	}

	function alinhamento(){
		var W=document.body.clientWidth;
		var W1 = W/2;
		var L1 = W1-375;
		document.all.dvtotal.style.left=L1;
		var L2 = W1-237;
		document.all.menu1.style.left=L2;
		var L3 = W1+365;
		var L4 = W1+365;
		var L5 = W1+160;
		document.all.divUpControl.style.left=L3;
		document.all.divDownControl.style.left=L4;
		document.all.divContainer.style.left=L5;
		document.all.divUpControl.style.top="100px";
		document.all.divDownControl.style.top="120px";
		document.all.divContainer.style.top="100px";
	}
	
	function alinhamentomenu(){
		var W=document.body.clientWidth;
		var W1 = W/2;
		var L1 = W1-237;
		document.all.menu1.style.left=L1;
	}

	function limpatexto(campo) {
		var str = "document.all." + campo + ".value";
		eval(str) = "";
	}

//-- Funções EVENTOS ------------------------------------------------------------------

	function verifyCompatibleBrowser(){ 
	    this.ver=navigator.appVersion 
	    this.dom=document.getElementById?1:0 
	    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0; 
	    this.ie4=(document.all && !this.dom)?1:0; 
	    this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	    this.ns4=(document.layers && !this.dom)?1:0; 
	    this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5) 
	    return this 
	} 

	bw=new verifyCompatibleBrowser() 
	var speed=50 
	var loop, timer 
 
	function ConstructObject(obj,nest){ 
	    nest=(!nest) ? '':'document.'+nest+'.' 
	    this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0; 
	    this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0; 
	    this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight 
	    this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight 
	    this.up=MoveAreaUp;this.down=MoveAreaDown; 
	    this.MoveArea=MoveArea; this.x; this.y; 
	    this.obj = obj + "Object" 
	    eval(this.obj + "=this") 
	    return this 
	} 
	
	function MoveArea(x,y){ 
	    this.x=x;this.y=y 
	    this.css.left=this.x 
	    this.css.top=this.y 
	} 
 
	function MoveAreaDown(move){ 
		if(this.y>-this.scrollHeight+objContainer.clipHeight){ 
	    this.MoveArea(0,this.y-move) 
	    if(loop) setTimeout(this.obj+".down("+move+")",speed) 
		} 
	} 
	
	function MoveAreaUp(move){ 
		if(this.y<0){ 
	    this.MoveArea(0,this.y-move) 
	    if(loop) setTimeout(this.obj+".up("+move+")",speed) 
		} 
	} 
 
	function PerformScroll(speed){ 
		if(initialised){ 
			loop=true; 
			if(speed>0) objScroller.down(speed) 
			else objScroller.up(speed) 
		} 
	} 
 
	function CeaseScroll(){ 
	    loop=false 
	    if(timer) clearTimeout(timer) 
	} 
	
	var initialised; 
	function InitialiseScrollableArea(){ 
	    objContainer=new ConstructObject('divContainer') 
	    objScroller=new ConstructObject('divContent','divContainer') 
	    objScroller.MoveArea(0,0) 
	    objContainer.css.visibility='visible' 
	    initialised=true; 
	} 

	function doTooltip(e, msg) {
	  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
	  Tooltip.show(e, msg);
	}
	
	function hideTip() {
	  if ( typeof Tooltip == "undefined" || !Tooltip.ready ) return;
	  Tooltip.hide();
	}




