// Função para abrir o Popup da Página

function popup_imagem(pag,largura,altura,barra)
{var Wnd = window.open(pag,"Janela","toolbar=no,location=no,directories=no,scrollbars=yes,resizable=no,copyhistory=no,width="+largura+ ",height="+altura+ ",status=no,left=1, top=1");
	 Wnd.focus();
}

function popup() {
w = 778;
h = 560;
posH = (screen.height - h) / 2;
posW = (screen.width - w) / 2;
window.open('principal.php','MoreiraOrtence','width='+w+',height='+h+',top='+posH+',left='+posW);
}


// 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
}

function AlteraAcompanhe( campo_selecionado ) {
	url = 'acompanhe.php?id=' + campo_selecionado.value;
	location=(url);
}

//Funcao para validacao de e-mail
function valida_email( email ) {
	//Expressao Regular utilizada para validar o endereco de email
	var ExpReg = /^[a-zA-Z0-9_\.-]{2,}@([A-Za-z0-9_-]{2,}\.)+[A-Za-z]{2,4}$/;
	if ( !ExpReg.test(email) ) {
		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 ( $('nome').value == "" ) {
		alert("O campo NOME é obrigatório!");
		$('nome').focus();
		return false;
	}

	if ( $('email').value == "" ) {
		alert("O campo E-MAIL é obrigatório!");
		$('email').focus();
		return false;
	}

	if ( $('email').value != "" ) {
		if ( !valida_email( $('email').value ) ) {
			alert("Seu E-MAIL não é válido!");
			$('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 ( $('mensagem').value == "" ) {
		alert("O campo MENSAGEM é obrigatório!");
		$('mensagem').focus();
		return false;
	}
	return true;
}

//Validacao de Indicacao
function valida_indique() {
	if ( $('seunome').value == "" ) {
		alert("O campo Seu Nome é obrigatório!");
		$('seunome').focus();
		return false;
	}

	if ( $('seuemail').value == "" ) {
		alert("O campo Seu E-mail é obrigatório!");
		$('seuemail').focus();
		return false;
	}

	if ( $('seuemail').value != "" ) {
		if ( !valida_email( $('seuemail').value ) ) {
			alert("Seu E-mail não é válido!");
			$('seuemail').focus();
			return false;
		}
	}
	
	if ( $('nomeamigo').value == "" ) {
		alert("O campo Nome do Amigo(a) é obrigatório!");
		$('nomeamigo').focus();
		return false;
	}

	if ( $('emailamigo').value == "" ) {
		alert("O campo E-mail do Amigo(a) é obrigatório!");
		$('emailamigo').focus();
		return false;
	}

	if ( $('emailamigo').value != "" ) {
		if ( !valida_email( $('emailamigo').value ) ) {
			alert("O campo E-mail do Amigo(a) não é válido!");
			$('emailamigo').focus();
			return false;
		}
	}

	if ( $('comentario').value == "" ) {
		alert("O campo Comentário é obrigatório!");
		$('comentario').focus();
		return false;
	}
	return true;
}

function valida_data() {
	var date = $('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");
		$('data').focus();
	}
}

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);
}

///////////////////////////////////////////////////////////


/*
 * This file contains functions to generate OBJECT and EMBED tags for QuickTime content. 
 */

/************** LOCALIZABLE GLOBAL VARIABLES ****************/

var gArgCountErr =	'The "%%" function requires an even number of arguments.'
				+	'\nArguments should be in the form "atttributeName", "attributeValue", ...';

/******************** END LOCALIZABLE **********************/

var gTagAttrs				= null;
var gQTGeneratorVersion		= 1.0;

function AC_QuickTimeVersion()	{ return gQTGeneratorVersion; }

function _QTComplain(callingFcnName, errMsg)
{
    errMsg = errMsg.replace("%%", callingFcnName);
	alert(errMsg);
}

function _QTAddAttribute(prefix, slotName, tagName)
{
	var		value;

	value = gTagAttrs[prefix + slotName];
	if ( null == value )
		value = gTagAttrs[slotName];

	if ( null != value )
	{
		if ( 0 == slotName.indexOf(prefix) && (null == tagName) )
			tagName = slotName.substring(prefix.length); 
		if ( null == tagName ) 
			tagName = slotName;
		return tagName + '="' + value + '" ';
	}
	else
		return "";
}

function _QTAddObjectAttr(slotName, tagName)
{
	// don't bother if it is only for the embed tag
	if ( 0 == slotName.indexOf("emb#") )
		return "";

	if ( 0 == slotName.indexOf("obj#") && (null == tagName) )
		tagName = slotName.substring(4); 

	return _QTAddAttribute("obj#", slotName, tagName);
}

function _QTAddEmbedAttr(slotName, tagName)
{
	// don't bother if it is only for the object tag
	if ( 0 == slotName.indexOf("obj#") )
		return "";

	if ( 0 == slotName.indexOf("emb#") && (null == tagName) )
		tagName = slotName.substring(4); 

	return _QTAddAttribute("emb#", slotName, tagName);
}


function _QTAddObjectParam(slotName, generateXHTML)
{
	var		paramValue;
	var		paramStr = "";
	var		endTagChar = (generateXHTML) ? ' />' : '>';

	if ( -1 == slotName.indexOf("emb#") )
	{
		// look for the OBJECT-only param first. if there is none, look for a generic one
		paramValue = gTagAttrs["obj#" + slotName];
		if ( null == paramValue )
			paramValue = gTagAttrs[slotName];

		if ( 0 == slotName.indexOf("obj#") )
			slotName = slotName.substring(4); 
	
		if ( null != paramValue )
			paramStr = '  <param name="' + slotName + '" value="' + paramValue + '"' + endTagChar + '\n';
	}

	return paramStr;
}

function _QTDeleteTagAttrs()
{
	for ( var ndx = 0; ndx < arguments.length; ndx++ )
	{
		var attrName = arguments[ndx];
		delete gTagAttrs[attrName];
		delete gTagAttrs["emb#" + attrName];
		delete gTagAttrs["obj#" + attrName];
	}
}

		

// generate an embed and object tag, return as a string
function _QTGenerate(callingFcnName, generateXHTML, args)
{
	// is the number of optional arguments even?
	if ( args.length < 4 || (0 != (args.length % 2)) )
	{
		_QTComplain(callingFcnName, gArgCountErr);
		return "";
	}
	
	// allocate an array, fill in the required attributes with fixed place params and defaults
	gTagAttrs = new Array();
	gTagAttrs["src"] = args[0];
	gTagAttrs["width"] = args[1];
	gTagAttrs["height"] = args[2];
	gTagAttrs["classid"] = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
	gTagAttrs["pluginspage"] = "http://www.apple.com/quicktime/download/";

	// set up codebase attribute with specified or default version before parsing args so
	//  anything passed in will override
	var activexVers = args[3]
	if ( (null == activexVers) || ("" == activexVers) )
		activexVers = "6,0,2,0";
	gTagAttrs["codebase"] = "http://www.apple.com/qtactivex/qtplugin.cab#version=" + activexVers;

	var	attrName,
		attrValue;

	// add all of the optional attributes to the array
	for ( var ndx = 4; ndx < args.length; ndx += 2)
	{
		attrName = args[ndx].toLowerCase();
		attrValue = args[ndx + 1];

		// "name" and "id" should have the same value, the former goes in the embed and the later goes in
		//  the object. use one array slot 
		if ( "name" == attrName || "id" == attrName )
			gTagAttrs["name"] = attrValue;

		else 
			gTagAttrs[attrName] = attrValue;
	}

	// init both tags with the required and "special" attributes
	var objTag =  '<object '
					+ _QTAddObjectAttr("classid")
					+ _QTAddObjectAttr("width")
					+ _QTAddObjectAttr("height")
					+ _QTAddObjectAttr("codebase")
					+ _QTAddObjectAttr("name", "id")
					+ _QTAddObjectAttr("tabindex")
					+ _QTAddObjectAttr("hspace")
					+ _QTAddObjectAttr("vspace")
					+ _QTAddObjectAttr("border")
					+ _QTAddObjectAttr("align")
					+ _QTAddObjectAttr("class")
					+ _QTAddObjectAttr("title")
					+ _QTAddObjectAttr("accesskey")
					+ _QTAddObjectAttr("noexternaldata")
					+ '>\n'
					+ _QTAddObjectParam("src", generateXHTML);
	var embedTag = '  <embed '
					+ _QTAddEmbedAttr("src")
					+ _QTAddEmbedAttr("width")
					+ _QTAddEmbedAttr("height")
					+ _QTAddEmbedAttr("pluginspage")
					+ _QTAddEmbedAttr("name")
					+ _QTAddEmbedAttr("align")
					+ _QTAddEmbedAttr("tabindex");

	// delete the attributes/params we have already added
	_QTDeleteTagAttrs("src","width","height","pluginspage","classid","codebase","name","tabindex",
					"hspace","vspace","border","align","noexternaldata","class","title","accesskey");

	// and finally, add all of the remaining attributes to the embed and object
	for ( var attrName in gTagAttrs )
	{
		attrValue = gTagAttrs[attrName];
		if ( null != attrValue )
		{
			embedTag += _QTAddEmbedAttr(attrName);
			objTag += _QTAddObjectParam(attrName, generateXHTML);
		}
	} 

	// end both tags, we're done
	return objTag + embedTag + '> </em' + 'bed>\n</ob' + 'ject' + '>';
}

// return the object/embed as a string
function QT_GenerateOBJECTText()
{
	return _QTGenerate("QT_GenerateOBJECTText", false, arguments);
}

function QT_GenerateOBJECTText_XHTML()
{
	return _QTGenerate("QT_GenerateOBJECTText_XHTML", true, arguments);
}

function QT_WriteOBJECT()
{
	document.writeln(_QTGenerate("QT_WriteOBJECT", false, arguments));
}

function QT_WriteOBJECT_XHTML()
{
	document.writeln(_QTGenerate("QT_WriteOBJECT_XHTML", true, arguments));
}


