function mudaCor(n) {
	document.body.style.backgroundColor = 'rgb(255,255,255)';	
	var cores = new Array('rgb(204,204,204)','rgb(255,212,125)','rgb(176,202,255)','rgb(204,194,155)','rgb(255,212,125)','rgb(217,255,140)');
	document.body.style.backgroundImage = 'url(img/bl1_bck_'+n+'.jpg)';
	document.body.style.backgroundColor = cores[n-1];
	
	var m = document.getElementById("bl2_l1").childNodes;
	if(m.length>10) {
		var i = 0;
		var j = 0;
		for(i=0;i<m.length;i++) {
			if(i>=3 && i<=17) {
				for(j=0;j<m[i].childNodes.length;j++) {
					m[i].childNodes[j].style.backgroundColor = cores[n-1];
				}
			}
		}
	}
	
	if(document.getElementById("bl2_l1_cl1") != undefined) {
		document.getElementById("bl2_l1_cl1").style.backgroundImage = 'url(img/bl2_l1_cl_bck_'+n+'.jpg)';
	}
	
	if(document.getElementById("bl2_l1_cl2") != undefined) {
		document.getElementById("bl2_l1_cl2").style.backgroundImage = 'url(img/bl2_l1_cl_bck_'+n+'.jpg)';
	}
	
	if(document.getElementById("bl2_l1_cl3") != undefined) {
		document.getElementById("bl2_l1_cl3").style.backgroundImage = 'url(img/bl2_l1_cl_bck_'+n+'.jpg)';
	}
}
function abreSuporteMsn() {
	document.getElementById("bl2_cl2").innerHTML = '<iframe src="http://settings.messenger.live.com/Conversation/IMMe.aspx?invitee=570559a4cf22c2f2@apps.messenger.live.com&mkt=pt-br&useTheme=true&themeName=blue&foreColor=333333&backColor=E8F1F8&linkColor=333333&borderColor=AFD3EB&buttonForeColor=333333&buttonBackColor=EEF7FE&buttonBorderColor=AFD3EB&buttonDisabledColor=EEF7FE&headerForeColor=0066A7&headerBackColor=8EBBD8&menuForeColor=333333&menuBackColor=FFFFFF&chatForeColor=333333&chatBackColor=FFFFFF&chatDisabledColor=F6F6F6&chatErrorColor=760502&chatLabelColor=6E6C6C" width="314" height="450" frameborder="0" scrolling="no"></iframe>';
	document.getElementById("bl2_cl2").style.border = '2px solid lightblue';
}
function enviarContato(){
	if(validarContato()){
		document.contato.submit();
	}
}
function validarContato(){
	if(document.contato.Nome.value==''){
		alert("ATENÇÃO!\nNome - Campo obrigatório.");
		document.contato.Nome.focus();
		return false;
	}
	if(document.contato.Email.value==''){
		alert("ATENÇÃO!\nE-mail - Campo obrigatório.");
		document.contato.Email.focus();
		return false;
	}else{
		if(isEmail(document.contato.Email.value)==false){
			alert("ATENÇÃO!\nE-mail inválido.");
			document.contato.Email.focus();
			return false;
		}
	}
	if(document.contato.Telefone.value=='' && document.contato.Celular.value==''){
		alert("ATENÇÃO!\nÉ necessário o preenchimento de pelo menos um dos telefones de contato.");
		document.contato.Telefone.focus();
		return false;
	}
	if(document.contato.Mensagem.value==''){
		alert("ATENÇÃO!\nMensagem - Campo obrigatório.");
		document.contato.Mensagem.focus();
		return false;
	}
	return true;
}
function isNumero(campo) {
	var s = campo.value.length;
	var i = 0;
	var valida = '';
	for(i=0;i<s;i++) {
		if(isFinite(campo.value.charAt(i))) {
			valida += campo.value.charAt(i);
		}
	}
	campo.value = valida;
	return;
}

function mascara(campo,event,tipo){
	var nTecla;

	if(document.all) { // Internet Explorer
		nTecla = event.keyCode;
	} else if(document.layers) { // Nestcape
		nTecla = event.which;
	} else {
		nTecla = event.which;
	}
	
	if(tipo	==	"int"){
		numMenor=0;
		numMaior=9;
		if (nTecla < (48 + numMenor) || nTecla > (48 + numMaior)){
			if (event.preventDefault){ //standart browsers
				event.preventDefault();
			}else{ // internet explorer
				event.returnValue = false;
			}
		}
		//48 a 57 ascII - 0 a 9
	}
	if(tipo	==	"double"){
		var tamMax = campo.maxLength;
		var tam = campo.value.length;
		numMenor=0;
		numMaior=9;
		
		if(nTecla < (48 + numMenor) || nTecla > (48 + numMaior) || tamMax == tam){
			event.returnValue = false
		}else{				
			 mascara_float(campo,'onkeypress');
		}
	}
	if(tipo	==	"float"){
		var tamMax = campo.maxLength;
		var tam = campo.value.length;
		numMenor=0;
		numMaior=9;
		
		if(nTecla < (48 + numMenor) || nTecla > (48 + numMaior) || tamMax == tam){
			event.returnValue = false
		}else{				
			 mascara_double(campo,'onkeypress');
		}
	}
	if(tipo	==	"date"){
		if(campo.value.length>=10){
			return false;
		}
		numMenor=0;
		numMaior=9;
		if (nTecla < (48 + numMenor) || nTecla > (48 + numMaior)){
			event.returnValue = false
			//48 a 57 ascII - 0 a 9
		}
		if(campo.value.length==2 || campo.value.length==5){
			campo.value = campo.value + "/";
		}
	}
	if(tipo	==	"cnpj"){
		if(campo.value.length>=18){
			return false;
		}
		numMenor=0;
		numMaior=9;
		if (nTecla < (48 + numMenor) || nTecla > (48 + numMaior)){
			event.returnValue = false
			//48 a 57 ascII - 0 a 9
		}
		if(campo.value.length==2 || campo.value.length==6){
			campo.value = campo.value + ".";
		}
		if(campo.value.length==10){
			campo.value = campo.value + "/";
		}
		if(campo.value.length==15){
			campo.value = campo.value + "-";
		}
	}
	if(tipo== "cpf"){
		if(campo.value.length>=14){
			return false;
		}
		numMenor=0;
		numMaior=9;
		if (nTecla < (48 + numMenor) || nTecla > (48 + numMaior)){
			event.returnValue = false
			//48 a 57 ascII - 0 a 9
		}
		var mycpf = '';
		mycpf = mycpf + campo;
		if (campo.value.length == 3){
			  campo.value = campo.value + '.';
		}
		if (campo.value.length == 7){
			  campo.value = campo.value + '.';
		}
		if (campo.value.length == 11){
			  campo.value = campo.value + '-';
		}
	}
	if(tipo	==	"fone"){
		if(campo.value.length>=13){
			return false;
		}
		numMenor=0;
		numMaior=9;
		if ((nTecla < (48 + numMenor) || nTecla > (48 + numMaior)) && nTecla != 8){
			if (event.preventDefault){ //standart browsers
				if(nTecla!=9){
					event.preventDefault();
				}
			} else{ // internet explorer
				event.returnValue = false;
			}
			//48 a 57 ascII - 0 a 9
		}
		if(campo.value.length==0 && nTecla != 8){
			campo.value = campo.value + "(";
		}
		if(campo.value.length==3 && nTecla != 8){
			campo.value = campo.value + ")";
		}
		if(campo.value.length==8 && nTecla != 8){
			campo.value = campo.value + "-";
		}
	}
	if(tipo	==	"cep"){
		if(campo.value.length>=9){
			return false;
		}
		numMenor=0;
		numMaior=9;
		if (nTecla < (48 + numMenor) || nTecla > (48 + numMaior)){
			event.returnValue = false
			//48 a 57 ascII - 0 a 9
		}
		if(campo.value.length==5){
			campo.value = campo.value + "-";
		}
	}
	if(tipo	==	"mes"){
		if(campo.value.length>7){
			return false;
		}
		numMenor=0;
		numMaior=9;
		if (nTecla < (48 + numMenor) || nTecla > (48 + numMaior)){
			event.returnValue = false
			//48 a 57 ascII - 0 a 9
		}
		if(campo.value.length==2){
			campo.value = campo.value + "/";
		}
	}
	if(tipo	==	"hora"){
		if(campo.value.length>7){
			return false;
		}
		numMenor=0;
		numMaior=9;
		if (nTecla < (48 + numMenor) || nTecla > (48 + numMaior)){
			event.returnValue = false
			//48 a 57 ascII - 0 a 9
		}
		if(campo.value.length==2){
			campo.value = campo.value + ":";
		}
	}
}
function isEmail(nform){
	if (nform == "") {
		return false;
	}else {
		prim = nform.indexOf("@")
		if(prim < 2) {
			return false;
		}
		if(nform.indexOf("@",prim + 1) != -1) {
			return false;
		}
		if(nform.indexOf(".") < 1) {
			return false;
		}
		if(nform.indexOf(" ") != -1) {
			return false;
		}
		if(nform.indexOf(".@") > 0) {
			return false;
		}
		if(nform.indexOf("@.") > 0) {
			return false;
		}
		if(nform.indexOf("/") > 0) {
			return false;
		}
		if(nform.indexOf("[") > 0) {
			return false;
		}
		if(nform.indexOf("]") > 0) {
			return false;
		}
		if(nform.indexOf("(") > 0) {
			return false;
		}
		if(nform.indexOf(")") > 0) {
			return false;
		}
		if(nform.indexOf("..") > 0) {
			return false;
		}
		if(nform.indexOf("*") > 0) {
			return false;
		}
		if(nform.indexOf("+") > 0) {
			return false;
		}
	}
	return true;
}
