
ie5 = (document.all && document.getElementById);
ns6 = (!document.all && document.getElementById);

function MeritoHeadControl() {

	this.addInlineJScript = AddInlineJScript;
	this.addFileJScript = AddFileJScript;
	this.addFileStyleSheet = AddFileStyleSheet;

	function AddInlineJScript( JScriptText ) {

		var head = document.getElementsByTagName("head")[0];

		var jscript = document.createElement('script');
		jscript.type = 'text/javascript';
		jscript.text = JScriptText;

		head.appendChild( jscript );
	}

	function AddFileStyleSheet( CSSFile ) {

		var head = document.getElementsByTagName("head")[0];

		var hlinks = head.getElementsByTagName( "link" );
		var count = hlinks.length;
		var found = false;

		var hlink = document.createElement('link');
		hlink.type = 'text/css';
		hlink.rel = 'stylesheet';
		hlink.href = CSSFile;

		//because the baseurl is added to hlink.src automaticaly
		// [or not if CSSFilename has URL like struct]
		//the compare is set here

		if ( count ) {

			for (i = 0; i < count; i++ ) {

				if ( hlinks[i].href == hlink.href ) {

					found = true;
					break;
				}
			}
		}

		//if css not found
		if ( !found ) {

			//add css to document's head
			head.appendChild( hlink );
		}

		return true;
	}

	function AddFileJScript( JSFilename, recursive ) {

		var head = document.getElementsByTagName("head")[0];

		var jscripts = head.getElementsByTagName( "script" );
		var count = jscripts.length;
		var found = false;

		var jscript = document.createElement('script');
		jscript.type = 'text/javascript';
		jscript.src = JSFilename;

		//because the baseurl is added to jscript.src automaticaly
		// [or not if JSFilename has URL like struct]
		//the compare is set here

		if ( count ) {

			for (i = 0; i < count; i++ ) {

				if ( jscripts[i].src == jscript.src ) {

					found = true;
					break;
				}
			}
		}

		//if script not found
		if ( !found ) {

			//add script to document's head
			head.appendChild( jscript );
			//document.write('<script type="text/javascript" src="' + JSFilename + '"></scr' + 'ipt>');
		}

		return true;
	}
}

function MeritoControl( ) {

	this.head = new MeritoHeadControl();
	this.version = '0.2';

}

if ( !document.getElementById ) {

	throw 'merito: document method getElementById() is required';
}

merito = new MeritoControl();

function MeritoRemoteControl( ) {

	this.remotes = new Array( );
	this.remoteIndex = '/ajax.php';
	this.remoteTimeout = 24000;

	//methods
	this.setupOnce = SetupRemoteElementOnce;
	this.setupReload = SetupRemoteElementReload;
	this.remoteCall = RemoteCall;
	this.remoteManage = RemoteManage;
	this.call = CallSetuped;
	this.manage = ManageSetuped;
	this.loading = SimpleLoading;

	// core functions

	function getRemoteObject() {

		var xmlhttp;

		/*@cc_on
		@if (@_jscript_version >= 5)
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (E) {
				xmlhttp = false;
				}
			}
		@else
		xmlhttp = false;
		@end @*/

		if ( !xmlhttp && typeof XMLHttpRequest != 'undefined' ) {

			try {
				xmlhttp = new XMLHttpRequest();
				//ocb ? opera spits on that
				//xmlhttp.overrideMimeType("text/xml");
			} catch (e) {
				xmlhttp = false;
			}
		}

		return xmlhttp;
	}

	function RemoteManage( id, value, afterloadscript ) {

		if ( !value ) {

			throw 'merito.remote: undefined ajax return';
			return;
		}

		if ( !merito.version ) {

			throw 'merito.remote: unable to locate merito js console';
			return;
		}

		var cont = '';
		var script = '';

		var type = typeof value;

		if ( type == 'string' ) {

			if( ie5 || ns6 ) { document.getElementById( id ).innerHTML = value; }
			else return false;

			if ( afterloadscript ) {

				eval( afterloadscript );
			}

			return true;
		}

		cont = value.documentElement.getElementsByTagName( 'content' )[0].childNodes[0].nodeValue;

		if( ie5 || ns6 ) { document.getElementById( id ).innerHTML = cont; }
		else return false;

		if ( value.documentElement.getElementsByTagName( 'jscript' ) ) {

			var jscripts = value.documentElement.getElementsByTagName( 'jscript' );
			var count = jscripts.length;
			var jse;

			for ( var i = 0; i < count; i++ ) {

				if ( jscripts[i].firstChild.nodeValue ) {

					merito.head.addFileJScript( jscripts[i].firstChild.nodeValue );
				}
			}
		}

		if ( value.documentElement.getElementsByTagName( 'stylesheet' ) ) {

			var styles = value.documentElement.getElementsByTagName( 'stylesheet' );
			var count = styles.length;

			for ( var i = 0; i < count; i++ ) {

				if ( styles[i].firstChild.nodeValue ) {

					merito.head.addFileStyleSheet( styles[i].firstChild.nodeValue );
				}
			}
		}

		if ( value.documentElement.getElementsByTagName( 'inlinejscript' )[0] ) {

			merito.head.addInlineJScript( value.documentElement.getElementsByTagName( 'inlinejscript' )[0].childNodes[0].nodeValue );
		}

		if ( value.documentElement.getElementsByTagName( 'evaluatejscript' )[0] ) {

			eval(  value.documentElement.getElementsByTagName( 'evaluatejscript' )[0].childNodes[0].nodeValue );
		}

		if ( value.documentElement.getElementsByTagName( 'debugs' )[0] ) {

			merito.debug.addDebugs( value.documentElement.getElementsByTagName( 'debugs' )[0].childNodes[0].nodeValue );
		}

		if ( afterloadscript ) {

			eval( afterload );
		}

		return true;
	}

	function RemoteCall( method, id, link, script, params ) {

		if ( !merito.version ) {

			throw 'merito.remote: unable to locate merito js console';
			return;
		}

		var http = getRemoteObject();
		var timeoutId;
		var openFuncExists = false;
		var timeoutId;

		this.remoteManage( id, this.loading( id ) );

		http.open( method, link, true );
		http.onreadystatechange = function( ) {

			if ( http.readyState == 4 ) {

				if ( http.status == 200 ) {

					window.clearTimeout( timeoutId );
					var value = http.responseXML;
					merito.remote.remoteManage( id, value, script );
					return;
				}

			}
		}

		http.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" );

		if ( method == 'post' || method == 'POST' ) {

			http.send( params );
		} else {

			http.send( null );
		}

		timeoutId = window.setTimeout(
			function( ) {

				switch ( http.readyState ) {

					default:
						http.abort();
						var value = 'merito.remote: problems during remote call (waiting time exceeded)! You may want to try again.';
						merito.remote.remoteManage( id, value );
						break;
				}
			},
			merito.remote.remoteTimeout
		);
	}

	function CallSetuped( callid ) {

		if ( this.remotes[ callid ] ) {

			if ( !merito.version ) {

				throw 'merito.remote: unable to locate merito js console';
				return;
			}

			var http = getRemoteObject();
			var timeoutId;
			var openFuncExists = false;
			var timeoutId;

			if ( this.remotes[ callid ].mode == 'once' ) {

				if ( this.remotes[ callid ].value ) return;
			}

			if ( this.remotes[ callid ].loading ) {

				this.remotes[ callid ].value = this.loading( this.remotes[ callid ].id );
				this.manage( callid );
			}

			http.open( this.remotes[ callid ].method, this.remotes[ callid ].link, true );
			http.onreadystatechange = function( ) {

				if ( http.readyState == 4 ) {

					if ( http.status == 200 ) {

						window.clearTimeout( timeoutId );
						merito.remote.remotes[ callid ].value = http.responseXML;
						merito.remote.manage( callid );
					}
				}
			}

			http.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" );
			http.send( null );

			timeoutId = window.setTimeout(
				function( ) {

					switch ( http.readyState ) {

						default:
							http.abort();
							merito.remote.remotes[ callid ].value = 'merito.remote: problems during remote call (waiting time exceeded)! You may want to try again.';
							merito.remote.manage( callid );
							break;
					}
				},
				merito.remote.remoteTimeout
			);

			return ;
		}

		throw 'merito.remote: call \'' + callid + '\'does not exist';
	}

	function ManageSetuped( callid ) {

		if ( !merito.version ) {

			throw 'merito.remote: unable to locate merito js console';
			return;
		}

		var cont = '';
		var script = '';

		if ( merito.remote.remotes[ callid ].script ) {

			script = merito.remote.remotes[ callid ].script;
		}

		var type = typeof merito.remote.remotes[ callid ].value;

		if ( type == 'string' ) {

			if( ie5 || ns6 ) { document.getElementById( merito.remote.remotes[ callid ].id ).innerHTML = merito.remote.remotes[ callid ].value; }
			else return false;

			if ( merito.remote.remotes[ callid ].script ) {

				eval( merito.remote.remotes[ callid ].script );
			}

			return true;
		}

		var value = merito.remote.remotes[ callid ].value

		cont = value.documentElement.getElementsByTagName( 'content' )[0].childNodes[0].nodeValue;

		if( ie5 || ns6 ) { document.getElementById( merito.remote.remotes[ callid ].id ).innerHTML = cont; }
		else return false;

		if ( value.documentElement.getElementsByTagName( 'jscript' ) ) {

			var jscripts = value.documentElement.getElementsByTagName( 'jscript' );
			var count = jscripts.length;
			var jse;

			for ( var i = 0; i < count; i++ ) {

				if ( jscripts[i].firstChild.nodeValue ) {

					merito.head.addFileJScript( jscripts[i].firstChild.nodeValue );
				}
			}
		}

		if ( value.documentElement.getElementsByTagName( 'stylesheet' ) ) {

			var styles = value.documentElement.getElementsByTagName( 'stylesheet' );
			var count = styles.length;

			for ( var i = 0; i < count; i++ ) {

				if ( styles[i].firstChild.nodeValue ) {

					merito.head.addFileStyleSheet( styles[i].firstChild.nodeValue );
				}
			}
		}

		if ( value.documentElement.getElementsByTagName( 'inlinejscript' )[0] ) {

			merito.head.addInlineJScript( value.documentElement.getElementsByTagName( 'inlinejscript' )[0].childNodes[0].nodeValue );
		}

		if ( value.documentElement.getElementsByTagName( 'evaluatejscript' )[0] ) {

			eval(  value.documentElement.getElementsByTagName( 'evaluatejscript' )[0].childNodes[0].nodeValue );
		}

		if ( value.documentElement.getElementsByTagName( 'debugs' )[0] ) {

			merito.debug.addDebugs(  value.documentElement.getElementsByTagName( 'debugs' )[0].childNodes[0].nodeValue );
		}

		eval( script );

		return true;
	}

	function SetupRemoteElementOnce( callid, id, link, script, noloading ) {

		if ( this.remotes[ callid ] ) {

			//throw 'merito.remote: call \''+ callid +'\' already exists';
			//return;
		}

		var loading = true;

		if ( noloading ) {

			loading = false;
		}

		this.remotes[ callid ] = new Array();
		this.remotes[ callid ].id = id;
		this.remotes[ callid ].link = link;
		this.remotes[ callid ].script = script;
		this.remotes[ callid ].mode = 'once';
		this.remotes[ callid ].loading = loading;
		this.remotes[ callid ].method = 'get';
	}

	function SetupRemoteElementReload( callid, id, link, script, noloading ) {

		if ( this.remotes[ callid ] ) {

			//throw 'merito.remote: call \''+ callid +'\' already exists';
			//return;
		}

		var loading = true;

		if ( noloading ) {

			loading = false;
		}

		this.remotes[ callid ] = new Array();
		this.remotes[ callid ].id = id;
		this.remotes[ callid ].link = link;
		this.remotes[ callid ].script = script;
		this.remotes[ callid ].mode = 'reload';
		this.remotes[ callid ].loading = loading;
		this.remotes[ callid ].method = 'GET';
	}

	function SimpleLoading( id ) {

		return 'loading..';
	}
}

merito.remote = new MeritoRemoteControl( );

merito.remote.loading = function( id ) {

	var box = document.getElementById( id );
	var height = ( box.offsetHeight - 70 ) / 2;
	var width = ( box.offsetWidth - 150 ) / 2;

	return '<div class="loading" style="position: absolute; z-index:2; background-color: #f2f2f2; border: 1px #bbb solid; -moz-border-radius:10px; width:70px; margin-left:' + width +'px; height:70px; margin-top:' + height + 'px;"><img src="/inc.img/merito/loading.gif" title="loading" alt="loading" style="position:absolute;top:50%;left:50%;margin-top:-8px;margin-left:-8px;"/></div>' + box.innerHTML;
}

/*

merito.remote.loading = function( id ) {

	var box = document.getElementById( id );

	var height = box.offsetHeight;

	if ( height > 16 ) {

		return '<div style="border:0; margin:0; padding:0; height: '+height.toString()+'px;"><img src="inc.img/merito/loading.gif" title="loading" alt="loading" style="width:16px; height:16px;" /></div>';
	}

	return '<img src="inc.img/merito/loading.gif" title="loading" alt="loading" />';
}

*/



function MeritoTabsControl( ) {

	this.tabs = new Array( );
	this.tabsGroups = new Array( );
	this.tabsStates = new Array( );

	this.tabsStatesCookie = 'merito.tabs.tabsStates';

	//methods declaration
	this.setup = Setup;
	this.setupRemoteReload = SetupRemoteReload;
	this.setupRemoteOnce = SetupRemoteOnce;
	this.trigger = Trigger;
	this.show = Show;
	this.hide = Hide;

	this.stateRemember = StateRemember;
	this.stateSave = StateSave;
	this.stateLoad = StateLoad;
	this.enableStateRemember = EnableStateRemember;

	this.createTabsGroup = CreateTabsGroup;
	this.addTabToGroup = AddTabToGroup;

	//methods definition

	function Setup( id ) {

		if ( document.getElementById( id ) ) {

			this.tabs[ id ] = new Array();
			this.tabs[ id ].remote = false;
			this.tabs[ id ].visible = ( document.getElementById( id ).style.display != 'none' );
			this.tabs[ id ].remember = false;
			return true;
		}
		throw 'merito.tabs: impossible to setup a tab for not-existing document element';
		return false;
	}

	function SetupRemoteReload( id, link, script ) {

		if ( document.getElementById( id ) ) {

			merito.remote.setupReload( 'merito.tab_' + id, id, link, script );
			this.tabs[ id ] = new Array();
			this.tabs[ id ].remote = true;
			this.tabs[ id ].visible = ( document.getElementById( id ).style.display != 'none' );
			this.tabs[ id ].remember = false;
			return true;
		}
	}

	function SetupRemoteOnce( id, link, script ) {

		if ( document.getElementById( id ) ) {

			merito.remote.setupOnce( 'merito.tab_' + id, id, link, script );
			this.tabs[ id ] = new Array();
			this.tabs[ id ].remote = true;
			this.tabs[ id ].visible = ( document.getElementById( id ).style.display != 'none' );
			this.tabs[ id ].remember = false;
			return true;
		}

		//TODO obsluga bledow
	}

	function Trigger( id ) {

		if ( this.tabs[ id ] ) {

			if ( this.tabs[ id ].visible ) {

				return this.hide( id );
			}
			return this.show( id );
		}

		throw 'merito.tabs: tab does not exists';
		//TODO obsluga bledow
	}

	function Hide( id ) {

		if ( this.tabs[ id ] && this.tabs[ id ].visible ) {

			if ( document.getElementById( id ) ) {

				document.getElementById( id ).style.display = 'none';
				this.tabs[ id ].visible = false;
				this.stateRemember( id );

				return ;
			}

		}

		return ;
	}

	function Show( id ) {

		if ( this.tabs[ id ] && !this.tabs[ id ].visible ) {

			if ( document.getElementById( id ) ) {

				if ( this.tabs[ id ].remote ) {

					merito.remote.call( 'merito.tab_' + id );
				}

				document.getElementById( id ).style.display = "";
				this.tabs[ id ].visible = true;
				this.stateRemember( id );

				return;
			}

			throw 'merito.tabs: cant show not-existing document element';
		}
		return;
	}

	function StateRemember( id ) {

		if ( this.tabs[ id ].remember ) {

			if ( this.tabs[ id ].visible ) this.tabsStates[ id ] = 'VIS';
			else this.tabsStates[ id ] = 'HID';

			this.stateSave( );
		}
	}

	function StateSave( ) {

		var tabsStatesCookieValue = '';

		for ( var i in this.tabsStates ) {

			tabsStatesCookieValue += i + '=' + this.tabsStates[ i ] + '`';
		}

		if ( tabsStatesCookieValue != '' ) {

			setCookie( this.tabsStatesCookie, tabsStatesCookieValue );
		}
	}

	function StateLoad( ) {

		var tabsStatesCookieValue = getCookie( this.tabsStatesCookie );

		if ( tabsStatesCookieValue ) {

			var tabsStatesSplit = tabsStatesCookieValue.split( '`' );

			for ( var i in tabsStatesSplit ) {

				if ( i ) {

					if ( tabsStatesSplit[i].split ) {

						var tab = tabsStatesSplit[i].split( '=' );
						if ( tab[0] ) {

							this.tabsStates[ tab[0] ] = tab[1];
						}
					}
				}
			}
		}
	}

	function CreateTabsGroup( groupid ) {

		if ( !this.tabsGroups[ groupid ] ) {

			this.tabsGroups[ groupid ] = new Object( );
			return true;
		}

		throw "merito.tabs: tab-group already exists";
	}

	function AddTabToGroup( groupid, id ) {

		if ( !this.tabs[ id ] ) {

			throw "merito.tabs: cant add not-existing tab to tab-group";
		}

		if ( !this.tabsGroups[ groupid ] ) {

			this.createTabsGroup( groupid );
		}

		this.tabsGroups[ groupid ][ id ] = id;
	}

	function EnableStateRemember( groupid ) {

		if ( this.tabsGroups[ groupid ] ) {

			for ( var id in this.tabsGroups[ groupid ] ) {

				this.tabs[ id ].remember = true;

				if ( this.tabsStates[ id ] ) {

					 if ( this.tabsStates[ id ] == 'HID' ) {

						this.hide( id );
					 } else {

						this.show( id );
					 }
				}
			}

			return true;
		}

	}
}

merito.tabs = new MeritoTabsControl( );
merito.tabs.stateLoad();


function meritoFormControl() {

	this.forms = new Array( );

	//methods
	this.getValues = GetValues;
	this.setup = Setup;
	this.call = Call;
	this.buildParams = BuildParams;

	function GetValues( formu ) {

		var result = new Array( );
		var ri = 0;
		var elmnts = formu.elements;
		var count = elmnts.length;

		if ( count ) {

			for ( var i=0; i<count; i++ ) {

				var typee = typeof elmnts[i];

				if ( isSimple( elmnts[i] ) ) {

					if(elmnts[i].multiple){

						for( var idx=0; idx<elmnts[i].length; idx++) {

							if( elmnts[i].options[ idx ].selected ) {

								result[ri] = new Array();
								result[ri].name = elmnts[i].name;
								result[ri].value = elmnts[i][idx].value;
								ri++;
							}

						}
					} else {

						result[ri] = new Array();
						result[ri].name = elmnts[i].name;
						result[ri].value = elmnts[i].value;
						ri++;
					}

				} else if( isCheckable( elmnts[i] ) ) {

					if ( elmnts[i].checked ) {

						result[ri] = new Array();
						result[ri].name = elmnts[i].name;
						result[ri].value = elmnts[i].value;
						ri++;
					}

				}
			}
		}

		return result;
	}

	function isSimple( el ) {

		if ( el.disabled ) {

			return false;
		}

		var tag = el.tagName;

		if ( tag == 'TEXTAREA' ) {

			return true;
		}

		if ( tag == 'SELECT' ) {

			return true;
		}

		if ( tag == 'INPUT' ) {

			var typ = el.type;

			if ( typ == 'hidden' ) {

				return true;
			}

			if ( typ == 'text' ) {

				return true;
			}

			if ( typ == 'password' ) {

				return true;
			}
		}

		return false;
	}

	function isCheckable( el ) {

		if ( el.disabled ) {

			return false;
		}

		var tag = el.tagName;

		if ( tag == 'INPUT' ) {

			var typ = el.type;

			if ( typ == 'radio' ) {

				return true;
			}

			if ( typ == 'checkbox' ) {

				return true;
			}
		}
		return false;
	}

	function Setup( callid, formId, id, method, seedName, seedVersion, seedPackage, params ) {

		this.forms[ callid ] = new Array( );
		this.forms[ callid ].formId = formId;
		this.forms[ callid ].id = id;
		this.forms[ callid ].method = method;
		this.forms[ callid ].seedName = seedName;
		this.forms[ callid ].seedVersion = seedVersion;
		this.forms[ callid ].seedPackage = seedPackage;

		if ( params ) {

			this.forms[ callid ].params = params;
		} else {

			this.forms[ callid ].params = new Array( );
		}
	}

	function Call( callid ) {

		if ( !this.forms[ callid ] ) {

			throw 'merito.form: call \''+ callid +'\' not exists';
			return false;
		}

		var values = this.getValues( document.getElementById( this.forms[ callid ].formId ) );
		var count = values.length;

		if ( this.forms[ callid ].method == 'get' ) {

			values[ count ] = new Array( );
			values[ count ].name = 'sn';
			values[ count ].value = this.forms[ callid ].seedName;
			values[ count+1 ] = new Array( );
			values[ count+1 ].name = 'sv';
			values[ count+1 ].value = this.forms[ callid ].seedVersion;
			values[ count+2 ] = new Array( );
			values[ count+2 ].name = 'sp';
			values[ count+2 ].value = this.forms[ callid ].seedPackage;

			var count2 = this.forms[ callid ].params.length;

			if ( count2 ) {

				for ( i = 0; i < count2; i++ ) {

					values[ count + 2 + i + 1 ] = this.forms[ callid ].params[i];
				}
			}

			var link = merito.remote.remoteIndex + '?' + this.buildParams( values );
		} else {

			ln = new Array( );
			ln[ 0 ] = new Array( );
			ln[ 0 ].name = 'sv';
			ln[ 0 ].value = this.forms[ callid ].seedVersion;
			ln[ 1 ] = new Array( );
			ln[ 1 ].name = 'sp';
			ln[ 1 ].value = this.forms[ callid ].seedPackage;
			ln[ 2 ] = new Array( );
			ln[ 2 ].name = 'sn';
			ln[ 2 ].value = this.forms[ callid ].seedName;

			var count2 = this.forms[ callid ].params.length;

			if ( count2 ) {

				for ( i = 0; i < count2; i++ ) {

					ln[ 2 + i + 1 ] = this.forms[ callid ].params[i];
				}
			}

			var link = merito.remote.remoteIndex + '?' + this.buildParams( ln );
		}

		merito.remote.remoteCall( this.forms[ callid ].method, this.forms[ callid ].id, link, '', this.buildParams( values ) );
	}

	function BuildParams( values ) {

		var count = values.length;
		var link = '';

		if ( count ) {

			for ( var i=0; i<count; i++ ) {

				if ( link == '' ) {

					link = values[ i ].name + '=' + encodeURIComponent( values[ i ].value );
				} else {

					link = link + '&' + values[ i ].name + '=' + encodeURIComponent( values[ i ].value );
				}
			}
		}


		return link;
	}
}

merito.form = new meritoFormControl();


function meritoDebugControl() {

	this.setStatus = SetStatus;
	this.hideStatus = HideStatus;
	this.addDebugs = AddDebugs;

	this.debugTabId = 'mdc_debugs';

	function SetStatus( id, content ) {

		if ( document.getElementById( id ) ) {

			var status = document.getElementById( id );

			status.style.display = 'none';
			status.innerHTML += '<ul class="status"><li>' + content + '</li></ul>';
			status.style.display = '';
		}
	}

	function HideStatus( id ) {

		if ( document.getElementById( id ) ) {

			var status = document.getElementById( id );

			status.style.display = 'none';
			status.innerHTML = '';
		}

	}

	function AddDebugs( content ) {

		if ( document.getElementById( this.debugTabId ) ) {

			var debug = document.getElementById( this.debugTabId );

			debug.innerHTML = debug.innerHTML + content;
			return ;
		}

		if (  window.opener && window.opener.document.getElementById( this.debugTabId ) ) {

			var debug = window.opener.document.getElementById( this.debugTabId );

			debug.innerHTML = debug.innerHTML + content;
			return ;
		}

		if ( window.parent && window.parent.document.getElementById( this.debugTabId ) ) {

			var debug = window.parent.document.getElementById( this.debugTabId );

			debug.innerHTML = debug.innerHTML + content;
			return ;
		}

	}
}

merito.debug = new meritoDebugControl();


