
function setHomepage(hurl)
{
if (document.all)
{
document.body.style.behavior='url(#default#homepage)';
document.body.setHomePage(hurl);

}
else if (window.sidebar)
{
if(window.netscape)
{
try
{ 
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
} 
catch(e) 
{ 
alert("Arraste o link para o botão home que se encontra antes da URL para tornar esta a sua homepage"); 
}
} 
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage',hurl);
}
}








function CreateBookmarkLink(url, title) {
//title = "4por4 – Web, Imagem e Consultoria";
//url = "http://www.4porquatro.com/";

if (window.sidebar) {
// Mozilla Firefox Bookmark

//alert("FIREFOX!");
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {

// IE Favorite
//alert("YES IE");
window.external.AddFavorite( url, title);
}
else if(window.opera && window.print) {
// Opera Hotlist
return true; }
}




















var anterior = 0;

function escondeProgramaReg(code) {
	var obj = document.getElementById("prog"+code);
	if(obj) {
		obj.style.display = "none";
	}
	var objAnt = document.getElementById("prog0");
	if(objAnt) {
		objAnt.style.display = "";
	}
}

function mostraProgramaReg(code) {
	var objAnt = document.getElementById("prog0");
	if(objAnt) {
		objAnt.style.display = "none";
	}
	var obj = document.getElementById("prog"+code);
	if(obj) {
		obj.style.display = "";
	}
}

/*
function mostraProgramaReg(code) {
	if(anterior == code) {
		var obj = document.getElementById("prog"+code);
		if(obj) {
			obj.style.display = "none";
		}
		var objAnt = document.getElementById("prog0");
		if(objAnt) {
			objAnt.style.display = "";
		}
		anterior = 0;
	} else {
		var objAnt = document.getElementById("prog"+anterior);
		if(objAnt) {
			objAnt.style.display = "none";
		}
		var obj = document.getElementById("prog"+code);
		if(obj) {
			obj.style.display = "";
		}
		anterior = code;
	}	
}*/


function loadToOuvir(u) {
	dn(u, dn1007); 
}
function dn1007(s) {
document.getElementById('OUVIR').innerHTML = s;
}


function loadTo5(u) {
	dn(u, dn1005); 
}
function dn1005(s) {
document.getElementById('IMGS').innerHTML = s;
}

function loadToC(u) {
	dn(u, dn100C); 
}
function dn100C(s) {
document.getElementById('CAL').innerHTML = s;
}


function simv(e, dv,co) {
	var ww = document.getElementById('VOT'+co).childNodes[0].clientWidth;
 	if(vv_browser == 2) document.getElementById('VOT'+co).style.width = event.offsetX+"px";
	else {
		document.getElementById('VOT'+co).style.width = e.layerX+"px";
	}
}
function simv2(dv,w,co) {
	document.getElementById('VOT'+co).style.width=w+"px";
}
//Insere a votação de imagens
function dnvt(s) {}
var votado = 0;
function vt(dv,co) {
	dv.onmouseover = null;
	dv.onmouseout = null;
	dv.onmousemove = null;
	dv.onclick = null;
	dn("index.php?it=dovot&op=22&co="+co+"&w="+document.getElementById('VOT'+co).style.width, dnvt);
	document.getElementById('VOTTXT1'+co).innerHTML = "&nbsp;";
	//alert("Obrigado pela sua participação.");
}

//Insere a votação de videos
function dnvt_video(s) {}
var votado = 0;
function vt_video(dv,co) {
	dv.onmouseover = null;
	dv.onmouseout = null;
	dv.onmousemove = null;
	dv.onclick = null;
	dn("index.php?it=dovot_video&op=22&co="+co+"&w="+document.getElementById('VOT'+co).style.width, dnvt_video);
	document.getElementById('VOTTXT1'+co).innerHTML = "&nbsp;";
	//alert("Obrigado pela sua participação - Video.");
}
	



function mudaCat(s,f) {
	clearSelect("codseccao");
	
	if(s.value == 0)
	return; 
	obj = document.getElementById("codseccao");
	dn2("/?it=seccao&co="+s.value, dnSelect, obj);  

}

function mudaCatf(s,f) {
	clearSelect("codseccaof");
	if(s.value == 0)
	return; 
	obj = document.getElementById("codseccaof");
	dn2("/?it=seccao2&co="+s.value, dnSelect, obj);  

}

function clearSelect(idcampo){
	var obj = document.getElementById(idcampo);
	if(!obj || !obj.options) return; 
	var tot = obj.options.length; 
	for(var i = 0; i<tot; i++) obj.options[1] = null;
}

function dn(url, func, p) {
	var xd = null;
	try {
		xd = (vv_browser == 2?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest());
		if(xd) {
			xd.open("GET",url,true);
			xd.onreadystatechange=function() {
				if(xd.readyState == 4 && xd.status == 200){
					if(p && func)func(xd.responseText,p);
					else{
						if(func)func(xd.responseText);
						else dn1(xd.responseText);
					}
				}
			}
    		xd.send(null);
  	 	}
    } catch(e) {}
}


function dn2(url, func, p) {
	var xd = null;
	try {
		xd = (vv_browser == 2?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest());
		if(xd) {
			xd.open("GET",url,true);
			xd.onreadystatechange=function() {
				if(xd.readyState == 4 && xd.status == 200){
					if(p && func)func(xd.responseText,p);
					else{
						if(func)func(xd.responseText);
						else dn1(xd.responseText);
					}
				}
			}
    		xd.send(null);
  	 	}
    } catch(e) {}
}

function dnSelect(s,sel) {
	if(s){
		var linhas = s.split(/#/);
		var tam = linhas.length;
		for(var i = 0; i < tam-1; i++) {
			var campos = linhas[i].split(/\|/);
			sel.options[i+1] = new Option(campos[1], campos[0]);	
		}
	}
	
}



function pop(it){
	var wnd=window.open(it,'Revistas',  'STATUS=NO, TOOLBAR=NO, LOCATION=NO, MENUBAR=NO, DIRECTORIES=NO, RESISABLE=YES, SCROLLBARS=YES, width=850, height=2000, BORDER=NO');
	if(wnd) wnd.focus();
	return wnd;
}



function gup( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}



function mostra(co){
	var op = document.getElementById(co);
	if(op.style.display == "none"){
		op.style.display = "";
	}else{
		op.style.display = "none";
		}
}


function glTTA(f,id) {
   f.action=id;
}

campos=new Array();
function fc(campo,ivalue){
	var v1=campos[campo.form.name];
	if(v1 && v1.length)for(i=0;i<v1.length;i++)if((v1[i][0]==campo.name)&&(campo.value==v1[i][1]))campo.value="";
}

function lfc(campo){
 	var v1=campos[campo.form.name];
 	if(v1 && v1.length)for(i=0;i<v1.length;i++)if((v1[i][0]==campo.name)&&(campo.value==""))campo.value=v1[i][1];
}

function initField(form,campo,inicial,obrigatorio,texto) {
	if(!campos[form])campos[form]=new Array();
	campos[form][campos[form].length]=new Array(campo,inicial,obrigatorio,texto);
	if(document.forms[form].elements[campo].value=="")document.forms[form].elements[campo].value=inicial;
}

function tstForm(f){
	var form = f.name; 
 	var v1=campos[form];
 	if(v1 && v1.length)for(i=0;i<v1.length;i++){
  		c=v1[i];
  		if(c[2] && (document.forms[form].elements[c[0]].value=="") || (document.forms[form].elements[c[0]].value==c[1]))return e(c[3],document.forms[form].elements[c[0]]);
 	}
 	return 1;
}

function submitenter(myfield,e) {
 	var keycode;
 	if(window.event)keyCode=window.event.keyCode;
 	else if(e)keyCode=e.which;
 	else return true;
 	if(keyCode == 13){
  		if(tstForm(myfield.form))myfield.form.submit();
  		return false;
 	} else return true;
}

function validadata(data){
	if(data.value.length != 10) return false;
	if(!(res = data.value.split(/-/)) || res.length!=3) return false;
	
	var dia = data.value.substring(0,2);
	var mes = data.value.substring(3,5);
	var ano = data.value.substring(6,10);

	var hoje = new Date();
	var anoh = hoje.getYear();
	
	if (ano > anoh || ano < 1900) return false;
	
	if(mes == '01' || mes == '03' || mes == '05' || mes == '07' || mes == '08' || mes == '10' || mes == '12'){
		if (dia > 31) return false;
	}
	else if( mes == '04' || mes == '06' || mes == '09' || mes == '11'){
		if(dia > 30) return false;
	}
	else if((ano % 4) != 0 && mes == '02' && dia > 28)
		return false;
	else if((ano % 4) == 0 && mes == '02' && dia > 29)
		return false;
	return true;
}

function lmp() {document.fnews.email.value = ''}
function goEm() {if(tstNews(document.fnews))document.fnews.submit()}
function tstEmail(email) {
	if(!email.value.match(/.*?@.*?\.[a-zA-Z][a-zA-Z]/) || email.value.match(/www/)) return false;
	return true;
}
function voltaTopo(id){
	var objDiv = document.getElementById(id);
	objDiv.scrollTop = "0px";
}
function e(mess, obj) {
	alert(mess);
	if(obj) obj.focus();
	return false;
}
/*function tstNum() {
	var tc = event.keyCode;
	if(event.ctrlKey || event.altKey) return;
	if(tc == 38 || tc == 35 || tc == 37 || tc == 36 || tc == 39 || tc==40 || tc==41 || tc==43 || tc==45 || tc==46 || tc==127 || tc <= 31 || (tc >= 48 && tc <= 57) || (tc>=96 && tc<=105)) return;
	event.returnValue=false;
}*/

function tstNum(e)
{
 	//var charCode = (evt.which) ? evt.which : event.keyCode;

	var charCode;
	if(vv_browser == 2) { // IE
		charCode=e.keyCode;
	} else {
		charCode=e.which;
	}
	
	 if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 95 || charCode > 105)){
	 	if(vv_browser == 2) {
	 		e.returnValue=false;
	 	} else {
	 		e.preventDefault();
	 	}
	 }
	 return true; 	
 	
	/*
	if (charCode > 31 && (charCode < 48 || charCode > 57)) {
 		return false;
 	}
 	return true;*/
}

function tstNum2(evt)
{
 var charCode = (evt.which) ? evt.which : event.keyCode
 if (charCode > 31 && ((charCode < 48 && charCode!=45)|| charCode > 57))
	return false;
 return true;
}

function tstMoney(campo) {
	var tc = event.keyCode;
	if(event.ctrlKey || event.altKey) return;
	if(tc == 110) tc = 188;
	if(tc == 188 && campo.value.lastIndexOf(',')!=-1) {
		event.returnValue=false;
		return;
	}
	if(tc == 109 || tc == 189 || tc==188 || tc==45 || tc==127 || tc <= 31 || tc==144 || (tc >= 35 && tc <= 40) || (tc >= 46 && tc <= 57) || (tc>=96 && tc<=105)) return;
	event.returnValue=false;
}
function ow(url, w, h) {
	var wd = window.open(url, "IMG", "width="+w+",height="+(h+30)+",location=no,menubar=no,personalbar=no,resizable=no,scrollbars=no,status=no,titlebar=yes,toolbar=no");
	if(wd) wd.focus();
}

function tstDataFinal(data) {
	var res = null;
	if(!(res = data.value.split(/-/)) || res.length!=3) return e("Data Inv�lida", data);
	var dia = parseInt(res[0], 10);
	var mes = parseInt(res[1], 10);
	var ano = parseInt(res[2], 10);
	if(dia > 31) return 1; //Indique correctamente o dia da data
	if(mes > 12) return 2; //Indique correctamente o mês da data
	if(ano < 1900) return 3; //Indique correctamente o ano da data
	return true;
}

function tstsnd(f,rd) {
	if (rd.checked) return true;
	else for (x = 0; x < rd.length; x++) if (rd[x].checked) return true;
	return e("Por favor, selecione uma resposta");
}
function tstCB(rd) {
	if(rd.checked) return true;
	else for (x = 0; x < rd.length; x++) if (rd[x].checked) return true;
	return false;
}
function dn(url, func) {
	if(!func) func = dn1;
	var xd = null;
	try {
		xd = (vv_browser == 2?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest());
		if(xd) {
			xd.open("GET",url,true);
			xd.onreadystatechange=function() {if(xd.readyState == 4 && xd.status == 200) func(xd.responseText);};
    		xd.send(null);
  	 	}
    } catch(e) {}
}

var vv_browser = 0;
var vv_version = 0;
var vv_cookies = 0;
getVersion();

function getVersion() {
	var agt=navigator.userAgent.toLowerCase();
	var is_major = parseInt(navigator.appVersion);
	var is_minor = parseFloat(navigator.appVersion);

	var is_nav = is_ie = 0;
	var res = null;
	if((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
		&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
		&& (agt.indexOf('webtv')==-1)) {
		vv_browser = 1;
		if(is_major == 2) vv_version = 2;
		else if(is_major == 3) vv_servion = 3;
		else if(is_major == 4) vv_servion = 4;
		else if(is_major == 5) vv_version = 5;
		else if(is_major >= 5) vv_version = 6;
  	} else if(res = agt.match(/msie (\d+)\.(\d+)/)) {
		vv_browser = 2;
		if(is_major < 4) vv_version = 6;
		else if(res[1] == 5 && res[2] == 0) vv_version = 7;
		else if(res[1] == 5 && res[2]) vv_version = 8;
		else if(res[1] == 6 && !res[2]) vv_version = 9;
		else if(res[1] == 6 && res[2]) vv_version = 10;
	} else if(agt.indexOf("aol") != -1) {
		vv_browser = 4;
		if(is_major < 4) vv_version = 11;
		else if(is_major == 4 && agt.indexOf("msie 5.0")==-1) vv_version = 12;
	} else if(agt.indexOf("opera") != -1) vv_browser = 5;
	else if(agt.indexOf("webtv") != -1) vv_browser = 3;
	vv_cookies = (window.navigator.cookieEnabled?1:0);
}

function tstDataErro(data) {
	var res = null;
	if(!(res = data.value.split(/-/)) || res.length!=3) return false;
	var dia = parseInt(res[0], 10);
	var mes = parseInt(res[1], 10);
	var ano = parseInt(res[2], 10);
	if(dia > 31) return false;
	if(mes > 12) return false;
	if(ano < 1900) return false;
	return true;
}

/*Adicionado por Joana para fazer a cena de aumentar o tamanho da fonte. Teste na pini "Alterar tamanho do texto*/

var tam = 15;

function mudaFonte(tipo,elemento){

	if (tipo=="mais") {
		if(tam<24) tam+=1;
		createCookie('fonte',tam,365);
	} else {
		if(tam>10) tam-=1;
		createCookie('fonte',tam,365);
	}
	document.getElementById('txt_home').style.fontSize = tam+'px';
}

function createCookie(name,value,days) {

	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
		} else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
}

 

function readCookie(name) {

	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;

}

/*fim*/


function loadTo(u) {
	dn(u, dn100); 
}
function dn100(s) {
	document.getElementById('BOLDES').innerHTML = s;
}

function loadTo2(u) {
	dn(u, dn1001); 
}
function dn1001(s) {
	document.getElementById('REVDES').innerHTML = s;
}

function loadTo3(u) {
	dn(u, dn1003); 
}
function dn1003(s) {
	document.getElementById('NOTDES').innerHTML = s;
}




function loadTo4(u) {
	dn(u, dn1004); 
}
function dn1004(s) {
	document.getElementById('HOME_INQ').innerHTML = s;
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//Teste
function bodyOnReady(func){    
	done = false   
init = function()
{ if(!done) { done=true; func() } } 
	var d=document; //apelido para o document  
	//pra quem tem o DOMContent (FF)  
	if(document.addEventListener){ d.addEventListener("DOMContentLoaded", init, false );}  
	if( /msie/i.test( navigator.userAgent ) ){
		//IE       
		(function () {            try { // throws errors until after ondocumentready     
			d.documentElement.doScroll("left");            } catch (e) {                setTimeout(arguments.callee, 10); return;            }            // no errors, fire  
			init();        })();    }    if ( window.opera ){        d.addEventListener( "DOMContentLoaded", function () {            if (done) return;            //no opera, os estilos só são habilitados no fim do DOMready    
			for (var i = 0; i < d.styleSheets.length; i++){                if (d.styleSheets[i].disabled)                    setTimeout( arguments.callee, 10 ); return;            }            // fire 
			init();        }, false);    }    if (/webkit/i.test( navigator.userAgent )){ //safari's   
				if(done) return;        //testando o readyState igual a loaded ou complete    
				if ( /loaded|complete/i.test(d.readyState)===false ) {            setTimeout( arguments.callee, 10 );    return;        }        init();    }  
			//se nada funfou eu mando a velha window.onload lenta mesmo  
			if(!done) window.onload = init}


function bodyOnReady2(func){    
	done = false   
init = function()
{ if(!done) { done=true; func() } } 
	var d=document; //apelido para o document  
	//pra quem tem o DOMContent (FF)  
	if(document.addEventListener){ d.addEventListener("DOMContentLoaded", init, false );}  
	if( /msie/i.test( navigator.userAgent ) ){
		//IE       
		(function () {            try { // throws errors until after ondocumentready     
			d.documentElement.doScroll("left");            } catch (e) {                setTimeout(arguments.callee, 10); return;            }            // no errors, fire  
			init();        })();    }    if ( window.opera ){        d.addEventListener( "DOMContentLoaded", function () {            if (done) return;            //no opera, os estilos só são habilitados no fim do DOMready    
			for (var i = 0; i < d.styleSheets.length; i++){                if (d.styleSheets[i].disabled)                    setTimeout( arguments.callee, 10 ); return;            }            // fire 
			init();        }, false);    }    if (/webkit/i.test( navigator.userAgent )){ //safari's   
				if(done) return;        //testando o readyState igual a loaded ou complete    
				if ( /loaded|complete/i.test(d.readyState)===false ) {            setTimeout( arguments.callee, 10 );    return;        }        init();    }  
			//se nada funfou eu mando a velha window.onload lenta mesmo  
			if(!done) window.onload = init}

