var combodropimage='images/downbox.gif' //path to "drop down" image
var combodropoffsetY=2 //offset of drop down menu vertically from default location (in px)
var combozindex=100
var timeout_ID_kinyit =new Array();
var timeout_ID_bezar =new Array();

if (combodropimage!="")
combodropimage='<img class="downimage" src="'+combodropimage+'" width="16" height="16" title="Válassz a listából" />'

function dhtmlselect(selectid, formname){
	var selectbox=document.getElementById(selectid)

	if (!document.getElementById("dhtml_"+selectid))
	{
		document.write('<div id="dhtml_'+selectid+'" class="dhtmlselect"><div id="dhtml_1_'+selectid+'"><span class="dhtmlselect_1" id="'+selectid +'_i">' + selectbox.title + '</span> '+combodropimage+'</div><div class="dropdown" id="dhtml_2_'+selectid+'"></div></div>');
		var dhtmlselectbox=document.getElementById("dhtml_"+selectid)
		var selbox_1=document.getElementById("dhtml_1_"+selectid)
		var selbox_2=document.getElementById("dhtml_2_"+selectid)
		dhtmlselectbox.style.zIndex=combozindex
		combozindex--

	}
	else
	{
		var dhtmlselectbox=document.getElementById("dhtml_"+selectid)
		var selbox_1=document.getElementById("dhtml_1_"+selectid)
		var selbox_2=document.getElementById("dhtml_2_"+selectid)

	}

	document.getElementById('dhtml_2_'+selectid).innerHTML="";
	s="";
	//	document.getElementById("dhtml_"+selectid).innerHTML='<div id="dhtml_1_'+selectid+'"><span class="dhtmlselect_1" id="'+selectid +'_i">' + selectbox.title + '</span> '+combodropimage+'</div><div class="dropdown" id="dhtml_2_'+selectid+'">';
	if (document.getElementById(selectid).onchange)
	{
		for (var i=0; i<selectbox.options.length; i++)
		s=s+'<a href="javascript: document.getElementById(\'' + selectid + '_i\').innerHTML=\''+ selectbox.options[i].text +'\'; document.'+formname+'.' + selectid + '.value=\''+ selectbox.options[i].value +'\';  if (document.'+formname+'.' + selectid + '.onchange) document.'+formname+'.' + selectid + '.onchange();">' + selectbox.options[i].text + '</a>';

	}
	else
	{
		for (var i=0; i<selectbox.options.length; i++)
		s=s+'<a href="javascript:; " onClick="document.getElementById(\'' + selectid + '_i\').innerHTML=\''+ selectbox.options[i].text +'\'; document.'+formname+'.' + selectid + '.value=\''+ selectbox.options[i].value +'\'; ">' + selectbox.options[i].text + '</a>';
	}

	//		document.getElementById('dhtml_2_'+selectid).innerHTML=document.getElementById('dhtml_2_'+selectid).innerHTML+'<a href="javascript:;" onclick="document.getElementById(\'' + selectid + '_i\').innerHTML=\''+ selectbox.options[i].text +'\'; document.'+formname+'.' + selectid + '.value=\''+ selectbox.options[i].value +'\'">' + selectbox.options[i].text + '</a>';

	document.getElementById('dhtml_2_'+selectid).innerHTML=s;
	//document.getElementById("dhtml_"+selectid).innerHTML=document.getElementById("dhtml_"+selectid).innerHTML+'</div></div>';

	//alert(document.getElementById("dhtml_"+selectid).innerHTML);
	selectbox.style.display="none"


	dhtmlselectbox.getElementsByTagName("div")[0].style.top=dhtmlselectbox.offsetHeight-combodropoffsetY+"px"
	if (combodropimage!="")
	dhtmlselectbox.getElementsByTagName("img")[0].style.left=dhtmlselectbox.offsetWidth+3+"px"
	selbox_1.onclick=function(){
		selbox_2.style.display="block"
		timeout_ID_bezar[selbox_2.id] =setTimeout("bezar('"+selbox_2.id+"')", 2000);
	}
	dhtmlselectbox.onmouseout=function(){
		//		setTimeout("", 1000);
		//		selbox_2.style.display="none"
	}
	timeout_ID_bezar[this.id]=null;
	timeout_ID_kinyit[this.id]=null;


	selbox_2.onmouseout=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}

		timeout_ID_bezar[this.id] =setTimeout("bezar('"+this.id+"')", 1000);
	}
	selbox_2.onmouseover=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}
		timeout_ID_kinyit[this.id]=setTimeout("kinyit('"+this.id+"')", 1000);


	}

	selbox_2.onclick=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}

		bezar(this.id);

	}
	var selected;
	selected = -1;
	selected=document.getElementById(selectid).selectedIndex;

	if (selected>=0)
	{
		document.getElementById(selectid +'_i').innerHTML=document.getElementById(selectid).options[selected].text;
		document.getElementById(selectid).selectedIndex= selected;
	}


}

function dhtmlselect2(selectid, formname, selectwidth, optionwidth){
	var selectbox=document.getElementById(selectid)
	document.write('<div id="dhtml_'+selectid+'" class="dhtmlselect"><div id="dhtml_1_'+selectid+'"><span class="dhtmlselect_1" id="'+selectid +'_i">' + selectbox.title + '</span> '+combodropimage+'</div><div class="dropdown" id="dhtml_2_'+selectid+'">')
	for (var i=0; i<selectbox.options.length; i++)
	document.write('<a href="javascript:;" onclick="document.getElementById(\'' + selectid + '_i\').innerHTML=\''+ selectbox.options[i].text +'\'; document.'+formname+'.' + selectid + '.value=\''+ selectbox.options[i].value +'\'; onOrszagChange();">' + selectbox.options[i].text + '</a>')
	document.write('</div></div>')
	selectbox.style.display="none"
	var dhtmlselectbox=document.getElementById("dhtml_"+selectid)
	var selbox_1=document.getElementById("dhtml_1_"+selectid)
	var selbox_2=document.getElementById("dhtml_2_"+selectid)
	dhtmlselectbox.style.zIndex=combozindex
	combozindex--
	if (typeof selectwidth!="undefined")
	dhtmlselectbox.style.width=selectwidth
	if (typeof optionwidth!="undefined")
	dhtmlselectbox.getElementsByTagName("div")[0].style.width=optionwidth
	dhtmlselectbox.getElementsByTagName("div")[0].style.top=dhtmlselectbox.offsetHeight-combodropoffsetY+"px"
	if (combodropimage!="")
	dhtmlselectbox.getElementsByTagName("img")[0].style.left=dhtmlselectbox.offsetWidth+3+"px"
	selbox_1.onclick=function(){
		selbox_2.style.display="block"
		timeout_ID_bezar[selbox_2.id] =setTimeout("bezar('"+selbox_2.id+"')", 2000);
	}

	timeout_ID_bezar[this.id]=null;
	timeout_ID_kinyit[this.id]=null;


	selbox_2.onmouseout=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}

		timeout_ID_bezar[this.id] =setTimeout("bezar('"+this.id+"')", 1000);
	}
	selbox_2.onmouseover=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}
		timeout_ID_kinyit[this.id]=setTimeout("kinyit('"+this.id+"')", 1000);


	}

	selbox_2.onclick=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}

		bezar(this.id);

	}
}

function dhtmlselect3(selectid, formname, selectwidth, optionwidth){
	var selectbox=document.getElementById(selectid)
	var htmlOutput;
	htmlOutput = '<div id="dhtml_'+selectid+'" class="dhtmlselect"><div id="dhtml_1_'+selectid+'"><span class="dhtmlselect_1" id="'+selectid +'_i">' + selectbox.title + '</span> '+combodropimage+'</div><div class="dropdown" id="dhtml_2_'+selectid+'">';
	for (var i=0; i<selectbox.options.length; i++)
	htmlOutput = htmlOutput + '<a href="javascript:;" onclick="document.getElementById(\'' + selectid + '_i\').innerHTML=\''+ selectbox.options[i].text +'\'; document.'+formname+'.' + selectid + '.value=\''+ selectbox.options[i].value +'\'">' + selectbox.options[i].text + '</a>';
	htmlOutput = htmlOutput + '</div></div>';
	document.getElementById("mySelect-" + selectid).innerHTML = htmlOutput;
	selectbox.style.display="none"
	var dhtmlselectbox=document.getElementById("dhtml_"+selectid)
	var selbox_1=document.getElementById("dhtml_1_"+selectid)
	var selbox_2=document.getElementById("dhtml_2_"+selectid)
	dhtmlselectbox.style.zIndex=combozindex
	combozindex--
	if (typeof selectwidth!="undefined")
	dhtmlselectbox.style.width=selectwidth
	if (typeof optionwidth!="undefined")
	dhtmlselectbox.getElementsByTagName("div")[0].style.width=optionwidth
	dhtmlselectbox.getElementsByTagName("div")[0].style.top=dhtmlselectbox.offsetHeight-combodropoffsetY+"px"
	if (combodropimage!="")
	dhtmlselectbox.getElementsByTagName("img")[0].style.left=dhtmlselectbox.offsetWidth+3+"px"
	selbox_1.onclick=function(){
		selbox_2.style.display="block"
		timeout_ID_bezar[selbox_2.id] =setTimeout("bezar('"+selbox_2.id+"')", 2000);
	}


	timeout_ID_bezar[this.id]=null;
	timeout_ID_kinyit[this.id]=null;


	selbox_2.onmouseout=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}

		timeout_ID_bezar[this.id] =setTimeout("bezar('"+this.id+"')", 1000);
	}
	selbox_2.onmouseover=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}
		timeout_ID_kinyit[this.id]=setTimeout("kinyit('"+this.id+"')", 1000);


	}

	selbox_2.onclick=function(){
		if (timeout_ID_bezar[this.id])
		{
			window.clearTimeout(timeout_ID_bezar[this.id]);
		}
		if (timeout_ID_kinyit[this.id])
		{
			window.clearTimeout(timeout_ID_kinyit[this.id]);
		}

		bezar(this.id);

	}
}

function aa(selectid) {
	document.getElementById("dhtml_2_"+selectid)
}


function kinyit(id)
{
	for (key in timeout_ID_bezar)
	{
		if (key!=id)
		{
			document.getElementById(key).style.display="none";
		}

	}
	document.getElementById(id).style.display="block";

}
function bezar(id)
{
	document.getElementById(id).style.display="none";

}

