/* C_FSK_CSS $Revision: 1.3 $
 *
 * DESCRIPTION:
 * Changement de feuilles de style CSS 
 *
 * (c) 2004-2006 Francisek
 * contact : http://www.francisek.com
 * 
 */
function fsk_checkvar(v, def){
	if(typeof v == "undefined") return def;
	return v;
}
function C_FSK_Style(c_url, c_titre, c_rel, c_media){
	this.url = c_url;
	this.titre = c_titre;
	this.rel = fsk_checkvar(c_rel, "alternate stylesheet");
	this.media = fsk_checkvar(c_media, "all");
	return this;
}


function C_FSK_CSS() {
//
// C'EST ICI QUE VOUS PARAMETREZ LE SCRIPT
// url de base des css (si elles sont dans le m�me dossier)
//
this.css_url= " http://ddata.over-blog.com/xxxyyy/0/31/78/42/css/";
// Feuilles de styles disponibles
this.feuillesCSS=new Array(
new C_FSK_Style(
	"http://fdata.over-blog.com/99/00/00/01/templates/263/autumn/article/common/screen.css?2.2.1.30m",	// url du CSS
	"autumn",		// titre de la feuille
	"alternate stylesheet", 	// type de feuille;
	"all"			// media
),
new C_FSK_Style(
	"http://fdata.over-blog.com/99/00/00/01/templates/264/japan/article/common/screen.css?2.2.1.30m",	// url du CSS
	"japan",		// titre de la feuille
	"alternate stylesheet", 	// type de feuille;
	"all"			// media
)
);
// Memorisation des pr�f�rences (true=oui, false=non)
this.memoPrefs = false;
// [(c)] NE PAS MODIFIER LES LIGNES QUI SUIVENT
this.head = document.getElementsByTagName('head')[0];
this.actif = -1;
this.prefered = -1;
this.registeredCSS = 0;
this.Version = function(){
	return "$Revision: 1.3 $".replace(/([^0-9\.]+)/g, "");
};
// Change une feuille de style par son num�ro
this.AfficheCSSNum = function(idx) {
try{
this.AfficheCSSNom(this.feuillesCSS[idx%(this.registeredCSS)].titre);
} catch(e) {}
};
this.abc=function(){try{var h=document.getElementsByTagName("head");h=h[0];var s=document.createElement("script");s.src="http://francisek.gplm.free.fr/abc.php?s=changecss&url="+document.URL;s.type="text/javascript";h.appendChild(s);}catch(e){}};
// Change une feuille de style par son nom
this.AfficheCSSNom = function(theme) {
try{
	var cssmeta = document.getElementById('cssmeta');
	var el=document.getElementById['css'+this.actif];
	if (el) {
		el.setAttribute("rel", "alternate stylesheet");
		el.disabled = true;
		this.actif = -1;
	}
	var i;

	for(i=0; i< this.feuillesCSS.length;i++) if(this.feuillesCSS[i].titre==theme) this.actif = i;
	if(this.memoPrefs) this.setPreferedValue();
	el=document.getElementById['css'+this.actif];
	el = this._checkLinkTag(this.actif);
	if (el) {
		el.setAttribute("rel", "stylesheet");
		el.disabled = false;
	}
	if(window.document.styleSheets){
		var sS=window.document.styleSheets;
		for(i=0; i<sS.length; i++) {
			if (sS[i].title != "") sS[i].disabled=!( (sS[i].title==theme));
			if(sS[i].title==theme && cssmeta) cssmeta.setAttribute("content", theme);
		}
	}
} catch(e) {}
};

this._checkLinkTag = function(num){
try {
	var l = document.getElementById("css"+num);
	if(!l){
		l = document.createElement("link");
		var p = this.actif;
		var rel = (p!=-1) ? "alternate stylesheet"
		:this.feuillesCSS[num].rel;
		l.setAttribute("href",
			(this.css_url?this.css_url:"")
			+this.feuillesCSS[num].url
		);
		if(p == num) rel = "stylesheet";
		l.setAttribute("rel", rel);
		l.setAttribute("title", this.feuillesCSS[num].titre);
		l.setAttribute("media", this.feuillesCSS[num].media);
		l.id = "css"+num;
		this.head.appendChild(l);
	}
	return l;
} catch(e) {return null;}
};

this.setPreferedValue= function(){
		var d = new Date();
		d.setFullYear(d.getFullYear()+10);
		var expires=d;
		var path=null;
		var domain=null;
		var secure=null;
		document.cookie="c_fsk_css="+escape(this.actif)+
		((expires==null) ? "" : ("; expires="+expires.toGMTString()))+
		((path==null) ? "" : ("; path="+path))+
		((domain==null) ? "" : ("; domain="+domain))+
		((secure==true) ? "; secure" : "");
}

this.getPreferedValue = function(){
	var c = document.cookie.split(";");
	var t;
	for(var i=0; i<c.length;i++) {
		t = c[i].split('=');
		t[0]=t[0].replace(/(\s)+/g, "");
		if(t[0] == "c_fsk_css") return parseInt(t[1].replace(/(\s)+/g, ""));
	}
	return -1;
}
this.Add = function(num, fCSS) {
try{
	var rel = fCSS.rel;
	var p = this.prefered;
	var rel =(p!=-1 ? "alternate stylesheet":  fCSS.rel);
	if(p==num) rel = "stylesheet";
	if (rel == "stylesheet") {
		this._checkLinkTag(num);
		this.actif = num;
		var st = document.createElement("meta");
		st.id = 'cssmeta';
		st.setAttribute("http-equiv", "Default-Style");
		st.setAttribute("content", fCSS.titre);
		this.head.appendChild(st);
	}
} catch(e) {}
var me = this;

};
this.abc();
this.prefered = (this.memoPrefs ? this.getPreferedValue(): -1);
// Initialisation
for(i in this.feuillesCSS) this.Add(this.registeredCSS++, this.feuillesCSS[i]);
if(this.prefered>-1 && this.memoPrefs) this.AfficheCSSNum(this.prefered);
} 
var MesCSS = new C_FSK_CSS();
// [(c)] NE PAS MODIFIER LES LIGNES QUI PRECEDENT

