function limpar(caixa)
{
	if (caixa.value == 'insira aqui o seu email')
	{
		caixa.value = '';
	}
}
function preenche(caixa)
{
	if (caixa.value == '')
	{
		caixa.value = 'insira aqui o seu email';
	}
}

function openC(id)
{
	if (document.getElementById(id).className == 'close')
	{
		document.getElementById(id).className = 'addComent';
	}
	else
	{
		document.getElementById(id).className = 'close';
	}
}

/*function menu(thisID, thatID)
{
	if (document.getElementById(thisID).className == 'menuBtn')
	{
		if (document.getElementById(thatID).className == 'closed')
		{
			document.getElementById(thisID).className = 'selected';
			document.getElementById(thatID).className = 'subMenu1';
		}
	}
	else {
		if (document.getElementById(thatID).className == 'subMenu1')
		{
			document.getElementById(thisID).className = 'menuBtn';
			document.getElementById(thatID).className = 'closed';
		}
	}
}

function subMenu(thisID, thatID)
{
	if (document.getElementById(thisID).className == 'linkSubMenu')
	{
		document.getElementById(thisID).className = 'linkSubMenuSelected';
		document.getElementById(thatID).className = 'subMenu2';
	}
	else
	{
		document.getElementById(thisID).className = 'linkSubMenu';
		document.getElementById(thatID).className = 'closed';
	}
}
*/
function lv2Menu(idBtn,idSub){
	if(document.getElementById(idBtn).className==''){
		document.getElementById(idBtn).className='hovered';
		document.getElementById(idSub).className='lv2';
	}else{
		document.getElementById(idBtn).className='';
		document.getElementById(idSub).className='closed';
	}
}
function lv3Menu(idBtn,idSub){
	if(document.getElementById(idSub).className=='closed'){
		document.getElementById(idBtn).className='wSubHovered';
		document.getElementById(idSub).className='lv3';
	}else{
		document.getElementById(idBtn).className='wSub';
		document.getElementById(idSub).className='closed';
	}
}


function validacao_form(obri,campo,formato){
	ok=validacao_obrigatorio(obri);
	if (ok==false) {
		return ok;
	}
	ok=validacao_formato(campo,formato);
	return ok;
}

function validacao_obrigatorio(campo){
	for (i=0 ;i<campo.length;i++) {
		if (typeof(document.getElementById(campo[i]))=="object") {
			if (document.getElementById(campo[i]).value=='') {
				document.getElementById(campo[i]).focus();
				alert("Tem que preencher os campos obrigatórios");
				return false;
			}
		}else{
			var campos=document.getElementById(campo[i]+"[]");
			var ok=false;
			if (campos.length>1){
				for (y=0;y<campos.length ;y++ ) {
					if (campos[y].checked==true) {
						ok=true;
					}
				}
			}else{
				if (campos.checked==true) {
					ok=true;
				}
			}
			if (ok==false){
				campos.focus();
				alert("Tem que preencher os campos obrigatórios");
				return false;
			}
		}
	}
	return true;
}

function validacao_formato(campo,formato){
	for (i=0;i<campo.length;i++) {
		valor=document.getElementById(campo[i]).value;
		if (valor!=''){
			switch (formato[i]) {
				case '2':
					var validformat=/^[0-9\.,]+$/;
					if (!validformat.test(valor)) {
						document.getElementById(campo[i]).focus();
						alert("O campo não esta correctamente preenchido.\nO campo tem que ser em formato numérico");
						return false;
					}
					break
				case '3':
					var validformat=/^[a-zA-Z0-9\-\._]+@[a-zA-Z0-9\-_]+(\.?[a-zA-Z0-9\-_]*)\.[a-zA-Z]{2,3}$/;
					if (!validformat.test(valor)) {
						document.getElementById(campo[i]).focus();
						alert("O campo não esta correctamente preenchido.\nO campo não tem um email válido");
						return false;
					}
					break
				case '4':
					var validformat=/^\d{2}-\d{2}-\d{4}$/;
					if (!validformat.test(valor)) {
						document.getElementById(campo[i]).focus();
						alert("O campo não esta correctamente preenchido.\nO campo não tem uma data válida (dd-mm-aaaa)");
						return false;
					}
					break
			}
		}
	}
	return true;
}


function coment_move(id){
	var i=1;
	while(document.getElementById('page_coments'+i)){
		if (id==i) {
			document.getElementById('page_coments'+i).className='';
		}else{
			document.getElementById('page_coments'+i).className='close';
		}
		i++;
	}
	return false;
}

function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
