﻿//\\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////////////////////\\
//	Nom de projet : 	http://www.queryatall.com           \\
//	Version :    		2.0.47                              \\
//	Date de création : 	2008-04-10                          \\
//	Copyright : 		©2008 Y.A.L.E. Multi-Informatique   \\
//  Courriel :          admin@lapointearsenault.com         \\
//  Website :           http://www.lapointearsenault.com    \\
//                                                          \\
//	Développeur : 		XEMMEX                              \\
//	Courriel :    		admin@xemmex.com                   \\
//	Website :    		http://www.xemmex.com              \\
//\\\\\\\\\\\\\\\\\\\\\\\\\\\\//////////////////////////////\\
var usercolor="";
var userfore="";

function writeCookie(name, value, hours)
{
  var expire = "";
  if(hours != null)
  {
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
  }
  document.cookie = name + "=" + escape(value) + expire;
}

function readCookie(name)
{
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0)
  { 
    offset = document.cookie.indexOf(search);
    if (offset != -1)
    { 
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if (end == -1) end = document.cookie.length;
      cookieValue = unescape(document.cookie.substring(offset, end))
    }
  }
  return cookieValue;
}

function setStylesheet(title, randomize){ //Main stylesheet switcher function. Second parameter if defined causes a random alternate stylesheet (including none) to be enabled
var i, cacheobj, altsheets=[""]
for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
if(cacheobj.getAttribute("rel").toLowerCase()=="alternate stylesheet" && cacheobj.getAttribute("title")) { //if this is an alternate stylesheet with title
cacheobj.disabled = true
altsheets.push(cacheobj) //store reference to alt stylesheets inside array
if(cacheobj.getAttribute("title") == title) //enable alternate stylesheet with title that matches parameter
cacheobj.disabled = false //enable chosen style sheet
}
}
if (typeof randomize!="undefined"){ //if second paramter is defined, randomly enable an alt style sheet (includes non)
var randomnumber=Math.floor(Math.random()*altsheets.length)
altsheets[randomnumber].disabled=false
}
return (typeof randomize!="undefined" && altsheets[randomnumber]!="")? altsheets[randomnumber].getAttribute("title") : "" //if in "random" mode, return "title" of randomly enabled alt stylesheet
}

function chooseStyle(styletitle){ //Interface function to switch style sheets plus save "title" attr of selected stylesheet to cookie
if (document.getElementById){
setStylesheet(styletitle)
}
}

usercolor=readCookie('color');

userfore=readCookie('fore');

if (usercolor==""){
    usercolor="stanless";
    userfore="#006699"
}

if (usercolor!==""){
if (document.getElementById && usercolor!=null) //load user chosen style sheet from cookie if there is one stored
setStylesheet(usercolor)
}


