	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 excluirGrupoUsuario(id,nome){
	if((id == 0)){
		alert('Não é possível excluir o grupo ' + nome);
	} else {
		if(confirm('Excluir o grupo: ' + nome + '?'))
			document.location.href = 'usuarios_newsletter_grupos_excluir.php?id=' + id;	
	}
}

function copyStringTo(item,str){
	var element = document.getElementById(item);
	element.value += str;
	element.focus();
}

function excluirGrupoRepresentantes(id,nome){
	if((id == 0)){
		alert('Não é possível excluir o grupo ' + nome);
	} else {
		if(confirm('Excluir o grupo: ' + nome + '?'))
			document.location.href = 'representantes_grupos_excluir.php?id=' + id;	
	}
}

function excluirAlbum(id,nome){
	if(confirm('Excluir o álbum: ' + nome + '?\n\nAtenção: Todas as fotos também serão excluídas.'))
		document.location.href = 'album_excluir.php?id=' + id;
}

function excluirNewsletter(id){
	if(confirm('Excluir a newsletter?'))
		document.location.href = 'newsletter_excluir.php?id=' + id;
}

function visualizarNewsletter(id){
	var width  = 600;
	var height = 500;
	var left   = screen.Width / 2 - width / 2;
	var top    = screen.Height / 2 - height / 2;
	window.open('newsletter_visualizar.php?id='+id,'','height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=yes,status=yes');
}

function selectCheckBox(theBoxes,value){
	var qtd = theBoxes.length;	
	if(qtd){
		for(i = 0 ; i < qtd; i++){
			theBoxes[i].checked = value;
		}	
	} else {
		theBoxes.checked = value;
	}
}

function selectCheckBox2(name,value){
	var element = document.getElementsByName(name);
	var qtd = element.length;	
	if(qtd){
		for(i = 0 ; i < qtd; i++){
			element[i].checked = value;
		}	
	} else {
		element.checked = value;
	}
}

function checkTheBox(theBox){
	theBox.checked = !theBox.checked;
}

function confirmar(texto){
	if(confirm(texto))
		return true
	else 
		return false
}

function confirmarLink(texto,url){
	if(confirm(texto))
		document.location.href=url;
}

function lembreteSenha(){
	window.open('usuarios_senha.php','','width=320,height=100');
}

function grabFocus(item){
	item.focus();
}

function janelaSelecaoGrupo(){
	var width  = 300;
	var height = 170;
	var left   = screen.Width / 2 - width / 2;
	var top    = screen.Height / 2 - height / 2;
	window.open('produto_cadastro_selecionar_grupo.php','PLATTSELGRUPO','height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=no,status=yes');
}

function selecionarGrupo(id,nome){

	if(confirm('Selecionar o grupo ' + nome + '?')){
		self.opener.form1.idgrupo.value = id;
		self.opener.form1.nomegrupo.value = nome;
		self.close();
		if(submitForm)
			self.opener.form1.submit();		
	}

}

function showHideItem(id){
	var elemento = document.getElementById(id);
	if(elemento.style.display == 'none'){
		elemento.style.display = 'inline';
	} else {
		elemento.style.display = 'none';
	}
	
}

function visualizarTrabalho(id_trabalho,id_autor){
	window.open('trabalho_visualizar.php?id_trabalho='+id_trabalho+'&id_autor='+id_autor,'VIEW','status=yes,menubar=yes,scrollbars=yes,width=700,height=500');
}

function option(value,label){
	this.value = value;
	this.label = label;
}

	function moveItem(qtd){
		var index = document.form1.produtos.selectedIndex;
		if(index != -1){
			var total = document.form1.produtos.length;
			var target = index + qtd;
			if(target > -1 && target < total){
				var aux = new Option(document.form1.produtos.options[index].text,document.form1.produtos.options[index].value);
				document.form1.produtos.options[index].text = document.form1.produtos.options[target].text;
				document.form1.produtos.options[index].value = document.form1.produtos.options[target].value;
				document.form1.produtos.options[target].text = aux.text;		
				document.form1.produtos.options[target].value = aux.value;
				document.form1.produtos.options[target].selected = true;
			} else {
				alert("Ação inválida.");
			}
		} else {
			alert("Nenhum item selecionado.");			
		}
	}
	
	function salvarOrdenacao(){
		if(confirmar('Salvar alterações?')){
			var total = document.form1.produtos.length;
			document.form1.listaID.value = implode(';;',document.form1.produtos.options);
			document.form1.submit();	
		}
	}
	
	/**
	 * implode: pega todos os elementos do array pieces e junta em uma string utilizado glue como separador
	 * @param glue: String separadora dos elementos
	 * @param pieces: array com os elementos a serem concatenados	
	 */
	function implode(glue,pieces){
		var str = "";
		var numPieces = pieces.length;
		for(var i = 0; i < (numPieces-1); i++){
			str += pieces[i].value + glue;
		}
		str += pieces[i].value;
		return str;
	}
function abreImagem(file,w,h){
	var width  = parseInt(w);
	var height = parseInt(h);
	var left   = screen.Width / 2 - width / 2;
	var top    = screen.Height / 2 - height / 2;
	window.open('zoom.php?file='+file,'','height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=no,status=yes')
}

function excluirEmailMarketing(id){
	if(confirm('Excluir este Email Marketing ?'))
		document.location.href = 'emarketing_excluir.php?id=' + id;
}

function visualizarEmailMarketing(id){
	var width  = 600;
	var height = 500;
	var left   = screen.Width / 2 - width / 2;
	var top    = screen.Height / 2 - height / 2;
	window.open('emarketing_visualizar.php?id='+id,'','height='+height+',width='+width+',top='+top+',left='+left+',scrollbars=yes,status=yes');
}
