var IE = (document.all) ? 1 : 0;
var DOM = 0; 
if (parseInt(navigator.appVersion) >=5) {DOM=1};

function txtshow(txt2show,elemento) {
 	if (DOM) {
		var viewer = document.getElementById(""+elemento+"");
   	    viewer.innerHTML=txt2show;
 	 }else if(IE) {
          document.all[""+elemento+""].innerHTML=txt2show;
     }
}

function keyup(what,maxKeys,div_id,mensagem) 
{
   	var y=what.value;
	var r = 0;
	a=y.replace(/\s/g,' ');
	a=a.split(' ');
	for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}
	
	var showstr = r + " / " + maxKeys + "";
  	if (r > maxKeys) {
    		showstr += '<br>'+mensagem;		
	}
  	txtshow(showstr,div_id);
}
function keyupKeywords(what,maxKeys,div_id,mensagem) 
{
   	var y=what.value;
	var r = 0;
	a=y.split(',');

	for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}	
  	
	var showstr = r + " / " + maxKeys + "";
  	if (r > maxKeys) {
    		showstr += '<br>'+mensagem;		
	}
  	txtshow(showstr,div_id);
}
function keyupLines(what,maxKeys,div_id,mensagem) 
{
   	var y=what.value;
	var r = 0;
	a=y.replace(/\s+$/g,"");
	a=a.split('\n');
	for (z=0; z<a.length; z++) {if (a[z].length > 0) r++;}	
  	
	var showstr = r + " / " + maxKeys + "";
  	if (r > maxKeys) {
    		showstr += '<br>'+mensagem;		
	}
  	txtshow(showstr,div_id);
}

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 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 open_abstract(link){

	var largura = 332;
	var altura = 539;
	var w = largura;
	var h = altura;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',title=Sociedade Portuguesa de Reumatologia,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no';
	win = window.open(link, 'SPR', winprops);
	if (parseInt(navigator.appVersion) >= 4) win.window.focus();
}
function open_abstract2(link){

	var largura = 510;
	var altura = 570;
	var w = largura;
	var h = altura;
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',title=Sociedade Portuguesa de Reumatologia,status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no';
	win = window.open(link, 'SPR', winprops);
	if (parseInt(navigator.appVersion) >= 4) win.window.focus();
}

function ver_imagem(path, titulo,imgwidth,imgheight){

	var w = imgwidth;
	var h = imgheight;
	var largura = w;
	var altura = h;
	var screenX = screen.width;
	var screenY = screen.height;
	var winl;
	var wint;

	if (w > screenX){
		largura = screenX;
		if (h > screenY){
			altura = screenY;
			largura = (w * screenY) / (h);
		} else {
			altura = (h * screenX) / (w);
		}
	} else {
		largura = w;
		if (h > screenY){
			altura = screenY;
			largura = (w * screenY) / (h);
		} else {
			altura = h;
		}
	}

	winl = (screenX - largura) / 2;
	wint = (screenY - altura) / 2;

	winprops = 'height='+altura+',width='+largura+',top='+wint+',left='+winl+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,directories=no';
	win = window.open('imagem.php?titulo='+titulo+'&imagem='+path+'&width='+largura+'&height='+altura,'', winprops);
	if (parseInt(navigator.appVersion) >= 4) win.window.focus();
}

function ver_imagem_keyword(raiz,path, titulo,imgwidth,imgheight){

	var w = imgwidth;
	var h = imgheight;
	var largura = w;
	var altura = h;
	var screenX = screen.width;
	var screenY = screen.height;
	var winl;
	var wint;

	if (w > screenX){
		largura = screenX;
		if (h > screenY){
			altura = screenY;
			largura = (w * screenY) / (h);
		} else {
			altura = (h * screenX) / (w);
		}
	} else {
		largura = w;
		if (h > screenY){
			altura = screenY;
			largura = (w * screenY) / (h);
		} else {
			altura = h;
		}
	}

	winl = (screenX - largura) / 2;
	wint = (screenY - altura) / 2;

	winprops = 'height='+altura+',width='+largura+',top='+wint+',left='+winl+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,directories=no';
	win = window.open(raiz+'imagem.php?titulo='+titulo+'&imagem='+path+'&width='+largura+'&height='+altura,'', winprops);
	if (parseInt(navigator.appVersion) >= 4) win.window.focus();
}

//esta funcao serve para alterar a cor do texto de press_realeases ao passar o rato
function changeStyleById(id, color){
	if (document.getElementById){
		var nodeObj = document.getElementById(id);
		nodeObj.style.color = color;
	}
}

function open_calendario(url, form, campo, dataEntrada)
 {
	urlFinal = url + "?form=" + form + "&campo=" + campo;
			if(!dataEntrada == "") {
				urlFinal += "&data_entrada=" + dataEntrada;
			}
			var newWindow;
	newWindow = window.open(urlFinal,'','height=250,width=255,toolbar=no,minimize=no,status=no,menubar=no,location=no,scrollbars=no');
}

function nltobr (str){
	var str=new String(str);
	var primeira_pos=str.search(/<[ ]*table/g);
	var temp_pos;
	var inicio=1;

	var ma_array=str.match(/<[ ]*\/[ ]*table/g);
	if (ma_array) {
			ultima_pos=str.lastIndexOf(ma_array[ma_array.length-1]);
	}
	if (primeira_pos!=-1) {
			var new_str=(str.slice(0,primeira_pos)).replace(/\n/g,"<br>");
			new_str+=(str.slice(primeira_pos,ultima_pos));
			new_str+=(str.slice(ultima_pos)).replace(/\n/g,"<br>");
	}
	else {
			var new_str=str.replace(/\n/g,"<br>");
	}
	return new_str;
}

function mostra_imagem(strFile,file_dir) {
	var file_dir = file_dir || '/';
	if (strFile != '')
			preview3(file_dir+strFile, 600, 400);

}

function checkEnterPage(nform, evt)
{
	evt = (evt) ? evt : event
	var charCode = (evt.wich) ? evt.wich : evt.keyCode
	if (charCode == 13)
	{
		 nform.submit();
		 return false
	}
	return true
}

function sub_caract_esq(str)
{
	var str_sub=String(str);
	var regexp=/€/g;
	str_sub=str_sub.replace(regexp,'&euro;');
	regexp=/[”“]/g;
	str_sub=str_sub.replace(regexp,'"');
	regexp=/…/g;
	str_sub=str_sub.replace(regexp,'...');
	regexp=/–/g;
	str_sub=str_sub.replace(regexp,'-');
	return str_sub;
}

function IsNumeric(sText)
{
    var re = /^[0-9]+$/;
	var test = re.test(sText);
	var valida = true;
	if (test)
	  valida = false;
	//alert(valida);
	return valida;   
}


function ComandoSelected(nome,accao)
{
	document.forms[nome].action=accao;
	document.forms[nome].submit();
}

function ver_header(id_ficheiro, w, h){

	var largura = w;
	var altura = h;
	var screenX = screen.width;
	var screenY = screen.height;
	var winl;
	var wint;

	if (w > screenX){
		largura = screenX;
		if (h > screenY){
			altura = screenY;
			largura = (w * screenY) / (h);
		} else {
			altura = (h * screenX) / (w);
		}
	} else {
		largura = w;
		if (h > screenY){
			altura = screenY;
			largura = (w * screenY) / (h);
		} else {
			altura = h;
		}
	}

	winl = (screenX - largura) / 2;
	wint = (screenY - altura) / 2;

	winprops = 'height='+altura+',width='+largura+',top='+wint+',left='+winl+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,directories=no';
	win = window.open('imagem.php?imagem='+id_ficheiro+'&width='+w+'&height='+h,'', winprops);
	if (parseInt(navigator.appVersion) >= 4) win.window.focus();
}

function MultiSelector(list_target,max_file){
	var maxfile = max_file;
	
	this.list_target = list_target;
	this.count = 0;
	this.id = 0;
	this.addElement = function( element ){
		if( element.tagName == 'INPUT' && element.type == 'file' ){
			element.name = 'file[]';			
			element.className= 'texto_w550_button';			
			if ((maxfile) <= this.count) {				
				element.disabled = true;
			}	
			element.multi_selector = this;element.onchange = function(){
				var new_element = document.createElement( 'input' );
				new_element.type = 'file';
				this.parentNode.insertBefore( new_element, this );
				this.multi_selector.addElement( new_element );
				this.multi_selector.addListRow( this );
				this.style.position = 'absolute';
				this.style.left = '-1000px';
				
			};
			this.count++;			
			this.current_element = element;
		} else {
			alert( 'Error: not a file input element' );
		};
		
	};	
	this.addListRow = function(element){
			var new_row = document.createElement('div');
			var new_row_button = document.createElement('input');
			new_row.className = 'texto_w574';
			new_row_button.type = 'button';
			new_row_button.value = 'remover';
			new_row_button.className = 'texto_button';
			new_row.element = element;
			new_row_button.onclick = function(){
				this.parentNode.element.parentNode.removeChild(this.parentNode.element);
				this.parentNode.parentNode.removeChild(this.parentNode);
				this.parentNode.element.multi_selector.count--;
				this.parentNode.element.multi_selector.current_element.disabled = false;
				return false;
			};
			var nn = strrpos(element.value, '\\');
			new_row.innerHTML = (substr(element.value, (nn + 1))) + ' ';
			new_row.appendChild(new_row_button);
			this.list_target.appendChild(new_row);
	};
};
function MultiSelector2(list_target,max_file,elemento){
	var maxfile = max_file;
	
	this.list_target = list_target;
	this.count = 0;
	this.id = 0;
	this.addElement = function( element ){
		if( element.tagName == 'INPUT' && element.type == 'file' ){
			element.name = elemento;			
			element.className= 'texto_w550_button';	
					
			if ((maxfile) <= this.count) {				
				element.disabled = true;
			}	
			element.multi_selector = this;element.onchange = function(){
				var new_element = document.createElement( 'input' );
				new_element.type = 'file';
				this.parentNode.insertBefore( new_element, this );
				this.multi_selector.addElement( new_element );
				this.multi_selector.addListRow( this );
				this.style.position = 'absolute';
				this.style.left = '-1000px';
				
			};
			this.count++;			
			this.current_element = element;
		} else {
			alert( 'Error: not a file input element' );
		};
		
	};	
	this.addListRow = function(element){
			var new_row = document.createElement('div');
			var new_row_button = document.createElement('input');
			new_row.className = 'texto_w574';
			new_row_button.type = 'button';
			new_row_button.value = 'remover';
			new_row_button.className = 'texto_button';
			new_row.element = element;
			new_row_button.onclick = function(){
				this.parentNode.element.parentNode.removeChild(this.parentNode.element);
				this.parentNode.parentNode.removeChild(this.parentNode);
				this.parentNode.element.multi_selector.count--;
				this.parentNode.element.multi_selector.current_element.disabled = false;
				return false;
			};
			var nn = strrpos(element.value, '\\');
			new_row.innerHTML = (substr(element.value, (nn + 1))) + ' ';
			new_row.appendChild(new_row_button);
			this.list_target.appendChild(new_row);
	};
};
function addRowLegenda()
{
	var tbl = document.getElementById('tblGrid');
	var lastRow = tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
	var row = tbl.insertRow(lastRow);
		
	// right center
	var cellLeft  = row.insertCell(0);
	var el1 = document.createElement('input');
	el1.type = 'text';
	el1.name = 'legenda_titulo' + iteration;
	el1.id = 'legenda_titulo' + iteration;
	el1.size = 25;
	el1.className = 'texto_w150';

	// cellCenterRight
	var cellCenter= row.insertCell(1);
	var el2 = document.createElement('input');
	el2.type = 'text';
	el2.name = 'legenda_legenda' + iteration;
	el2.id = 'legenda_legenda' + iteration;
	el2.size = 25;
	el2.className = 'texto_w150';
	
// left esquerda
	var cellCenterRight = row.insertCell(2);
	var el3 = document.createElement('input');
	el3.type = 'file';
	el3.name = 'legenda_ficheiro' + iteration;
	el3.id = 'legenda_ficheiro' + iteration;	
	el3.className = 'texto_w100';

	// right direira
	var cellRight = row.insertCell(3);
	var el4 = document.createElement('a');
	el4.onclick = function () {
	//var oRow = this.parentElement.parentElement;
	var i=this.parentNode.parentNode.rowIndex
	document.getElementById('tblGrid').deleteRow(i)		
	//	document.getElementById("tblGrid").deleteRow(this.parentElement.rowIndex);	

	};
	el4.setAttribute('alt', 'Clique aqui para remover');
	el4.style.cursor='pointer';
	el4.className='texto_button2';
	el4.appendChild(document.createTextNode("remover"));
	
	cellLeft.appendChild(el1);
	cellCenter.appendChild(el2);
	cellCenterRight.appendChild(el3);
	cellRight.appendChild(el4);

}


function apagar_files (id,elemento,ckb){	
	if(ckb.checked == true){		
		elemento = elemento+id;		
		document.getElementById(elemento).innerHTML='<strike>'+document.getElementById(elemento).innerHTML+'</strike>';
	}else{	
		elemento = elemento+id;			
		var x = document.getElementById(elemento).innerHTML 
		x = substr(x,8);
		x = substr(x,0,-8);
		document.getElementById(elemento).innerHTML = x;	
	}
}

function strrpos( haystack, needle, offset){
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: strrpos('Kevin van Zonneveld', 'e');
    // *     returns 1: 16
 
    var i = haystack.lastIndexOf( needle, offset ); // returns -1
    return i >= 0 ? i : false;
}
function substr( f_string, f_start, f_length ) {
    // http://kevin.vanzonneveld.net
    // +     original by: Martijn Wieringa
    // *         example 1: substr('abcdef', 0, -1);
    // *         returns 1: 'abcde'
 
    if(f_start < 0) {
        f_start += f_string.length;
    }
 
    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }
 
    if(f_length < f_start) {
        f_length = f_start;
    }
 
    return f_string.substring(f_start, f_length);
}
function ver_cartao(membro){

	var largura = 250;
	var altura = 420;
	var screenX = screen.width;
	var screenY = screen.height;
	
	winl = (screenX - largura) / 2;
	wint = (screenY - altura) / 2;

	winprops = 'height='+altura+',width='+largura+',top='+wint+',left='+winl+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,directories=no';
	window.open('cartao.php?id_membro='+membro,'Cartão', winprops);
	
}
function ver_cartao_pesquisado(membro){
	
	var largura = 250;
	var altura = 420;
	var screenX = screen.width;
	var screenY = screen.height;
	
	winl = (screenX - largura) / 2;
	wint = (screenY - altura) / 2;
	
	winprops = 'height='+altura+',width='+largura+',top='+wint+',left='+winl+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,directories=no';
	window.open('cartao.php?id_membro='+membro,'Cartão', winprops);

}

function displayWindow(theURL,winName,width,height,features) {

	var window_width = width;
    var window_height = height;
    var newfeatures= features;
    var window_top = (screen.height-window_height)/2;
    var window_left = (screen.width-window_width)/2;
    newWindow=window.open(''+ theURL + '',''+ winName + '','width=' + window_width + ',height=' + window_height + ',top=' + window_top + ',left=' + window_left + ',features=' + newfeatures + ',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,directories=no');
    newWindow.focus();
}

function ver_comentario(id_coment){

	var screenX = screen.width;
	var screenY = screen.height;

	winl = (screenX - 500) / 2;
	wint = (screenY - 260) / 2;

	winprops = 'height=260,width=500,top='+wint+',left='+winl+',status=no,toolbar=no,menubar=no,scrollbars=no,resizable=no,directories=no';
	win = window.open('coment.php?coment='+id_coment,'', winprops);
	if (parseInt(navigator.appVersion) >= 4) win.window.focus();
}

function fillSelectFromArray(selectCtrl, itemArray, defaultItem, goodPrompt, badPrompt) {
	var i, j;
	var prompt;
		
	// empty existing items
	for (i = selectCtrl.options.length; i >= 0; i--) {
		selectCtrl.options[i] = null;
	}
	prompt = (itemArray != null) ? goodPrompt : badPrompt;
	if (prompt == null) {
		j = 0;
	}
	else {
		selectCtrl.options[0] = new Option(prompt);
		j = 1;
	}
	if (itemArray != null) {
		// add new items
		for (i = 0; i < itemArray.length; i++) {
			selectCtrl.options[j] = new Option(itemArray[i][0]);
			if (itemArray[i][1] != null) {
				selectCtrl.options[j].value = itemArray[i][1];
			}
			if(itemArray[i][1] == defaultItem && defaultItem != null){
				selectCtrl.options[j].selected = true;
			}
			j++;
		}
		// select first item (prompt) for sub list

	 }
}


function addRow1(){
	
	elements = document.getElementById("tblGrid").getElementsByTagName("tr");   
    rowCount = 10;
    for (i = 0; i < elements.length; i++) {
    	rowCount++
    }
   	// alert(rowCount);
   	var newRow = document.getElementById("tblGrid");
	var oCell = newRow.insertCell();
	oCell.innerHTML = "<input type='text' name='nome"+rowCount+"' size='43' class='style12'>";
	
	oCell = newRow.insertCell();
	oCell.innerHTML = "<input type='text' name='afiliacao"+rowCount+"'  size='43' class='style12'>";
	
	oCell = newRow.insertCell();
	oCell.innerHTML = "<a href='#' onclick='removeRow(this);'>remover</a>";	
  		
}

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""

if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function addRow()
{
	var tbl = document.getElementById('tblGrid');
	var lastRow = tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
	var Lastiteration = lastRow-1;
	var row = tbl.insertRow(lastRow);
	// left esquerda
	var cellLeft = row.insertCell(0);
	var el1 = document.createElement('input');
	el1.type = 'text';
	el1.name = 'nome' + iteration;
	el1.id = 'nome' + iteration;
	el1.size = 25;
	el1.className = 'texto_w230';
	
	// right center
	var cellCenter = row.insertCell(1);
	var el2 = document.createElement('input');
	el2.type = 'text';
	el2.name = 'afiliacao' + iteration;
	el2.id = 'afiliacao' + iteration;
	el2.value=document.getElementById('auxAutorAfiliacao').value;
	el2.size = 25;
	el2.className = 'texto_w150';
	el2.onchange = function () {
		document.getElementById('auxAutorAfiliacao').value = document.getElementById('afiliacao'+iteration).value;		
		
	};
	el2.value=document.getElementById('auxAutorAfiliacao').value;


	// cellCenterRight
	var cellCenterRight= row.insertCell(2);
	var el3 = document.createElement('input');
	el3.type = 'text';
	el3.name = 'servico' + iteration;
	el3.id = 'servico' + iteration;
	el3.size = 25;
	el3.value=document.getElementById('auxAutorServico').value;
	el3.className = 'texto_w150';
	el3.onchange = function () {		
		document.getElementById('auxAutorServico').value = document.getElementById('servico'+iteration).value;		

	};

	el3.value=document.getElementById('auxAutorServico').value;
	
	// right direira
	var cellRight = row.insertCell(3);
	var el4 = document.createElement('a');
	el4.onclick = function () {
	//var oRow = this.parentElement.parentElement;
	var i=this.parentNode.parentNode.rowIndex
	document.getElementById('tblGrid').deleteRow(i)		
	//	document.getElementById("tblGrid").deleteRow(this.parentElement.rowIndex);	
	};
	el4.setAttribute('alt', 'Clique aqui para remover');
	el4.style.cursor='pointer';
	el4.className='texto_button2';
	//el4.setAttribute("href", "javascript:removeRow("+el4+")");
	el4.appendChild(document.createTextNode("remover"));
	
	cellLeft.appendChild(el1);
	cellCenter.appendChild(el2);
	cellCenterRight.appendChild(el3);
	cellRight.appendChild(el4);

}
function addRow2()
{
	var tbl = document.getElementById('tblGrid');
	var lastRow = tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
	var row = tbl.insertRow(lastRow);
	
	// left esquerda
	
	var cellLeft = row.insertCell(0);
	var el1 = document.createElement('input');
	el1.type = 'text';
	el1.name = 'nome' + iteration;
	el1.id = 'nome' + iteration;
	el1.size = 25;
	el1.className = 'texto_w276';
	
	var espac1 = row.insertCell(1);
	var esp1 = document.createElement('span');
	esp1.setAttribute('width',5);
	
	// right center
	var cellCenter = row.insertCell(2);
	var el2 = document.createElement('input');
	el2.type = 'text';
	el2.name = 'email' + iteration;
	el2.id = 'email' + iteration;
	el2.size = 25;
	el2.className = 'texto_w276';
	
	var espac2 = row.insertCell(3);
	var esp2 = document.createElement('span');
	esp2.setAttribute('width',5);
	
	
	// right direira
	var cellRight = row.insertCell(4);
	var el3 = document.createElement('a');
	el3.onclick = function () {
	//var oRow = this.parentElement.parentElement;
	var i=this.parentNode.parentNode.rowIndex
	document.getElementById('tblGrid').deleteRow(i)		
	//	document.getElementById("tblGrid").deleteRow(this.parentElement.rowIndex);	
	};
	el3.setAttribute('alt', 'Clique aqui para remover');
	el3.style.cursor='pointer';
	el3.className='texto_button2';
	//el3.setAttribute("href", "javascript:removeRow("+el3+")");
	el3.appendChild(document.createTextNode("remover"));
	
	cellLeft.appendChild(el1);
	espac1.appendChild(esp1);
	cellCenter.appendChild(el2);
	espac2.appendChild(esp2);
	cellRight.appendChild(el3);
}
function addRow3()
{
	var tbl = document.getElementById('tblGrid');
	var lastRow = tbl.rows.length;
	// if there's no header row in the table, then iteration = lastRow + 1
	var iteration = lastRow;
	var row = tbl.insertRow(lastRow);
	
	// left esquerda
	
	var cellLeft = row.insertCell(0);
	var el1 = document.createElement('input');
	el1.type = 'text';
	el1.name = 'nome' + iteration;
	el1.id = 'nome' + iteration;
	el1.size = 25;
	el1.className = 'admin_main_text_input_295';
	
	var espac1 = row.insertCell(1);
	var esp1 = document.createElement('span');
	esp1.setAttribute('width',6);
	
	// right center
	var cellCenter = row.insertCell(2);
	var el2 = document.createElement('input');
	el2.type = 'text';
	el2.name = 'email' + iteration;
	el2.id = 'email' + iteration;
	el2.size = 25;
	el2.className = 'admin_main_text_input_295';
	
	var espac2 = row.insertCell(3);
	var esp2 = document.createElement('span');
	esp2.setAttribute('width',6);
	
	
	// right direira
	var cellRight = row.insertCell(4);
	var el3 = document.createElement('a');
	el3.onclick = function () {
	//var oRow = this.parentElement.parentElement;
	var i=this.parentNode.parentNode.rowIndex
	document.getElementById('tblGrid').deleteRow(i)		
	//	document.getElementById("tblGrid").deleteRow(this.parentElement.rowIndex);	
	};
	el3.setAttribute('alt', 'Clique aqui para remover');
	el3.style.cursor='pointer';
	el3.className='admin_main_text';
	//el3.setAttribute("href", "javascript:removeRow("+el3+")");
	el3.appendChild(document.createTextNode("remover"));
	
	cellLeft.appendChild(el1);
	espac1.appendChild(esp1);
	cellCenter.appendChild(el2);
	espac2.appendChild(esp2);
	cellRight.appendChild(el3);
}

function removeRow(src){
	var i=src.parentNode.parentNode.rowIndex;
	document.getElementById('tblGrid').deleteRow(i);		
}


function addquot (str){
	var str=new String(str);
	var new_str=str.replace(/["]/g,"&quot;");
	return new_str;
}

function limitInput(limitField, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	}
}

function altera_href_link(document,campo){
	$(document.body).getElements('a.membro_link').addEvents({'mouseover': function(){this.href = this.href.replace(/campo=.*/,'campo='+campo);}});
}

function centra_e_mostra_div(div,width){
	
	BrowserDetect.init();
	
	switch ( BrowserDetect.browser ) {
		case "Netscape":
		case "Safari":
		case "Opera":
		case "Firefox":
				winW = window.innerWidth;
		  		winH = window.innerHeight;				
			break;
		case "Explorer":
			  	winW = document.body.offsetWidth;
			  	winH = document.body.offsetHeight;		
			break;
	}
	
	div = document.getElementById(div);
	div.style.left = (winW/2)-(width/2)+"px";
	div.style.visibility = 'visible';
}

function mostra_div(div){
	
	div = document.getElementById(div);
	div.style.visibility = 'visible';
	
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "browser desconhecido";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "versão desconhecida";
		this.OS = this.searchString(this.dataOS) || "OS desconhecido";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]
};

function start_count(seconds){
	if ( seconds == 0 ) {
		finnish_countdown();
		return false ;
	}
	$('counter_timer').innerHTML = seconds ;
	seconds--;
	self.setTimeout("start_count("+seconds+")",1000);	
}
var uid = 0 ;
function rvSuccess(s){
	if ( s == "1" ) {
	// OK
	// WINDOW LOCATION TO ARTICLE PATH
	window.location = '/membros/edicao/?imr=118&imc=5&fmo=rev&id='+uid;
	} else {
	// NOT OK
	}
}

function revisor_valida(id,opcao){
	uid = id ; 
	request = new Request({method: 'get', url:'/membros/revisao/_valida_resposta.php', onComplete: function(response){rvSuccess(response);}}).send('id='+id+'&opcao='+opcao);
}
