/************************************************
 *
 * CssSwitcherクラス
 *
 * Author        : $Author: suzuki_chie $
 * Last Modified : $Date: 2006/07/18 10:44:22 $
 * Version       : $Revision: 1.1 $
 *
 * (c) CYBER AGENT.LTD
 *
 ************************************************/

function CssSwitcher(prefix_str){
	this.prefix = prefix_str;

	this.setActiveCss = function(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.getAttribute("title").indexOf(this.prefix) != -1){
				a.disabled = true;
				if(a.getAttribute("title") == title){
					//activate
					a.disabled = false;
				}
			}
		}
	}

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

	this.getPreferredStyleSheet = function(){
		var i, a;
		for(i=0; (a = document.getElementsByTagName("link")[i]); i++){
			if(a.getAttribute("rel").indexOf("style") != -1
			&& a.getAttribute("rel").indexOf("alternate") == -1
			&& a.getAttribute("title")
			&& a.getAttribute("title").indexOf(this.prefix) != -1
			) {
//				alert("DEFAULT:"+a.getAttribute("title"));
				return a.getAttribute("title");
			}
		}
		return null;
	}
}
