//cette variable est utilisee pour les ressources statiques (images, js, css)
var absolutePathForStaticResources="http://static.wanadoo.co.uk/webmail/en_GB/Images/Images200905061123/";
//cette seconde variable n'est utilisee pour les pages html (non statiques)
var absolutePath="";
var menuOptionsServices = 0;

function redirectWithLocale(urlToRedirect, typeRedirect) {
	var param = "";
	if (locale != null && locale != ""
		&& (urlToRedirect != "#" && urlToRedirect.indexOf("http", 0) == 0)) {
		var posFinChemin = urlToRedirect.indexOf("/	",0);
		var posDebutParam = urlToRedirect.indexOf("?",0);
		if (posDebutParam > 0) {
			if (posFinChemin < posDebutParam) {
				param = "&locale="+locale;
			}
		} else {
			param = "?locale="+locale;
		}
	}

	if (typeRedirect == "self") {
		self.location = urlToRedirect + param;
	} else if (typeRedirect == "top") {
		top.location = urlToRedirect + param;
	} else {
		self.location = urlToRedirect + param;
	}
}

function MailSMS(actif)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "mailSms.html";
	} else {
		urlToRedirect = absolutePath+ "mailSmsPresentation.html";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function MailSMSMU(actif)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "MU_xmsNotification_dashboard.html?TAB_WANTED=5";
	} else {
		urlToRedirect = absolutePath + "xmsNotification_presentation.html?TAB_WANTED=5";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function MailXMS(actif)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "xmsNotification_switcher.html?TAB_WANTED=2";
	} else {
		urlToRedirect = absolutePath + "xmsNotification_presentation.html?TAB_WANTED=2";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function MailXMSFromMU(actif)
{
	if (actif=="1") {
		self.location = absolutePath + "xmsNotification_switcher.html?TAB_WANTED=5";
	} else {
		self.location = absolutePath + "xmsNotification_presentation.html?TAB_WANTED=5";
	}
}

function MailSMSAllUserLinkFromMU(actif,produit){

     if (produit=="0") {
         MailSMSMU(actif)
     }else if (produit=="1") {
         MailSMSMU(actif)
     }else if (produit=="2") {
         MailXMSFromMU(actif)
     }else{
         MailSMSMU(actif)
     }
}

function MailSMSAllUserLink(actif, side)
{
	if (actif=="1") {
		if (side=="left") {
			self.location = absolutePath + LEFT_ALERTESMS_SUBSCRIBED_LINK;
		}else{
			self.location = absolutePath + RIGHT_ALERTESMS_SUBSCRIBED_LINK;
		}
	}else {
		if (side=="left") {
			self.location = absolutePath + LEFT_ALERTESMS_NOTSUBSCRIBED_LINK;
		}else{
			self.location = absolutePath + RIGHT_ALERTESMS_NOTSUBSCRIBED_LINK;
		}
	}
}

function MailMMSInternetUserLink(actif, side)
{
		if (actif=="1") {
			if (side=="left") {
				self.location = absolutePath + LEFT_ALERTEMMS_I_SUBSCRIBED_LINK;
			}else{
				self.location = absolutePath + RIGHT_ALERTEMMS_I_SUBSCRIBED_LINK;
			}
		}else {
			if (side=="left") {
				self.location = absolutePath + LEFT_ALERTEMMS_I_NOTSUBSCRIBED_LINK;
			}else{
				self.location = absolutePath + RIGHT_ALERTEMMS_I_NOTSUBSCRIBED_LINK;
			}
		}

}

function MailMMSMorCUserLink(actif, side, mmslink)
{
	if (mmslink=="mailtiers") {
		if (actif=="1") {
			if (side=="left") {
				self.location = absolutePath + LEFT_ALERTEMMS_M_OR_C_MAILTIERS_SUBSCRIBED_LINK;
			}else{
				self.location = absolutePath + RIGHT_ALERTEMMS_M_OR_C_MAILTIERS_SUBSCRIBED_LINK;
			}
		}else {
			if (side=="left") {
				self.location = absolutePath + LEFT_ALERTEMMS_M_OR_C_MAILTIERS_NOTSUBSCRIBED_LINK;
			}else{
				self.location = absolutePath + RIGHT_ALERTEMMS_M_OR_C_MAILTIERS_NOTSUBSCRIBED_LINK;
			}
		}
	}else if(mmslink=="mailorange"){
		if (actif=="1") {
			if (side=="left") {
				self.location = absolutePath + LEFT_ALERTEMMS_M_OR_C_MAILORANGE_SUBSCRIBED_LINK;
			}else{
				self.location = absolutePath + RIGHT_ALERTEMMS_M_OR_C_MAILORANGE_SUBSCRIBED_LINK;
			}
		}else {
			if (side=="left") {
				self.location = absolutePath + LEFT_ALERTEMMS_M_OR_C_MAILORANGE_NOTSUBSCRIBED_LINK;
			}else{
				self.location = absolutePath + RIGHT_ALERTEMMS_M_OR_C_MAILORANGE_NOTSUBSCRIBED_LINK;
			}
		}
	}else{
		self.location = absolutePath + RIGHT_ALERTEMMS_M_OR_C_MAILMMS_LINK;

	}
}

function MU_droits(actif)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "MU_settings_droits_acces.html";
	} else {
		urlToRedirect = absolutePath + "MU_settings_home.html";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function MU_tel(actif)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "MU_settings_param_tel.html";
	} else {
		urlToRedirect = absolutePath + "MU_settings_home.html";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function MU_perso(actif)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "MU_settings_param_perso.html";
	} else {
		urlToRedirect = absolutePath + "MU_settings_home.html";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function MailPerformance(actif, link)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "persoMailPerformance.html";
	} else {
		if (link != null && link != "")
			urlToRedirect = link ;
			else
				urlToRedirect = "NOT_TRANSLATED";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function GigamailMobile(actif, link)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "persoGigaMailMobile.html";
	} else {
		if (link != null && link != "")
			urlToRedirect = link ;
			else
				urlToRedirect = "http://nos-offres.wanadoo.fr/op3a-produit-gigamail.html";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function Antivirus(actif, link)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + "http://help.orange.co.uk/sessionBegin.do?solutionId=kb5342";
	} else {
		if (link != null && link != "")
			urlToRedirect = link ;
		else
			urlToRedirect="http://help.orange.co.uk/sessionBegin.do?solutionId=kb5342";
	}
	redirectWithLocale(urlToRedirect, "self");
}

function manageAntiVirus(actif, page, link)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect = absolutePath + page;
	}
	else
	{
		if (link != null && link != "")
		{
			urlToRedirect = link ;
		}
		else
		{
			urlToRedirect = "http://help.orange.co.uk/sessionBegin.do?solutionId=kb5342";
		}
	}
	redirectWithLocale(urlToRedirect, "self");
}


function Antispam(actif, link)
{
	if (actif=="1") {
		var urlToRedirect = "";
		urlToRedirect = absolutePath + "antiSpam.html";
		redirectWithLocale(urlToRedirect, "self");
	} else {
		if (link != null && link != "")
				window.open(link);
		else
			window.open("http://help.orange.co.uk/sessionBegin.do?solutionId=kb2168");

	}
}

 function manageAntispam(actif, page, link)
{

	if (actif=="1") {
		document.FORM_SETTINGS.action=absolutePath + page;
		document.FORM_SETTINGS.submit();
	}
	else
	{
		var urlToRedirect = "";
		if (link != null && link != "")
		{
			urlToRedirect = link ;
		}
		else
			urlToRedirect = "http://help.orange.co.uk/sessionBegin.do?solutionId=kb2168";
		redirectWithLocale(urlToRedirect, "self");
	}
}
function MPU(actif)
{
	var urlToRedirect = "";
	if (actif=="1") {
		urlToRedirect=absolutePath + LINK_MPU_ACTIVE;
	} else {
		urlToRedirect = absolutePath + LINK_MPU_INACTIVE;
	}
	redirectWithLocale(urlToRedirect, "self");
}



function SmsInbox()
{
	redirectWithLocale(smsInboxUrl, "self");
}

function Sms()
{
	redirectWithLocale(smsTabUrl, "self");
}

function Mms()
{
	redirectWithLocale(mmsTabUrl, "self");
}

function SmsPub()
{
	var urlSmsPub = "http://webmessage.nat.rec.orange.co.uk";
	redirectWithLocale(urlSmsPub, "self");
}

function MmsPub()
{
	var urlMmsPub = "http://webmessage.nat.rec.orange.co.uk";
	redirectWithLocale(urlMmsPub, "self");
}

function CalendarHelp()
{
	var urlCalendarHelp = "[i18n:link.calendar_help.page]";
	window.open(urlCalendarHelp);
}

function TaskHelp()
{
	var urlTaskHelp = "[i18n:link.task_help.page]";
	window.open(urlTaskHelp);
}

function Agenda()
{
	redirectWithLocale(agendaTabUrl, "self");
}

function Video_messages()
{
	var urlVideoMessages = "NOT_TRANSLATED";
	redirectWithLocale(urlVideoMessages, "top");
}

function MailToFax()
{
    // La page appelee redirigera vers la page de souscription
    // au produit MailToFax s'il n'est pas actif.
	var urlToRedirect = "";
	urlToRedirect = absolutePath + "mailToFax.html";
	redirectWithLocale(urlToRedirect, "self");
}

function BuyMoreStorage(link)
{
	self.location=link;
}

function ShowHideMenuItem()
{
  if (menuOptionsServices==0)
    document.getElementById("blocServices").style.display = "none";
  else
    document.getElementById("blocServices").style.display = "";
}

function LeftMenuItem(labelToDisplayTestOk,linkToDisplayTestOk,testResultOK,labelToDisplayTestNok,linkToDisplayTestNok,classe)
{
	var labelToDisplay="";
	var linkToDisplay="";
	if (testResultOK=="TRUE"){
		labelToDisplay = labelToDisplayTestOk;
		linkToDisplay  = linkToDisplayTestOk;
	}else if (testResultOK=="FALSE"){
		labelToDisplay = labelToDisplayTestNok;
		linkToDisplay  = linkToDisplayTestNok;
	}
	if ((labelToDisplay.length==0)||(linkToDisplay.length==0)){
		document.write("");
	}else{
	  menuOptionsServices = 1;
		document.write("<p><a href="+linkToDisplay+" class='"+classe+"'>"+labelToDisplay+"</a><a href="+linkToDisplay+" class=\"chevron\">&gt;&gt;</a></p>");
	}
}

function Faq()
{
	var urlFaq = "http://www.orange.co.uk/communicate/email/7104.htm";
	redirectWithLocale(urlFaq, "top");
}
function footerAssistance()
{
	self.location = window.open("http://www.orange.co.uk/communicate/email/helpsigningin/default.htm","orange");
}

function footerPub()
{
	var urlFooterPub = "http://www.orange.co.uk/mediapack/default.htm";
	redirectWithLocale(urlFooterPub, "self");
}

function footerAbout()
{
	var urlFooterAbout = "";
	redirectWithLocale(urlFooterAbout, "self");
}

function addBook() {
	var addBookUrl = "";
	if (usePab==1) {
		var param = "";
		if (locale != null && locale != "") {
			var posFinChemin = URL_ADDRESSBOOK.indexOf("/",0);
			var posDebutParam = URL_ADDRESSBOOK.indexOf("?",0);
			if (posDebutParam > 0) {
				if (posFinChemin < posDebutParam) {
					param = "&locale="+locale;
				}
			} else {
				param = "?locale="+locale;
			}
		}
		addBookUrl = URL_ADDRESSBOOK + param;

	} else {
		addBookUrl = absolutePath + "aBook.html";
	}

	return addBookUrl;
}

function addBookFromHeader()
{
	var addBookUrl = addBook();
	if (usePab==1) {
		redirectWithLocale(addBookUrl, "top");
	} else {
		redirectWithLocale(addBookUrl, "self");
	}
}


function addBookFromHeaderCallContact()
{
	var addBookUrl = addBook();
	if (usePab==1) {
		window.opener.location= addBookUrl;
	} else {
		redirectWithLocale(addBookUrl, "self");
	}
}

function logOffFromHeader()
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath + "logout.html";
	redirectWithLocale(urlToRedirect, "self");
}

function Repondeur()
{
	var urlToRedirect = "";
	urlToRedirect=absolutePath + "MU_checkAccess.html";
	redirectWithLocale(urlToRedirect, "self");
}

function MissedCall()
{
	self.location=absolutePath + "MU_answerPhone_List.html?FOLDER=SF_ANSWERPHONE_JOURNALIZATION";
}

function SmsFromMU()
{
	document.headerform.URL_REDIRECT.value=smsTabUrl;
	document.headerform.action=absolutePath + "MU_synchronize.html";
	document.headerform.submit();
}

function MmsFromMU()
{
	document.headerform.URL_REDIRECT.value=mmsTabUrl;
	document.headerform.action=absolutePath + "MU_synchronize.html";
	document.headerform.submit();
}

function RepondeurFromMU()
{
	document.headerform.URL_REDIRECT.value=absolutePath + "MU_checkAccess.html";
	document.headerform.action=absolutePath + "MU_synchronize.html";
	document.headerform.submit();
}

function addBookFromHeaderFromMU()
{
	if (usePab==1)
		document.headerform.URL_REDIRECT.value=URL_ADDRESSBOOK;
	else
		document.headerform.URL_REDIRECT.value=absolutePath + "aBook.html";
	document.headerform.action=absolutePath + "MU_synchronize.html";
	document.headerform.submit();
}

function welcomeFromMU()
{
	document.headerform.URL_REDIRECT.value=absolutePath + "welcome.html";
	document.headerform.action=absolutePath + "MU_synchronize.html";
	document.headerform.submit();
}

function inboxFromMU()
{
	document.headerform.URL_REDIRECT.value=absolutePath + "inbox.html";
	document.headerform.action=absolutePath + "MU_synchronize.html";
	document.headerform.submit();
}

function writeMail()
{
	var urlToRedirect = "";
	urlToRedirect=absolutePath + "write.html";
	redirectWithLocale(urlToRedirect, "self");
}

function writeIcal()
{
	var urlToRedirect = "";
	urlToRedirect=absolutePath + "writeICal.html";
	redirectWithLocale(urlToRedirect, "self");
}

function inboxFromCollectiveBoard()
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath + "sso_redirect.html?URI=inbox.html";
	redirectWithLocale(urlToRedirect, "self");
}

function goToMPlusSubscription()
{
	var urlMPlusSubscription = "http://www.orange.fr";
	redirectWithLocale(urlMPlusSubscription, "self");
}

function MobileRedirectMU(email)
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath +"http://www.orange.fr";
	redirectWithLocale(urlToRedirect, "self");
}

function ConvergedRedirectMU(email)
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath +"http://www.orange.fr";
	redirectWithLocale(urlToRedirect, "self");
}

function ConvergedRedirectMUavecDroit()
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath + "MU_messages.html";
	redirectWithLocale(urlToRedirect, "self");
}

function ConvergedRedirect888()
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath +"MU_messages.html?SORTBY=1&FOLDER=SF_ANSWERPHONE";
	redirectWithLocale(urlToRedirect, "self");
}


function InternetRedirectMU()
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath + "MU_messages.html";
	redirectWithLocale(urlToRedirect, "self");
}

function OngletMULeftMenuInternet()
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath + SUIVICONSO_LINK_VOICEMAIL_M;
	redirectWithLocale(urlToRedirect, "self");
}

function OngletMULeftMenuMobile(email)
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath + SUIVICONSO_LINK_VOICEMAIL_M;
	redirectWithLocale(urlToRedirect, "self");
}

function aleatoire()
{
    return (Math.floor((1000)*Math.random()+1));
}

function ThirdParties()
{
	var urlToRedirect = "";
	urlToRedirect = absolutePath + thirdPartiesUrl;
	redirectWithLocale(urlToRedirect, "self");
}

