function calendarSetup(id)
{
	Calendar.setup({
        inputField     :    id,      // id of the input field
        ifFormat       :    "%Y-%m-%d %H:%M",       // format of the input field
        showsTime      :    true,            // will display a time selector
        singleClick    :    true,           // double-click mode
        step           :    1                // show all years in drop-down boxes (instead of every other year as default)
    });
}




/* admin functions */
function setMenuType(obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8) {
	obj1=getValue(obj1);
	if (obj1) {
		hideObj(obj2);
		disableObj(obj2);
		hideObj(obj3);
		disableObj(obj3);
		hideObj(obj4);
		disableObj(obj4);
		hideObj(obj5);
		disableObj(obj5);
		hideObj(obj6);
		disableObj(obj6);
		switch(parseInt(obj1)) {
			case 9:
				showObj(obj2);
				enableObj(obj2);
			break;
			case 7:
				showObj(obj5);
				enableObj(obj5);				
			break;
			case 6:
				showObj(obj3);
				enableObj(obj3);
			break;
			case 3:
				showObj(obj4);
				enableObj(obj4);
			break;
			case 27:
				showObj(obj6);
				enableObj(obj6);
				showObj(obj7);
				enableObj(obj7);
				showObj(obj8);
				enableObj(obj8);
//				alert('iframe');
			break;
			default:
				setValue(obj2,'');
				setValue(obj3,'');
				setValue(obj4,'');
				setValue(obj5,'');
			break;
		}
	}
}

function setKiallitasEv( obj1, obj2 ) {
	var ev_id = obj1.value ;
	for (var i=0;i< obj1.options.length;i++) {
		if( obj1.options[i].value == ev_id ){
			obj = obj2 + ev_id;
			showObj(obj);
			enableObj(obj);
		}else{
			obj = obj2 + obj1.options[i].value;
			hideObj(obj);
			disableObj(obj);
		}
	}
	
}

function openChildren(obj,tag) {
	obj=getObjfromIdorObj(obj);
	var children=obj.parentNode.childNodes;
	tag=new RegExp(tag);
	for (var i=0;i<children.length;i++) {
		if (children[i] && children[i].nodeName.match(tag)) {
			toggleObj(children[i]);
		}
	}
}


function hideSzelei() {
	var kozep=getObjfromIdorObj("kozepre");
	if (getMaxWidth(true)<kozep.offsetWidth+20) {
		hideObj("szelebalra");
		hideObj("szelejobbra");
	} else {
		showObj("szelebalra");
		showObj("szelejobbra");
	}
}

var onLoadMethods=new Array(whatCorrector);//hideSzelei
var onResizeMethods=new Array();//hideSzelei
function onResize() {
	if (onResizeMethods) {
		for(var i=0;i<onResizeMethods.length;i++) {
			var func = onResizeMethods[i];
			func();
		}
	}
}
function onLoad() {
	if (onLoadMethods) {
		for(var i=0;i<onLoadMethods.length;i++) {
			var func = onLoadMethods[i];
			func();
		}
	}
}


function togglePerformance() {
    var div=getObjfromIdorObj('performance');
    if (div) {
        if (div.style.display=='none' || div.style.display=='') {
            div.style.display='block';
            setClassHover('performancetoggle');
            location.href='#performancebottom';
        } else {
            div.style.display='none';
            setClassBaseRoot('performancetoggle');
        }
    }
}




  function aktivElem(obj){
    obj.style.backgroundColor = '#000000';
    obj.style.color = '#ffffff';
  }
  function inaktivElem(obj){
    obj.style.backgroundColor = '#ffffff';
    obj.style.color = '#666666';
  }
  function legordulo_be(){
    obj=document.getElementById('legorduloKepMenu');
    if(obj.style.display == 'inline'){
      obj.style.display='none';
    }else{
      obj.style.display='inline';
    }
  }



window.VerticalProjectorTimeout=new Array();
function VerticalProjector(obj,classname,options) {
	this.interval=3000;
	this.tags=['li','div'];
	this.classname=classname;
	obj=getObjfromIdorObj(obj);
	this.container=obj;
	if (typeof options!="undefined") {
		if (!isNaN(options.interval))this.interval=options.interval;
	}

	this.start=function() {
		if (typeof myLightWindow=="object" && myLightWindow && myLightWindow.animating) {
			return false;
		}
//		debug(this.classname+" start = "+this.running);
		this.running=1;
		this.refresh();
	}
	this.timeout=function() {
//		debug(this.classname+" timeout = "+this.running);
		if (this.running) {
			this.next();
		} else {
			this.stop();
		}
	}
	this.next=function() {
//		debug(this.classname+" next = "+this.running);
		this.stop();
		
		var writenext=0;
		var nodes=this.container.childNodes;
		var elso=0;
		
		for(var i=0;i<nodes.length;i++) {
			for(var j=0;j<this.tags.length;j++) {
				if (!elso && nodes[i].nodeName.toLowerCase()==this.tags[j].toLowerCase()) {
					elso=nodes[i];
				}
				if (writenext>0 && nodes[i].nodeName.toLowerCase()==this.tags[j].toLowerCase()) {
					setClassHover(nodes[i]);
					writenext=-1;
				}
				if (writenext>=0 && nodes[i].nodeName.toLowerCase()==this.tags[j].toLowerCase() && nodes[i].className.match(/hover$/)) {
//					nodes[i].className='';
					writenext=1;
					setClassBaseRoot(nodes[i]);
				}
			}
		}
		if (writenext>0)setClassHover(elso);
		
		this.running=1;
		this.refresh();
	}
	this.prev=function() {
//		debug(this.classname+" prev = "+this.running);
		this.stop();
		
		var writenext=0;
		var nodes=this.container.childNodes;
		var elso=0;
		
		for(var i=nodes.length-1;i>0;i--) {
			for(var j=0;j<this.tags.length;j++) {
				if (!elso && nodes[i].nodeName.toLowerCase()==this.tags[j].toLowerCase()) {
					elso=nodes[i];
				}
				if (writenext>0 && nodes[i].nodeName.toLowerCase()==this.tags[j].toLowerCase()) {
					setClassHover(nodes[i]);
					writenext=-1;
				}
				if (writenext>=0 && nodes[i].nodeName.toLowerCase()==this.tags[j].toLowerCase() && nodes[i].className.match(/hover$/)) {
//					nodes[i].className='';
					writenext=1;
					setClassBaseRoot(nodes[i]);
				}
			}
		}
		if (writenext>0)setClassHover(elso);
		
		this.running=1;
		this.refresh();
	}
	this.stop=function() {
//		debug(this.classname+" stop = "+this.running);
		this.running=0;
//      debug("ProjectorTimeout "+this.classname+" clear:"+this.running);
		clearTimeout(window.VerticalProjectorTimeout[this.classname]);
//		debug(this.classname+" stop#2 = "+this.running);
		return false;
	}
	this.refresh=function() {
//		debug(this.classname+" refresh = "+this.running);
		window.VerticalProjectorTimeout[this.classname]=setTimeout(classname+".timeout()",this.interval);
//      debug("ProjectorTimeout "+this.classname+" refresh"+window.VerticalProjectorTimeout[this.classname]);
	}

	this.start();
}




function oc(id){
	obj=document.getElementById(id);
	if( obj.style.display == 'none' ){
		obj.style.display='block';
	}else{
		obj.style.display='none';
	}
}



function ajaxExhibitorColor(id,color) {
 	PostData="action=kiallito&action2=ajaxExhibitorColor&kiallito="+id+"&color="+color;
	var opts = {
		method: 'post',
		postBody:PostData
	}
	new Ajax.Request('/ajax.php', opts);
	return false;
}



function ajaxFavouritesAddExhibition(id) {
 	PostData="action=kedvencek&action2=ajaxFavouritesAddExhibition&exhibition[id]="+id;
	var opts = {
		method: 'post',
		postBody:PostData,
		onSuccess: function(t) {
			alert('A kedvenc felvétele sikeres volt!');
		},
		on404: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/ajax.php', opts);
	return false;
}
function ajaxFavouritesAddExhibitor(id) {
 	PostData="action=kedvencek&action2=ajaxFavouritesAddExhibitor&exhibitor[id]="+id;
	var opts = {
		method: 'post',
		postBody:PostData,
		onSuccess: function(t) {
			alert('A kedvenc felvétele sikeres volt!');
		},
		on404: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Request('/ajax.php', opts);
	return false;
}

function ajaxSendMSGRefreshExhibitor(id) {
 	PostData="action=uzenetkuldes&action2=ajaxFavouritesAddExhibitor&exhibition[id]="+id;
	var opts = {
		method: 'post',
		postBody:PostData,
		onSuccess: function(t) {
		},
		on404: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Updater('uzenet[kiallito][id][label]','/ajax.php', opts);
	return false;
}


function ajaxRefreshExhibitor(id, select_id) {
 	PostData="action=naptar&action2=ajaxFavouritesAddExhibitor&exhibition[id]="+id;
	var opts = {
		method: 'post',
		postBody:PostData,
		onSuccess: function(t) {
		},
		on404: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		},
		onFailure: function(t) {
			alert('Error ' + t.status + ' -- ' + t.statusText);
		}
	}
	new Ajax.Updater('kiallito_id','/ajax.php', opts);
	return false;
}


function setUserAction(obj) {
    var formname="";
    if (typeof(obj)=="string") {
        formname=obj;
    } else if(obj.id) {
        formname=obj.id;
    } else if(obj.name) {
        formname=obj.name;
    }
    if (!isFormChanged(formname) && isFormChanged()) {
      //ha nem az aktuális változott
      if (confirm("Az adatlap változott. Biztosam tovább akar lépni, mentés nélkül,\nmely kitöltött adatok elvesztéséhez vezethet?")) {
//           getObjfromIdorObj(lastFormChanged()).reset();
           clearFormChanged();
          return true;
      } else {
          return false;
      }
    } else {
      return true;
    }
}




function whatCorrector() {  
	var replaces = 0;  
	var alltags = document.all ? document.all.tags("A") : document.getElementsByTagName("*");  
	for (i=0; i < alltags.length; i++) {  
		if (alltags[i].className == 'whateffect') {  
			while (alltags[i].innerHTML.indexOf('##'+'kukac##') != -1 && replaces < 10000) {  
            	alltags[i].innerHTML = alltags[i].innerHTML.replace('##'+'kukac##', String.fromCharCode(64));  
            	replaces++;  
        	}  
			while (alltags[i].href.indexOf('##'+'kukac##') != -1 && replaces < 10000) {  
            	alltags[i].href = alltags[i].href.replace('##'+'kukac##', String.fromCharCode(64));  
            	replaces++;  
        	}  
    	}  
	}  
}  


function lightwindowHeightCorrector() {
/*	if (typeof myLightWindow=="object") {
		myLightWindow.pageDimensions.height=getMaxHeight();
		myLightWindow._addLightWindowMarkup(true);
	}*/
	var Overlay=getObjfromIdorObj('lightwindow_overlay');
	Overlay.style.height=getMaxHeight()+'px';
	Overlay.height=getMaxHeight()+'px';
}