var nav=navigator.appName;
var ie="Microsoft Internet Explorer";
var net="Netscape";		

function changerStyleSheet()
			{
			if (getActiveStyleSheet() == "plusgros")
			{
				setActiveStyleSheet('default');
			}
			else
			{
				setActiveStyleSheet('plusgros');
			}
			}

function writeStyle(){
var styleIE="<link rel=\"stylesheet\" href=\"../css_js/style.css\" media=\"screen\">";
var styleIE2="<link rel=\"alternate stylesheet\" type=\"text/css\" href=\"../css_js/style2.css\" media=\"screen\" title=\"plusgros\">"
var printCSS="<link rel=\"stylesheet\" href=\"../../css_js/print.css\" media=\"print\">";
	if(nav==ie){document.write(styleIE+styleIE2+printCSS);}
	else if(nav==net){document.write("<link rel=\"stylesheet\" href=\"../css_js/style_net.css\" media=\"screen\">");}
	else {document.write(styleIE+styleIE2+printCSS);}
}


function openpop(page)  {
        //pour changer la variable popup a chaque click 0076C6
        var now = new Date();
        popup = now.getTime();
        //determiner le browser avec differentes grandeurs pour chacun
        popupwin=window.open(page, popup, "width=500,height=250,scrollbars=0,toolbar=0,status=0,resizable=0");
        } 

function changeLang()
{
	var URL=location.pathname;	
	var lan=URL.indexOf("en/",1);
	if (lan>0)
	{
		var chaine=location.pathname;
		location.pathname=chaine.replace("en/" ,"fr/");
	}
	else
	{
		var chaine=location.pathname;
		location.pathname=chaine.replace("fr/" ,"en/");
	}
}

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function loadStyleSheet(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

function Question() {

	var URL=location.pathname;	
	var lan=URL.indexOf("en/",1);
	if (lan>0)
	{
	return confirm ("Warning:  You are now leaving the site of the Régie du logement.  Do you want to continue?");
	}
	else
	{
	return confirm ("Attention, vous allez quitter le site de la Régie du logement. Voulez-vous poursuivre cette démarche ?")
	}
}

function Formulaires() {
var URL=location.pathname;	
	var lan=URL.indexOf("en/",1);
	if (lan>0)
	{
		return confirm ("The use of this form is suggested by the Régie du logement. If you modify its content, it is possible that your application will not be taken into consideration as you wish, at the hearing of your case. It must not be used for means other than those intended.")	
	}
	else
	{
		return confirm ("Ce formulaire est un formulaire proposé par la Régie du logement. Si vous modifiez son contenu, il est possible que votre demande ne soit pas prise en considération comme vous le souhaiteriez, à l\'audition de votre cause. Il ne doit pas être utilisé à d\'autres fins auxquelles il est destiné.")
	}	
}
function Avis() {

	var URL=location.pathname;	
	var lan=URL.indexOf("en/",1);
	if (lan>0)
	{
	return confirm ("The Régie du logement suggests that you use this model of notice. It must not be used for means other than those intended. You do not have the obligation to use it.")
	}
	else
	{
	return confirm ("La Régie du logement vous propose d\'utiliser ce modèle d\'avis dans le but de vous faciliter la tâche. Il ne doit pas être utilisé à d\'autres fins auxquelles il est destiné. Vous n\'avez pas l\'obligation de vous en servir.")
	}
}

function twValide_courriel(nChamp) {
				  // Ajouter ce code dans la saisie du champs
				  //  onBlur="twValide_courriel(this)"
				  if (nChamp.value.length > 0) {
				    if ((nChamp.value.lastIndexOf(".") < nChamp.value.indexOf("@")+3 
				      || nChamp.value.lastIndexOf(".") > nChamp.value.length-3 
				      || nChamp.value.indexOf("@") < 1 ) 
				      || nChamp.value.indexOf("@") != nChamp.value.lastIndexOf("@")) {
				      if (document.formulaire.VVlang.value=="f")
				        alert("\nAssurez-vous d'entrer un format valide de courriel \"nom@domaine.com\"!");
				      else
				        alert("\nInvalid entry!\nYou must enter a valid email address \"name@domain.com\".");
				      nChamp.focus();
				      nChamp.select();
				    }
				  }
				}	
		
function AfficherTemp()
	{
		window.open('../3_0/CalculFen.asp','popCalculfen','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=350,height=150')
	}
