Ext.ns('rabbit.additional');

rabbit.additional.fontsize = new function() {
	this.fontsize = '10pt';
	
	this.setFontsize = function(size) {
		switch(size) {
			case 'small':
				Ext.getBody().dom.style.fontSize = '0.7em';;
				break;
			case 'normal':
				Ext.getBody().dom.style.fontSize = '0.85em';
				break;
			case 'large':
				Ext.getBody().dom.style.fontSize = '1.0em';
				break;
			default:
				Ext.getBody().dom.style.fontSize = '0.85em';
				break;
		}
	};
	
	this.setDefaultStyle = function() {
		var style = this.readCookie("style");
		
		if(style != null) this.setStyle(style);
		else this.setStyle("normal");
	};
	
	this.setStyle = function(title) {
		this.createCookie("style", title, 365);
		location.reload();
		
//		var i, a, main; 
//		
//		for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { 
//			if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
//				if(a.getAttribute("title") != "") {
//					a.disabled = true; 
//					
//					this.createCookie("style", title, 365);
//					if(a.getAttribute("title") == title) a.disabled = false;
//				}
//			}
//		}
	};
	
	this.changeStyle = function() {
		var style = this.readCookie("style");
		
		if(style == "normal") style = "contrast";
		else style = "normal";
		
		this.setStyle(style);
	};
	
	this.createCookie = function(name,value,days) { 
		if(days) { 
			var date = new Date(); 
			date.setTime(date.getTime()+(days*24*60*60*1000)); 
			var expires = "; expires="+date.toGMTString(); 
		} else expires = ""; 
		
		document.cookie = name + "=" + value + expires + "; path=/"; 
	}; 
	
	this.readCookie = function(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 null; 
	};
};