//<!--

var req;
var alvo;
var carregando = '<table width="100%" border="0"><tr><td width="100%"><img src="imagens/loader.gif" border="0"></td></tr></table>';

var bookmarkurl="http://www.jornalexpressoregional.com.br";
var bookmarktitle="EXPRESSO REGIONAL Online";

function favoritos(){
    if (window.sidebar) {
    	window.sidebar.addPanel(bookmarktitle, bookmarkurl,"");
    } else {
    	if(window.opera && window.print){
	        var mbm = document.createElement('a');
	        mbm.setAttribute('rel', 'sidebar');
	        mbm.setAttribute('href', bookmarkurl);
	        mbm.setAttribute('title', bookmarktitle);
	        mbm.click();
    	} else {
    		if(document.all){
    			window.external.AddFavorite(bookmarkurl, bookmarktitle);
    		}
    	}
    }
}

function loadXMLDoc(url){
	req = null;

	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange1;
		req.open("GET", url, true);
		req.send('');
	} else if (window.ActiveXObject) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP.4.0");
		} catch(e) {
			try {
				req = new ActiveXObject("Msxml2.XMLHTTP.3.0");
			} catch(e) {
				try {
					req = new ActiveXObject("Msxml2.XMLHTTP");
				} catch(e) {
					try {
						req = new ActiveXObject("Microsoft.XMLHTTP");
					} catch(e) {
						req = false;
					}
				}
			}
		}
		if (req) {
			req.onreadystatechange = processReqChange1;
			req.open("GET", url, true);
			req.send('');
		}
	}
}

function processReqChange1(){ 
	if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById(alvo).innerHTML = req.responseText;
		} else {
			alert("Houve um problema ao atualizar os dados:\n" + req.statusText);
		}
	} else {
		document.getElementById(alvo).innerHTML = carregando;
	}
}

function atualiza(url, target){
	alvo = target;
	
	loadXMLDoc(url);
}

var intContaTam = 0;
var vetFonte = new Array ();
vetFonte [0] = "10px";
vetFonte [1] = "11px";
vetFonte [2] = "12px";
vetFonte [3] = "13px";
vetFonte [4] = "14px";

function tamTexto (strAD) {
	
	if (strAD=="A") {
		intContaTam++;
		if (intContaTam>=vetFonte.length)
			intContaTam = vetFonte.length-1;
		document.getElementById('spanTexto').style.fontSize = vetFonte[intContaTam];
	} else {
		intContaTam--;
		if (intContaTam<0)
			intContaTam=0;
		document.getElementById('spanTexto').style.fontSize = vetFonte[intContaTam];
	}
}

function enviar(id) {
	er1 = /[A-Za-z]{3,}/;
	er2 = /[A-Za-z0-9_.-]+@([A-Za-z0-9_-]+)+\.[A-Za-z]{2,}/;
	
	var rem  = '';
	var nome = '';
	var email = '';
	
	rem = prompt('Informe seu nome:');

	if(rem != null){
		nome = prompt('Informe o nome da pessoa que deseja indicar esta notícia:');
		
		if(nome != null) {
			email = prompt('Informe o e-mail da pessoa que deseja indicar esta notícia:');
			
			if(! er1.test(rem) || ! er1.test(nome) || ! er2.test(email)) {
				alert('Verifique os dados informados e tente novamente enviar a indicação da notícia. Obrigado.');
				
				enviar(id);
			} else {
				atualiza('noticias_ver_enviar.php?id=' + id + '&rem=' + rem + '&nome=' + nome + '&email=' + email, 'divEnviar');
			}
		}
	}
}

function coluna(id) {
	er1 = /[A-Za-z]{3,}/;
	er2 = /[A-Za-z0-9_.-]+@([A-Za-z0-9_-]+)+\.[A-Za-z]{2,}/;
	
	var rem  = '';
	var nome = '';
	var email = '';
	
	rem = prompt('Informe seu nome:');

	if(rem != null){
		nome = prompt('Informe o nome da pessoa que deseja indicar esta matéria:');
		
		if(nome != null) {
			email = prompt('Informe o e-mail da pessoa que deseja indicar esta matéria:');
			
			if(! er1.test(rem) || ! er1.test(nome) || ! er2.test(email)) {
				alert('Verifique os dados informados e tente novamente enviar a indicação da matéria. Obrigado.');
				
				coluna(id);
			} else {
				atualiza('colunas_enviar.php?id=' + id + '&rem=' + rem + '&nome=' + nome + '&email=' + email, 'divEnviar');
			}
		}
	}
}

function validaForm(id){
	switch (id)	{
		case 1:
			f = document.formFale;
			
			er1 = /[A-Za-z]{3,}/;
			er2 = /[A-Za-z0-9_.-]+@([A-Za-z0-9_-]+)+\.[A-Za-z]{2,}/;
			
			if(! er1.test(f.nome.value) || ! er2.test(f.email.value) || ! er1.test(f.assunto.value) || ! er1.test(f.mensagem.value)) {
				msgErro(1);
				
				f.nome.focus();
				
				return false;
			}

			return true;
			
			break;
	}
}

function msgErro(tipo){
	switch (tipo) {
		case 1:
			msg = 'Preencha corretamente todos os campos. Obrigado.';
					
			break;
	}

	alert (msg);
}

//-->
