// global variables //
var TIMER = 5;
var SPEED = 10;
var WRAPPER = 'content';

// calculate the current window width //
function pageWidth() {
  return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

// calculate the current window height //
function pageHeight() {
  return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

// calculate the current window vertical offset //
function topPosition() {
  return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

// calculate the position starting at the left of the window //
function leftPosition() {
  return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}

// build/show the dialog box, populate the data and call the fadeDialog function //
function showDialog(title,message,type,autohide) {
  if(!type) {
    type = 'error';
  }
  var dialog;
  var dialogheader;
  var dialogclose;
  var dialogtitle;
  var dialogcontent;
  var dialogmask;
  if(!document.getElementById('dialog')) {
    dialog = document.createElement('div');
    dialog.id = 'dialog';
    dialogheader = document.createElement('div');
    dialogheader.id = 'dialog-header';
    dialogtitle = document.createElement('div');
    dialogtitle.id = 'dialog-title';
    dialogclose = document.createElement('div');
    dialogclose.id = 'dialog-close'
    dialogcontent = document.createElement('div');
    dialogcontent.id = 'dialog-content';
    dialogmask = document.createElement('div');
    dialogmask.id = 'dialog-mask';
    document.body.appendChild(dialogmask);
    document.body.appendChild(dialog);
    dialog.appendChild(dialogheader);
    dialogheader.appendChild(dialogtitle);
    dialogheader.appendChild(dialogclose);
    dialog.appendChild(dialogcontent);;
    dialogclose.setAttribute('onclick','hideDialog()');
    dialogclose.onclick = hideDialog;
	//added ANGR 01/06/2010
    document.body.onclick = hideDialog;
  } else {
    dialog = document.getElementById('dialog');
    dialogheader = document.getElementById('dialog-header');
    dialogtitle = document.getElementById('dialog-title');
    dialogclose = document.getElementById('dialog-close');
    dialogcontent = document.getElementById('dialog-content');
    dialogmask = document.getElementById('dialog-mask');
    dialogmask.style.visibility = "visible";
    dialog.style.visibility = "visible";
    document.body.onclick = hideDialog;
  }
  dialog.style.opacity = .00;
  dialog.style.filter = 'alpha(opacity=0)';
  dialog.alpha = 0;
  var width = pageWidth();
  var height = pageHeight();
  var left = leftPosition();
  var top = topPosition();
  var dialogwidth = dialog.offsetWidth;
  var dialogheight = dialog.offsetHeight;
//   var topposition = top + (height / 3) - (dialogheight / 2)+150;
  var topposition = top + (height / 3) - (dialogheight / 2)+50;
  var leftposition = left + (width / 2) - (dialogwidth / 2);
  dialog.style.top = topposition + "px";
  dialog.style.left = leftposition + "px";
  dialogheader.className = type + "header";
  dialogtitle.innerHTML = title;
  dialogcontent.className = type;
  dialogcontent.innerHTML = message;
  var content = document.getElementById(WRAPPER);
if (content == null) content = document.body;
//   dialogmask.style.height = content.offsetHeight + 'px';
  dialogmask.style.height = content.offsetHeight*2 + 'px';
  dialog.timer = setInterval("fadeDialog(1)", TIMER);
  if(autohide) {
    dialogclose.style.visibility = "hidden";
    window.setTimeout("hideDialog()", (autohide * 1000));
  } else {
    dialogclose.style.visibility = "visible";
  }
}

// hide the dialog box //
function hideDialog() {
  var dialog = document.getElementById('dialog');
  clearInterval(dialog.timer);
  dialog.timer = setInterval("fadeDialog(0)", TIMER);
}

// fade-in the dialog box //
function fadeDialog(flag) {
  if(flag == null) {
    flag = 1;
  }
  var dialog = document.getElementById('dialog');
  var value;
  if(flag == 1) {
    value = dialog.alpha + SPEED;
  } else {
    value = dialog.alpha - SPEED;
  }
  dialog.alpha = value;
  dialog.style.opacity = (value / 100);
  dialog.style.filter = 'alpha(opacity=' + value + ')';
  if(value >= 99) {
    clearInterval(dialog.timer);
    dialog.timer = null;
  } else if(value <= 1) {
    dialog.style.visibility = "hidden";
    document.getElementById('dialog-mask').style.visibility = "hidden";
    clearInterval(dialog.timer);
  }
}

function showMess() {
//  activate to warn all customers , no other messages please
//		 showMess1();
// activate for specific customers
// 		 showMess2();
//activate for Xmas and New Year
// 		 showMessXMNY();
//  activate to warn all customers about maintenance   and sorry message
// 		 showMess3();
}

function showMess1() {
	var replie;
	var e='<b>Attention, Attention, Opgelet !!!!!!</b>';     //title
	var add="<br> Cher client,";
	add+="<br>	Beste klant,	";
	add+="<br>	Dear customer,	";
	add+="<br>	";
	var t='success';        //style (alert, warning, prompt or success)
	var s =2;
	var mainte='';
	mainte+='<br><br>Due to important maintenance works the on-line tools of GLS Belgium Distribution will not be available from Tuesday, 17th of Januar 2012  12.00h until Tuesday, 17th of Januar 2012 13.00h.';
	mainte+='<br><br>Wegens belangrijke onderhoudswerken zal de site OnlineTools GLS Belgium Distribution niet beschikbaar zijn van dinsdag 17 januari 2012 12.00uur  tot dinsdag 17 januari 2012 13.00uur.';
	mainte+="<br><br>Suite à d'importants travaux de maintenance le site des outils en ligne de GLS Belgium Distribution ne sera pas disponible à partir du mardi 17 Janvier 2012 de 12.00h  au mardi 17 Janvier 2012 13.00h";
// 	mainte+='<br><br>On fridays december 24 and december 31, no express orders will be accepted for saturday delivery. We wish you a merry Xmas and a happy New Year';
	mainte+='<br><br>';
	mainte+="<br><br>";

		showDialog(e,mainte,t,false);
}

function showMess2() {
	var replie;
	var e='<b>Attention, Attention, Opgelet !!!!!!</b>';     //title
	var m='';
// 	m='<input type=radio name="account2" id=rBD value="BD" onclick="returnval();hideDialog()">GLS Belgium Distribution ';
// 	m+='<br><input type=radio name="account2" id=rBE value="BE" onclick="returnval();hideDialog()" >GLS Belgium.';

// 	m+='<br><br>Due to important maintenance works the on-line tools of GLS Belgium Distribution will not be available from Saturday, 5th of June  06.00h until Saturday, 5th of June  13.00h.';
// 	m+='<br><br>Wegens belangrijke onderhoudswerken zal de site OnlineTools GLS Belgium Distribution niet beschikbaar zijn van zaterdag 05 juni 2010  tot zaterdag 05 juni 2010 13.00uur.';
// 	m+="<br><br>Suite à d'importants travaux de maintenance le site des outils en ligne de GLS Belgium Distribution ne sera pas disponible à partir du samedi 5 Juin de 06.00h  au samedi 5 Juin  13.00h";

	var add="<br> Cher client,";
	add+="<br>	";

	var addnl="<br>	Beste klant,	";
	addnl+="<br>	";

	var adden="<br>	Dear customer,	";
	adden+="<br>	";



// 	var dd="<br> -> Etiquettes: afin de toujours mieux vous servir, GLS Belgium Distribution a adapté la  	";
// 	dd+="	présentation des étiquettes imprimées avec l’application SPRINT Online.   	";
// 	dd+="	Ces étiquettes intègrent à partir d’aujourd’hui les informations complètes	";
// 	dd+="	servant à la livraison de vos expéditions dans les meilleures conditions.	";
// 	dd+="	Ceci évite tout réétiquetage supplémentaire des marchandises à l’arrivée	";
// 	dd+="	dans nos centres logistiques, ce qui supprime tout risque lié à ce réétiquetage.		";
// 	dd+="<br><br>                                                                              	   ";
// 	
// 	var ddnl="<br>	-> Etiketten: om u nog beter te dienen heeft GLS Belgium Distribution de presentatie van    	";
// 	ddnl+="	zijn etiketten, die gedrukt worden met de applicatie SPRINT Online, aangepast.	";
// 	ddnl+=" Deze etiketten bevatten vanaf vandaag de volledige informatie nodig voor de  	";
// 	ddnl+="	levering van uw zendingen onder de beste omstandigheden. Hierdoor vermijden  	";
// 	ddnl+="	we het heretiketteren van de goederen bij aankomst in onze logistieke centra,	";
// 	ddnl+="	wat elk risico in verband met het heretiketteren vermijdt.						";
// 	ddnl+="<br><br>																			";
// 	
// 	var dden="<br>	-> Labels: to serve you better, GLS Belgium Distribution has changed the lay-out of its	";
// 	dden+="	labels printed by the application SPRINT Online. These labels contain as from	";
// 	dden+="	today the complete information necessary for the delivery of your consignments	";
// 	dden+="	under the best circumstances.	";
// 	dden+="<br>	This way we avoid the relabeling of your goods at arrival in our logistic	";
// 	dden+="   centres, what avoids all risk concerning the relabeling.	";
// 	dden+="<br><br>                                                                                  ";
// 	
//
// 	var xdd="<br>	-> Produits: afin d'être mieux aligné avec la structure de votre tarif personnel,  	";
// 	xdd+="	GLS Belgium Distribution a supprimé le choix entre Parcel et Freight qui   	";
// 	xdd+="	était lié à votre login.  Vous ne devez donc plus choisir, GLS choisira	";
// 	xdd+="	pour vous son réseau le plus adapté à la livraison de vos marchandises.	";
// 	xdd+="<br><br>                                                                                  ";
// 
// 	var xddnl="<br>	-> Producten: om beter aangepast te zijn met de structuur van uw persoonlijke    	";
// 	xddnl+="	tarief bij GLS Belgium Distribution, hebben we de keuze tussen Parcel en Freight in onze	";
// 	xddnl+="	SPRINT Online applicatie voor uw login verwijderd. U moet dus niet meer kiezen,  	";
// 	xddnl+="	GLS zal voor de levering van uw goederen zijn meest geschikte netwerk selecteren.  	";
// 	xddnl+="<br><br>                                                                                  ";
// 	
// 	var xdden="<br>	-> Products: to be better aligned with the structure of your personnal tariff,	";
// 	xdden+="	GLS Belgium Distribution has removed the selection between Parcel and Freight	";
// 	xdden+="	that was linked to your profile.  Your do not have to choose anymore, GLS will	";
// 	xdden+="	select for you his best network to deliver your goods.	";
// 	xdden+="<br><br>                                                                                  ";



	var dd="<br> Afin de toujours mieux vous servir, GLS Belgium Distribution a adapté   	";
	dd+="	la présentation des <b>étiquettes</b> imprimées.   	";
	dd+="	<br>Ces étiquettes intègrent à partir d'aujourd'hui les informations complètes 	";
	dd+="	servant à la livraison de vos expéditions dans les meilleures conditions. 	";
	dd+="<br><br>                                                                              	   ";
	
	var ddnl="<br> Om u nog beter te dienen heeft GLS Belgium Distribution de lay-out van    	";
	ddnl+="	 zijn <b>etiketten</b> aangepast.	";
	ddnl+="  <br>Deze etiketten bevatten vanaf vandaag de volledige informatie die nodig is voor de  	";
	ddnl+="	 levering van uw zendingen onder de beste omstandigheden.  	";
	ddnl+="<br><br>																			";
	
	var dden="<br> To serve you better, GLS Belgium Distribution has changed the lay-out of its	";
	dden+="	 <b>labels</b>. 	";
	dden+="	 <br>These labels contain as from today the complete information necessary	";
	dden+="	 for the delivery of your consignments under the best circumstances.	";
	dden+="<br><br>                                                                                  ";
	

	var xdd="<br> Dans le but d'optimaliser, GLS Belgium Distribution a fait les changements	";
	xdd+="	 appropriés dans l'application Sprint online en tenant compte de votre <b>profil</b> de transport. 	";
	xdd+="	 <br>Vous ne devez donc plus choisir entre Parcel et Freight, vos expéditions seront en livraison 	";
	xdd+="	 via le réseau GLS le plus adapté à vos envois.  	";
	xdd+="<br><br>                                                                                  ";

	var xddnl="<br>	GLS Belgium Distribution heeft wijzigingen aangebracht in de applicatie    	";
	xddnl+="  Sprint online, rekening houdend met uw persoonlijk transport<b>tarief</b>.   		";
	xddnl+="  <br>U hoeft dus niet meer te kiezen tussen Parcel en Freight, 	";
	xddnl+="  GLS zal voor de levering van uw goederen zijn meest geschikte netwerk selecteren.  	";
	xddnl+="<br><br>                                                                                  ";
	
	var xdden="<br>	GLS Belgium Distribution made some changes in the application Sprint online, 	";
	xdden+="  to be better aligned with the structure of your personnal <b>tariff</b>.	";
	xdden+="  <br>You do not have to choose anymore between Parcel and Freight, 	";
	xdden+="  GLS will select his best network to deliver your goods.	";
	xdden+="<br><br>                                                                                  ";

	var ydd="<br>	Merci de nous faire confiance.	";
	ydd+="<br>	";

	var yddnl="<br>Wij danken u voor uw vertrouwen.	";
	yddnl+="<br>	";

	var ydden="<br>	We thank you for your trust.	";
	ydden+="<br>	";




	var t='success';        //style (alert, warning, prompt or success)
	var s =2;

	if (  ((XMLLabelType && (XMLLabelType.substr(3,1)=='5')) || (XMLS2 && (XMLS2.substr(3,1)=='4')) )
            && ((servName=='testBD')||(servName=='appBD')||(servName=='prodBD'))  )
        {

            switch (docdir)
             {
               case 'F':
               m+=add
               if (XMLLabelType && (XMLLabelType.substr(3,1)=='5')){m+=dd;}
               if (XMLS2 && (XMLS2.substr(3,1)=='4')){m+=xdd;}
               m+=ydd;
                    break;
               case 'N':
               m+=addnl
               if (XMLLabelType && (XMLLabelType.substr(3,1)=='5')){m+=ddnl;}
               if (XMLS2 && (XMLS2.substr(3,1)=='4')){m+=xddnl;}
               m+=yddnl;
                    break;
               case 'E':
               m+=adden
               if (XMLLabelType && (XMLLabelType.substr(3,1)=='5')){m+=dden;}
               if (XMLS2 && (XMLS2.substr(3,1)=='4')){m+=xdden;}
               m+=ydden;
                    break;
               default:
                    break;

             }
		showDialog(e,m,t,false);

        }
}
function showMessXMNY() {
	var replie;
	var e='<b>Attention, Attention, Opgelet !!!!!!</b>';     //title
	var m='';
	var add="<br> Cher client,";
	add+="<br>	";

	var addnl="<br>	Beste klant,	";
	addnl+="<br>	";

	var adden="<br>	Dear customer,	";
	adden+="<br>	";



	var dd="<br>GLS sera fermé le samedi 25 décembre et le samedi 1 janvier.	";
	dd+="	<br><br>Les envois express envoyées le vendredi 24 décembre ne seront livrés que le lundi 27 décembre.";
	dd+="	<br><br>Seuls des enlèvements seront effectués en date du lundi 03/01/2011. 	";
	dd+="	De ce fait, les envois express envoyés le vendredi 31 décembre seront livrés le mardi 04/01/2011.";
	dd+="	<br><br>En espérant que ces informations vous permettront de mieux planifier la distribution de vos 	";
	dd+="	 marchandises, nous restons à votre disposition pour plus de 	";
	dd+="	renseignements et vous souhaitons d’ores et déjà un joyeux Noël et une bonne année 2011.";
	dd+="<br><br>Votre équipe GLS                                                                              	   ";

	var ddnl="<br>GLS zal op zaterdag 25 december en zaterdag 1 januari gesloten zijn.";
	ddnl+="  <br><br>De express-zendingen opgehaald op vrijdag 24/12/2010 zullen pas ";
	ddnl+="	 uitgeleverd worden op maandag 27/12/2010.";
	ddnl+="  <br><br>Op maandag 03/01/2011 zijn er geen leveringen, enkel ophalingen.";
	ddnl+="  <br><br>De zendingen opgehaald op vrijdag 31/12/2010 zullen pas	";
	ddnl+="	 uitgeleverd worden op dinsdag 04/01/2011. ";
	ddnl+="	 <br><br>In de hoop U hiermee van dienst te zijn geweest, wensen we u reeds een zalig kerstfeest en een gelukkig 2011 toe.	";
	ddnl+="<br><br>Uw GLS-team.																			";
	
	var dden="<br>GLS will be closed Saturday, December 25 and Saturday, the first of January.";
	dden+="	 <br><br>The express shipments picked up on Friday, December 24 will be delivered on Monday, December 27.";
	dden+="	 <br><br>On Monday, January 3, there are no deliveries, just collections.";
	dden+="	 <br><br>The shipments collected on Friday, December 31 will be delivered on Tuesday, January 4.";
	dden+="	 <br><br>Hoping to have served you, we wish you already a Merry Christmas and a Happy New Year 2011.";
	dden+="<br><br>Your GLS team.                                                                                  ";
	

	var t='success';        //style (alert, warning, prompt or success)
	var s =2;

// 	if (  ((XMLLabelType && (XMLLabelType.substr(3,1)=='5')) || (XMLS2 && (XMLS2.substr(3,1)=='4')) )
//             && ((servName=='testBD')||(servName=='appBD')||(servName=='prodBD'))  )
//         {

            switch (docdir)
             {
               case 'F':
               m+=add;
               m+=dd;
                    break;
               case 'N':
               m+=addnl;
               m+=ddnl;
                    break;
               case 'E':
               m+=adden;
               m+=dden;
                    break;
               default:
                    break;
             }
		showDialog(e,m,t,false);

//         }
}

function showMess3() {
	var replie;
	var e='<b>Attention, Attention, Opgelet !!!!!!</b>';     //title
	var m='';
	var add="<br> Cher client,";
	add+="<br>	";

	var addnl="<br>	Beste klant,	";
	addnl+="<br>	";

	var adden="<br>	Dear customer,	";
	adden+="<br>	";



	var dd="<br>Nous sommes désolés des soucis occasionnés par la mise à jour de notre site Internet	";
	dd+="ce lundi 24 janvier 2011.  Croyez bien que tout le nécessaire sera fait afin que de tels désagréments ";
	dd+="ne se représentent plus.";
	dd+="<br><br>Toutefois, nous attirons votre attention sur le fait qu'une nouvelle mise à jour majeure de notre ";
	dd+="application en ligne aura lieu durant le week-end des 29 et 30 janvier prochains.	";
	dd+="<br><br>Il se peut donc que de nouvelles perturbations dans votre mode de travail soient occasionnées ";
	dd+="par ces modifications, mais croyez bien que celles-ci ont été étudiées en profondeur afin de ";
	dd+="répondre au mieux aux besoins de nos clients. ";
	dd+="<br><br>Merci de votre compréhension, ";
	dd+="<br><br>Votre équipe GLS";

	var ddnl="<br>Onze excuses voor het ongemak veroorzaakt door het actualiseren van onze website op  ";
	ddnl+="  maandag 24 januari 2011. Wij verzekeren u dat we er alles aan doen om dergelijke ";
	ddnl+="	 ongemakken in de toekomst te voorkomen.";
	ddnl+="  <br><br>Wij willen echter uw aandacht vestigen op het feit dat er een nieuwe update van onze online ";
	ddnl+="  applicatie zal plaatshebben tijdens het weekend van 29 en 30 januari. ";
	ddnl+="  <br><br>Het is mogelijk dat er zich tijdens het werken enige problemen kunnen voordoen veroorzaakt 	";
	ddnl+="	 door deze wijzigingen, maar u kan er zeker van zijn dat deze grondig bestudeerd werden  ";
	ddnl+="	 om beter aan de behoeften van onze klanten te voldoen.	";
	ddnl+="<br><br>Uw GLS-team.																			";

	
	var dden="<br>We are sorry for the inconvenience caused by the update of our Internet site on Monday the 24th of Januari 2011. ";
	dden+="Please believe that we do anything we can to avoid such desagreements in the future.";
	dden+="<br><br>Be informed that again a new version of our online applications will be activated during the week-end ";
	dden+="of the 29th and 30th of January.";
	dden+="<br><br>It can happen that you experience then some problems in your actual way of working, but you can be sure ";
	dden+="that all the modifications are deeply investigated to answer the needs of our customers."	
	dden+="<br><br>Thank you for your comprehension,"
	dden+="<br><br>Your GLS team.";
	

	var t='success';        //style (alert, warning, prompt or success)
	var s =2;


            switch (docdir)
             {
               case 'F':
               m+=add;
               m+=dd;
                    break;
               case 'N':
               m+=addnl;
               m+=ddnl;
                    break;
               case 'E':
               m+=adden;
               m+=dden;
                    break;
               default:
                    break;
             }
		showDialog(e,m,t,false);

//         }
}


