// JavaScript Document
caminho_template = "07";


$(document).ready(function(){
	$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/jquery.colorbox.js"></script>').appendTo('head');
	$('<script language="javascript" type="text/javascript" src="templates/'+caminho_template+'/js/script.js"></script>').appendTo('head');
});

/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CCAttribution-ShareAlike 2.5 Brazil - http://creativecommons.org/licenses/by-sa/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */

// Offering a Custom Alias suport - More info: http://docs.jquery.com/Plugins/Authoring#Custom_Alias
(function($) {
	/**
	 * $ is an alias to jQuery object
	 *
	 */
	$.fn.lightBox = function(settings) {
		// Settings to configure the jQuery lightBox plugin how you like
		settings = jQuery.extend({
			// Configuration related to overlay
			overlayBgColor: 		'#000',		// (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
			overlayOpacity:			0.8,		// (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
			// Configuration related to navigation
			fixedNavigation:		true,		// (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
			// Configuration related to images
			imageLoading:			'templates/'+caminho_template+'/'+idioma+'/img/lightbox-ico-loading.gif',		// (string) Path and the name of the loading icon templates/'+caminho_template+'/'+idioma+'/img/aba_lanc_off.png
			imageBtnPrev:			'templates/'+caminho_template+'/'+idioma+'/img/lightbox-btn-prev.gif',			// (string) Path and the name of the prev button image
			imageBtnNext:			'templates/'+caminho_template+'/'+idioma+'/img/lightbox-btn-next.gif',			// (string) Path and the name of the next button image
			imageBtnClose:			'templates/'+caminho_template+'/'+idioma+'/img/lightbox-btn-close.gif',		// (string) Path and the name of the close btn
			imageBlank:				'templates/'+caminho_template+'/'+idioma+'/img/lightbox-blank.gif',			// (string) Path and the name of a blank image (one pixel)
			// Configuration related to container image box
			containerBorderSize:	10,			// (integer) If you adjust the padding in the CSS for the container, #lightbox-container-image-box, you will need to update this value
			containerResizeSpeed:	100,		// (integer) Specify the resize duration of container image. These number are miliseconds. 400 is default.
			// Configuration related to texts in caption. For example: Image 2 of 8. You can alter either "Image" and "of" texts.
			txtImage:				'Image',	// (string) Specify text "Image"
			txtOf:					'of',		// (string) Specify text "of"
			// Configuration related to keyboard navigation
			keyToClose:				'c',		// (string) (c = close) Letter to close the jQuery lightBox interface. Beyond this letter, the letter X and the SCAPE key is used to.
			keyToPrev:				'p',		// (string) (p = previous) Letter to show the previous image
			keyToNext:				'n',		// (string) (n = next) Letter to show the next image.
			// Don´t alter these variables in any way
			imageArray:				[],
			activeImage:			0
		},settings);
		// Caching the jQuery object with all elements matched
		var jQueryMatchedObj = this; // This, in this context, refer to jQuery object
		/**
		 * Initializing the plugin calling the start function
		 *
		 * @return boolean false
		 */
		function _initialize() {
			_start(this,jQueryMatchedObj); // This, in this context, refer to object (link) which the user have clicked
			return false; // Avoid the browser following the link
		}
		/**
		 * Start the jQuery lightBox plugin
		 *
		 * @param object objClicked The object (link) whick the user have clicked
		 * @param object jQueryMatchedObj The jQuery object with all elements matched
		 */
		function _start(objClicked,jQueryMatchedObj) {
			// Hime some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'hidden' });
			// Call the function to create the markup structure; style some elements; assign events in some elements.
			_set_interface();
			// Unset total images in imageArray
			settings.imageArray.length = 0;
			// Unset image active information
			settings.activeImage = 0;
			// We have an image set? Or just an image? Let´s see it.
			if ( jQueryMatchedObj.length == 1 ) {
				settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));
			} else {
				// Add an Array (as many as we have), with href and title atributes, inside the Array that storage the images references		
				for ( var i = 0; i < jQueryMatchedObj.length; i++ ) {
					settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));
				}
			}
			while ( settings.imageArray[settings.activeImage][0] != objClicked.getAttribute('href') ) {
				settings.activeImage++;
			}
			// Call the function that prepares image exibition
			_set_image_to_view();
		}
		/**
		 * Create the jQuery lightBox plugin interface
		 *
		 * The HTML markup will be like that:
			<div id="jquery-overlay"></div>
			<div id="jquery-lightbox">
				<div id="lightbox-container-image-box">
					<div id="lightbox-container-image">
						<img src="../fotos/XX.jpg" id="lightbox-image">
						<div id="lightbox-nav">
							<a href="#" id="lightbox-nav-btnPrev"></a>
							<a href="#" id="lightbox-nav-btnNext"></a>
						</div>
						<div id="lightbox-loading">
							<a href="#" id="lightbox-loading-link">
								<img src="../images/lightbox-ico-loading.gif">
							</a>
						</div>
					</div>
				</div>
				<div id="lightbox-container-image-data-box">
					<div id="lightbox-container-image-data">
						<div id="lightbox-image-details">
							<span id="lightbox-image-details-caption"></span>
							<span id="lightbox-image-details-currentNumber"></span>
						</div>
						<div id="lightbox-secNav">
							<a href="#" id="lightbox-secNav-btnClose">
								<img src="../images/lightbox-btn-close.gif">
							</a>
						</div>
					</div>
				</div>
			</div>
		 *
		 */
		function _set_interface() {
			// Apply the HTML markup into body tag
			$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"><img src="' + settings.imageLoading + '"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav"><a href="#" id="lightbox-secNav-btnClose"><img src="' + settings.imageBtnClose + '"></a></div></div></div></div>');	
			// Get page sizes
			var arrPageSizes = ___getPageSize();
			// Style overlay and show it
			$('#jquery-overlay').css({
				backgroundColor:	settings.overlayBgColor,
				opacity:			settings.overlayOpacity,
				width:				arrPageSizes[0],
				height:				arrPageSizes[1]
			}).fadeIn();
			// Get page scroll
			var arrPageScroll = ___getPageScroll();
			// Calculate top and left offset for the jquery-lightbox div object and show it
			$('#jquery-lightbox').css({
				top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
				left:	arrPageScroll[0]
			}).show();
			// Assigning click events in elements to close overlay
			$('#jquery-overlay,#jquery-lightbox').click(function() {
				_finish();									
			});
			// Assign the _finish function to lightbox-loading-link and lightbox-secNav-btnClose objects
			$('#lightbox-loading-link,#lightbox-secNav-btnClose').click(function() {
				_finish();
				return false;
			});
			// If window was resized, calculate the new overlay dimensions
			$(window).resize(function() {
				// Get page sizes
				var arrPageSizes = ___getPageSize();
				// Style overlay and show it
				$('#jquery-overlay').css({
					width:		arrPageSizes[0],
					height:		arrPageSizes[1]
				});
				// Get page scroll
				var arrPageScroll = ___getPageScroll();
				// Calculate top and left offset for the jquery-lightbox div object and show it
				$('#jquery-lightbox').css({
					top:	arrPageScroll[1] + (arrPageSizes[3] / 10),
					left:	arrPageScroll[0]
				});
			});
		}
		/**
		 * Prepares image exibition; doing a image´s preloader to calculate it´s size
		 *
		 */
		function _set_image_to_view() { // show the loading
			// Show the loading
			$('#lightbox-loading').show();
			if ( settings.fixedNavigation ) {
				$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
			} else {
				// Hide some elements
				$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();
			}
			// Image preload process
			var objImagePreloader = new Image();
			objImagePreloader.onload = function() {
				$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);
				// Perfomance an effect in the image container resizing it
				_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);
				//	clear onLoad, IE behaves irratically with animated gifs otherwise
				objImagePreloader.onload=function(){};
			};
			objImagePreloader.src = settings.imageArray[settings.activeImage][0];
		};
		/**
		 * Perfomance an effect in the image container resizing it
		 *
		 * @param integer intImageWidth The image´s width that will be showed
		 * @param integer intImageHeight The image´s height that will be showed
		 */
		function _resize_container_image_box(intImageWidth,intImageHeight) {
			// Get current width and height
			var intCurrentWidth = $('#lightbox-container-image-box').width();
			var intCurrentHeight = $('#lightbox-container-image-box').height();
			// Get the width and height of the selected image plus the padding
			var intWidth = (intImageWidth + (settings.containerBorderSize * 2)); // Plus the image´s width and the left and right padding value
			var intHeight = (intImageHeight + (settings.containerBorderSize * 2)); // Plus the image´s height and the left and right padding value
			// Diferences
			var intDiffW = intCurrentWidth - intWidth;
			var intDiffH = intCurrentHeight - intHeight;
			// Perfomance the effect
			$('#lightbox-container-image-box').animate({ width: intWidth, height: intHeight },settings.containerResizeSpeed,function() { _show_image(); });
			if ( ( intDiffW == 0 ) && ( intDiffH == 0 ) ) {
				if ( $.browser.msie ) {
					___pause(250);
				} else {
					___pause(100);	
				}
			} 
			$('#lightbox-container-image-data-box').css({ width: intImageWidth });
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ height: intImageHeight + (settings.containerBorderSize * 2) });
		};
		/**
		 * Show the prepared image
		 *
		 */
		function _show_image() {
			$('#lightbox-loading').hide();
			$('#lightbox-image').fadeIn(function() {
				_show_image_data();
				_set_navigation();
			});
			_preload_neighbor_images();
		};
		/**
		 * Show the image information
		 *
		 */
		function _show_image_data() {
			$('#lightbox-container-image-data-box').slideDown('fast');
			$('#lightbox-image-details-caption').hide();
			if ( settings.imageArray[settings.activeImage][1] ) {
				$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();
			}
			// If we have a image set, display 'Image X of X'
			if ( settings.imageArray.length > 1 ) {
				$('#lightbox-image-details-currentNumber').html(settings.txtImage + ' ' + ( settings.activeImage + 1 ) + ' ' + settings.txtOf + ' ' + settings.imageArray.length).show();
			}		
		}
		/**
		 * Display the button navigations
		 *
		 */
		function _set_navigation() {
			$('#lightbox-nav').show();

			// Instead to define this configuration in CSS file, we define here. And it´s need to IE. Just.
			$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
			
			// Show the prev button, if not the first image in set
			if ( settings.activeImage != 0 ) {
				if ( settings.fixedNavigation ) {
					$('#lightbox-nav-btnPrev').css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' })
						.unbind()
						.bind('click',function() {
							settings.activeImage = settings.activeImage - 1;
							_set_image_to_view();
							return false;
						});
				} else {
					// Show the images button for Next buttons
					$('#lightbox-nav-btnPrev').unbind().hover(function() {
						$(this).css({ 'background' : 'url(' + settings.imageBtnPrev + ') left 15% no-repeat' });
					},function() {
						$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
					}).show().bind('click',function() {
						settings.activeImage = settings.activeImage - 1;
						_set_image_to_view();
						return false;
					});
				}
			}
			
			// Show the next button, if not the last image in set
			if ( settings.activeImage != ( settings.imageArray.length -1 ) ) {
				if ( settings.fixedNavigation ) {
					$('#lightbox-nav-btnNext').css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' })
						.unbind()
						.bind('click',function() {
							settings.activeImage = settings.activeImage + 1;
							_set_image_to_view();
							return false;
						});
				} else {
					// Show the images button for Next buttons
					$('#lightbox-nav-btnNext').unbind().hover(function() {
						$(this).css({ 'background' : 'url(' + settings.imageBtnNext + ') right 15% no-repeat' });
					},function() {
						$(this).css({ 'background' : 'transparent url(' + settings.imageBlank + ') no-repeat' });
					}).show().bind('click',function() {
						settings.activeImage = settings.activeImage + 1;
						_set_image_to_view();
						return false;
					});
				}
			}
			// Enable keyboard navigation
			_enable_keyboard_navigation();
		}
		/**
		 * Enable a support to keyboard navigation
		 *
		 */
		function _enable_keyboard_navigation() {
			$(document).keydown(function(objEvent) {
				_keyboard_action(objEvent);
			});
		}
		/**
		 * Disable the support to keyboard navigation
		 *
		 */
		function _disable_keyboard_navigation() {
			$(document).unbind();
		}
		/**
		 * Perform the keyboard actions
		 *
		 */
		function _keyboard_action(objEvent) {
			// To ie
			if ( objEvent == null ) {
				keycode = event.keyCode;
				escapeKey = 27;
			// To Mozilla
			} else {
				keycode = objEvent.keyCode;
				escapeKey = objEvent.DOM_VK_ESCAPE;
			}
			// Get the key in lower case form
			key = String.fromCharCode(keycode).toLowerCase();
			// Verify the keys to close the ligthBox
			if ( ( key == settings.keyToClose ) || ( key == 'x' ) || ( keycode == escapeKey ) ) {
				_finish();
			}
			// Verify the key to show the previous image
			if ( ( key == settings.keyToPrev ) || ( keycode == 37 ) ) {
				// If we´re not showing the first image, call the previous
				if ( settings.activeImage != 0 ) {
					settings.activeImage = settings.activeImage - 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
			// Verify the key to show the next image
			if ( ( key == settings.keyToNext ) || ( keycode == 39 ) ) {
				// If we´re not showing the last image, call the next
				if ( settings.activeImage != ( settings.imageArray.length - 1 ) ) {
					settings.activeImage = settings.activeImage + 1;
					_set_image_to_view();
					_disable_keyboard_navigation();
				}
			}
		}
		/**
		 * Preload prev and next images being showed
		 *
		 */
		function _preload_neighbor_images() {
			if ( (settings.imageArray.length -1) > settings.activeImage ) {
				objNext = new Image();
				objNext.src = settings.imageArray[settings.activeImage + 1][0];
			}
			if ( settings.activeImage > 0 ) {
				objPrev = new Image();
				objPrev.src = settings.imageArray[settings.activeImage -1][0];
			}
		}
		/**
		 * Remove jQuery lightBox plugin HTML markup
		 *
		 */
		function _finish() {
			$('#jquery-lightbox').remove();
			$('#jquery-overlay').fadeOut(function() { $('#jquery-overlay').remove(); });
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
		/**
		 / THIRD FUNCTION
		 * getPageSize() by quirksmode.com
		 *
		 * @return Array Return an array with page width, height and window width, height
		 */
		function ___getPageSize() {
			var xScroll, yScroll;
			if (window.innerHeight && window.scrollMaxY) {	
				xScroll = window.innerWidth + window.scrollMaxX;
				yScroll = window.innerHeight + window.scrollMaxY;
			} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
				xScroll = document.body.scrollWidth;
				yScroll = document.body.scrollHeight;
			} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
				xScroll = document.body.offsetWidth;
				yScroll = document.body.offsetHeight;
			}
			var windowWidth, windowHeight;
			if (self.innerHeight) {	// all except Explorer
				if(document.documentElement.clientWidth){
					windowWidth = document.documentElement.clientWidth; 
				} else {
					windowWidth = self.innerWidth;
				}
				windowHeight = self.innerHeight;
			} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
				windowWidth = document.documentElement.clientWidth;
				windowHeight = document.documentElement.clientHeight;
			} else if (document.body) { // other Explorers
				windowWidth = document.body.clientWidth;
				windowHeight = document.body.clientHeight;
			}	
			// for small pages with total height less then height of the viewport
			if(yScroll < windowHeight){
				pageHeight = windowHeight;
			} else { 
				pageHeight = yScroll;
			}
			// for small pages with total width less then width of the viewport
			if(xScroll < windowWidth){	
				pageWidth = xScroll;		
			} else {
				pageWidth = windowWidth;
			}
			arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
			return arrayPageSize;
		};
		/**
		 / THIRD FUNCTION
		 * getPageScroll() by quirksmode.com
		 *
		 * @return Array Return an array with x,y page scroll values.
		 */
		function ___getPageScroll() {
			var xScroll, yScroll;
			if (self.pageYOffset) {
				yScroll = self.pageYOffset;
				xScroll = self.pageXOffset;
			} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
				yScroll = document.documentElement.scrollTop;
				xScroll = document.documentElement.scrollLeft;
			} else if (document.body) {// all other Explorers
				yScroll = document.body.scrollTop;
				xScroll = document.body.scrollLeft;	
			}
			arrayPageScroll = new Array(xScroll,yScroll);
			return arrayPageScroll;
		};
		 /**
		  * Stop the code execution from a escified time in milisecond
		  *
		  */
		 function ___pause(ms) {
			var date = new Date(); 
			curDate = null;
			do { var curDate = new Date(); }
			while ( curDate - date < ms);
		 };
		// Return the jQuery object for chaining. The unbind method is used to avoid click conflict when the plugin is called more than once
		return this.unbind('click').click(_initialize);
	};
})(jQuery); // Call and execute the function immediately passing the jQuery object


$(document).ready(function(){
	$(function() {
		$('.lightbox a').lightBox();
	});
	
	$(".envia-amigo").click(function(){
		$(".detalhes-checkout").hide();
		$(".envia-amigo-checkin").show();
		$(".solicite-checkin").hide();
	});
	
	$(".envia-amigo-fechar").click(function(){
		$(".detalhes-checkout").show();
		$(".envia-amigo-checkin").hide();
	});
	
	$(".solicite-info").click(function(){
		$(".detalhes-checkout").hide();
		$(".solicite-checkin").show();
		$(".envia-amigo-checkin").hide();
	});
	
	$(".recebe-info-fechar").click(function(){
		$(".detalhes-checkout").show();
		$(".solicite-checkin").hide();
	});
	
	if($("#detalhesEmpTexto > p").html() == null){
		$("#detalhesEmpTexto").hide();
	}
	
});

var concecValidate = 0;
function tempOnLoad() {
	var tamanhoTela = document.getElementById('totTela').offsetWidth;
	var tamanhoCont = 960;
	var tamanhoEspa = Math.floor((tamanhoTela/2)-(tamanhoCont/2));
	
	if (tamanhoEspa > 0) {
		var posicaoBanners = tamanhoEspa + tamanhoCont + 5;
	}else{
		var posicaoBanners = tamanhoCont + 5;
	}
	
	document.getElementById('frameBanners').style.left = posicaoBanners+"px";
	document.getElementById('boxClimatempo').style.left = posicaoBanners+"px";
	document.getElementById('frameBanners').style.display = "";
	
	document.getElementById('boxFavoritos').style.left = (posicaoBanners-5)+"px";
	if (window.frames['favoritos'].document.getElementById('frameFavoritos')) {
		document.getElementById('favoritos').style.height = window.frames['favoritos'].document.getElementById('frameFavoritos').offsetHeight+"px";
		var yBanners = document.getElementById('boxFavoritos').offsetTop + document.getElementById('boxFavoritos').offsetHeight + 10;
	}else{
		var yBanners = 200;
	}
	
	document.getElementById('frameBanners').style.top = yBanners+"px";
	document.getElementById('boxClimatempo').style.top = (yBanners+document.getElementById('frameBanners').offsetHeight)+"px";
	
	if (tamanhoTela < 965 || concecValidate < 5) { setTimeout("tempOnLoad()",1000);concecValidate++; }
}
function pesquisaSelecionaCombo(sItem,input) {
	if (sItem.className == "pesquisaPaginasComboItemOn") {
		input.checked = false;
		sItem.className = "pesquisaPaginasComboItem";
	}else{
		input.checked = true;
		sItem.className = "pesquisaPaginasComboItemOn";
	}
}

function enviaEscolheBairro(cod,tipo,cliente,caminho,msg) {
	if (tipo == "imo") {
		document.getElementById('recebe_cd_bairro').innerHTML = "<div style='margin:3px'>"+msg+"...</div>";
	}else{
		document.getElementById('recebe_cd_bairro_lanc').innerHTML = "<div style='margin:3px'>"+msg+"...</div>";
	}
	xajax_escolheBairro(cod,tipo,cliente,caminho);
}

function trocaAbaPesquisa(tipo) {
	if (tipo == "I") {
		document.getElementById('pesquisaImoveisEsc').style.display = '';
		document.getElementById('pesquisaLancamentosEsc').style.display = 'none';
		document.getElementById('abaPesquisaImoveis').className = 'abasPesquisaOn';
		document.getElementById('abaPesquisaLanc').className = 'abasPesquisaOff';
		document.getElementById('abaPesquisaImoveis').src = 'templates/'+caminho_template+'/'+idioma+'/img/aba_pesquisa_imoveis_on.png';
		document.getElementById('abaPesquisaLanc').src = 'templates/'+caminho_template+'/'+idioma+'/img/aba_pesquisa_lanc_off.png';
	}else{
		document.getElementById('pesquisaImoveisEsc').style.display = 'none';
		document.getElementById('pesquisaLancamentosEsc').style.display = '';
		document.getElementById('abaPesquisaImoveis').className = 'abasPesquisaOff';
		document.getElementById('abaPesquisaLanc').className = 'abasPesquisaOn';
		document.getElementById('abaPesquisaImoveis').src = 'templates/'+caminho_template+'/'+idioma+'/img/aba_pesquisa_imoveis_off.png';
		document.getElementById('abaPesquisaLanc').src = 'templates/'+caminho_template+'/'+idioma+'/img/aba_pesquisa_lanc_on.png';
	}
	document.getElementById('tipoPesq').value = tipo;
}

function trocaTransacaoPesquisa(valor,caminho) {
	document.getElementById('pesquisaTransacoesTexto1').className = "pesquisaTransacoesTexto";
	document.getElementById('pesquisaTransacoesTexto2').className = "pesquisaTransacoesTexto";
	document.getElementById('pesquisaTransacoesTexto3').className = "pesquisaTransacoesTexto";
	document.getElementById('pesquisaTransacoesTexto'+valor).className = "pesquisaTransacoesTextoOn";
	document.getElementById('selectFaixaPreco').style.visibility='hidden';
	xajax_faixaPreco(valor,caminho);
}

function verifica_pesquisa() {
	var tipo = document.getElementById('tipoPesq').value;
	if (tipo == "I") {
		var texto = document.getElementById('cd_referencia').value;
		if (texto != "") {
			document.getElementById('tipoPesqI').value = "ref";
			document.fpesc.submit();
		}else{
			document.getElementById('tipoPesqI').value = "";
			document.fpesc.submit();
		}
	}else{
		document.fpesc.submit();
	}
}

function concatFormValues(objForm) {
	var formElements = objForm.elements;
	var concatValues = "";
	
	for( var i=0; i < formElements.length; i++)
	{
		var name = formElements[i].name;
		if (name)
		{
			if(formElements[i].type=='select-multiple')
			{
				for (var j = 0; j < formElements[i].length; j++)
				{
					if (formElements[i].options[j].selected == true)
						concatValues += name+"="+encodeURI(formElements[i].options[j].value)+"###";
				}
			}
			else
			{
				if (formElements[i].type=='radio')
				{
					if (formElements[i].checked == true)
						concatValues += name+"="+encodeURI(formElements[i].value)+"###";
				}
				else
				{
					concatValues += name+"="+encodeURI(formElements[i].value)+"###";
				}
			}
		} 
	}
	
	return concatValues;
}

function clearForm(objForm,objCaptcha) {
	var formElements = objForm.elements;
	
	for( var i=0; i < formElements.length; i++)
	{
		switch (formElements[i].type)
		{
			case 'hidden': break;
			case 'select-multiple':
				for (var j=0; j<formElements[i].length; j++) formElements[i].options[j].selected = false;
				formElements[i].options[0].selected = true;
				break;
			case 'radio':
			case 'checkbox':
				formElements[i].checked = false;
				break;
			default:
				formElements[i].value = '';
				break;
		}
	}
	
	if (objCaptcha) {
		objCaptcha.src = '';
		objCaptcha.src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
	}
}

function enviaSolicite() {
	
	document.getElementById('detalhesSoliciteDados').style.display = "none";
	document.getElementById('detalhesSoliciteTopo').style.display = "none";
	document.getElementById('detalhesSoliciteMsgErr1').style.display = "none";
	document.getElementById('detalhesSoliciteMsgErr2').style.display = "none";
	document.getElementById('detalhesSoliciteInfo').style.display = "none";
	
	document.getElementById('detalhesSoliciteDadosEnviando').style.display = "";

	var objForm = document.getElementById('formSolicite');
	var concatValues = concatFormValues(objForm);
	
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	
	xajax_enviaSoliciteInformacoes(concatValues);
	
}

function detalhesSoliciteAjaxReturn(resp,tipo) {	
	if (resp == 'tipo_err') {
		document.getElementById('detalhesSoliciteDados').style.display = "";
		document.getElementById('detalhesSoliciteDadosEnviando').style.display = "none";
	}else{
		switch (resp)
		{
			case 'captcha_err':
			case 'captcha_nok':
				/*document.getElementById('captchaSourceSolicite').src = '';*/
				document.getElementById('captchaSourceSolicite').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
				document.getElementById('captchaSolicite').value = '';
				document.getElementById('captchaSolicite').src = '';
				document.getElementById('detalhesSoliciteInfo').style.display = "";
				document.getElementById('detalhesSoliciteDados').style.display = "";
				document.getElementById('detalhesSoliciteTopo').style.display = "";
				document.getElementById('detalhesSoliciteDadosEnviando').style.display = "none";
				document.getElementById('detalhesSoliciteMsgErr1').style.display = "";
				document.getElementById('detalhesSoliciteMsgErr2').style.display = "none";
				break;
			case 'info_err':
			case 'email_err':
				/*document.getElementById('captchaSourceSolicite').src = '';*/
				document.getElementById('captchaSourceSolicite').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
				document.getElementById('captchaSolicite').value = '';
				document.getElementById('captchaSolicite').src = '';
				document.getElementById('detalhesSoliciteDados').style.display = "";
				document.getElementById('detalhesSoliciteTopo').style.display = "";
				document.getElementById('detalhesSoliciteMsgErr1').style.display = "none";
				document.getElementById('detalhesSoliciteMsgErr2').style.display = "";
				document.getElementById('detalhesSoliciteInfo').style.display = "";
				break;
			case 'ok':
				clearForm(document.getElementById('formSolicite'),document.getElementById('captchaSourceSolicite'));
				document.getElementById('detalhesSoliciteMsgErr1').style.display = "none";
				document.getElementById('detalhesSoliciteMsgErr2').style.display = "none";
				document.getElementById('detalhesSoliciteMsgOk').style.display = "";
				break;
		}
		document.getElementById('detalhesSoliciteDadosEnviando').style.display = "none";
	}
}

function enviaEnviarAmigo() {
	document.getElementById('detalhesEnviarAmigoDados').style.display = "none";
	document.getElementById('detalhesEnviarAmigoTopo').style.display = "none";
	document.getElementById('detalhesEnviarAmigoMsgErr1').style.display = "none";
	document.getElementById('detalhesEnviarAmigoMsgErr2').style.display = "none";
	document.getElementById('detalhesEnviarAmigoInfo').style.display = "none";
	document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "";

	var objForm = document.getElementById('formEnviarAmigo');
	var concatValues = concatFormValues(objForm);
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	xajax_enviaEnviarParaAmigo(concatValues);
}

function detalhesEnvieAjaxReturn(resp,tipo) {
	if (resp == 'tipo_err') {
		document.getElementById('detalhesEnviarAmigoDados').style.display = "";
		document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "none";
	}else{
		switch (resp)
		{
			case 'captcha_err':
			case 'captcha_nok':
				/*document.getElementById('captchaSourceEnviarAmigo').src = '';*/
				document.getElementById('captchaSourceEnviarAmigo').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
				document.getElementById('captchaEnviarAmigo').value = '';
				document.getElementById('captchaEnviarAmigo').src = '';
				document.getElementById('detalhesEnviarAmigoMsgErr1').style.display = "";
				document.getElementById('detalhesEnviarAmigoMsgErr2').style.display = "none";
				document.getElementById('detalhesEnviarAmigoInfo').style.display = "";
				document.getElementById('detalhesEnviarAmigoDados').style.display = "";
				document.getElementById('detalhesEnviarAmigoTopo').style.display = "";
				document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "none";
				break;
			case 'info_err':
			case 'email_err':
				/*document.getElementById('captchaSourceEnviarAmigo').src = '';*/
				document.getElementById('captchaSourceEnviarAmigo').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
				document.getElementById('captchaEnviarAmigo').value = '';
				document.getElementById('captchaEnviarAmigo').src = '';
				document.getElementById('detalhesEnviarAmigoMsgErr1').style.display = "none";
				document.getElementById('detalhesEnviarAmigoMsgErr2').style.display = "";
				document.getElementById('detalhesEnviarAmigoInfo').style.display = "";
				document.getElementById('detalhesEnviarAmigoDados').style.display = "";
				document.getElementById('detalhesEnviarAmigoTopo').style.display = "";
				document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "none";
				break;
			case 'ok':
				clearForm(document.getElementById('formEnviarAmigo'),document.getElementById('captchaSourceEnviarAmigo'));
				document.getElementById('detalhesEnviarAmigoMsgErr1').style.display = "none";
				document.getElementById('detalhesEnviarAmigoMsgErr2').style.display = "none";
				document.getElementById('detalhesEnviarAmigoMsgOk').style.display = "";
				break;
		}
		document.getElementById('detalhesEnviarAmigoDadosEnviando').style.display = "none";
	}
}

function enviaFinanciamento() {
	document.getElementById('financiamentoFormFrame').style.display = "none";
	document.getElementById('financiamentoRetorno').style.display = "";
	var objForm = document.getElementById('formFinanciamento');
	var concatValues = concatFormValues(objForm);
	
	document.documentElement.scrollTop = 0;
	document.body.scrollTop = 0;
	
	xajax_enviaFinanciamento(concatValues);
}

function some(elem) {
	document.getElementById(elem).style.display = "none";
}

function returnElementPosition(elem) {
	var left = elem.offsetLeft;
	var handlerLeft = elem.offsetParent;
	while (handlerLeft) {
		left += handlerLeft.offsetLeft;
		handlerLeft = handlerLeft.offsetParent;
	}
	
	var top = elem.offsetTop;
	var handlerTop = elem.offsetParent;
	while (handlerTop) {
		top += handlerTop.offsetTop;
		handlerTop = handlerTop.offsetParent;
	}
	
	var retorno = new Array();
	retorno[0] = left;
	retorno[1] = top;
	
	return retorno;
}

function abreComboSecoes() {
	mouseOutComboSecoes = 1;
	var botao = document.getElementById('topoItemMaisPaginas');
	var combo = document.getElementById('topoComboMaisPaginas');
	var cabec = document.getElementById('frameCabecalho');

	var left = returnElementPosition(botao);
	var top = returnElementPosition(cabec);

	botao.className = "topoItemPlus";
	combo.style.display = "block";
	combo.style.left = left[0]+"px";
	combo.style.top = top[1]+"px";
}

var mouseOutComboSecoes = 0;
function fechaComboSecoes() {
	if (mouseOutComboSecoes == 0) {
		document.getElementById('topoComboMaisPaginas').style.display = "none";
		document.getElementById('topoItemMaisPaginas').className = "topoItem";
	}
}

function verificaMouseOut() {
	mouseOutComboSecoes = 0;
	setTimeout("fechaComboSecoes()",1000);
}

function topoComboMouseOver(obj) {
	mouseOutComboSecoes = 1;
	obj.className = "topoComboItemOn";
}

function topoComboMouseOut(obj) {
	obj.className = "topoComboItemOff";
}

function abreComboIdioma() {
	mouseOutComboIdioma = 1;
	var botao = document.getElementById('abaIdioma');
	var combo = document.getElementById('idiomaAbaCombo');
	var cabec = document.getElementById('frameCabecalho');

	var left = returnElementPosition(botao);
	var top = returnElementPosition(cabec);

	combo.style.display = "block";
	combo.style.left = left[0]+"px";
	combo.style.top = top[1]+"px";
}

var mouseOutComboIdioma = 0;
function fechaComboIdioma() {
	if (mouseOutComboIdioma == 0) {
		document.getElementById('idiomaAbaCombo').style.display = "none";
	}
}

function verificaMouseOutIdioma() {
	mouseOutComboIdioma = 0;
	setTimeout("fechaComboIdioma()",1000);
}

function topoComboMouseOver(obj) {
	mouseOutComboSecoes = 1;
	obj.className = "topoComboItemOn";
}

function topoComboMouseOut(obj) {
	obj.className = "topoComboItemOff";
}

//function change_detalhe(v) {
//	
//	var arrAbas = new Array();
//	arrAbas[0] = "geral";
//	arrAbas[1] = "fotos";
//	arrAbas[2] = "video";
//	arrAbas[3] = "mapa";
//	arrAbas[4] = "solicite";
//	arrAbas[5] = "envie";
//	
//	var elemAtual = document.getElementById('detalhesAba_'+v);
//	if (elemAtual.className == 'detalhesAbasOn') return true;
//	
//	for (i=0; i<arrAbas.length; i++) {
//		document.getElementById("detalhesAba_"+arrAbas[i]).className = 'detalhesAbasOff';
//		document.getElementById("imodetalhecont_"+arrAbas[i]).style.display = 'none';
//	}
//	
//	if (v == 'geral') {
//		document.getElementById("detalhes-imoveis-foto").style.visibility = 'visible';
//	}else{
//		document.getElementById("detalhes-imoveis-foto").style.visibility = 'hidden';
//	}
//	
//	if (v == 'solicite' || v == 'envie') {
//		document.getElementById("detalhesFavoritos").style.display = 'none';
//		document.getElementById("detalhesDadosFixos").style.display = 'none';
//	}else{
//		document.getElementById("detalhesFavoritos").style.display = '';
//		document.getElementById("detalhesDadosFixos").style.display = '';
//		document.getElementById("detalhesAba_"+v).className = 'detalhesAbasOn';
//	}
//
//	document.getElementById("detalhesSoliciteMsgErr1").style.display = 'none';
//	document.getElementById("detalhesSoliciteMsgErr2").style.display = 'none';
//	document.getElementById("detalhesEnviarAmigoMsgErr1").style.display = 'none';
//	document.getElementById("detalhesEnviarAmigoMsgErr2").style.display = 'none';
//
//	document.getElementById('captchaSourceSolicite').src = '';
//	document.getElementById('captchaSourceSolicite').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
//	document.getElementById('captchaSourceEnviarAmigo').src = '';
//	document.getElementById('captchaSourceEnviarAmigo').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
//	document.getElementById('captchaSolicite').value = '';
//	document.getElementById('captchaSolicite').src = '';
//	document.getElementById('captchaEnviarAmigo').value = '';
//	document.getElementById('captchaEnviarAmigo').src = '';
//
//	document.getElementById("imodetalhecont_"+v).style.display = '';
//}

function change_detalhe(v) {
	
	var arrAbas = new Array();
	arrAbas[0] = "geral";
	arrAbas[1] = "fotos";
	arrAbas[2] = "video";
	arrAbas[3] = "mapa";
	arrAbas[4] = "solicite";
	arrAbas[5] = "envie";
	
	var elemAtual = document.getElementById('detalhesAba_'+v);
	if (elemAtual.className == 'detalhesAbasOn') return true;
	
	for (i=0; i<arrAbas.length; i++) {
		document.getElementById("detalhesAba_"+arrAbas[i]).className = 'detalhesAbasOff';
		document.getElementById("imodetalhecont_"+arrAbas[i]).style.display = 'none';
	}
	
	if (v == 'geral') {
		document.getElementById("detalhes-imoveis-foto").style.visibility = 'visible';
	}else{
		document.getElementById("detalhes-imoveis-foto").style.visibility = 'hidden';
	}
	
	if (v == 'geral') {
		document.getElementById("valorTopo").style.visibility = 'visible';
	}else{
		document.getElementById("valorTopo").style.visibility = 'hidden';
	}

	if (v == 'solicite' || v == 'envie') {
		document.getElementById("detalhesFavoritos").style.display = 'none';
		document.getElementById("detalhesDadosFixos").style.display = 'none';
	}else{
		document.getElementById("detalhesFavoritos").style.display = '';
		document.getElementById("detalhesDadosFixos").style.display = '';
		document.getElementById("detalhesAba_"+v).className = 'detalhesAbasOn';
	}

	document.getElementById("detalhesSoliciteMsgErr1").style.display = 'none';
	document.getElementById("detalhesSoliciteMsgErr2").style.display = 'none';
	document.getElementById("detalhesEnviarAmigoMsgErr1").style.display = 'none';
	document.getElementById("detalhesEnviarAmigoMsgErr2").style.display = 'none';

	document.getElementById('captchaSourceSolicite').src = '';
	document.getElementById('captchaSourceSolicite').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
	document.getElementById('captchaSourceEnviarAmigo').src = '';
	document.getElementById('captchaSourceEnviarAmigo').src = 'captcha.php?cachebuster=' + Math.floor(Math.random()*100000);
	document.getElementById('captchaSolicite').value = '';
	document.getElementById('captchaSolicite').src = '';
	document.getElementById('captchaEnviarAmigo').value = '';
	document.getElementById('captchaEnviarAmigo').src = '';

	document.getElementById("imodetalhecont_"+v).style.display = '';
}

function change_detalhe_lanc(param) {

	var arrAbas = new Array();
	arrAbas[0] = "emp";
	arrAbas[1] = "uni";
	arrAbas[2] = "img";
	arrAbas[3] = "vid";
	arrAbas[4] = "map";
	
	for (i=0; i<arrAbas.length; i++) {
		document.getElementById("lancdetalhe_"+arrAbas[i]).className = 'detalhesAbasOff';
		document.getElementById("lancdetalhecont_"+arrAbas[i]).style.display = 'none';
	}
	
	if (param == 'emp') {
		$('div[aba_emp=1]').show();
	}else{
		$('div[aba_emp=1]').hide();
	}
	
	document.getElementById("lancdetalhe_"+param).className = 'detalhesAbasOn';
	document.getElementById("lancdetalhecont_"+param).style.display = '';
}


function destalhesLanc(valor,id) {
	if (valor != 0 && valor != "0") {
		window.location = "engine.php?id="+id+"&page=lancamento_detalhe&cd_lancamento="+valor;
	}
}

function rolaCalendarioDireita() {
	if (document.getElementById('calendarioInner').scrollLeft == 0) {
		var inicioTween = 0;
		var finalTween = 520;
		var tweenScroll = new Tween(document.getElementById('calendarioInner'),'scrollLeft',Tween.regularEaseOut,inicioTween,finalTween,0.5,'');
		tweenScroll.start();
	}
}

function rolaCalendarioEsquerda() {
	if (document.getElementById('calendarioInner').scrollLeft == 520) {
		var inicioTween = document.getElementById('calendarioInner').scrollLeft;
		var finalTween = 0;
		var tweenScroll = new Tween(document.getElementById('calendarioInner'),'scrollLeft',Tween.regularEaseOut,inicioTween,finalTween,0.5,'');
		tweenScroll.start();
	}
}

var intSlideFotos;
function slideFotos() {
	if (document.getElementById('detalhesFotosSlideBotao').style.backgroundPosition == "0px 0px") {
		slideFotosStop();
	}else{
		slideFotosStart();
	}
}

function slideFotosStart() {
	document.getElementById('detalhesFotosSlideBotao').style.backgroundPosition = "0px 0px";
	document.getElementById('detalhesFotosSlideProgress').style.display = "";
	document.getElementById('detalhesFotosSlideProgressBar').style.display = "";
	document.getElementById('detalhesFotosSlideProgressBar').style.height = "41px";
	intSlideFotos = setInterval("slideFotosProgress()",250);
}

function slideFotosStop() {
	clearInterval(intSlideFotos);
	document.getElementById('detalhesFotosSlideBotao').style.backgroundPosition = "0px -23px";
	document.getElementById('detalhesFotosSlideProgress').style.display = "none";
	document.getElementById('detalhesFotosSlideProgressBar').style.height = "41px";
}

function slideFotosInterval() {
	var count = foto_atual + 1;
	
	if (foto_detalhe.length > count) {
		var alturaThumb = 66;
		var posThumb = (count*alturaThumb)-(2*alturaThumb);
		document.getElementById('detalhesFotosThumbsFrame').scrollTop = posThumb;
		troca_foto_detalhes(count);
	}else{
		document.getElementById('detalhesFotosThumbsFrame').scrollTop = 0;
		troca_foto_detalhes(0);
	}
	
	document.getElementById('detalhesFotosSlideProgress').style.display = "";
	document.getElementById('detalhesFotosSlideProgressBar').style.display = "";
	document.getElementById('detalhesFotosSlideProgressBar').style.height = "41px";
	intSlideFotos = setInterval("slideFotosProgress()",200);
}

function slideFotosProgress() {
	var elem = document.getElementById('detalhesFotosSlideProgressBar');
	var atual = elem.offsetHeight;

	if (atual == 2) {
		elem.style.display = "none";
		clearInterval(intSlideFotos);
		slideFotosInterval();
	}else{
		var valor = atual-1;
		elem.style.height = valor+"px";
	}
}

function secaoMenuMouseOver(obj) {
	obj.style.backgroundPosition = "0px -30px";
}

function secaoMenuMouseOut(obj) {
	obj.style.backgroundPosition = "0px 0px";
}

function verTabelaUnid(unid,lanc,id) {
	$('object').css('visibility','hidden');
	$('body').attr('scroll','no').css('overflow','hidden');
	$('#cortinaPopup').show().height($('html').height()).css('opacity',0);
	$('#cortinaPopup').fadeTo('slow',0.5,function(){
		$('#popup').show();
		verificaPopup();
		jah('detlanc_uni_tab.php?lanc='+unid+'&unid='+unid+'&id='+id,'popup');
	});
}

function fechaTabelaUnid() {
	$('object').css('visibility','visible');
	$('body').attr('scroll','auto').css('overflow','auto');
	fechaPopup();
}

function deleteFavorito(cod,tipo,id) {
	var formContato = new Array();
	formContato[0] = "nome";
	formContato[1] = "email";
	formContato[2] = "ddd";
	formContato[3] = "telefone";
	formContato[4] = "mensagem";
	formContato[5] = "tipo_recebe_indiferente";
	formContato[6] = "tipo_recebe_email";
	formContato[7] = "tipo_recebe_telefone";
	
	var locacao = "del_favoritos.php?"; 
	
	if (tipo == "Empreendimento") {
		locacao += "cd_lancamento=";
	}else{
		locacao += "cd_imovel=";
	}
	
	locacao += cod;
	locacao += "&id="+id+"&page=contato&info=1";
	
	for (i=0;i<formContato.length;i++) {
		if (document.getElementById(formContato[i])) {
			if (document.getElementById(formContato[i]).type == "text") {
				locacao += "&"+formContato[i]+"="+encodeURIComponent(document.getElementById(formContato[i]).value);
			}
			if ((document.getElementById(formContato[i]).type == "checkbox" || document.getElementById(formContato[i]).type == "radio") && document.getElementById(formContato[i]).checked == true) {
				locacao += "&"+formContato[i]+"=checked";
			}
			if (formContato[i] == "mensagem") {
				locacao += "&"+formContato[i]+"="+encodeURIComponent(document.getElementById(formContato[i]).innerHTML);
			}
		}
	}
	
	window.location=locacao;
}

function validate_encomende() {
	var formEncomende = new Array();
	formEncomende[0] = "nome";
	formEncomende[1] = "email";
	formEncomende[2] = "ddd";
	formEncomende[3] = "telefone";
	formEncomende[4] = "mensagem";
	formEncomende[5] = "valor";
	
	var objForm = document.getElementById('formEncomende');
	var formElements = objForm.elements;
	
	var validaCheckbox = new Array();
	validaCheckbox['cd_negocio'] = false;
	validaCheckbox['cd_tipo'] = false;
	validaCheckbox['cd_bairro'] = false;
	
	for( var i=0; i < formElements.length; i++)
	{
		var name = formElements[i].name;
		var nameHandler = name.substring(0,name.length-2);
		if (name)
		{
			if (formElements[i].type == 'checkbox')
			{
				if (formElements[i].checked == true)
				{
					validaCheckbox[nameHandler] = true;
				}
			}
			if (formElements[i].type == 'text' || formElements[i].type == 'textarea')
			{
				if (formElements[i].name == "captcha")
				{
					var valoresPossiveis = "bcdfghjklmnpqrstvwxyz";
					var captcha = formElements[i].value;
					if ((captcha.length != 4)||(valoresPossiveis.indexOf(captcha.charAt(0))==-1)||(valoresPossiveis.indexOf(captcha.charAt(1))==-1)||(valoresPossiveis.indexOf(captcha.charAt(2))==-1)||(valoresPossiveis.indexOf(captcha.charAt(3))==-1))
					{
						alert('Digite as quatro consoantes da imagem no campo de validação!');
						formElements[i].focus();
						return false;
					}
				}
				else
				{
					if (formElements[i].value == "")
					{
						alert('Preencha corretamente os campos obrigatórios!');
						formElements[i].focus();
						return false;
					}
				}
			}
		}
	}
	
	if ( validaCheckbox['cd_negocio'] != true ) {
		alert('É necessário escolher pelo menos uma das opções de negociação');
		return false;
	}
	
	if ( validaCheckbox['cd_tipo'] != true ) {
		alert('É necessário escolher pelo menos uma das opções de tipos de imóvel');
		return false;
	}
	
	objForm.submit();
}

function validate_cadastre() {
	var formCadastre = new Array();
	formCadastre[0] = "cd_tipo_padrao";
	formCadastre[1] = "estado_imovel";
	formCadastre[2] = "cidade_imovel";
	formCadastre[3] = "bairro_imovel";
	formCadastre[4] = "nome";
	formCadastre[5] = "ddd";
	formCadastre[6] = "telefone";
	formCadastre[7] = "real_email";
	
	
	var objForm = document.getElementById('formCadastre');
	var formElements = objForm.elements;
	
	var validaCheckbox = new Array();
	validaCheckbox['cd_negocio'] = false;
	
	for( var i=0; i < formElements.length; i++)
	{
		var name = formElements[i].name;
		var nameHandler = name.substring(0,name.length-2);
		if (name)
		{
			if (formElements[i].type == 'checkbox')
			{
				if (formElements[i].checked == true)
				{
					validaCheckbox[nameHandler] = true;
				}
			}
			else
			{
				if (formElements[i].name == "captcha")
				{
					var valoresPossiveis = "bcdfghjklmnpqrstvwxyz";
					var captcha = formElements[i].value;
					if ((captcha.length != 4)||(valoresPossiveis.indexOf(captcha.charAt(0))==-1)||(valoresPossiveis.indexOf(captcha.charAt(1))==-1)||(valoresPossiveis.indexOf(captcha.charAt(2))==-1)||(valoresPossiveis.indexOf(captcha.charAt(3))==-1))
					{
						alert('Digite as quatro consoantes da imagem no campo de validação!');
						formElements[i].focus();
						return false;
					}
				}
				else
				{
					if (formElements[i].value == "" && formCadastre.in_array(name))
					{
						alert('Preencha corretamente os campos obrigatórios!');
						formElements[i].focus();
						return false;
					}
				}
			}
		}
	}
	
	if ( validaCheckbox['cd_negocio'] != true ) {
		alert('É necessário escolher pelo menos uma das opções de negociação');
		return false;
	}
	
	objForm.submit();
}

function selectBairroEncomende(cd_bairro,status) {
	var obj = document.getElementById("encomendeBairroItem"+cd_bairro);
	
	if (obj.className == "encomendeBairroItem") {
		obj.className = "encomendeBairroItemSelected";
	}else{
		obj.className = "encomendeBairroItem";
	}
}

Array.prototype.in_array = function(p_val) {
	for(var i = 0, l = this.length; i < l; i++) {
		if(this[i] == p_val) {
			return true;
		}
	}
	return false;
}

function mostraFavoritos() {
	window.parent.document.getElementById('boxFavoritos').style.display = "";
}

function mostraIndicadores() {
	document.getElementById('boxIndicadores').style.display = "";
}

function mostraClima() {
	document.getElementById('boxClimatempo').style.display = "";
}



$(document).ready(function(){
	$("a[rel='example1']").colorbox();
	$("a.openTable").colorbox();
	$("#valorTopo > .detalhesGeralTitulo").hide();
});
