/* Fonctions présentes dans ce fichier:
   goPage(pageId, init, param, useGo, CDOPTRN, newLanguage, mfPage, mfRfsigna, mfNoidscr, mfCdtypvi, mfNvswqp2)
   goUsing(param, mfNoidscr)
   goMyEthias()
   demande_aff()
   demande_mdp(noidaff)
   forgetPwd()
   goSearch()
   goSociete(aEnviro)
   goInfos()
   goJobs()
   goStaticConcours()
   popupCharte()
   popupSofisk()
   goQuotes()
   goQubscriptions()
*/


// --------------------------------------------------------
// goPage(pageId, init, param, useGo, CDOPTRN, newLanguage)
// --------------------------------------------------------
// PURPOSE : Switch page in the site

/* pageId : page destination
 * init   : I - page initiale
 *        : S - page statique
 *        : M - page mainframe
 * param  : chaine contenant les paramètres supplémentaires
 * useGo  : action à utiliser si différents de 'pageId'.go
 * newLanguage : permet de changer la langue du site
 *
 * mfPage 	 : uniq pour mainframe - valeur page retour
 * mfRfsigna : uniq pour mainframe - valeur rfsigna retour
 * mfNoidscr : uniq pour mainframe - valeur noidscr retour
 * mfCdtypvi : uniq pour mainframe - type de visiteur
 * mfNvswqp2 : uniq pour mainframe - ident utilisateur (cookie)
 *
 **********************************************************/
function goPage(pageId, init, param, useGo, CDOPTRN, newLanguage, mfPage, mfRfsigna, mfNoidscr, mfCdtypvi, mfNvswqp2){

	if(param == null) param = '';
  if(CDOPTRN == null) CDOPTRN = 'SMINT';

  var loc='';

  if(useGo == null){
    if(init == 'I'){
      loc = "/en/" + pageId + ".go?NOPGDEM=" + pageId;
    }else{
      loc = "/en/static/static.go?NOPGDEM=" + pageId;
    }
  }else{
    if(init == 'I'){
      loc = "/en/" + useGo + ".go?NOPGDEM=" + pageId;
    }else{
      loc = "/en/static/" + useGo + ".go?NOPGDEM=" + pageId;
    }
  }

  if (init=='M'){
    loc = "/en/smapinter.go?IMSTRAN=" + mfPage.substr(0,6) + "&CDEMID=" + mfPage.substr(6,2) + "&RFSIGNA=" + mfRfsigna + "&NOIDSCR=" + mfNoidscr + "&CLE=&CDLGPAG=E&CDTYPVI=" + mfCdtypvi + "&NOIDUSR=" + mfNvswqp2.substr(0,7) + "&NOSQUSR=" + mfNvswqp2.substr(7,2) + "&CDOPTRN=" + CDOPTRN;

    if(newLanguage != null){
      loc += '&CDLGTRN=' + newLanguage;
    }else{
      loc += '&CDLGTRN=E';
    }
  }

  if(newLanguage != null){
    loc += '&amp;qs_lg=' + newLanguage;
  }

  loc+=param;

  // PDO 18/03/2004 : Correction pour que, lors du changement de langue, l'url passe de assurance à verzekering
  if(newLanguage != null){
    location.href = "http://europe.ethias.be/?" + newLanguage;
  }

  document.location.href=loc;
}

// --------------------------------------------------------
// goUsing(param, mfNoidscr)
// --------------------------------------------------------
// PURPOSE : Access a page using an action ".go" matching the pageid instead of the "static.go"

/* param 		 : pageid to set to the action ".go"
 * mfNoidscr : only for mainframe  - scratch number
 *
 **********************************************************/

function goUsing(param, mfNoidscr){
	var pageId = param;

	if(pageId.indexOf('|') > 0){
	  pageId = pageId.substr(0, pageId.indexOf('|'));
	}

	var useGo = pageId.substr(0,2).toLowerCase() + '/' + pageId;

	var paramExt = '';

	if(param.lastIndexOf('|') > 0){
	  paramExt= param.substr(param.lastIndexOf('|') + 1);
	}

	if(param == 'D5SC020' || param == 'SMIF090'){
	  if(mfNoidscr == '' || mfNoidscr == null){
	    var urlInit = '/initMF.go?IMSTRAN=WSM328&CDEMID=1&CDOPTRN=SMINT&CLE=&CDLGTRN=E&aIMSTRAN=USING&aCDOPTRN=' + pageId;

	    document.location.href = urlInit;
	  }else{
	    goPage(pageId, 'S', paramExt, useGo);
	  }
	}else{
	  goPage(pageId, 'S', paramExt, useGo);
	}
}

// --------------------------------------------------------
// goMyEthias()
// --------------------------------------------------------
// PURPOSE : Open the MyEthias Login Page

function goMyEthias(){
  switch (enviro){
    case 'TEST':
      {
        location.href="https://devsol.nrb.be/myethias-en";
        return;
        break;
      }
    case 'HOMO':
      {
        location.href="http://myethiaspreprod.ethias.be/?E";
        return;
        break;
      }
    case 'PROD':
      {
        location.href="http://myethias.ethias.be/?E";
        return;
        break;
      }
    default:
      {
        location.href="http://myethias.ethias.be/?E";
        return;
        break;
      }
  }
}

// --------------------------------------------------------
// demande_aff()
// --------------------------------------------------------
// PURPOSE : Open the Request MyEthias Login Page
function demande_aff(){
	window.open("/smapinter.go?IMSTRAN=WS1098&CDEMID=1&CDOPTRN=S2VAF&CLE=&CDLGTRN=E&CDLGPAG=E&CDENTREE=N&NOPGACT=SMIF190&NOPGDEM=WS1098O1AFFIL","Demande_numéro_d_affilié","width=600,height=350,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes");
}

// --------------------------------------------------------
// demande_mdp(noidaff)
// --------------------------------------------------------
// PURPOSE : Open the Request MyEthias Password Page
// IN : noidaff : id of the client
function demande_mdp(noidaff){
	window.open("/smapinter.go?IMSTRAN=WS1098&CDEMID=1&CDOPTRN=S2CPW&CLE=&CDLGTRN=E&CDLGPAG=E&CDENTREE=N&NOPGACT=SMIF190&NOPGDEM=WS1098O1AFFIL&NOIDAFF="+noidaff,"Demande_mot_de_passe","width=600,height=415,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes");
}

// --------------------------------------------------------
// forgetPwd()
// --------------------------------------------------------
// PURPOSE : Open the Request MyEthias Forgotten Password Page
function forgetPwd(){
	window.open("/forgetPwd.go?NOPGDEM=","Oubli_mot_de_passe","width=600,height=380,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes");
}


// ---------------------------------------
// goSearch()
// ---------------------------------------
// PURPOSE : Execute the search in the indexes for the keywords entered in the form

function goSearch(){
  var kern = document.forms[0].topic.value.substr(0,4).toUpperCase();

  if(kern == 'A2PR' || kern == 'IBPR' || kern == 'D5PR' || kern == 'SMIF' || kern == 'VIPR'){
    goPage(document.forms[0].topic.value.toUpperCase());
  }else{
    goPage('SEARCH', 'I', '&cat=productPagesE&topic=' + escape(document.forms[0].topic.value), 'search');
  }
}


// ---------------------------------------
// goSociete(aEnviro)
// ---------------------------------------
// PURPOSE : Link to the corporate homepage according to the environnement
// IN : aEnviro : the consulting environnement of the site

function goSociete(aEnviro){
  switch (aEnviro){
    case 'TEST':
      {
        window.open("http://ethiascorporate.neron/?E","Ethias");
        return;
        break;
      }
    case 'HOMO':
      {
        window.open("http://ethiaspreprod.ethias.be/?E","Ethias");
        return;
        break;
      }
    case 'PROD':
      {
        window.open("http://www.ethias.be/?E","Ethias");
        return;
        break;
      }
    default:
    break;
  }
}

// ---------------------------------------
// goInfos()
// ---------------------------------------
// PURPOSE : Link to the corporate information page
function goInfos(){
	urlWindow = "http://www.ethias.be/public/html/qui/assureur_en.htm";

  var options="toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes";
  var top=100;
  var left=100;

  xyz=window.open(urlWindow,"New","top="+top+",left="+left+",width=800,height=600,"+options);
}


// ---------------------------------------
// goJobs()
// ---------------------------------------
// PURPOSE : Link to the corporate jobs page
function goJobs(){
	urlWindow = "http://www.ethias.be/public/html/jobs/jobs_en.htm";

  var options="toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes";
  var top=100;
  var left=100;

  xyz=window.open(urlWindow,"New","top="+top+",left="+left+",width=800,height=600,"+options);
}


// ---------------------------------------
// goStaticConcours()
// ---------------------------------------
// PURPOSE : Link to the static contest window

function goStaticConcours(){
  urlWindow = "/en/static/concoursMail.go";
  var options="toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes";
  var top=100;
  var left=100;
  xyz=window.open(urlWindow,"StaticCcrs","top="+top+",left="+left+",width=800,height=700,"+options);
  xyz.focus();
}

// ---------------------------------------
// popupCharte()
// ---------------------------------------
// PURPOSE : Open a popup window with the privacy charter page

function popupCharte(){
  urlCharte = "/html/en/popup/charte.htm";
  var options="toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes";
  var top=100;
  var left=150;
  xyz=window.open(urlCharte,"Charte","top="+top+",left="+left+",width=600,height=500,"+options);
}

// ---------------------------------------
// popupSofisk()
// ---------------------------------------
// PURPOSE : Open a popup window with the sofisk index page

function popupSofisk(){
  urlSofisk = "/sofisk/index_en.html";
  var options="toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=yes";
  var top=100;
  var left=100;
  xyz=window.open(urlSofisk,"Sofisk","top="+top+",left="+left+",width=600,height=500,"+options);
  this.location.href="/banner.go?IMSTRAN=WSM328&CDOPTRN=SMINT&qs_lg=E&CDLGTRN=E&CDENTREE=O&BANNER=SFSKSM633";
}

// ---------------------------------------
// goBanner(aBanner)
// ---------------------------------------
// PURPOSE : Links to the french pages of assurance site according to a banner number
// IN : aBanner : banner code representing the page to go to.

function goBanner(aBanner){
	urlBanner = "http://assurance.ethias.be/web/banner.go?IMSTRAN=WSM328&CDOPTRN=SMINT&qs_lg=F&CDLGTRN=F&CDENTREE=O&BANNER=XXXX" + aBanner;
  var options="toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes";
  var top=0;
  var left=0;
  xyz=window.open(urlBanner,"Assurance","top="+top+",left="+left+",width=1024,height=768,"+options);
}
