// JavaScript Document
function setState(id) {
	var o = document.getElementById(id);
	var isrc = o.src.split('/');
	var iname = isrc[isrc.length - 1];
	var status = iname.substring(2,3);
	var s = id.substring(1);
	var ss = 's'+s;
	var sm = document.getElementById(ss);
	if(status =='i' || status =='o') {
		if(status == 'i') {
			var newname = iname.replace(/_i_/, '_o_');
			if(sm) sm.style.display ='block';			
			if(typeof(activeSub) != 'undefined' && activeSub != ss) hideSub(0);
			activeSub = ss;
		} else if(status == 'o') {			
			var newname = iname.replace(/_o_/, '_i_');
			to = setTimeout(function() {
				if(sm) sm.style.display ='none';
			},2000);			
		}
		isrc[isrc.length - 1] = newname;
		o.src = isrc.join('/');
	}
}

function keepSub(id) {
	if(typeof(to) != 'undefined' ) clearTimeout(to);
}
function hideSub(id) {
	if(id == 0) {
		id = activeSub;
	}
	var sm = document.getElementById(id);
	if(sm) sm.style.display ='none';
}

function chkForm_Contato() {
	var e = document.getElementById('email').value;
	var n = document.getElementById('nome').value;
	var m = document.getElementById('mensagem').value;
	
	var msg = new Array();
	if(n.length < 5) {
		msg.push('Nome deve conter 5 ou mais caracteres');
	}
	if(e.indexOf('@') == -1 || e.length < 8) {
		msg.push('E-mail inválido');
	}
	if(m.length < 10) {
		msg.push('Sua mensagem deve conter mais de 10 caracteres');
	}
	
	if(msg.length == 0) {
		return true;
	} else {
		alert('Dados incorretos: ' + msg.join(', '));
	}

	return false;
}


function chkForm_Newsletter() {
	var e = document.getElementById('email').value;
	var n = document.getElementById('nome').value;
	
	var msg = new Array();
	if(n.toUpperCase() == 'NOME' || n.length < 5) {
		msg.push('Nome deve conter 5 ou mais caracteres');
	}
	if(e.indexOf('@') == -1 || e.length < 8) {
		msg.push('E-mail inválido');
	}
	
	if(msg.length == 0) {
		return true;
	} else {
		alert('Dados incorretos: ' + msg.join(', '));
	}

	return false;
}

function popWin(param) {
	var wd = window.open('popimage.php?f='+param,'','width=700,height=500,top=10,left=10,resizable=yes,scrollbars=yes');
}

function resize(id) {
	var o = document.getElementById(id);
	window.resizeTo(o.width+30,o.height+35);
}
/*
//fades layer in
ie5  = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);
opac = 0;

function fadeIn(id) {
    if(opac < 100){
        opac+=8;
		if(ie5) document.getElementById(id).style['filter'] = "alpha(opacity = "+opac+")";
        if(ns6) document.getElementById(id).style.opacity = opac/100;
       	setTimeout('fadeIn("'+id+'")', 50);
    }
}
function fadeOut(id) {		
		if(ie5) {
			var getop= document.getElementById(id).style['filter'];
			var tmp = getop.split('=');
			var ieop = tmp[tmp.length - 1].split(')');
			var opc = ieop[0] - 5;
			document.getElementById(id).style['filter'] = "alpha(opacity = "+opc+")";
		}
		if(ns6) {
			var opc = document.getElementById(id).style.opacity - 5;
			document.getElementById(id).style.opacity = opc/100;
		}        
       	setTimeout('fadeOut("'+id+'")', 50);
}
*/

