function Elvira(op) {
that = this;
this.VERSION = '10.08';
this.COPYRIGHT = '(c) MÁV INFORMATIKA Zrt.';
this.OP = op || {}; // res, lang, ed
this.THEME = 'alphacube'; // 'alphacube' | darkX | mac-os-x
this.latszikMind = true;

// preload
if (this.OP.res) {
	var j;

	var a = ['button01.gif','button03.gif'];
	for (var k=0; k<a.length; k++) {
		j = new Image();
		j.src = this.OP.res+a[k];
		};
		
	if (this.THEME=='alphacube') {
		a = ['bottom-left-c.gif','bottom-middle.gif','bottom-right-c.gif',
		 'button-close-focus.gif','button-max-focus.gif','button-min-focus.gif',
		 'frame-left.gif','frame-right.gif','left-top.gif','right-top.gif','top-middle.gif'];
	}
	else if (this.THEME=='darkX') {
		a = ['button-close-focused.png','button-maximize-focused.png','button-minimize-focused.png',
		 'frame-bottom-left-focused.png','frame-bottom-mid-focused.png','frame-bottom-right-focused.png',
		 'frame-left-focused.png','frame-right-focused.png',
		 'titlebar-left-focused.png','titlebar-mid-focused.png','titlebar-right-focused.png'];
	}
	for (var k=0; k<a.length; k++) {
			j = new Image();
			j.src = this.OP.res+'js/windows/themes/'+this.THEME+'/'+a[k];
			};
}
}

Elvira.prototype = {

exxiteShow:	function(id) {
	if (!document.getElementById)
		return;
	var o = document.getElementById( id);
	if (o) {
		o.style.display = (o.style.display=="block")?"none":"block";
	}
},

exxiteShowVice:	function(id,id1) {
//layer hiddener vice versa, show a layer and hide an other
	if (!document.getElementById)
		return;
	var o = document.getElementById(id);
	var o1 = document.getElementById(id1);
	if (o) {
		if(o.style.display=="block") {
			o.style.display="none";
			o1.style.display="block";
		}
		else {
			o.style.display="block";
			o1.style.display="none";
		}
	}
},
exxiteFShow:	function(id) {
	if( !document.getElementById) return;
	var o=document.getElementById(id);
	var i=document.getElementById('b'+id);
	if(o)
	{
		if(o.style.display=="block")
		{
			o.style.display="none";
			i.src=this.OP.res+"button01.gif";
		}
		else
	 {
			o.style.display="block";
			i.src=this.OP.res+"button03.gif";
	 }
	}
}
,
checkForm:	function(lng) {
 if ( document.uff.i.value.trim()=='') {
  if (lng == 1) { alert('Az induló állomás nem lehet üres!');}
  if (lng == 2) { alert('Please give a starting station'); }
  if (lng == 3) { alert('Der Bahnhof "Von" muss ausgefüllt werden'); }
  document.uff.i.focus();
  return false;
 }
 else if (document.uff.e.value.trim()=='') {
  if (lng == 1) { alert('A célállomás nem lehet üres'); }
  if (lng == 2) { alert('Please give a destination station'); }
  if (lng == 3) { alert('Der Bahnhof "Nach" muss ausgefüllt werden'); }
  document.uff.e.focus();
  return false;
 }
 else {
  return true;
 }
},


kiMind:	function(ki) {
 var am = $$('div.more');
 if (ki!=undefined) {
  this.latszikMind = ki;
 }
 for (var i=0; i<am.length; ++i) {
    am[i].style.display = (this.latszikMind)?"none":"block";
 }
 am = $$('.morebutton img');
 for (var i=0; i<am.length; ++i) {
    am[i].src = (this.latszikMind)?this.OP.res+"button01.gif":this.OP.res+"button03.gif";
 }
 this.latszikMind = !this.latszikMind;
},

SorSzinezo:	function( idTabla, selectedClass, clickedClass) {
 this.selectedClass = selectedClass;
 this.clickedClass = clickedClass;
 var that = this;
 var tabla = $(idTabla);
 var tablaRow = null;
 
 this.tableMouseIn = function( ev) {
	if (Event.element( ev).tagName.toLowerCase() != 'th') {
		var e = Event.findElement(ev,'tr');
		if (e) {
			Element.addClassName( e, that.selectedClass);
		}
	}
 }
 
 this.tableMouseOut = function( ev) {
	if (Event.element( ev).tagName.toLowerCase() != 'th') {
	 	var e = Event.findElement(ev,'tr');
		if (e) {
			Element.removeClassName(e, that.selectedClass);
		}
	}
 }

 this.tableMouseClick = function( ev) {
	if (Event.element( ev).tagName.toLowerCase() != 'th') {
	 	var e = Event.findElement(ev,'tr');
		if (e) {
			if (that.rowClicked) {
				Element.removeClassName( that.rowClicked, that.clickedClass);
			}
			that.rowClicked = e;
			Element.addClassName(e, that.clickedClass);
		}
	}
 }
 
 if (tabla) {
	Event.observe( tabla, 'mouseover', this.tableMouseIn);
	Event.observe( tabla, 'mouseout', this.tableMouseOut);
	Event.observe( tabla, 'click', this.tableMouseClick);
 }
} // sorSzinezo
,
VT : function(vt,d) {
	try {
		var wVT = new top.Window({className:this.THEME, width:700, height:480, destroyOnClose:true, recenterAuto:false});
	}
	catch (e) {
		var wVT = new Window({className:this.THEME, width:700, height:480, destroyOnClose:true, recenterAuto:false});
	}
	with (wVT) {
		setURL('vt?v=' + vt + '&amp;language='+this.OP.lang+'&amp;ed='+this.OP.ed+'&amp;ajax=i&amp;d='+d);
		showCenter();
	}
}
,
AF : function(am,datum) {
	try {
		var wAF = new top.Window({className:this.THEME, width:640, height:440, destroyOnClose:true, recenterAuto:false});
	}
	catch( e) {
		var wAF = new Window({className:this.THEME, width:640, height:440, destroyOnClose:true, recenterAuto:false});
	}
	with (wAF) {
		setURL('af?i=' + am + '&amp;d='+ datum +'&amp;language='+this.OP.lang+'&amp;ed='+this.OP.ed+'&amp;ajax=i');
		showCenter();
	}
}
,
DA : function( alany,datum) {
	var wDA = new Window({className:this.THEME, width:640, height:440, destroyOnClose:true, recenterAuto:false});
	with (wDA) {
		setURL('da?a=' + alany + '&amp;d='+ datum +'&amp;language='+this.OP.lang+'&amp;ed='+this.OP.ed+'&amp;ajax=i');
		showCenter();
	}
}
,
HK : function( id) {
	var wHK = new top.Window({className:this.THEME, width:640, height:220, destroyOnClose:true, recenterAuto:false});
	with (wHK) {
		setURL('hk?id=' + id +'&amp;language='+this.OP.lang+'&amp;ed='+this.OP.ed+'&amp;ajax=i');
		showCenter();
	}
}
,
MK : function( id) {
	var wMK = new top.Window({className:this.THEME, width:640, height:440, destroyOnClose:true, recenterAuto:false});
	id = id || '';
	with (wMK) {
		setURL('mk?mk=' + id +'&amp;language='+this.OP.lang+'&amp;ed='+this.OP.ed+'&amp;ajax=i');
		showCenter();
	}
}

}
if(typeof String.prototype.trim=='undefined')
String.prototype.trim = function() {
   return this.replace(/^\s+|\s+$/g,"");
}

simOptGroup = {
	s: ''
	,
	init: function( sName) {
		s = document.getElementById( sName);
		for (var i=0,j=0; i<s.childNodes.length;i++) {
			if (s.childNodes[i].tagName) {
				s.childNodes[i].myIndex = j++;
			}
		}
		this.closeAll();
		s.onchange = function(e) {
			simOptGroup.choose( e)
		};
	}
	,
	closeAll: function() {
		try {
			var aOG = s.getElementsByTagName('optgroup');
			if (aOG && (aOG.length>0)) {
				var i = 0;
				while (aOG.length>i) {
					aOG[i].selected = false;
					for( var j=0; j<aOG[i].childNodes.length; j++) {
						if (aOG[i].childNodes[j].selected) {
							// alert('TESZT: selected: '+i+':'+j);
							aOG[i].selected = true;
							s.title = '{'+aOG[i].childNodes[j].title+'}';
							break;
						}
					}
					if (aOG[i].selected) {
						i = i+1;
					}
					else {
						var o = document.createElement('option');
						o.appendChild( document.createTextNode( aOG[i].label+' ==>'));
						o.value = 0;
						o.className = "optgroup";
						o.disabled = aOG[i].disabled;
						o.style.display = aOG[i].style.display;
						o.optGroup = aOG[i].cloneNode(true);
						o.myIndex = aOG[i].myIndex;
						s.insertBefore( o, aOG[i]);
						s.removeChild(aOG[i]);
					}
				}
			}
		}
		catch(e) {
			alert(e);
		}
	}
	,
	choose: function( e) {
		if (s.selectedIndex == -1) {
			return (true);
		}
		else {
			var o = s.options[s.selectedIndex];
			if (o.optGroup!=undefined) {
				this.closeAll();
				var uo = o.optGroup.cloneNode(true);
				s.insertBefore(uo,o);
				uo.selected = true;
				uo.myIndex = o.myIndex;
				s.removeChild( o);
				s.size = 1+s.options.length;
				s.selectedIndex = o.myIndex;
				s.title = '('+o.title+')';
				return true;
			}
			else {
				s.size = 1;
				s.title = '['+o.title+']';
				return (true);
			}
		}
	}
}

