
var MultiStyleController = {
	
	_default_class_names : {background:'background02', menu:'menu01', width:'width1', text:'mediumtext'}
	
	,
	init : function(){
		 
		
	}
	,
	make : function(){
		//alert('make')
		this.setOldStyleSheet();
	}
	,
	CreateStyleSheet : function(){
		$styleSheet = document.createElement("link");
		return($styleSheet);
	}//end func
	,
	setActiveStyleSheet : function($class, $type, $set){
		var $old_class = this._default_class_names[$type]
		var $E = MK111.$ES('.'+ $old_class);
		for(var $i=0;$i<$E.length; $i++){
			var e = $E[$i];
			e.className = e.className.replace($old_class, $class);
		}
		this._default_class_names[$type] = $class;
		if($set)this.createCookie(365);
	}//end func
	,
	createCookie : function($days){
	  if($days) {
		var $date = new Date();
		$date.setTime($date.getTime()+($days*24*60*60*1000));
		var $expires = "; expires="+ $date.toGMTString();
		
	  }else{
		var $expires = "";
	  }//end if
	  var $cookie_str = "background=" + this._default_class_names['background'] + "&menu=" + this._default_class_names['menu'] + "&width=" + this._default_class_names['width'] + "&text=" + this._default_class_names['text'] + $expires +"; path=/";
	  document.cookie = $cookie_str;
	}//end func
	,
	readCookie : function(){
		$cookie = document.cookie.split('&');
		if($cookie.length>2){
			var $old_style = {};
			for(var $i=0; $i<4; $i++){
				var $info = $cookie[$i].split('=');
				$old_style[$info[0]] = $info[1];
			}//end for
			
		}else{
			var $old_style = '';
		}//end if
	
		return($old_style);
	}//end func
	,
	setOldStyleSheet : function(){
		var $old_style = this.readCookie();
		if($old_style){
			this.setActiveStyleSheet($old_style['background'], 'background');
			this.setActiveStyleSheet($old_style['menu'], 'menu');
			this.setActiveStyleSheet($old_style['width'], 'width');
			this.setActiveStyleSheet($old_style['text'], 'text');
		}//end if
	}//end func
	
	
}//end MultiStyleController class
MultiStyleController.init();

