var APP={};APP.Account={};APP.Account.Signup={};APP.Account.Register={};var thisPage=window.location.href;if(thisPage.match(/^http:\/\/localhost/))var APP_URL='http://localhost/geski.com.br/www/';else var APP_URL='/';jQuery(function($){if($.browser.msie){$('.positive').hover(function(){$(this).addClass('positive-hover')},function(){$(this).removeClass('positive-hover')})}$('#wrap-signup-form').fadeOut();$('#user_email').focus().val($.cookie('_user_email_to_login'));$('.wrap-options > ol').tabs({event:'mouseover',cookie:{expires:30}});$('.tabs > ul').tabs({event:'mouseover',cookie:{expires:30},fxFade:{opacity:'toggle'},fxSpeed:'fast'});$('.wrap-carousel').before('<p id="btn-tour-prev" class="prev"><a href="javascript:;">Anterior</a></p>').after('<p id="btn-tour-next" class="next"><a href="javascript:;">Próximo</a></p>').jCarouselLite({btnNext:".next",btnPrev:".prev",circular:false,visible:1,easing:'backin',speed:750});jQuery.validator.setDefaults({errorClass:'invalid'});$('#frm-signup').validate({rules:{user_name:'required',user_email:{required:true,email:true,remote:APP_URL+'ajax-signup.php'},user_email2:{required:true,email:true,equalTo:'#user_email'},user_password:'required',user_password2:{required:true,equalTo:'#user_password'},company_address_state:'required',company_address_city:'required',company_periodicity_pay:'required',accepts_eula:'required'},messages:{user_name:'Qual o seu nome?',user_email:{required:'Informe seu e-mail.',email:'Informe um e-mail válido.',remote:jQuery.format("Ops! O e-mail informado, {0}, já está em uso. Você já possui uma conta no Geski? Entre em contato.")},user_email2:{required:'Confirme o e-mail.',email:'Informe um e-mail válido.',equalTo:'Os e-mails informados não conferem.'},user_password:'Informe uma senha.',user_password2:{required:'Confirme a senha.',equalTo:'As senhas informadas não conferem.'},company_address_city:'Qual a cidade onde sua imobiliária reside?',company_address_state:'Qual o estado onde sua imobiliária reside?',company_periodicity_pay:'Por favor, escolha a periodicidade de pagamento desejada.',accepts_eula:'Você deve estar de acordo com os termos de uso.'},submitHandler:function(form){$('#btn-signup').ajaxStart(function(){$(this).html('Criando sua conta...')});$.post($(form).attr('action'),$(form).serialize(),function(ajaxReturn){if(1==ajaxReturn){$.cookie('_user_email_to_login',$('#user_email').val(),{expires:1});window.scrollTo(0,0);$('#frm-signup').slideUp(function(){$('#account_created').slideDown()})}})}})});APP.Account.Register.selectPlan=function(planClassName,planName){$('#dl-periodicity').html('Calculando...').load(APP_URL+'ajax-signup.php?signup_periodicity=true&plan='+planName);$('th').removeClass('selected').not('.features').fadeOut('normal');$('td').removeClass('selected').not('.features').fadeOut('normal');$('.'+planClassName).addClass('selected').fadeIn('normal');$('#wrap-signup-form').fadeIn('normal',function(){$('#user_email').focus()});$('#company_plan').val(planName)};APP.Account.Register.showPlans=function(){$('#wrap-signup-form').hide();$('th, td',$('#tbl-planos')).show()};APP.load_cities_from_state=function(objState,objCity,is_resale){var jQSelState=$(objState);var jQSelCity=$(objCity);var url;if(!jQSelState.val())return;jQSelCity.html('<option value="">Carregando cidades...</option>');if(is_resale)url=APP_URL+'ajax-signup.php?strWhat=get_resales_cities&state_id='+jQSelState.val();else url=APP_URL+'ajax-signup.php?strWhat=cities-from-state&state_id='+jQSelState.val();$.getJSON(url,function(jsonReturn){jQSelCity.html('<option value="" selected="selected">&#8212; Selecione a cidade</option>');var i=0,_option,_options;for(i;i<jsonReturn.length;i++){_option=new Option(jsonReturn[i].cidade_name,jsonReturn[i].cidade_id);_options=jQSelCity.get(0).options;_options[_options.length]=_option}jQSelCity.focus()})};APP.add_telephone_fields=function(){var total=$('[class*="_wrap-add-telephones"]').length,html='';html+='<div id="_'+total+'" class="wrap-fields-related _wrap-add-telephones">';html+='<p><label for="telephone_type_1">Tipo de telefone:</label>';html+='<input type="text" class="small" id="telephone_type_1" name="arrTelephonesType[]" /></p>';html+='<p><label for="ddd_1">DDD:</label>';html+='<input type="text" class="xx-small" id="ddd_1" name="arrDDDs[]" maxlength="2" /></p>';html+='<p><label for="telephone_1">Telefone:</label>';html+='<input type="text" class="small" id="telephone_1" name="arrTelephones[]" maxlength="9" />';html+=' <a href="javascript:;" title="Clique para adicionar outros telefones" onclick="APP.add_telephone_fields();">';html+='<img src="'+APP_URL+'assets/images/ico-add.png" width="16" height="16" alt="" /></a>';html+=' <a href="javascript:;" onclick="$(\'#_'+total+'\').fadeOut(\'normal\', function() { $(this).remove(); });">';html+='<img src="'+APP_URL+'assets/images/ico-delete.png" width="16" height="16" alt="" /></a></p></div>';$('[class*="_wrap-add-telephones"]').eq(total-1).after(html)};APP.Account.Register.verifyReferrer=function(){var referrer_info=$('#consult_referrer_code');referrer_info.ajaxStart(function(){$(this).fadeIn('normal')});$.get('ajax-signup.php',{referrer_code:$('#account_referrer_code').val()},function(ajaxReturn){if(1==ajaxReturn){referrer_info.html('Válido! O código de indicação informado.').css({color:'#009900',fontWeight:'bold'})}else{referrer_info.html('Inválido! O código de indicação é inexistente.').css({color:'#FF0000',fontWeight:'bold'})}})};