function fakeRadio(){ $$('a[inputId="'+this.readAttribute('inputId')+'"]').each(function (e){e.removeClassName('radioFocus')}); if($(this.readAttribute('inputId')).value != this.readAttribute('value')){ this.addClassName('radioFocus'); $(this.readAttribute('inputId')).value = this.readAttribute('value'); }else{ this.removeClassName('radioFocus'); $(this.readAttribute('inputId')).value = ''; } } function imprimir( ){ window.print(); } function flashPutHref( _v ){ } function abrirAtendimento(){ w = window.open('http://www.tomenotablocos.com.br/online/request_email.php?l=admin&x=1&deptid=0',"atendimento","width=500,height=450,scrollbars=yes,left=0,resizable=yes"); w.focus(); pageTracker._trackPageview('Atendimento Online'); } function adicionarFavorito( _id ){ new Ajax.Request('http://www.tomenotablocos.com.br/_ajax.php?acao=adicionarFavorito&id='+_id, { onComplete: function(transport) { var notice = $('marker_'+_id); if (transport.responseText == 'ok'){ notice.removeClassName("desmarcado"); notice.addClassName("marcado"); } } }); } function cadastraNewsletter(){ var email = $('newsletterEmail').value; $('newsletter').update("Carregando..."); new Ajax.Updater($('newsletter'),'http://www.tomenotablocos.com.br/_ajax.php?acao=cadastraNewsletter&email='+email); } function confirmaSenha(){ if($F('senha') != $F('confirmacao')){ alert('A senha deve ser digitada igualmente no campo de confirmação'); $('confirmacao').value = ''; $('senha').focus(); } } catStatus = false; function popCategorias(){ if(catStatus == false){ new Effect.Morph($('menuProdutos'),{ style:{width:'780px'}, duration : 1 }); catStatus = true; }else{ new Effect.Morph($('menuProdutos'),{ style:{width:'100px'}, duration : 1 }); catStatus = false; } } function abrirListaCarrinho( ){ carregaCarrinho(); new Effect.Appear($('carrinho'), {duration: 0.3, afterFinish: function(){ new Effect.Appear($('orcamento'), {duration: 0.3}); }}); } function adicionarCarrinho( _id ){ new Ajax.Request('http://www.tomenotablocos.com.br/_ajax.php?acao=adicionarCarrinho&id='+_id+'&qtd='+$('quantidade'+_id).value, { onComplete: function(transport) { carregaCarrinho(); new Effect.Appear($('encerrarCarrinho'), {duration: 0.3}); } }); return false; } function carregaCarrinho() { new Ajax.Updater('carrinhoLista','http://www.tomenotablocos.com.br/_ajax.php?acao=carregaCarrinhoMini',{ onComplete: function(transport) { //$('carrinhoProdutos').show(); new Effect.Appear($('carrinho'), {duration: 0.3}); //$('carrinhoForm').fade(); } }); } function removerItemCarrinho( _id ) { new Ajax.Request('http://www.tomenotablocos.com.br/_ajax.php?acao=removerItemCarrinho&id='+_id, { onComplete: function(transport) { $('itemCarrinho_' + _id).remove(); } }); return false; } function atualizarQuantidade( _id ){ new Ajax.Request('http://www.tomenotablocos.com.br/_ajax.php?acao=atualizarQuantidade&id='+_id+'&qtd='+$('qtd_'+_id).value, { onComplete: function(transport) { carregaCarrinho(); } }); } function sifrReplace(){ //sIFR.replace(titulo, { selector: 'h2',css: {'.sIFR-root': { 'background-color': '#F1F6E6', 'font-size':'30px','letter-spacing': '-3', 'kerning': 'true' }}}); } function menu(_div){ new Effect.Appear($('statusSite'), { duration: 0.3, from: 0.0, to: 0.5, afterFinish: function (){ new Effect.Fade($('conteudo'),{ duration: 0.3, afterFinish:function(){ new Ajax.Request('http://www.tomenotablocos.com.br/_ajax.php?acao=carregaPagina&pagina=' + _div, { onComplete: function(transport) { $('conteudo').update(transport.responseText); new Effect.Fade($('statusSite'),{ duration: 0.3, afterFinish:function(){ new Effect.Appear($('conteudo'), {duration: 0.3, afterFinish:function(){ pageTracker._trackPageview(_div); sifrReplace(); initForm(); }}); }}); } }); }}); }}); } function rolar( dir ){ x = dir == 'up' ? +1 : -1; contentProdutosLeft = $('contentProdutos').getStyle('left').replace("px","").replace("pt",""); contentProdutosWidth = $('contentProdutos').getStyle('width').replace("px","").replace("pt",""); conteudoWidth = $('conteudo').getStyle('width').replace("px",""); tB = contentProdutosLeft * x < contentProdutosWidth - conteudoWidth ; tC = eval(contentProdutosLeft + x * 700 ) < 0; if ( tB && tC ) { new Effect.MoveBy( $('contentProdutos'), 0 ,x * 700); } } function sendWindowForm( divForm, _form ){ zeraInputs(); var valid; valid = new Validation( _form.id ,{onSubmit:false}); if(valid.validate()){ if($(divForm).firstDescendant().id != 'emailResponse'+divForm) $(divForm).insert({'top' : '
'}); new Effect.Appear($('emailResponse'+divForm),{duration: 1}); $('emailResponse'+divForm).update('Enviando...').setStyle({ background: '#FFFF99' }); new Ajax.Request('http://www.tomenotablocos.com.br/_ajax.php',{ parameters:_form.serialize(), onCreate: function(){_form.hide();}, onComplete: function(transport) { if(transport.responseText == 'ok') $('emailResponse'+divForm).update('A mensagem foi enviado com sucesso').setStyle({ background: "#00FF00" }); else $('emailResponse'+divForm).update('Não foi possível enviar a mensagem neste momento. Tente novamente, por favor.').setStyle({ background: "#FF0000" }); _form.show(); } }); } preencheInputs() //_form.enable(); return false; } function zeraInputs(){ //$$(".inputField").each(function(_ele){ if(_ele.value == _ele.previous('label').innerHTML) _ele.value = ''; }); } function preencheInputs(){ //$$(".inputField").each(function(_ele){ if(_ele.value == '') _ele.value = _ele.title = _ele.previous('label').innerHTML; }); } function blog_focus(){ this.addClassName('inputFocus'); if(this.value == this.previous('label').innerHTML){ this.value = ''; } this.previous('label').addClassName('labelFocus'); } function blog_blur(){ if(this.value == ''){ this.removeClassName('inputFocus'); this.value = this.previous('label').innerHTML; this.previous('label').removeClassName('labelFocus'); } } function initForm(){ preencheInputs() $$(".inputField").each(function(_ele){ Event.observe(_ele, 'focus', blog_focus.bindAsEventListener(_ele)); Event.observe(_ele, 'blur', blog_blur.bindAsEventListener(_ele)); }); $$('a.radio').each(function (_ele){ Event.observe(_ele, 'click', fakeRadio.bindAsEventListener(_ele)); }); } function init() { initForm(); sifrReplace(); uploadArquivo = new SWFUpload({ // Backend Settings upload_url: "http://www.tomenotablocos.com.br/arquivo.php", // Relative to the SWF file // File Upload Settings file_size_limit : "2MB", // 2MB file_post_name : "arquivo", flash_url : "http://www.tomenotablocos.com.br/_shared/_swf/swfupload_f9.swf", post_params : { "chave" : "" }, file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete, upload_start_handler : uploadStartFunction, upload_progress_handler : uploadProgress, upload_error_handler : uploadCompleteArquivo, upload_success_handler : uploadSuccessArquivo, upload_complete_handler : uploadCompleteArquivo, debug_handler : debugFunction//, }); hs.graphicsDir = 'http://www.tomenotablocos.com.br/_shared/images/highslide/'; hs.showCredits = false; hs.allowMultipleInstances = false; hs.loadingText = 'Carregando...'; //var titulo = { src: 'http://www.tomenotablocos.com.br/_imagens/sifr.swf'}; //sIFR.activate(titulo); } Event.observe(window, 'load',init); function debugFunction(message) { //$('debug').insert("\n\n\n" + message); } function fileQueueError(file, error_code, message) { try { if (error_code !== "") { alert("Erro: "+message); return; } } catch (ex) { this.debug(ex); } } function fileDialogComplete(num_files_queued) { try { if (num_files_queued > 0) { this.startUpload(); } } catch (ex) { this.debug(ex); } } function uploadStartFunction(file) { //arquivo = document.createElement("div"); //arquivo.id = file.id+"Div"; $('divFileProgressContainer').insert(''); } function uploadProgress(file, bytesLoaded) { try { var percent = Math.ceil((bytesLoaded / file.size) * 100); $('div_'+file.index).update(percent+" %"); } catch (ex) { this.debug(ex); } } function uploadSuccessArquivo(file, server_data) { try { $('thumbnails').insert(server_data); } catch (ex) { this.debug(ex); } } function uploadCompleteArquivo(file) { try { $('div_'+file.index).fade(); if (this.getStats().files_queued >= 0) { this.startUpload(); } else { $('divFileProgressContainer').insert('O arquivo foi enviado corretamente'); } } catch (ex) { this.debug(ex); } } function uploadError(file, error_code, message) { var image_name = "error.gif"; var progress; try { switch (error_code) { case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: try { $(file.id).update('Cancelado'); } catch (ex1) { this.debug(ex1); } break; case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: try { $(file.id).update('Parado'); } catch (ex2) { this.debug(ex2); } case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: image_name = "uploadlimit.gif"; break; default: $(file.id).update(message); break; } } catch (ex3) { this.debug(ex3); } }