/**
 * Classe com funcionalidades do site
 * @author Adriano Fernandes [ Eurodance.com.br ] [ Xoxua.com.br ]
 **/

site = {
		
	zoomImagem : function( id, imagem, nome ) {
	
		this.id     = id;
		this.imagem = imagem;
		
		if(nome)
			this.nome   = nome;
		
		if( this.id != '' ) {			
			
			$( '#zoomImg' ).html( '<img src="index.php/imovel/getImage/' + this.id + '/' + this.imagem + '/226/226/imagens/true/" class="rightBorda" />' + this.nome   );
			
		}
	
	},
	
	MM_openBrWindow : function( theURL, winName, features ) {
	
	  window.open( theURL, winName, features );
	
	},
	
	newsletter : function() {
		
		this.nome = global.Dom.$( 'nomeNews' );
		
		if( this.nome.value == 'nome' ) {
			this.nome.value = '';
		}
		
		objValidacao = new validar();				
		
		objValidacao.setCampo( 'nomeNews' );
		objValidacao.setAviso( 'Informe o seu nome!' );
		objValidacao.adicionarCampo();
		
		objValidacao.setCampo( 'emailNews' );
		objValidacao.setAviso( 'Informe o seu email!' );
		objValidacao.adicionarCampo();		
		
		if( objValidacao.validarCampo() ) {
			
			global.Dom.$( 'salvarNews' ).disabled = true;	
			$( "#loading" ).show( "slow" );
		
			$.ajax( {
				type     : 'POST',
				url      : 'index.php/newsletter/cadastro/',
				data     : "nome_news=" + $( "#nomeNews" ).val( this.value ) + "&email_news=" + $( "#emailNews" ).val( this.value ),
				dataType : "json",				
				success  : function( msg ) {	
					
					if( msg.erro != '' ) {						
						
						$( "#htmlLoading" ).html( msg.erro );
						global.Dom.$( 'salvarNews' ).disabled = false;						
						
					} else {
							
						$( "#htmlLoading" ).html( 'email foi cadastrado!' );
						
						global.Dom.$( 'nomeNews'   ).value    = 'nome';						
						global.Dom.$( 'emailNews'  ).value    = 'email';												
						global.Dom.$( 'salvarNews' ).disabled = false;														
					
					}
					
				}
			 } );			
			
		}			
		
	},
	
	closeLoading : function() {		
		$( "#loading" ).css( "display", "none" );		
	},
	
	imprimir : function( secao, arquivo, id ) {		
		window.open( 'http://www.stuhlberger.com.br/site/index.php/imprimir/' + secao + '/' + id + '/' + arquivo );		
	}				
	
} 