
function visitar(form)
{
	var onde=form.selectedIndex
	if (form.options[onde].value != 1) window.open(form.options[onde].value,"_top")
}


function form_fale(ativo,inativo) {
	document.getElementById(ativo).style.display="block";
	document.getElementById(inativo).style.display="none";
}


function openBlank(url){window.open(url)}

function checkBrowser(){
	T=this
	b=navigator.appName
	v=navigator.appVersion
	u=navigator.userAgent
	if(b=='Netscape')T.b='ns'
	else if(b=='Microsoft Internet Explorer')T.b='ie'
	else T.b=b
	T.v=parseInt(v)
	T.ns=(T.b=='ns'&&T.v>=4)
	T.ns4=(T.b=='ns'&&T.v==4)
	T.ns5=(T.b=='ns'&&T.v==5)
	T.ns6=(T.b=='ns'&&T.v==5)
	T.ie=(T.b=='ie'&&T.v>=4)
	T.ie4=(u.indexOf('MSIE 4')>0)
	T.ie5=(u.indexOf('MSIE 5.0')>0)
	T.ie55=(u.indexOf('MSIE 5.5')>0)
	T.ie6=(u.indexOf('MSIE 6.0')>0)
	if(T.ie5)T.v=5
	if(T.ie55)T.v=5.5
	if(T.ie6)T.v=6
	T.min=(T.ns||T.ie)
	T.dom=(T.v>=5)
	T.win=(u.indexOf('Win')>0)
	T.mac=(u.indexOf('Mac')>0)
}
is=new checkBrowser()

function pauseNow(alvo){if (document.getElementById(alvo).PlayState == 2) document.getElementById(alvo).Pause();}
function stopNow(alvo){document.getElementById(alvo).Stop();}
function playNow(alvo){document.getElementById(alvo).Play();}

function VideoPause(alvo)
{
	pauseNow(alvo);
}
function VideoStop(alvo)
{
	stopNow(alvo);
}

function VideoPlay(alvo)
{
	playNow(alvo);
}


function menublt(menuID) {
menuID='menuitem'+menuID;
document.getElementById(menuID).style.display="block";
}
function menublt_restore(menuID) {
menuID='menuitem'+menuID;
document.getElementById(menuID).style.display="none";
}

function popup(url,w,h,s) {
	var aWm=window.open(url,'pop','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars='+s+',status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.width-w)/2)+-10)+',top='+(((screen.height-h)/2)+-30));
}
function abreDistribuidor(pagina) {
	var w = 500;
	var h = 580;
	window.open(pagina,'distribuidor','width='+w+',height='+h+',directories=0,location=0,menubar=0,resizable=0,scrollbars=yes,status=0,toolbar=0,marginleft=0,margintop=0,left='+(((screen.width-w)/2)+-10)+',top='+(((screen.height-h)/2)+-30));
}
function abreAmigo(w,h){
	window.open("../../content/noticias/envio_noticias.php",'',"width="+w+" ,height="+h+"', scrollbars=no");
}








function serverInserirVerif() {
	if (document.enviar.nome_destino.value != "Nome")
	{
		server.inserir();
	}
}

function dados () {
	this.rs = [];
	this.container = document.enviar.entrada;
	this.navegador = (navigator.appName.charAt(0) == "M");
}
dados.prototype.pega = function() {		
	return {nome:document.enviar.nome_destino.value, email:document.enviar.email_destino.value, _uid:Math.round(Math.random() * 100000000)};
}
dados.prototype.inserir = function() {

	var tp = this.pega();
	var flag = true;
	for (o in tp) {
		if(tp[o] == undefined) tp[o] = '';
		if (tp[o] == '') {
			flag = false;
			break;
		}
	}	
	if (flag) {
		this.rs.push(tp);
		if (this.navegador) {
			var _no = document.createElement("OPTION");
			_no.value = tp._uid;
			_no.text = tp.nome;
			_no.selected = true;
			this.container.options.add(_no);
			delete _no;
		} else {
			this.container.options[this.container.options.length] = new Option(tp["nome"], tp["_uid"], false, true);

		}
		document.enviar.nome_destino.value = 'Nome';
		document.enviar.email_destino.value = 'E-mail';
		
	} else {
		alert("Você deve preencher todos os campos");
	}
}
dados.prototype.deletar = function() {
	var s, l = this.container.options.length;
	for (var c = 0; c<l; c++) {
		if ((s=this.container.options[c]).selected) {
			var sel = s.value;
			break;
		}
	}
	if (sel) {
		for (var c = 0; c<this.rs.length; c++) {
			if (this.rs[c]["_uid"] == sel) {
				if(this.navegador){
					this.container.options.remove(c);
				} else {
					this.container.options[c] = null;
				}
				this.rs.splice(c, 1);
			}
		}
	} else {
		alert("Você deve selecionar um item para excluir");
	}
}




dados.prototype.submeter = function(){
	var nomes=emails='';
	for (var n=0; n < this.rs.length; n++){
		var obj = this.rs[n];
		nomes += '|' + obj["nome"]; 
		emails += '|' + obj["email"]; 
	}

	document.enviar.nomes.value = nomes;
	document.enviar.emails.value = emails;
	
	if(document.enviar.nomes.value == ""){

		alert('Nenhum Nome Foi Selecionado');
	}else if(document.enviar.nomes.value == ""){

		alert('Nenhum E-mail de Destino Foi Selecionado');
	}
	else{
	
	document.enviar.submit();
	}
	// -- setar os valores dos hiddens -- //
}

