function gInteractive() {
	this.toggles = new Array();
}

gInteractive.prototype = {

	//Általános fgvk
	getObj: function( name ) {
	    return document.getElementById( name );
	},

	getPos: function( name ) {
		obj = this.getObj( name );
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
		return [curleft,curtop];
	},

	addEvent: function(obj, evType, fn, useCapture) {
		if (obj.addEventListener) {
			obj.addEventListener(evType,fn,useCapture);
			return true;
		} else if(obj.attachEvent){
			return obj.attachEvent("on"+evType,fn);
		} else {
			return false;
		}
	},

	hideObj: function( name ) {
		if ( (typeof this.getObj( name ) == 'undefined') || (this.getObj( name ) == null) ) {
		    return false;
		}

	    this.getObj( name ).style.display = 'none';
	},

	showObj: function( name ) {
		if ( (typeof this.getObj( name ) == 'undefined') || (this.getObj( name ) == null) ) {
		    return false;
		}

	    this.getObj( name ).style.display = 'block';
	},



	//Toggle
	toggleActive: function( name, queue ) {
	    this.toggles[ queues ] = new Array();
		this.toggles[ queues ]['active'] = name;
	},

	toggleSimple: function( name, queue ) {
	    this.hideObj( this.toggles[ queues ]['active'] );
		this.showObj( name );
		this.toggles[ queues ]['active'] = name;
	},


	//SELECT-ek
	disableSelect: function( name ) {
	  this.getObj( name ).disabled       = true;
	  this.getObj( name ).selectedIndex  = 0;	    
	},

	clearSelect: function( name ) {
		select_obj = this.getObj( name );
		for ( i=l; i>=0; i--) { 
			select_obj.options[i] = null; 
		} 
	    
	},

	loadSelect: function( name, datas, ids ) {
		select_obj = this.getObj( name );
		l          = select_obj.options.length - 1;

		this.clearSelect( name );

		//Feltöltés adatokkal
		for(i=0; i < datas.length; i++) {
			select_obj.options[i]=new Option(datas[i], ids[i]);
		}
		select_obj.disabled = false;
	},


	//Üzenetek
	makeSplash: function( x, y, w, h, bg, opacity ) {
		var myDate = new Date();
		var splashID = 'splash_'+myDate.getTime();

		//Splash létrehozás
		    splash = document.createElement( 'DIV' );
			splash.setAttribute( 'id', splashID );

		//Méretek
			splash.style.left = x+'px';
			splash.style.top = y+'px';
			splash.style.width = w+'px';
			splash.style.height = h+'px';

		//Megjelenés
			splash.style.visibility = 'visible';
			splash.style.position = 'absolute';
			splash.style.backgroundColor = bg;
			splash.style.zIndex = 10;

			splash.className = 'splashDIV';

		//Opacity IE, MOZILLA, MAC, FF
			splash.style.opacity = (opacity / 100);
			splash.style.MozOpacity = (opacity / 100);
			splash.style.KhtmlOpacity = (opacity / 100);
			splash.style.filter = "alpha(opacity=" + opacity + ")"; 		

			document.body.appendChild(splash);

			return splashID;
	},

	showMessage: function( name, message ) {
	    var mainFrame = this.getObj( name );
		var pos = this.getPos( name );

		splashID = this.makeSplash( pos[0], pos[1], mainFrame.scrollWidth, mainFrame.scrollHeight, '#f2f2f2', 75 );
		var splashObj = this.getObj( splashID );
		
		splashObj.style.textAlign = 'center';
		splashObj.style.lineHeight = mainFrame.scrollHeight+'px';

		splashObj.innerHTML = message;

		if ( browser.isIE6x ) {
			var els = mainFrame.getElementsByTagName('select')
			var i;

			for ( i = 0; i < els.length; i++ ) {
				els[i].style.visibility = 'hidden';
			};
		}




		return splashID;
	},

	hideMessage: function( splashID ) {
		var splash = this.getObj( splashID );
		if ( browser.isIE6x ) {
			var els = splash.parentNode.getElementsByTagName('select')
			var i;

			for ( i = 0; i < els.length; i++ ) {
				els[i].style.visibility = 'visible';
			};
		}
		
		document.body.removeChild(splash);
	}

}

gInteractive = new gInteractive();

function initBrowser() {
	browserscript = document.createElement( 'script' );
	browserscript.src = 'js/browserdetect.js';
	document.body.appendChild( browserscript );
}

addEvent(window, 'load', initBrowser);
