/// START styleswitcher -- swissinfo appearance -- for example -- font size, contrast and text justified ///

// <![CDATA[
// <!--

var t;			
t = 62,5;
function changerTaille(modif) {
	t = t + modif;
	document.getElementsByTagName("body")[0].style.fontSize = t + "%";		
} 

function setActiveStyleSheet(title) {
  var i, j, a, main, title_type, title_list;
  title_list=title+",";
  while (title_list.indexOf(",")!=-1)
  	{
  	title=title_list.substring(0,title_list.indexOf(","));
  	title_list=title_list.substring(title_list.indexOf(",")+1,title_list.length);
	  title_type=title.substring(0,title.indexOf("_"));
	  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
	      if (a.getAttribute("title").indexOf(title_type)==0)
	      	{
	      	a.disabled = true;
		      if(a.getAttribute("title") == title) 
		      	{
		      	j=i;
				  	aid = document.getElementById(title);
				  	if (aid!=null)
				  		{
				  		aid.style.color="#003366";
				  		}      	
		      	}
		      else
		      	{
				  	aid = document.getElementById(a.getAttribute("title"));
				  	if (aid!=null)
				  		{
				  		aid.style.color="#000000";
				  		}      		
		      	}
		      }
	    }
	  }
	  a = document.getElementsByTagName("link")[j];
	  if (a!=null)
	  	{
	  	a.disabled = false;
	  	}
	  }
}

function getActiveStyleSheet() {
  var i, a, s;
  s='';
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled)
    	{
    	if (s=='')
    		{
    		s=a.getAttribute("title");
    		}
    	else
    		{
    		s=s+","+a.getAttribute("title");	
    		}
    	}
  }
  if ((s=='') || (s==null))
  	{
  	return null;
  	}
  else
  	{
  	return s;
  	}
}

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();  //'never';
  }
  else expires = "";
  var wawa = name+"="+value+expires+"; path=/";
//  alert(wawa);
  document.cookie = wawa;
}

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 "";
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

function initStyleSheet() {
var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
}

initStyleSheet();

// -->
// ]]>

/// END of styleswitcher ///

