/**
* ---------------------------- //
* Classe com metodos comuns
* ---------------------------- //
**/
var structure = {
isLoad : false,
init : function() {
if(!this.isLoad) this.isLoad = true;
else return false;
structure.header.init();
// structure.footer.init();
structure.internal.init();
// if(ROOT_TREE == 'Hotsites') hotsite.init();
},
/**
* ----------------- //
* Header [start]
* ----------------- //
**/
header : {
init : function() {
structure.header.form.init();
// structure.header.care();
/**
* Add Rounded Corners
**/
var navBg = null;
var titleBg = null;
var careBg = null;
if ($('body').attr('id') == 'marinheiro'){
titleBg = '#006d95';
navBg = '#0b889e';
careBg = '#02a4bb';
} else if ( $('body').attr('id') == 'somerj' ) {
titleBg = '#d8d9db';
navBg = '#088879';
careBg = '#0aa995';
} else if ( $('body').attr('id') == 'aeronautica' ) {
titleBg = '#82b007';
navBg = '#4c8c2c';
careBg = '#699e42';
} else {
titleBg = '#5a9600';
navBg = '#5a9600';
careBg = '#5a9600';
}
$('> li > a', '#areaLogin #navigation > ul').cornerz({ radius: 6, corners:'tl tr', background : navBg });
$('h3, fieldset', '#areaLogin form').cornerz({ radius: 6, background : titleBg });
$('label', '#areaLogin form').cornerz({ radius: 6, background : '#6ba11a' });
$('> h3', '#care').cornerz({ radius:6, corners:'tl tr bl', background : careBg });
if( $.browser.msie ) {
$( 'label.password-login' ).css( { width : 144 } );
}
/*
$('> ul > li > a', '#navigation').bind('click', function(){
return false;
});
*/
},
/**
* ------------------- //
* Form - Header
* ------------------- //
**/
form : {
init : function(){
var initval = 'Nº da carteirinha';
$( '#areaLogin form #usuario' ).setMask('9999999999999999').val(initval).focusin( function() {
$(this).val( ( $(this).val() == initval) ? '037' : $(this).val() );
} ).focusout( function() {
$(this).val( ( $(this).val() === '' || $(this).val() == '037') ? initval : $(this).val() );
});
$('#areaLogin form').submit(function() {
structure.header.form.validate();
return false;
});
},
validate : function(){
var form = $('#areaLogin form');
if( $('#usuario', form).val() == 'Nº da carteirinha'){
helpers.errorAlert( $('#areaLogin'), 'Número do cartão está incorreto.');
} else if( $('#usuario', form).val().length < 1){
helpers.errorAlert( $('#areaLogin'), 'Número do cartão está incorreto.');
} else if( $('#senha', form).val().length < 1){
helpers.errorAlert( $('#areaLogin'), 'Preencha corretamente sua senha.');
} else {
this.sendData();
}
},
sendData : function(){
helpers.errorAlert( $('#areaLogin'), 'Aguarde...', {'bgcolor':'#d3d3c3', 'color':'#3c493e', 'cornerzColor': '#B9D300', 'autoFadeOut': false, 'animTime':0});
var form = $('#areaLogin form');
var url = form.attr('action');
var data = {
cartao: $("#usuario", form).val(),
senha: $("#senha", form).val()
}
$.ajax({
url: url,
data: data,
type: 'POST',
success: function(data) {
if (data == "logado") {
window.location = AREA_EXCLUSIVA_URL;
} else {
helpers.errorAlert( $('#areaLogin'), 'Dados inválidos.', {'fadeOutDelay': 5000, 'cornerzColor': '#B9D300'});
}
},
error: function(request){
helpers.errorAlert( $('#areaLogin'), 'Dados inválidos.', {'fadeOutDelay': 5000, 'cornerzColor': '#B9D300'});
}
});
return false;
}
},
/**
* ------------------- //
* Care - Header
* ------------------- //
**/
care : function() {
/**
* Insert images dynamic
**/
$( '#care ul li' ).each( function() {
var tagImg = "";
$( tagImg ).appendTo( $( this ) );
} );
$( '#care ul li' ).click( function() {
$( this ).find( 'a' ).trigger( 'click' );
} );
/**
* Mouse Events
*/
var elm = $( '#care ul' );
var h = elm.height();
elm.hide().css( { height:0 } );
$( '#care' ).mouseleave( function() {
elm.stop().animate( { height:0 }, { duration:300, complete: function(){
elm.hide();
}});
}).mouseenter( function(){
elm.show().stop().animate( { height:h }, { duration:300 });
});
/**
* --------------------------------- //
* Mouse over dos itens do submenu
* --------------------------------- //
**/
elm.find( 'li' ).mouseenter( function() {
$( this ).find( 'div.border-color-box' ).show();
} ).mouseleave( function() {
$( this ).find( 'div.border-color-box' ).hide();
} );
$( '#care ul li' ).show();
}
/**
* ------------------- //
* Navigation - Header
* ------------------- //
**/
/*
navigation : function() {
helpers.menu.init();
}
*/
},
internal : {
init : function(){
structure.internal.breadcrumb();
structure.internal.addRoudedCorners();
$('input[placeholder]').placeholder();
// Veja também - mouseFX
helpers.buttonFx( $('> a', '#see-more .services'), '#ff8f2a');
helpers.buttonFx( $('> a', '#see-more .plans'), '#00bacb');
//Banner de Sustentabilidade
var banner = $('#sustainability li:last-child');
var imagePath = banner.attr('data-image');
// banner.css({ backgroundImage: 'url("' + imagePath + '")' });
$('#sustainability').bind('click', function(){
window.location = $('> a', '#sustainability li').attr('href');
});
// Eventos da barra do corretor
var el = $( '#simulate-contact' );
$( 'a.pop-send-message', el ).unbind( 'click' ).bind( 'click', function() {
window.location = "#" + jQuery.url.setUrl( $( this ).attr( 'href' ) ).attr( "anchor" );
helpers.openModal( $( this ).attr( 'href' ), care.init);
return false;
} );
},
breadcrumb : function() {
$('#breadcrumb li:last-child').addClass('current-page');
},
addRoudedCorners : function() {
/* Sustainability banner include */
$('#sustainability li:first-child').cornerz({radius:6, background : '#f8f8e9'});
$('#sustainability li:last-child').cornerz({radius:6, corners:'tl tr bl', background : '#f8f8e9'});
/* See more include */
$('.services ul').cornerz({ radius: 6, background : '#f8f8e9' });
/* Simulate / Contact include */
var simulateContact = $( '#simulate-contact' );
$('> li', simulateContact).cornerz({ radius: 6, background : '#f8f8e9' });
$('> .green-left > div > a', simulateContact).cornerz({ radius: 6, background : '#5a9600' });
$('> .green-right > a', simulateContact).cornerz({ radius: 6, background : '#b9d300' });
}
},
/**
* ----------------- //
* Header [end]
* ----------------- //
**/
/**
* ----------------- //
* Footer [start]
* ----------------- //
**/
footer : {
init : function() {
/**
* Social Network config
**/
$('#footer_social_network li, #holder-social li').bind('mouseenter', function(){
$(this).find('h3').stop().hide();
$(this).find('h4').stop().fadeTo(250, 1);
})
.bind('mouseleave', function(){
$(this).find('h3').stop().show();
$(this).find('h4').stop().fadeTo(250, 0);
})
.bind('click', function(){
window.open($(this).find('a').attr('href'));
});
/**
* Exclusive Areas config
**/
$('#footer_exclusive_areas li').find('img').hide();
for(var i=0; i < $('#footer_exclusive_areas li').length; i++)
{
var obj = $('#footer_exclusive_areas li:eq(' + i + ')');
var img = obj.find('img').attr('src');
obj.css({'background':'#a6c1b0 url(' + img + ') no-repeat'});
}
$('#footer_exclusive_areas li').bind('mouseenter', function(){
$(this).find('h3').stop().hide();
$(this).find('h4').stop().fadeTo(250, 1);
$(this).css({'background-color' : $(this).attr('rel'), 'background-position' : '0 -60px'});
})
.bind('mouseleave', function(){
$(this).find('h3').stop().show();
$(this).find('h4').stop().fadeTo(250, 0);
$(this).css({'background-color' : '', 'background-position' : '0 0'});
})
.bind('click', function(){
self.location = $(this).find('a').attr('href');
});
/**
* Lightbox config
**/
/*
$('#footer_info a.lightbox').bind('click', function(){
helpers.openModal( $( this ).attr( 'href' ), structure.footer.onLoadModal );
return false;
});
*/
/**
* Check if user has local storage
*/
if(localStorage.length) {
$('div.hide-medic').hide();
structure.footer.showMedics();
} else {
$('div.show-medic').hide();
// $('#footer_search aside > h3').hide();
}
/**
* Add Rounded Corners
**/
$('.itens-social-network li').cornerz({radius:6, background : '#d0dbca'});
$('#footer_exclusive_areas').cornerz({radius:6, corners:'tr', background : '#f8f8e9'});
$('#footer_exclusive_areas li').cornerz({radius:6, background : '#d0dbca'});
$('#footer-medical-guide').cornerz({radius:6, corners:'tl', background : '#f8f8e9'});
$('#fb').cornerz({radius:6, background : '#005746'});
$('aside > div', '#footer_search').cornerz({radius:6, background : '#005746'});
$('h3', '#footer_search aside div.show-medic').cornerz({radius:6, corners:'bl br'});
$('> h3', '#footer_search aside').cornerz({radius:6, background : '#005746'});
//$('#fancybox-outer').cornerz({radius:6, corners:'tl tr bl'});
helpers.buttonFx( $('.bt-medical-guide'), '#33796b' );
},
onLoadModal : function(){
$('.pop section').cornerz( { radius : 6, corners : "tl tr bl" } );
},
addMedic : function(){
//TODO: passar itens para serem adicionados: nome, endereço e telefone;
// Pegar itens dos elementos html;
$.getJSON(MEDIA_URL + 'assets/json/medics.json', function(data) {
var value = data.medic[0].name + ';' + data.medic[0].area + ';' + data.medic[0].adr + ';' + data.medic[0].phone;
localStorage.setItem( value, value );
});
},
showMedics : function() {
for(i = 0; i < localStorage.length; i++) {
var arr = localStorage.key(i).split(';');
var html = '
' + arr[1] + '
' + '' + '' + arr[2] + '' + '
' + 'Tel.: ' + arr[3] + '
' + '