		var window_callback = {
				cache:false
		}
		// Functions for manage the pop-ups (like Loading, Listing or Contact Form)

		function manageDivLegend(display)
		{
			div = document.getElementById('backgroundLoadingDiv');
			div.style.display = display;
			div = document.getElementById('centerLegendDiv');
			div.style.display = display;

		}

		function manageDivLoading(display, button)
		{
			div = document.getElementById('backgroundLoadingDiv');
			div.style.display = display;
			div = document.getElementById('centerLoadingDiv');
			div.style.display = display;
	
			// TODO: take YAHOO token	
			if(display != 'none' && document.getElementById('phone')){
				var request = YAHOO.util.Connect.asyncRequest('POST', base_url_global+'/ajax/leadwindow/button/'+button, window_callback, null);
			}
		}

		function manageSimpleLoadingDiv(display, button)
		{
			div = document.getElementById('backgroundLoadingDiv');
			div.style.display = display;
			div = document.getElementById('centerSimpleLoadingDiv');
			div.style.display = display;
	
			// TODO: take YAHOO token	
			if(display != 'none' && document.getElementById('phone')){
				var request = YAHOO.util.Connect.asyncRequest('POST', base_url_global+'/ajax/leadwindow/button/'+button, window_callback, null);
			}
		}
		
		function loadWindowsLoading(baseURL_param)
		{
			img = document.getElementById('imgLoadingHtml');
			div = document.getElementById('centerLoadingDiv');

			img.src = baseURL_param + '/images/ajax-loader.gif';
			div.style.border = "2px solid #CCCCCC";
			div.className = "centerLegendDiv";
			manageDivLoading('');
		}
		
		function loadWindowsLoadingSimple(baseURL_param)
		{
			img = document.getElementById('imgLoadingHtml');
			div = document.getElementById('centerSimpleLoadingDiv');

			img.src = baseURL_param + '/images/ajax-loader.gif';
			div.style.border = "2px solid #CCCCCC";
			div.className = "centerLegendDiv bigDivCenter";
			manageSimpleLoadingDiv('');
		}
	
		function loadWindowsFormContact(ret_value,email,phone,message, meeting,lang)
		{
			div = document.getElementById('centerLoadingDiv');
			div.style.background = '#FFFFFF';
			div.className = 'contact_form';
			
			if(meeting == true) {
				meeting = 'checked="yes"';
			} else {
				meeting = '';
			}
			
			if (lang == 'en')
			{
				div.innerHTML = '<span class="estates">Send your information directy to the agent. He will contact you as son as is possible</span>' +
							'<form method="post">' +
                    		'<div class="label"><label for="email">* E-Mail</label></div><input type="text" id="email" name="email" size="20" value="' +email+ '"><br />' +
                    		'<div class="label"><label for="phone">* Contact phone</label></div><input type="text" id="phone" name="phone" size="20" value="' +phone+ '"><br />' +
                    		'<div class="label"><label for="comments">Comments</label></div><textarea id="comments" name="comments" size="20" rows="3" >' + message + '</textarea><br />' +
                    		'<input type="checkbox" name="meeting" value="true" class="checkbox" id="meeting" ' + meeting + ' /><div class="label-checkbox"><label for="meeting">Request an appointment with the agent in the next 3 days.</label></div><br />' +
                   			'<center id="buttonsSubmit"><input type="submit" value="Send" class="submit" onClick="changeViewSubmitting();">' +
							'<input type="button" onClick="manageDivLoading(\'none\');" class="submit" value="Return"></center>' +
							'<center id="submitingtext" style="display:none"><img src="/images/ajax-loader-small.gif"> Sending data ...</center>' + 
                			'</form><br />';
			}
			else
			{
				div.innerHTML = '<span class="estates">Envía tus datos directamente al agente, para que se ponga en contacto contigo en la brevedad posible</span>' +
							'<form method="post">' +
                    		'<div class="label"><label for="email">* Correo electrónico</label></div><input type="text" id="email" name="email" size="20" value="' +email+ '"><br />' +
                    		'<div class="label"><label for="phone">* Teléfono de contacto</label></div><input type="text" id="phone" name="phone" size="20" value="' +phone+ '"><br />' +
                    		'<div class="label"><label for="comments">Comentarios</label></div><textarea id="comments" name="comments" size="20" rows="3" >' + message + '</textarea><br />' +
                    		'<input type="checkbox" name="meeting" value="true" class="checkbox" id="meeting" ' + meeting + '/><div class="label-checkbox">Quiero agendar una cita con el agente en los próximos 3 días.<label for="meeting"></label></div><br />' +
                    		'<center id="buttonsSubmit"><input type="submit" value="Enviar datos" class="submit" onClick="changeViewSubmitting();">' +
							'<input type="button" onClick="manageDivLoading(\'none\');" class="submit" value="Volver"></center></form>' +
							'<center id="submitingtext" style="display:none"><img src="/images/ajax-loader-small.gif"> Enviando datos ...</center>' + 
                			'</form><br />';
			}

			if (ret_value != 0) 
			{
				if (ret_value == 1)
				{
					if (lang == 'en') {
						div.innerHTML += '<center id="errorContactForm"><span class="red">The email format is not correct</span></center><br />';
					} else {
						div.innerHTML += '<center id="errorContactForm"><span class="red">El formato del correo no es correcto</span></center><br />';
					}
				}
				else if (ret_value == 2)
				{
					if (lang == 'en') {
						div.innerHTML += '<center id="errorContactForm"><span class="red">The contact phone format is not correct</span></center><br />';
					} else {
						div.innerHTML += '<center id="errorContactForm"><span class="red">El formato del teléfono no es correcto</span></center><br />';
					}
				}
				
				
			}

			if (lang == 'en') {
				div.innerHTML += '<center><a href="#" onclick="openPrivacity(\'true\')">Tips and information about privacity</a></center><br />';
			} else {
				div.innerHTML += '<center><a href="#" onclick="openPrivacity(\'true\')">Consejos e información sobre privacidad</a></center><br />';
			}
			
			div.innerHTML = '<div id="involve_popup">' + div.innerHTML + '</div>';
			div.innerHTML += loadWindowsPrivacityInformation(lang);
		}
		
function loadWindowsPrivacityInformation(lang) {
	stringContent = "";
	
	if (lang == 'en') {
		stringContent += '<span class="estates">Tips and information about privacity</span><br /><br />';
		stringContent += '<span>Your privacy is the most important for us, we will not share your private information with others and you will not recive spam.</span><br /><br />';
		stringContent += '<span>We will send you a email for verify that you are the owner of the email account that you have entered. Please, check that the mail is not in the junk mail.</span>' +
						'<form method="post">' + 
						'<center><input type="button" onClick="openPrivacity(\'false\');" class="submit nmt" value="Back"></center></form>' +
						'</form>';
	} else {
		stringContent += '<span class="estates">Consejos e información sobre privacidad</span><br /><br />';
		stringContent += '<span>Tu privacidad es lo más importante para nosortos, no compartimos tu información con terceros y no recibirás spam.</span><br /><br />';
		stringContent += '<span>A continuación te mandaremos un correo para que verifiques que eres el propietario de la cuenta de correo electrónico que has introducido. <b>Por favor, verifica que este no está en tu bandeja de correo no deseado.</b></span>' + 
						'<form method="post">' + 
						'<center><input type="button" onClick="openPrivacity(\'false\');" class="submit nmt" value="Anterior"></center></form>' +
						'</form>';
	}
	
	stringContent = '<div id="privacity_popup" style="display:none;">' + stringContent + '</div>';
	
	return stringContent;
}

function loadWindowsFormContactSent(lang)
{
	div = document.getElementById('centerLoadingDiv');
	div.style.background = '#FFFFFF';
	div.className = 'contact_form';
	if (lang == 'en')
	{
		/*div.innerHTML = '<span class="estates">Your information have been sent to the agent</span><br /><br /><br />' +
					'<span>Furthermore we have sent you an email to <b>confirm your e-mail address</b> and then make easy to the agent contact with you.</span>' +
					'<form method="post">' + 
					'<center><input type="button" onClick="manageDivLoading(\'none\');" class="submit nmt" value="Return"></center></form>' +
					'</form>';*/
	}
	else
	{
		/*div.innerHTML = '<span class="estates">Tus datos de contacto han sido enviados al agente</span> <br /><br />' +
            		'<span>Además le hemos enviado un email para que pueda <b>confirmar su contacto</b> y facilitarle al agente contactar con usted</span>' +
            		'<form method="post">' + 
            		'<center><input type="button" onClick="manageDivLoading(\'none\');" class="submit nmt" value="Volver"></center></form>' +
        			'</form>';*/
	}
	
	div.innerHTML = $('#lead-form-div-hidd').html();
}

function openPrivacity(openContent) {
	divPrivacity = document.getElementById('privacity_popup');
	divContact= document.getElementById('involve_popup');
	
	if(openContent == 'true') {
		divPrivacity.style.display = '';
		divContact.style.display = 'none';
	} else {
		divPrivacity.style.display = 'none';
		divContact.style.display = '';
	}
}

function loadWindowsFormLogin(contentWindow)
{
	div = document.getElementById('centerLoadingDiv');
	div.innerHTML = contentWindow;

	manageDivLoading('');
}

/** 
 * For contacting form, hide the buttons of submit, and show
 * the text that indicate us is sending the information
 * 
 * @return
 */
function changeViewSubmitting() {
	element1 = document.getElementById('buttonsSubmit');
	element2 = document.getElementById('submitingtext');
	element3 = document.getElementById('errorContactForm');
	
	element1.style.display = 'none';
	element2.style.display = '';
	element3.style.display = 'none';
}
