//////////////////////////////////////////////////////////////////////////////////
////////				   Webroom Soluções Interativa			        //////////
////////					A internet sob Medida						//////////
////////					http://www.webroom.com.br				    //////////
////////			  	  email:: webroom@webroom.com.br				//////////
////////////////////////////////////////////////////////////////////////////////// 


// Correctly handle PNG transparency in Win IE 5.5 or higher.
// http://homepage.ntlworld.com/bobosola. Updated 02-March-2004

function correctPNG() {
	var img;
	var imgName;
	var imgID;
	var imgClass;
	var imgTitle;
	var strNewHTML;
	for ( var i = 0; i < document.images.length; i++ ) {
		img = document.images[i];
		imgName = img.src.toUpperCase();
		if ( imgName.substring(imgName.length-3, imgName.length ) == "PNG") {
			imgID = (img.id) ? "id='" + img.id + "' " : "";
			imgClass = (img.className) ? "class='" + img.className + "' " : "";
			imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if ( img.align == "left" )
				imgStyle = "float:left;" + imgStyle;
			if ( img.align == "right" )
				imgStyle = "float:right;" + imgStyle;
			if ( img.parentElement.href )
				imgStyle = "cursor:hand;" + imgStyle;
			strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML;
			i = i - 1;
		} //if
	} //Fim do for
}

window.attachEvent("onload", correctPNG);

function AlteraAcompanhe( campo_selecionado ) {
	url = 'cronograma.php?id=' + campo_selecionado.value;
	location=(url);
}

var voto;

function popup(pag,largura,altura,barra) {
	var Wnd = window.open(pag,"Janela","toolbar=no,location=no,directories=no,scrollbars="+barra+",resizable=no,copyhistory=no,width="+largura+ ",height="+altura+ ",status=no,left=0, top=1");
	Wnd.focus();
}

//Funcao para setar o Voto
function setVoto(opcao) {
	voto = opcao;
}

//Funcao para Votar
function Votar(enquete,form) {
	if ( voto ) {
//		document.FormEnquete.reset();
		window.open('enquete.php?enquete=' + enquete + '&opcao=' + voto + '&votar=ok','Votação','width=350,height=350,status=yes');
	}
	else
		alert("Você precisa escolher uma opção para votar!!");
}

//Funcao para ver os Votos
function VerVotos(enquete) {
	window.open('enquete.php?enquete=' + enquete,'Votação','width=350,height=350,status=yes');
}

function popup(pag,largura,altura,barra) {
	var Wnd = window.open(pag,"Janela","toolbar=no,location=no,directories=no,scrollbars="+barra+",resizable=no,copyhistory=no,width="+largura+ ",height="+altura+ ",status=no,left=0, top=1");
	Wnd.focus();
}

//Funcao Utilizada para validar os campos do formulário para associar
function ValidaCampo(valor,campo) {
	MudaMouse(1);
	iframe_validacao.location = 'valida_usuario.php?valor=' + valor.value + '&campo=' + campo;
}

//Validacao de campos
function DadoExiste(campo) {
	alert("Este " + campo + " já existe!\nFavor informar outro!");
	document.getElementById(campo).value = '';
	document.getElementById(campo).focus();
}

//Muda estilo do mouse
function MudaMouse(estilo) {
	if ( estilo == 1 )
		document.body.style.cursor = 'wait';
	else
		document.body.style.cursor = '';
}

//Popup Configuravel
function PopConf(url,nome,tamanho){
	oWindow = window.open(url,nome,tamanho);
	//Posicao da janela no browser.
	oWindow.moveTo(100,80);
}

//Popup padrão
function PopPadrao(url,nome){
	window.open(url,nome,'width=600,height=400');
}

//Validacao da Newsletter
function valida_newsletter() {
	if ( document.FormNewsletter.nome.value == "" ) {
		alert("O campo NOME é obrigatório!");
		document.FormNewsletter.nome.focus();
		return false;
	}

	if ( document.FormNewsletter.email.value == "" ) {
		alert("O campo E-MAIL é obrigatório!");
		document.FormNewsletter.email.focus();
		return false;
	}

	if ( document.FormNewsletter.email.value != "" ) {
		if ( document.FormNewsletter.email.value.indexOf("@") == -1 || document.FormNewsletter.email.value.indexOf(".") == -1 || document.FormNewsletter.email.value.indexOf(" ") != -1 || document.FormNewsletter.email.value.length < 6 ) {
			alert("Seu E-MAIL não é válido!");
			document.FormNewsletter.email.focus();
			return false;
		}
	}
	return true;
}

function $(s) {
	return document.getElementById(s);
}

function F(s) {
	return document.getElementById(s).value;
}

//Validacao de Contato
function valida_contato() {
	if ( document.getElementById('nome').value == "" ) {
		alert("O campo NOME é obrigatório!");
		document.getElementById('nome').focus();
		return false;
	}

	if ( document.getElementById('email').value == "" ) {
		alert("O campo E-MAIL é obrigatório!");
		document.getElementById('email').focus();
		return false;
	}

	if ( document.getElementById('email').value != "" ) {
		if ( document.getElementById('email').value.indexOf("@") == -1 || document.getElementById('email').value.indexOf(".") == -1 || document.getElementById('email').value.indexOf(" ") != -1 || document.getElementById('email').value.length < 6 ) {
			alert("Seu E-MAIL não é válido!");
			document.getElementById('email').focus();
			return false;
		}
	}
	
	if ( $('cliente_mo_s').checked == true ) {
		if ( F('nome_proprietario') == "" ) {
			alert("O campo NOME DO PROPRIETÁRIO é obrigatório!");
			$('nome_proprietario').focus();
			return false;
		}
		if ( F('empreendimento') == "" ) {
			alert("O campo EMPREENDIMENTO é obrigatório!");
			$('empreendimento').focus();
			return false;
		}
		if ( F('edificio') == "" ) {
			alert("O campo EDIFÍCIO é obrigatório!");
			$('edificio').focus();
			return false;
		}
		if ( F('apartamento') == "" ) {
			alert("O campo APARTAMENTO é obrigatório!");
			$('apartamento').focus();
			return false;
		}
	}

	if ( document.getElementById('mensagem').value == "" ) {
		alert("O campo MENSAGEM é obrigatório!");
		document.getElementById('mensagem').focus();
		return false;
	}
	return true;
}

//Validacao de Indicacao
function valida_indique() {
	if ( document.getElementById('seunome').value == "" ) {
		alert("O campo Seu Nome é obrigatório!");
		document.getElementById('seunome').focus();
		return false;
	}

	if ( document.getElementById('seuemail').value == "" ) {
		alert("O campo Seu E-mail é obrigatório!");
		document.getElementById('seuemail').focus();
		return false;
	}

	if ( document.getElementById('seuemail').value != "" ) {
		if ( document.getElementById('seuemail').value.indexOf("@") == -1 || document.getElementById('seuemail').value.indexOf(".") == -1 || document.getElementById('seuemail').value.indexOf(" ") != -1 || document.getElementById('seuemail').value.length < 6 ) {
			alert("Seu E-mail não é válido!");
			document.getElementById('seuemail').focus();
			return false;
		}
	}
	
	if ( document.getElementById('nomeamigo').value == "" ) {
		alert("O campo Nome do Amigo(a) é obrigatório!");
		document.getElementById('nomeamigo').focus();
		return false;
	}

	if ( document.getElementById('emailamigo').value == "" ) {
		alert("O campo E-mail do Amigo(a) é obrigatório!");
		document.getElementById('emailamigo').focus();
		return false;
	}

	if ( document.getElementById('emailamigo').value != "" ) {
		if ( document.getElementById('emailamigo').value.indexOf("@") == -1 || document.getElementById('emailamigo').value.indexOf(".") == -1 || document.getElementById('emailamigo').value.indexOf(" ") != -1 || document.getElementById('emailamigo').value.length < 6 ) {
			alert("O campo E-mail do Amigo(a) não é válido!");
			document.getElementById('emailamigo').focus();
			return false;
		}
	}

	if ( document.getElementById('comentario').value == "" ) {
		alert("O campo Comentário é obrigatório!");
		document.getElementById('comentario').focus();
		return false;
	}
	return true;
}

function valida_data() {
	var date = document.getElementById('data').value;
	var array_data = new Array;
	//vetor que contem o dia o mes e o ano
	array_data = date.split("/");
	erro = false;
	//Valido se a data esta no formato dd/mm/yyyy
	if ( date.search("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/[12][0-9]{3}") == -1 )
		erro = true;
	//Valido os meses que nao tem 31 dias com execao de fevereiro
	if ( ( ( array_data[1] == 4 ) || ( array_data[1] == 6 ) || ( array_data[1] == 9 ) || ( array_data[1] == 11 ) ) && ( array_data[0] > 30 ) )
		erro = true;
	//Valido o mes de fevereiro
	if ( array_data[1] == 2 ) {
		//Valido ano que nao e bissexto
		if ( ( array_data[0] > 28 ) && ( ( array_data[2] % 4 ) != 0 ) )
			erro = true;
		//Valido ano bissexto
		if ( ( array_data[0] > 29 ) && ( ( array_data[2] % 4 ) == 0 ) )
			erro = true;
	}
	if ( erro ) {
		alert("Data Inválida");
		document.getElementById('data').focus();
	}
}

//Funcao que oculta ou exibe as DIVS
function ShowHiddenDiv(elemento, botao, pos) {
	if ( document.layers ) {
		document.layers[elemento].visibility = referencia[pos] ? "show" : "hide";
		document.layers[elemento].position = referencia[pos] ? "relative" : "absolute";
		referencia[pos] = !(referencia[pos]);
		if ( referencia[pos] == 0 )
			document.layers[botao].src = 'imagens/menos.gif';
		else
			document.layers[botao].src = 'imagens/mais.gif';
	} //if ( document.layers )
	else if ( document.getElementById ) {
		var obj = document.getElementById(elemento);
		obj.style.visibility = referencia[pos] ? "visible" : "hidden";
		obj.style.position = referencia[pos] ? "relative" : "absolute";
		referencia[pos] = !(referencia[pos]);
		if ( referencia[pos] == 0 )
			document.getElementById(botao).src = 'imagens/menos.gif';
		else
			document.getElementById(botao).src = 'imagens/mais.gif';
	} //Fim do else if ( document.getElementById )
	else if ( document.all ) {
		document.all[elemento].style.visibility = referencia[pos] ? "visible" : "hidden";
		document.all[elemento].style.position = referencia[pos] ? "relative" : "absolute";
		referencia[pos] = !(referencia[pos]);
		if ( referencia[pos] == 0 )
			document.all[botao].src = 'imagens/menos.gif';
		else
			document.all[botao].src = 'imagens/mais.gif';
	} //Fim do else if ( document.all )
} //Fim da function ShowHiddenDiv(elemento, botao, pos)

function fecha_div() {
	document.getElementById('selo_17').style.visibility = "hidden";
}

PositionX = 100;
PositionY = 100;

defaultWidth  = 500;
defaultHeight = 500;
var AutoClose = true;

if ( parseInt(navigator.appVersion.charAt(0) ) >= 4 ) {
  var isNN = ( navigator.appName=="Netscape" ) ? 1 : 0;
  var isIE = ( navigator.appName.indexOf("Microsoft") != -1 ) ? 1 : 0 ;
}

var optNN = 'scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE = 'scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;

function popImage(imageURL,imageTitle) {
	if ( isNN ) {
		imgWin = window.open('about:blank','',optNN);
	} //if
	if ( isIE ) {
		imgWin = window.open('about:blank','',optIE);
	} //if
	with ( imgWin.document ) {
	writeln('<html><head><title>Carregando...</title><style>body{margin:0px;}</style>');
	writeln('<sc'+'ript>');
	writeln('var isNN,isIE;');
	writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
	writeln('isNN=(navigator.appName=="Netscape")?1:0;');
	writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
	writeln('function reSizeToImage(){');
	writeln('if (isIE){');
	writeln('window.resizeTo(100,100);');
	writeln('width=100-(document.body.clientWidth-document.images[0].width);');
	writeln('height=100-(document.body.clientHeight-document.images[0].height);');
	writeln('window.resizeTo(width,height);}');
	writeln('if (isNN){');
	writeln('window.innerWidth=document.images["0"].width;');
	writeln('window.innerHeight=document.images["0"].height;}}');
	writeln('function doTitle(){document.title="'+imageTitle+'";}');
	writeln('</sc'+'ript>');
	if ( !AutoClose )
		writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
	else
		writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
	writeln('<img name="Imagem" src='+imageURL+' style="display:block"></body></html>');
	close();
	} //Fim do with
} //Fim da function popImage(imageURL,imageTitle)

function amplia_imagem( imagem, title, desc ) {
	PositionX = 0;
	PositionY = 0;
	window.open('imagem.php?imagem=' + imagem + '&title=' + title + '&desc=' + desc, '', 'resizable=1,scrollbars=no,width=100,height=100,left='+PositionX+',top='+PositionY);
}


function abre_janela( janela, titulo, defaultWidth, defaultHeight ) {
	window.open(janela, titulo, 'scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+'left=100,top=100');
}

function abre_hotsite(endereco, rolagem, width, height) {
	PositionX = ( screen.width - width ) / 2;
	PositionY = ( screen.height - height ) / 2;
	window.open( endereco + '?site=1', 'HOTSITE', 'resizable=0,scrollbars='+rolagem+',width='+width+',height='+height+',left='+PositionX+',top='+PositionY);
}