/**
 * Global functions
*/
function $O(element,hideError){
	return document.getElementById(element);
}
function $Ov(Object){
	if (typeof Object == 'string') {
		Object = $O(Object);
	}
	switch(Object.tagName){
		case 'TEXTAREA':
		case 'INPUT':
			return Object.value;
			break;
		case 'SELECT':
			if (Object.selectedIndex < 0) {
				return '';
			} else {
				return Object.options[Object.selectedIndex].value;
			}
			break;
		default:
			break;
	}
}
Function.prototype.bind=function(){
	var __method = this,args=$A(arguments),object=args.shift();
	return function(){
		return __method.apply(object, args.concat($A(arguments)));
	}
}
function $Ce(TagName,Attributes){
	var tag=document.createElement(TagName);
	if (Attributes instanceof Object){
		for (i in Attributes){
			tag.setAttribute(i, Attributes[i]);
		}
	}
	return tag;
}
var Class={
	create:function(){
		return function(){
			this.initialize.apply(this,arguments);
		}
	}
}
getElementsByClassName=function(param){
	var retnode=new Array();
	var regular_expression=new RegExp('\\b'+param+'\\b');
	var elements=document.getElementsByTagName('*');
	for (i=0;i<elements.length;i++){
		var classes=elements[i].className;
		if (regular_expression.test(classes)) retnode.push(elements[i]);
	}
	return retnode;
}

/**
 * MyEvent object
*/
MyEvent={
	attachedEvents:{1:[],2:[],3:[],4:[],5:[],6:[],7:[],8:[],9:[],10:[]},
	add:function(Object,EventType,FunctionObj,Params,Priority){
		if(Object==undefined || Object==null){
			Object=window;
		}
		if(typeof Object=='string'){
			Object=$O(Object);
		}

		if(Priority==undefined){
			this.attachedEvents[5].push(new MyEventRecord(Object,EventType,FunctionObj,Params));
		}
		else if(!isNaN(Priority)&&Priority>=1&&Priority<=10){
			this.attachedEvents[Priority].push(new MyEventRecord(Object,EventType,FunctionObj,Params));
		}
		else{
			return false;
		}
		return true;
	},
	attachEvent:function(EventRecord){
		if (EventRecord._object == null) {
			return false;
		}
		if(EventRecord._object.addEventListener){
			EventRecord._object.addEventListener(EventRecord._eventType,function(Event){EventRecord._function(EventRecord._object,Event,EventRecord._params);},false);
		}
		else if(EventRecord._object.attachEvent)
			EventRecord._object.attachEvent('on'+EventRecord._eventType,function(Event){EventRecord._function(EventRecord._object,Event,EventRecord._params);});
		else{
			EventRecord._eventType='on'+EventRecord._eventType;
			EventRecord._object.EventRecord._eventType=function(Event){EventRecord._function(EventRecord._object,Event,EventRecord._params);};
		}
	},
	stop:function(Event){
		if(Event.preventDefault){
			Event.preventDefault();
			Event.stopPropagation();
		}
		else{
			Event.cancelBubble=true;
			Event.returnValue=false;
		}
		return false;
	},
	loadEvents:function(Event){
		if (!Event){
			if (window.event){
				Event=window.event;
			}
			else if (window.Event){
				Event=window.Event;
			}
		}
		for(PriorityLevel in MyEvent.attachedEvents){
			for(var i=0;i<MyEvent.attachedEvents[PriorityLevel].length;i++){
				EventRecord=MyEvent.attachedEvents[PriorityLevel][i];
				if(EventRecord._object==window&&EventRecord._eventType=='load'){
					EventRecord._function(EventRecord._object,Event,EventRecord._params);
				}
				else{
					MyEvent.attachEvent(EventRecord);
				}
			}
		}
	}
}
MyEventRecord=Class.create();
MyEventRecord.prototype={
	_object:null,
	_eventType:null,
	_function:null,
	_params:null,
	initialize:function(_object,_eventType,_function,_params){
		this._object=_object;
		this._eventType=_eventType;
		this._function=_function;
		this._params=_params;
	}
}
MyEvent.attachEvent(new MyEventRecord(window,'load',MyEvent.loadEvents));

/* Utils */
Utils=Class.create();
/**
* common used functions
*/
function showhide(id) {
	if ($O(id).style.display=='none') {
		$O(id).style.display='';
	} else {
		$O(id).style.display='none';
	}
}
function helpabl(param) {
	ablak = window.open(DEF_URL + "popup/help.php?id=" + param, "Help", "width=500, height=360, status=no, menubar=no, scrollbars=yes");
}
function mailkuldes(cimzett) {
	ablak = window.open(DEF_URL + "popup/email.php?kinek=" + cimzett, "Emailküldés", "width=500, height=360, status=no, menubar=no, scrollbars=yes");
}
function submitform1() {
	document.form1.submit();
}
function require(scriptname) {
	var script = $Ce('script');
	script.type = 'text/javascript';
	script.src = JS_URL + scriptname;
	document.getElementsByTagName('head')[0].appendChild(script);
}

function showhint(obj, txt, classname) {
	hintcontainer=$O("hintcont");
	if (hintcontainer==undefined) {
		hintcontainer = document.createElement("div");
		hintcontainer.id = "hintcont";
		document.body.appendChild(hintcontainer);
	}
	if (hintcontainer.className!=classname) {
		hintcontainer.className=classname;
	}
	hintcontainer.innerHTML=txt;
	obj.onmouseout = hidehint;
	obj.onclick = hidehint;
	obj.onmousemove = movehint;
}
function movehint(e) {
	var mywidth = $j(window).width();
	var indent = 0;
	hintcontainer=$O("hintcont");
	if (!e) {
		e = event; //line for IE compatibility
	}
	//Opera and Chrome compatibility
	var rtop = parseInt(document.documentElement.scrollTop);
	if ( isNaN(rtop) || rtop == 0 ) {
		rtop = parseInt(document.body.scrollTop);
	}
	
	
	if (e.clientX > mywidth - 200 ) {
		indent = mywidth + 100 - e.clientX;
	}
	
	myleft = e.clientX+document.documentElement.scrollLeft-20-indent;
	hintcontainer.style.left = myleft+"px";
	hintcontainer.style.display="";
	if ( hintcontainer.offsetWidth > mywidth - myleft - 20) {
		hintcontainer.style.width=(mywidth - myleft -20)+"px";
	} else {
		hintcontainer.style.width="";
	}
	hintcontainer.style.top = (e.clientY+rtop-3-hintcontainer.offsetHeight)+"px";
}
function hidehint() {
	hintcontainer=$O("hintcont");
	hintcontainer.style.display="none";
}
// buborék megjelenítése
function showBox(name) {
	document.getElementById(name).style.visibility = 'visible';
}
// buborék elrejtése
function hideBox(name, name2) {
	document.getElementById(name).style.visibility = 'hidden';
	if (!(name2 === undefined )) {
		document.getElementById(name2).style.visibility = 'hidden';
	}
}

