function Elvira(op) {
that = this;
this.VERSION = 'AC02';
this.COPYRIGHT = '(c) MÁV INFORMATIKA Zrt.';
this.OP = op || {}; // res, lang, ed, mind, maxd
this.latszikMind = true;
}

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
,

uffAutoComplete: function() {
		var accentMap = {
			"á": "a", "Á":"A",
			"ä": "a", "Ä":"A",
			"â": "a", "Â":"A",
			"ã": "a", "Ã":"A",
			"è": "c", "È":"C",
			"ð": "d", "Ð":"D",
			"é": "e", "É":"E",
			"í": "i", "Í":"I",
			"³": "l", "£":"L",
			"¾": "l", "¼":"L",
			"ò": "n", "Ò":"N",
			"ó": "o", "Ó":"o",
			"ö": "o", "Ö":"O",
			"õ": "o", "Õ":"O",
			"º": "s",
			"š": "s", "Š":"S",
			"": "t",
			"ü": "u", "Ü":"U",
			"û": "u", "Û":"U",
			"ž": "z", "Ž":"Z",
			"Ÿ": "z", "":"Z"
		};
		var normalize = function( term ) {
			var ret = "";
			for ( var i = 0; i < term.length; i++ ) {
				ret += accentMap[ term.charAt(i) ] || term.charAt(i);
			}
			return ret;
		};

		function split( val ) {
			return val.split( /;\s*/ );
		};
		
		function extractLast( term ) {
			return split( term ).pop();
		};
		
		$('#i,#e').autocomplete({
			source: function( request, response ) {
				var matcher = new RegExp( '^'+$.ui.autocomplete.escapeRegex( request.term ), "i" );
				response( $.grep( mav, function( value ) {
					value = value.label || value.value || value;
					return matcher.test( value ) || matcher.test( normalize( value ) );
				}) )
			},
			minLength: 2
		});
		
		$( "#v" ).autocomplete({
			minLength: 2,
			source: function( request, response ) {
				// delegate back to autocomplete, but extract the last term
				response( $.ui.autocomplete.filter(
					mav, extractLast( request.term ) ) );
			},
			focus: function() {
				// prevent value inserted on focus
				return false;
			},
			select: function( event, ui ) {
				var terms = split( this.value );
				// remove the current input
				terms.pop();
				// add the selected item
				terms.push( ui.item.value );
				// add placeholder to get the comma-and-space at the end
				terms.push( "" );
				this.value = terms.join( "; " );
				return false;
			}
		});
}, // uffAutoComplete

Ablak: function(a,e,t,w,h){
	e.preventDefault();
	$(a).dialog({
            modal: false,
            open: function () { $(this).load(a.href+'&ajax=i'); },         
			close: function(e, i) { $(this).close(); },
            width: (w=='undefined')?320:w,
            height: (h=='undefined')?240:h,
            title: t
        });
	return false;
}
,
VT : function(a,e) {
	return this.Ablak(a,e,'vonatinformációk',480);
},
AF : function(a,e) {
	return this.Ablak(a,e,'állomásinformációk');
}
,
DA : function( alany,datum) {
	$('body').dialog('da?a=' + alany + '&amp;d='+ datum +'&amp;language='+this.OP.lang+'&amp;ed='+this.OP.ed+'&amp;ajax=i');
}
,
HK : function( id) {
	$('<div></div>').dialog('hk?id=' + id +'&amp;language='+this.OP.lang+'&amp;ed='+this.OP.ed+'&amp;ajax=i');
}
,
MK : function( id) {
	$('<div></div>').dialog('mk?mk=' + id +'&amp;language='+this.OP.lang+'&amp;ed='+this.OP.ed+'&amp;ajax=i');
}
,
JI : function() {
	$('<div></div>').dialog('/gyik0.htm');
}
}


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) {
							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);
			}
		}
	}
}


