var isLoggedInPage = false;
var topBarPanelSlidingDuration=800;
var specialGroupPrices = new Array(1008,1007);
var currentTopNavItemSite = false;
var loadedLoginPanel = false;
var loadedGroupPanel = false;
var logged_in_domains = new Array();
var logged_out_domains = new Array();
var Client = {
CORSsupport: null,
sid:'egckbkd06i9nh21r03u4sdptus',
account:{no: 14775724, group:1011},
cartId: "0"
};
var nhmgDomains = new Array('naturalhealthmeans.com','labosp.com','easynutrition.eu','naturalhealthmeans.net');
function showLoginPanel(data){
if(loadedLoginPanel){
close_nhmg_top_panel();
return;
}
$('#nhmg_top_panel .container').html(data);
setTopNavItem('login');
$('#nhmg_top_panel').slideDown(topBarPanelSlidingDuration);
loadedLoginPanel = true;
}
function showGroupPanel(name, data){
if(loadedGroupPanel!=false){
if(loadedGroupPanel==name){
close_nhmg_top_panel();
return;
}
close_nhmg_top_panel(0);
}
$('#nhmg_top_panel .container').html(data);
setTopNavItem(name);
$('#nhmg_top_panel').slideDown(topBarPanelSlidingDuration);
loadedGroupPanel = name;
}
function showGroupModal(name, data){
$("#nhmg_modal .modal-title").html(name);
$("#nhmg_modal .modal-body").html(data);
$("#nhmg_modal").modal();
}
function setTopNavItem(itemId){
$('#nhmg_topbar .nav_item').removeClass('selected');
$('#TopNavItem_'+itemId).addClass('selected');
}
function restoreTopNavItem(){
$('#nhmg_topbar .nav_item').removeClass('selected');
$('#TopNavItem_'+currentTopNavItemSite).addClass('selected');
}
function close_nhmg_top_panel(closeDuration){
if (typeof closeDuration === 'undefined') { closeDuration = topBarPanelSlidingDuration; }
$('#nhmg_top_panel').slideUp(closeDuration, restoreTopNavItem);
$('#nhmg_top_panel .container').html();
loadedGroupPanel = false;
}
function set_logged_in_domain(domain){
logged_in_domains.push(domain);
if(logged_in_domains.length == nhmgDomains.length){
nhmguidg = Client.get_nhmguidg();
if(nhmguidg.group==1011){
console.log('Type de compte non choisi');
} else if(nhmguidg.group==1012){
console.log('Commander sans compte');
} else {
console.log('logged in all domains');
window.location.reload();
$("#TopNavItem_login").hide();
$("#TopNavItem_account").show();
}
}
}
function set_logged_out_domain(domain){
logged_out_domains.push(domain);
if(logged_out_domains.length == nhmgDomains.length){
console.log('logged out all domains');
window.location.reload();
}
}
Client.browserSupportsCors = function() {
if (typeof XMLHttpRequest != 'undefined' && typeof XMLHttpRequest.prototype.withCredentials != 'undefined')
return true;
else if (window.XDomainRequest)
return true;
else
return false;
}
Client.login_success = function(data){
if(data.substr(0,11)==''){
this.login_all_domains();
}
return data;
}
Client.login_success_from_cart = function(data){
if(data.substr(0,11)==''){
document.cookie="login_from_cart=1";
this.login_all_domains();
}
return data;
}
Client.sync_session_domains = function(){
string = '';
for(i=0; i < nhmgDomains.length; i++){
string += '';
}
$("#nhmg_topbar .top.container").append(string);
}
Client.login_all_domains = function(){
string = '';
for(i=0; i < nhmgDomains.length; i++){
string += '';
}
$("#nhmg_topbar .top.container").append(string);
}
function showLoginSpinner(){
var opts = {
lines: 13 // The number of lines to draw
, length: 5 // The length of each line
, width: 3 // The line thickness
, radius: 8 // The radius of the inner circle
, scale: 0.5 // Scales overall size of the spinner
, corners: 1 // Corner roundness (0..1)
, color: '#333' // #rgb or #rrggbb or array of colors
, opacity: 0.25 // Opacity of the lines
, rotate: 0 // The rotation offset
, direction: 1 // 1: clockwise, -1: counterclockwise
, speed: 1 // Rounds per second
, trail: 60 // Afterglow percentage
, fps: 20 // Frames per second when using setTimeout() as a fallback for CSS
, zIndex: 2e9 // The z-index (defaults to 2000000000)
, className: 'spinner' // The CSS class to assign to the spinner
, top: '8px' // Top position relative to parent
, left: '50%' // Left position relative to parent
, shadow: false // Whether to render a shadow
, hwaccel: false // Whether to use hardware acceleration
, position: 'absolute' // Element positioning
}
if($('#loadingSpinnerLogin .spinWrap').length > 0)
var spinner = new Spinner(opts).spin($('#loadingSpinnerLogin .spinWrap').get(0));
}
Client.logout_all_domains = function(){
string = '';
for(i=0; i';
}
$("#nhmg_topbar .top.container").append(string);
}
Client.get_nhmguidg = function() {
var name = "nhmguidg=";
var nhmguidg = {no: 0, group: 0};
var ca = document.cookie.split(';');
for(var i=0; i