/**
* Global namespace for all RFR classes
*/
window.RFR = function(){}

window.RFR.TEssence=function(type,id){
	this.type=type;
	this.id=id;
}

/**
* RFR registry
*/
window.RFR.Registry = function(){
	this.con = function(){
		if (!this.rConsole){
			this.rConsole=new RFR.Console();
			this.rConsole.create();
		}
		return this.rConsole;
	}
	this.keyCatchers=[];
	this.catchKey = function(e){
		for (var i=0;i<r.keyCatchers.length;i++){
			r.keyCatchers[i](e);
		}
	}
	document.onkeyup = this.catchKey;
}

if (Prototype.Browser.IE || !window.console){
	window.console=function(){};
	window.console.log=function(text){
		$rfr.con().add(text);
	};
}



window.r=new RFR.Registry();
window.$rfr=r;
window.$rfr.gadgetMap=new Array();
window.$rfr.widgetMap=new Array();

window.RFR.Response = function(){

}
window.RFR.Response.fromJSON = function(content){
	try {
		var obj = content.evalJSON();
		return obj;
	} catch (e){
		console.log(e);
		$rfr.con().add('Bad JSON: '+content,'error');
		return false;
	}
}

window.RFR.Transaction = function(){
	this.t_id=RFR.Transaction.getNewId();
}
window.RFR.Transaction.currentId=0;
window.RFR.Transaction.getNewId=function(){
	return ++window.RFR.Transaction.currentId;
}

window.RFR.HTML=function(){}

window.RFR.HTML.condDisplay = function(element,value,text){
	if (value && (value.length>0)){
		if (text){
			element.innerHTML=text;
		} else {
			element.innerHTML=value;
		}
		element.style.display='';
	} else {
		element.style.display='none';
	}
}
window.RFR.HTML.toggleDisplay = function(element){
	element.style.display=(element.style.display=='none')?
		'' : 'none';
}
window.RFR.HTML.clearOptions=function(selectObj){
	selectObj.options.length=0;
}
window.RFR.HTML.addOption=function(selectObj,value,text){
	var doc=window.document;
	var opt=doc.createElement('option');
	opt.value=value;
	opt.text=text;
	selectObj.options[selectObj.options.length]=opt;
}
window.RFR.HTML.getAjaxLoading=function(){
	return '<div class="ajaxloading"><img src="module/Theme12/theme/img/loadarium.gif" /><br />loading</div>';
}