// JavaScript Document

//////////////////////////////////
// Impedir seleçao do texto

function disableselect(e){
    if(e.target.tagName != "INPUT" && e.target.tagName != "TEXTAREA")
    {
        return false
    }
    return true
}
function reEnable(){
	return true
}
document.onselectstart=new Function ("return false");
if (window.sidebar){
	document.onmousedown=disableselect;
	document.onclick=reEnable;
}
//////////////////////////////////
// Coloca foco no campo

function foco(nome){
	document.getElementsByName(nome)[0].focus();
}
//////////////////////////////////


//////////////////////////////////
// Abre popup dos comentários

function popup(id){
	window.open('http://gazeta-rs.com.br/comentar.php?idnoticia='+id,'','width=410,height=500,location=no,scrollbars=yes');	
}

//////////////////////////////////
// Abre popup das Opiniões

function opiniao(id){
	window.open('http://gazeta-rs.com.br/opiniao.php?idjornal='+id,'','width=410,height=500,location=no,scrollbars=yes');	
}


//////////////////////////////////
// Funções do Dreamweaver

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 MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}

//////////////////////////////////////////////////////////////////////
// JavaScript Document
// Função requisição - Implementa AJAX
// Parametros:
//
// url		- página a ser chamada
// retorno	- div que receberá resposta do AJAX
// params	- parâmetros enviados a url
//
function requisicao(url, retorno, params){
	if (window.XMLHttpRequest){ // Firefox, ie7
		http_request = new XMLHttpRequest();
	}
	else
		if (window.ActiveXObject){ // ie
			try{
				http_request = new ActiveXObject('Msxml2.XMLHTTP'); // ie6
			}
			catch(e){
				try{
					http_request = new ActveXObject('Microsoft.XMLHTTP'); // ie5.5
				}
				catch(e){
					alert('Não foi possível criar requisição!');
				}
			}
		}
	
	http_request.onreadystatechange = function exibe(){
											if (http_request.readyState == 4){
												rem_div();
												if (http_request.status == 200){
													document.getElementById(retorno).innerHTML = http_request.responseText;
												}
												else{
													alert ('Erro: ' + http_request.status);
												}
											}
											else
												if (!document.getElementById('carregando'))
													cria_div();
										}
										
	http_request.open('POST',url,true);
	http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http_request.send(params);
}
///////////////////////////////////////////
function cria_div(){
	div = document.createElement('div');
	div.setAttribute('id', 'carregando');
	div.style.backgroundColor = '#FF0000';
	div.style.clear = 'both';
	div.style.position = 'absolute';
	div.style.top = '0px';
	div.style.right = '0px';
	div.style.color = '#FFFFFF';
	div.innerHTML = 'Carregando ...';
	document.body.appendChild(div);
	
}
/////////////////////////////////////////
function rem_div(){
	document.body.removeChild(document.getElementById('carregando'));
}
////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////
//// Verifica Form Contato
////////////////////////////////////////////////////////////////////////////////////////

function verifica_contato(){
	if(!document.getElementById("nome").value){
		alert('Preencha o Campo Nome!');
		document.getElementById("nome").focus();
		return false;
	}
	mail = document.getElementById("email").value;
	if(!mail){
		alert('Preencha o Campo E-mail!');
		document.getElementById("email").focus();
		return false;
	}
	prim = mail.indexOf("@")
	if(prim < 2) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("@",prim + 1) != -1) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf(".") < 1) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf(" ") != -1) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("zipmeil.com") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("hotmeil.com") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("fisul.com.br") > 0) {
		alert("O e-mail informado não está correto, verfique se o dominio esta correto: @fisul.edu.br");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf(".@") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("@.") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf(".com.br.") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("/") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("[") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("]") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("(") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf(")") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	if(mail.indexOf("..") > 0) {
		alert("O e-mail informado parece não estar correto.");
		document.getElementById('email').focus();
		document.getElementById('email').select();
		return false;
	}
	
	if(document.getElementById("destino")){
		if(!document.getElementById("destino").value){
			alert('Preencha o Campo Fale Com!');
			document.getElementById("destino").focus();
			return false;
		}
	}
	
	if(document.getElementById("mensagem")){
		if(!document.getElementById("mensagem").value){
			alert('Preencha o Campo Mensagem!');
			document.getElementById("mensagem").focus();
			return false;
		}
	}
	
	if(document.getElementById("coment")){
		if(!document.getElementById("coment").value){
			alert('Preencha o Campo Comentário!');
			document.getElementById("coment").focus();
			return false;
		}
	}

}
////////////////////////////////////////////////////////////////////////////////////////
//// FINAL - Verifica Form Contato
////////////////////////////////////////////////////////////////////////////////////////
