function calendar(formu, field) {
	window.open("calendar_call.php?formu=" + formu + "&field=" + field , "calendar", "width=180,height=168,top=200,left=320"); 
}
function enlarge(picture,upload_dir) {
	window.open("enlarge.php?picture=" + picture + "&upload_dir=" + upload_dir, "enlarge", "resizable=yes,scrollbars=yes,width=200,height=130,top=0,left=0"); 
}
function makelarger(picture,upload_dir) {
	window.open("makelarger.php?picture=" + picture + "&upload_dir=" + upload_dir, "makelarger", "resizable=yes,scrollbars=yes,width=200,height=130,top=0,left=0"); 
}
function download(file) {
  	document.location = "download.php?file=" + file + "&send=download";
}
function ShowCep() {
	open('http://www.correios.com.br/servicos/cep/cep_default.cfm','ShowCep','location=no,resize=no, width=730,height=400,left=18,top=18,maximized=0,scrollbars=1');
}
function selectmenu_selected_page(form) {
	document.location = document.forms[form].selected_page.options[document.forms[form].selected_page.selectedIndex].value
}
function selectmenu_selected_page2(form) {
	document.location = document.forms[form].selected_page2.options[document.forms[form].selected_page2.selectedIndex].value
}
function selectmenu_register_page(form) {
	document.location = document.forms[form].register_page.options[document.forms[form].register_page.selectedIndex].value
}
function selectmenu_register_page2(form) {
	document.location = document.forms[form].register_page2.options[document.forms[form].register_page2.selectedIndex].value
}
function popup_open(template,idpk){
  	window.open("frameset.php?" + template + ".php?idpk=" + idpk, template, "top=0,left=0,scrollbars=yes,dependent=true,resizable=yes,width=776,height=400");
}
function popup(template,name,scrollbars,resizable,width,height){
  	window.open(template, name, "scrollbars=" + scrollbars + ",top=0,left=0,dependent=true,location=0,directories=0,status=1,resizable=" + resizable + ",width=" + width + ",height=" + height);
}
function popup_bar(template,name,scrollbars,resizable,width,height){
  	window.open(template, name, "scrollbars=" + scrollbars + ",top=0,left=0,dependent=true,location=0,directories=0,status=1,menubar=yes,resizable=" + resizable + ",width=" + width + ",height=" + height);
}
function redirect(url) {
	document.location = url;
}
function video_56k(file) {
  window.open("video_56k.php?file=" + file, "video_56k", "top=100,left=200,scrollbars=no,resizable=yes,width=240,height=270"); 
}
function video_speed(file) {
  window.open("video_speed.php?file=" + file, "video_speed", "top=100,left=200,scrollbars=no,resizable=yes,width=320,height=320"); 
}
function write_control(text) {
   document.write(text);
}
var isReady = true;
function saveas(template){
	if (document.execCommand){
		if (isReady){
			document.execCommand("SaveAs", null, template);
		}
	} else {
	
	}
}	
function toprint(){
	window.print();
}
// Identificação de browser
var isNav4, isNav, isIE;
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
  isNav = (navigator.appName=="Netscape") ? true : false;
  isIE = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}
if (navigator.appName=="Netscape") {
	isNav4 = (parseInt(navigator.appVersion.charAt(0))==4);
}

// <INPUT name="NomeDoCampo" maxlength="17" SIZE="17" onKeyDown="formatarOnKeyDown(this)" onKeyUp="formatarOnKeyUp(this)" onSelect="refreshCampo(this)"  Onkeypress="onlynum()">
function tirarZerosEsquerda(STR){

  var sAux='';
  var i=0;
  STR=new String(STR);

  while (i < STR.length ){
    if ((STR.charAt(i)!='.') && (STR.charAt(i)!=',')){
	  sAux += STR.charAt(i);
    }
	i++
  }


  STR = new String(sAux);
  sAux = '';
  i=0;

  while (i < STR.length ){
    if (STR.charAt(i) != '0'){
      sAux = STR.substring(i,STR.length)
	  i = STR.length;
	}
    i++;
  }

  return  sAux;
}

function formatarOnKeyUp(OBJ){
  var decimal,inteiro;
  var i,count;
  STR = new String(OBJ.value);
  STR = tirarZerosEsquerda(STR);
  inteiro='';
  if (isIE) {
		if (STR.length == 1){
			  inteiro  = '0';
			  decimal = '0' + STR;
			}
			else {
			  if (STR.length == 2){
				  inteiro  = '0';
				  decimal = STR;
				}
				else{
				  decimal = STR.substring(STR.length-2,STR.length);
				  i=3;
				  count=0;
				  while (i<=STR.length){
			 		if (count==3) {
					  inteiro = '.' + inteiro;
					  count = 0;
					}
				    inteiro = STR.charAt(STR.length-i) + inteiro;
					count++;
					i++;
				  }
				}
			}


		if (inteiro == '') {
		  inteiro = '0';
		}

		if (decimal == '') {
		  decimal = '00';
		}
		OBJ.value = inteiro+','+decimal;
  }
  else
  {

	if (navigator.appName=="Netscape")
	{
		var versao = navigator.userAgent;
		versao=versao.toString();
		menorVersao = versao.search("/6.0");
		if (menorVersao>-1)
		{
			var isNS6="sim";
		}
	}

	if(isNS6=="sim")
		OBJ.style.textAlign	= "left";


	if(STR=="")
		OBJ.value = "0,00";
	if((STR.length==1 || STR.length==2 || STR.length==3) && OBJ.value.substr(0,1)=='0')
		OBJ.value = OBJ.value.substr(1,OBJ.value.length-1);
	if((STR.length==2) && OBJ.value.substr(0,1)!='0')
		OBJ.value = "0," + OBJ.value;
	if((STR.length==1) && OBJ.value.substr(0,1)!='0')
		OBJ.value = "0,0" + OBJ.value;


	if(isNS6=="sim")
		OBJ.style.textAlign	= "right";

  }

}

function formatarOnKeyDown(OBJ,tammax,teclapres){
  var decimal,inteiro;
  var i,count;
  STR = new String(OBJ.value);

  inteiro='';

  if (isIE) {
	if (OBJ.maxLength > STR.length){
	  STR = tirarZerosEsquerda(STR); //ESTA FUNCAO TIRA TAMBEM PONTO E VIRGULA

	  if ( ((event.keyCode > 47) && (event.keyCode < 59)) || ((event.keyCode > 95) && (event.keyCode < 106))   ){

			if (STR.length == 0){
			  inteiro  = '0';
			  decimal = '0' + STR;
			}
			else {
			  if (STR.length == 1){
			    inteiro  = '0';
			    decimal = STR;
			  }
			  else{
			    decimal = STR.substring(STR.length-1,STR.length);
			    i=2;
			    count=0;
			    while (i<=STR.length){
			 		if (count==3) {
			  	  inteiro = '.' + inteiro;
			  	  count = 0;
			  	}
			      inteiro = STR.charAt(STR.length-i) + inteiro;
			  	count++;
			  	i++;
			    }
			  }
			}

	  }
	  else{
	    if (event.keyCode == 8){

	      if (STR.length == 0){
			  inteiro  = '0';
			  decimal = '000';
			}
			else {
			  if (STR.length == 1){
			    inteiro  = '0';
			    decimal = '00' + STR;
			  }
			  else {
			    if (STR.length == 2){
		          inteiro  = '0';
			      decimal = '0' + STR;
			     }
		         else{
	 			   decimal = STR.substring(STR.length-3,STR.length);
				   i=4;
				   count=0;
				   while (i<=STR.length){
			 		 if (count==3) {
					   inteiro = '.' + inteiro;
					   count = 0;
					  }
				      inteiro = STR.charAt(STR.length-i) + inteiro;
					  count++;
					  i++;
				    }
			     }
			  }
	      }
	    }
	    else {

	      if (STR.length == 1){
		 	  inteiro  = '0';
		      decimal = '0' + STR;
			}
			else {
			  if (STR.length == 2){
				  inteiro  = '0';
				  decimal = STR;
				}
				else{
				  decimal = STR.substring(STR.length-2,STR.length);
				  i=3;
				  count=0;
				  while (i<=STR.length){
			 		if (count==3) {
					  inteiro = '.' + inteiro;
					  count = 0;
					}
				    inteiro = STR.charAt(STR.length-i) + inteiro;
					count++;
					i++;
				  }
				}
			}
	    }
	  }

	  if (inteiro == '') {
	    inteiro = '0';
	  }

	  if (decimal == '') {
	    decimal = '00';
	  }
	  OBJ.value = inteiro+','+decimal;
	}
  }
  else
  {
	var tecla = teclapres.keyCode;
	valorSemFormato = OBJ.value;
	valorSemFormato = valorSemFormato.replace( ",", "" );
	valorSemFormato = valorSemFormato.replace( ".", "" );
	valorSemFormato = valorSemFormato.replace( ".", "" );
	valorSemFormato = valorSemFormato.replace( ".", "" );
	valorSemFormato = valorSemFormato.replace( ".", "" );
	tamanho = valorSemFormato.length;

	if (tecla == 46) {
	     OBJ.value = OBJ.value;

	}if (tamanho < tammax && tecla != 8) {
	    tamanho = valorSemFormato.length + 1;

	}if (tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
	     if (tecla == 8) {
	         tamanho = tamanho - 1;
	     }

	     if (tamanho <= 2) {
	 		 OBJ.value = valorSemFormato;

	 	 }else if ((tamanho > 2) && (tamanho <= 5)) {
	 		 OBJ.value = valorSemFormato.substr(0, tamanho - 2) + ',' +
	 		               valorSemFormato.substr(tamanho - 2, tamanho);

	 	 }else if ((tamanho >= 6) && (tamanho <= 8)) {
	 	 	 OBJ.value = valorSemFormato.substr(0, tamanho - 5) + '.' +
	 	 	               valorSemFormato.substr(tamanho - 5, 3) + ',' +
	 		               valorSemFormato.substr(tamanho - 2, tamanho);

	 	 }else if ((tamanho >= 9) && (tamanho <= 11)) {
	 		 OBJ.value = valorSemFormato.substr(0, tamanho - 8) + '.' +
	 		               valorSemFormato.substr(tamanho - 8, 3) + '.' +
	 		               valorSemFormato.substr(tamanho - 5, 3) + ',' +
	 		               valorSemFormato.substr(tamanho - 2, tamanho);

	 	 }else if ((tamanho >= 12) && (tamanho <= 14)) {
	 	 	 OBJ.value = valorSemFormato.substr(0, tamanho - 11) + '.' +
	 		               valorSemFormato.substr(tamanho - 11, 3) + '.' +
	 		               valorSemFormato.substr(tamanho - 8, 3)  + '.' +
	 		               valorSemFormato.substr(tamanho - 5, 3)  + ',' +
	 		               valorSemFormato.substr(tamanho - 2, tamanho);

	 	 }else if ((tamanho >= 15) && (tamanho <= 17)) {
	 	 	 OBJ.value = valorSemFormato.substr(0, tamanho - 14) + '.' +
	 		               valorSemFormato.substr(tamanho - 14, 3) + '.' +
	 		               valorSemFormato.substr(tamanho - 11, 3) + '.' +
	 		               valorSemFormato.substr(tamanho - 8, 3)  + '.' +
	 		               valorSemFormato.substr(tamanho - 5, 3)  + ',' +
	 		               valorSemFormato.substr(tamanho - 2, tamanho);
	    }
	}
  }
}

function refreshCampo(obj){
	if (isIE) {
		obj.value = obj.value;
	}
}
//  FIM   // funcoes para formartacao de valor


// Bloquear caracteres nao numericos - onKeyPress=onlynum()
function onlynum(e) {
	var keyNumber = (isIE) ? event.keyCode : e.which;
	if (((keyNumber<48)||(keyNumber>57)) && (keyNumber!=13) && (keyNumber!="0") && (keyNumber!=8)) {
		if (isIE) event.keyCode=0;
		return false;
	}
}

/* Video clip setting */
function fWriteWMV(id, w, h, url, controls){
	var wmp7;try{if(window.ActiveXObject){wmp7 = new ActiveXObject("WMPlayer.OCX.7");}else if(window.GeckoActiveXObject){wmp7 = new GeckoActiveXObject("WMPlayer.OCX.7");}} catch(oError){}
	var classID = "CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95";
	var txt = "";
	txt += '<object classid="'+classID+'" id="'+id+'" width="'+w+'" height="'+h+'" type="application/x-oleobject"';
	txt += '<param name="name" value="'+id+'" />';
	txt += '<param name="filename" value="'+url+'" />';
	txt += '<param name="autoStart" value="true" />';
	txt += '<param name="enabled" value="true" />';
	txt += '<param name="uiMode" value="full" />';
	txt += '<param name="mute" value="false" />';
	txt += '<param name="volume" value="1" />';
	txt += '<param name="ShowAudioControls" value="true" />';
	txt += '<param name="ShowStatusBar" value="true" />';
	txt += '<param name="ShowTracker" value="true" />';
	txt += '<param name="ShowDisplay" value="false" />';
	txt += '<param name="fullScreen" value="true" />';
	txt += '<param name="SAMIFileName" value="/videos/homepage.smi" />';
	txt += '<param name="CaptioningID" value="subtitle" />';
	
	if(!wmp7){ 
		txt += '<embed type="application/x-mplayer2" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" ';
		txt += 'id="'+id+'embed" name="'+id+'" ';
		txt += 'src="'+url+'" filename="'+url+'" ';
		
		if ( controls )
		{
			txt += 'width="'+w+'" height="'+h+'" autoStart="1" showstatusbar="1" showControls="1" showdisplay="0" showaudiocontrols="0" ></embed>';
		} else 
		{
			txt += 'width="'+w+'" height="'+h+'" autoStart="1" showstatusbar="1" showControls="1" showdisplay="0" showaudiocontrols="0" ></embed>';
		}

	}
	txt += '</object>';
	document.write(txt);
}

/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;

/**
 * enables highlight and marking of rows in data tables
 *
 */
function PMA_markRowsInit() {
    // for every table row ...
	var rows = document.getElementsByTagName('tr');
	for ( var i = 0; i < rows.length; i++ ) {
	    // ... with the class 'odd' or 'even' ...
		if ( 'odd' != rows[i].className && 'even' != rows[i].className ) {
		    continue;
		}
	    // ... add event listeners ...
        // ... to highlight the row on mouseover ...
	    if ( navigator.appName == 'Microsoft Internet Explorer' ) {
	        // but only for IE, other browsers are handled by :hover in css
			rows[i].onmouseover = function() {
			    this.className += ' hover';
			}
			rows[i].onmouseout = function() {
			    this.className = this.className.replace( ' hover', '' );
			}
	    }
        // ... and to mark the row on click ...
		rows[i].onmousedown = function() {
		    var unique_id;
            var checkbox;

            checkbox = this.getElementsByTagName( 'input' )[0];
            if ( checkbox && checkbox.type == 'checkbox' ) {
                unique_id = checkbox.name + checkbox.value;
            } else if (this.id.length > 0) {
                unique_id = this.id;
            } else {
		        return;
		    }

            if (typeof(marked_row[unique_id]) == 'undefined' || !marked_row[unique_id] ) {
                marked_row[unique_id] = true;
            } else {
                marked_row[unique_id] = false;
            }

            if ( marked_row[unique_id] ) {
			    this.className += ' marked';
            } else {
			    this.className = this.className.replace(' marked', '');
            }
		}

		// .. and checkbox clicks
		var checkbox = rows[i].getElementsByTagName('inputx')[0];
		if ( checkbox ) {
		    checkbox.onclick = function() {
		        // opera does not recognize return false;
		        this.checked = ! this.checked;
		    }
	    }
	}
}
window.onload=PMA_markRowsInit;

/* preload images */
var arrow1 = new Image(4, 7);
arrow1.src = "img/arrow1.gif";
var arrow2 = new Image(4, 7);
arrow2.src = "img/arrow2.gif";
