

// Verifica o formulario
function VerForm(){
	var form = document.contato;
	var cp = "";
	var erro = "";
	var val = "";
	var campos = arguments;
	Element.hide('erros');
	for(var i=0;i<campos.length;i++){
		cp = campos[i];
		val = "";
		if(form[cp].type=="select-one"){
			val = form[cp].selectedIndex;
			if(val<1) val = 0;
		}
		else{
			//if(form[cp].value!=form[cp].defaultValue) val = form[cp].value;
			val = form[cp].value;
		}
		cp = cp.replace(/ /g,'_');
		if(!val || val==0){
			erro = 1;
			Element.addClassName('c'+cp,'erro');
		}
		else{
			Element.removeClassName('c'+cp,'erro');
		}
	}
	if(erro){
		Element.show('erros');
		return false;
	}
	return true;
}


// abre o informativo
function AbreInformativo(informativo,artigo,lang){
	var lar = 810;
	var alt = 500;
	var langb = (lang=="en") ? "_en" : "";
	var lang = (lang) ? "l="+lang : "";
	var centrar = MyLib.Central(lar,alt);
	var nova = window.open(SUBPASTA+"/informativo"+langb+".php?"+lang+"&informativo="+informativo+"&artigo="+artigo, "informativo", "width="+lar+",height="+alt+",left="+centrar[0]+",top="+centrar[1]+",scrollbars=yes"+",resizable=1");
	if (window.focus) {nova.focus()}
}

// abre o informativo
function AbreTodosInformativo(informativo,lang){
	var lar = 810;
	var alt = 500;
	var langb = (lang=="en") ? "_en" : "";
	var lang = (lang) ? "l="+lang : "";
	var centrar = MyLib.Central(lar,alt);
	var nova = window.open(SUBPASTA+"/informativo"+langb+".php?"+lang+"&informativo="+informativo+"&t=1", "informativo", "width="+lar+",height="+alt+",left="+centrar[0]+",top="+centrar[1]+",scrollbars=yes"+",resizable=1");
	if (window.focus) {nova.focus()}
}

// mostra o video do youtube
function MostraVideo(id){
	$('video').innerHTML="<div id=\"videocont\"></div>";
	var jan = $('main').getDimensions();
	var tam = new Array(640,360);
	var box_scr = MyLib.getScrollXY();
	var centrar_videcont = MyLib.CentralArea(tam[0],tam[1]);
	$('videocont').setStyle({
		'width' : tam[0]+'px',
		'height' : tam[1]+'px',
		'left' : centrar_videcont[0]+'px',
		'top' : parseInt(centrar_videcont[1])+parseInt(box_scr[1])-45+'px',
	});
	$('video').setStyle({'height' : jan.height+'px'});
	$('videocont').innerHTML='<a href="#" onclick="VideoFecha();return false" class="fecha"><img src="/imgs/close.png" alt="" /></a></br /><iframe width="'+tam[0]+'" height="'+tam[1]+'" src="http://www.youtube.com/embed/'+id+'?rel=0&autoplay=1" frameborder="0" allowfullscreen></iframe>';
	Element.show('video');
}
function VideoFecha(){
	$('video').innerHTML="";
	Element.hide('video');
}
// mostra a imagem grande
function MostraImagem(id,x,y){
	$('video').innerHTML="<div id=\"videocont\"></div>";
	var jan = $('main').getDimensions();
	var tam = tamanho_img(x,y,screen.width-100,jan.height-100);
	var box_scr = MyLib.getScrollXY();
	var centrar_videcont = MyLib.CentralArea(tam[0],tam[1]);
	var top = parseInt(centrar_videcont[1])+parseInt(box_scr[1])-45;
	if(top<0) top = 0;
	$('videocont').setStyle({
		'width' : tam[0]+'px',
		'height' : tam[1]+'px',
		'left' : centrar_videcont[0]+'px',
		'top' : top+'px',
	});
	$('video').setStyle({'height' : parseInt(jan.height)+100+'px'});
	$('videocont').innerHTML='<a href="#" onclick="VideoFecha();return false" class="fecha"><img src="/imgs/close.png" alt="" /></a></br /><a href="#" onclick="VideoFecha();return false"><img src="'+id+'" width="'+tam[0]+'" height="'+tam[1]+'" /></a>"';
	Element.show('video');
}


function img_reduz(x,y,max,inv){
	var coi = (x/max);
	x = max;
	y = parseInt(y/coi);
	if(typeof(inv)!='undefined'){
		var tmp = x;
		x = y;
		y = tmp;
	}
	return new Array(x,y)
}
function tamanho_img(x,y,max_x,max_y){
	var tam = Array(x, y);
	var ver = {'x':0, 'y': 0};
	if(tam[0]<=max_x && tam[y]<=max_y) return tam;
	if(typeof(max_x)=='number' && max_x>0) ver.x = 1;
	if(typeof(max_y)=='number' && max_y>0) ver.y = 1;
	if(!ver.x && !ver.y) return tam;
	if(tam[0]>=tam[1]){
		if(tam[0]>max_x && ver.x) tam = img_reduz(tam[0],tam[1],max_x);
		if(tam[1]>max_y && ver.y) tam = img_reduz(tam[1],tam[0],max_y,1);
	}
	else{
		if(tam[1]>max_y && ver.y) tam = img_reduz(tam[1],tam[0],max_y,1);
		if(tam[0]>max_x && ver.x) tam = img_reduz(tam[0],tam[1],max_x);
	}
	return tam;
}


////////////////////////////////////////////////////////////////////////////////////

var message = "Caro usuário, não é possível copiar este conteúdo.\nPara qualquer outro tipo de transmissão, é necessária autorização prévia. Sendo este o caso, entre em contato conosco. Obrigado";
var JA = false;

function copyright (){
	if(!JA) alert(message);
	JA = true;
	setTimeout('JA=false',1000);
}

// exibe a mensagem de alerta ao dar ctrl-c ou ctrl-a em browsers não-IE
if ((document.getElementById || document.layers) && (!document.all)) {
	document.onkeypress = function (evt) {
		var r = '';
		var ctrl = 0;
		if (document.getElementById && (!document.all)) ctrl = evt.ctrlKey;
		else if (document.layers) ctrl = Event.CONTROL_MASK;
		r = String.fromCharCode(evt.which).toUpperCase();
		if (ctrl){
			if (r=='C'){
				if(!JA) alert(message);
				JA = true;
				setTimeout('JA=false',1000);
			}
		}
	}
}

