function iframeReplace()
{
    setTimeout(replaceSelects,100);
}

//if(window.location.href.indexOf("iframe")>-1)
//    iframeReplace(iframeReplace,100);
//else
//    addLoadEvent(replaceSelects);

/**
Parameterkent megkapott ifram-be irja bele a mÃƒÆ’Ã‚Â¡sodik parameterkent megkapott node-tartalmat.
Az IFRAME tartalma tolrodni fog, ÃƒÆ’Ã‚Â©s beincludolja a css-t ÃƒÆ’Ã‚Â©s js fÃƒÆ’Ã‚Â¡jlokat.
@node		-	iframe objetum
@nodesToWrite	-	beirando objektum(ok)	
*/
function WriteToIframe(node, nodesToWrite)
{
	//	mivel az  innerHTML-jet veszi ki a node-nak, ezert bele kell rakni egy tagbe, 
	var tempTag=document.createElement("DIV");
	tempTag.appendChild(nodesToWrite);
	
	var doc=node.contentDocument;
	//	be includolando js ÃƒÆ’Ã‚Â©s css fajlok
	var loc=location+"";
	if(loc.indexOf("portal")>-1)
		loc=loc.split("portal")[0];

	var head="<html><head>";
	head+="<link href=\""+"/sites/bet/css/dropDownMenu.css\" type=\"text/css\" rel=\"stylesheet\">";
	head+="<script type=\"text/javascript\" src=\""+"/sites/bet/js/iframeSelect.js\"></script>";
	head+="</head><body bgcolor=#1c4e80>";
	if(doc==undefined)
		doc=node.contentWindow.document;
		
	doc.open();
	doc.write(head+tempTag.innerHTML+"</body></html>");
	doc.close();
}

/**
#################################	SELECT	#############################

JSSelect osztaly
	Az osszes select tag-et lecsereli UL es LI tag-ekre, az eredeti SELECT-eket eltunteti, de az esemÃƒÆ’Ã‚Â©nyeket meghivja.
	Az UL-ket IFRAME tagekbe helyezi.
Konstruktor
@selectTag		-	A lecserelendo select
@ULclass		-	Ez a class lesz beallitva a letrehozott JSselect-re
@buttonSize	-	A select legordito gombjanak szelessege
*/
function JSselect(selectTag,ULclass,buttonSize,selectID)
{
	this.tag=selectTag;					//	a taget tÃƒÂ¯Ã‚Â¿Ã‚Â½rolja
	this.parentObj=this.tag.parentNode;	//	a szulo elem, ahova beszurjuk a select-et
	this.mainDiv=null;
	if(this.tag.id=="")
		this.tag.id="selectid#"+selectID;				//	ez alapjan talalja meg az IFRAME-be levo JS a selectet
	this.options=this.tag.options;
	this.UL=null;						//	a select-et helyettesito ul-t tÃƒÂ¯Ã‚Â¿Ã‚Â½rolja
	this.ULclass=ULclass;				//	az UL class nevÃƒÂ¯Ã‚Â¿Ã‚Â½t tÃƒÂ¯Ã‚Â¿Ã‚Â½rolja
	this.isOpen=false;					//	nyitva van e a menu
	this.shim;							//	ez tÃƒÂ¯Ã‚Â¿Ã‚Â½rolja majd a lenyilo iFrame-et
	this.LIs=Array;
	this.selectedOpt=0;
	this.selectedText=null;
		//	Abszolut poziciok meghatÃƒÂ¯Ã‚Â¿Ã‚Â½rozÃƒÂ¯Ã‚Â¿Ã‚Â½sa
	this.posX=getAbsoluteLeft(this.tag);
	this.posY=getAbsoluteTop(this.tag);
		
	if(this.tag.offsetWidth!=0)	
		this.width=this.tag.offsetWidth-buttonSize+5;
	else	
		this.width=235;
	this.btnSize=buttonSize;
	
	if(this.parentObj.clientHeight!=0)
		this.height=this.parentObj.clientHeight;
	else
		this.height=200;
	
	this.shimResize=1;

	try{
	    if(this.options.length>0)
	    {
		this.replaceTag();	
	    }
	    else
		selectTag.style.display="none";
	}catch(e){
	    return this;
	}
	return this;
}

/**

*/
JSselect.prototype.setSelected=function(id)
{
	this.options[this.selectedOpt].selected=false;
	this.options[id].selected=true;
	this.setText();
}

/**
A select tag eltuntetese ÃƒÆ’Ã‚Â©s azzal egyenlo meretu IFRAME letrehozasa, amelybe beleirja az UL-LI tageket.
*/
JSselect.prototype.replaceTag=function()
{
	
	//	IFRAME letrehozasa
	this.shim=document.createElement('IFRAME');
	this.shim.style.visibility="hidden";
	this.shim.setAttribute("scrolling","no");
	this.shim.setAttribute("frameBorder","0");
	this.shim.frameBorder =0;
	this.shim.style.backgroundColor="white";//"#5A8AC2";
	this.mainDiv=document.createElement('DIV');
	this.parentObj.appendChild(this.shim);
	this.parentObj.appendChild(this.mainDiv);

	this.UL=document.createElement("UL");
	this.UL.style.border="1px solid #b7d3e3";
	//	Az ul ÃƒÂ¡t lesz tÃƒÂ©ve az IFRAME-be, ez alapjan az ID alapjan, megtalalja a valodi select-et
	this.UL.id=this.tag.id;
	this.shim.id="iframe_"+this.tag.id;

	//  KeresÅ‘ mezÅ‘ hozzÃ¡fÅ±zÃ©se
	this.searchInput=document.createElement("INPUT");
	this.searchInput.setAttribute("id","searchinput");
	this.searchInput.setAttribute("type","text");
	this.searchInput.style.position="absolute";
	this.searchInput.style.width=this.shim.style.width;
	
	//	a kivalasztott option keresÃ¯Â¿Â½se,li-k lÃ¯Â¿Â½trehozÃ¯Â¿Â½sa, Ã¯Â¿Â½s a lÃ¯Â¿Â½thatohoz ahhoz tartozo li lÃ¯Â¿Â½thatovÃ¯Â¿Â½ tÃ¯Â¿Â½tele
	var l=this.options.length;
//	if(this.options[l-1].className.indexOf("defaultOption")>-1) l--;
	for(o=0; o<l; o++)
	{
		li=document.createElement("LI");
		p=document.createElement("P");
		text=document.createTextNode(this.options[o].text);
		if(this.options[o].selected) this.selectedOpt=o;
		p.appendChild(text);
		li.appendChild(p);
		li.style.width=this.width+"px";
		
		li.className="JSelectLI";
		
		this.UL.appendChild(li);
	}
	this.UL.className="JSelectUL";
	
	//	elrejti a select tag-et
	this.tag.style.display="none";

	this.UL.style.width=this.width+"px";	
	
	var par=document.createElement("DIV");
	this.searchInput.style.top=-20+"px";
	par.appendChild(this.searchInput);
	var scroll=document.createElement("DIV");
	scroll.id="scroll";
	scroll.style.position="absolute";
	scroll.style.left=0+"px";
	scroll.style.top=0+"px";
	
	//	A letrehozott elemek hozzafuzese a fo div-hez
	//	KIVALASZTOTT MEGJELENITESE
	
	scroll.appendChild(this.UL);		
	par.appendChild(scroll);
	
	this.shim.style.border="1px solid #1c4e80";
	
	if(this.options.length>10)
		par.appendChild(this.createNavBar());
		
	WriteToIframe(this.shim,par);

	this.createDefaultDiv();
	if(this.options.length>10)
	{
		this.shim.style.height=210+"px";
		var ver=parseFloat(navigator.appVersion);
		
		if((isIE)&&(ver<4))
		    this.shim.style.width=parseInt(this.UL.style.width)+22+"px";
		else
		    this.shim.style.width=parseInt(this.UL.style.width)+22+3+"px";
		//(this.parentObj.offsetWidth==0)?235+"px":this.parentObj.offsetWidth+"px";
	}
	else
	{
		this.shim.style.height=21*(this.options.length+1)+"px";		
		if((isIE)&&(ver<4))
		    this.shim.style.width=parseInt(this.UL.style.width)-2+"px";
		else
		    this.shim.style.width=parseInt(this.UL.style.width)+1+"px";

	}
	
	//	Company profile specko esetek
	var dir=this.tag.getAttribute("seldir");
	if(dir)
	{
	    if(dir.indexOf("comp_prof_sel_down")>-1)
    	    {
		this.mainDiv.className="JSelectDivDown";
	    }
	    else if(dir.indexOf("comp_prof_sel_up")>-1)
	    {
		this.parentObj.style.position="relative";
		this.shim.style.bottom=0+"px";
		this.mainDiv.className="JSelectDivUp";
	    }
	}
	else
	{
	//	Altalanos eset
	    this.mainDiv.className="JSelectDivDown";
    	    var btmPos=getAbsoluteTop(this.parentObj)+210;
	    
	    if(btmPos>getAbsoluteTop(document.getElementById("portalbottom")))
    	    {
	        this.parentObj.style.position="relative";
	        this.shim.style.bottom=0+"px";
	        this.mainDiv.className="JSelectDivUp";
	    }
	}
	if(this.tag.disabled==true)
	{
		this.mainDiv.className="JSelectDiv_disabled";
	}
	this.shim.style.visibility="visible";

}
JSselect.prototype.createNavBar=function()
{
	var bar=document.createElement("DIV");
	var nav=document.createElement("DIV");
	
	bar.appendChild(nav);
	
	bar.style.position="absolute";
	bar.style.zIndex=100;
	bar.style.left=parseInt(this.UL.style.width)+3+"px";
	bar.style.top=0+"px";
	bar.style.width=22+"px";
	bar.style.height=212+"px";
	//bar.style.backgroundImage="url(../../bet/images/jselect_scroll.gif) no-repeat right top)";
	bar.className="JSelectBar";
	bar.id="bar";
	
	nav.style.position="absolute";
//	nav.style.width=16+"px";
	nav.style.height=30+"px";
	nav.style.top=18+"px";
	
	nav.className="JSelectNav";
	nav.id="nav";

	return bar;
}
/**
Alapbol ez a resze lathato a dolognak, erre kattintva jelenik meg az IFRAME
*/
JSselect.prototype.createDefaultDiv=function()
{
	this.mainDiv.style.width=parseInt(this.UL.style.width)+this.btnSize+5+"px";
	
	this.setText();
	
	this.shim.style.position="absolute";
	var t=this;

	this.mainDiv.onclick=function()
	{
		if(t.tag.disabled==false)
		{
			//	a dokumentum onclick esemÃƒÆ’Ã‚Â©nye, mindig meghivodik, ezÃƒÆ’Ã‚Â©rt beÃƒÆ’Ã‚Â¡llitjuk, hogy a kovetkezo hivÃƒÆ’Ã‚Â¡snÃƒÆ’Ã‚Â¡l ÃƒÆ’Ã‚Â¡llitsa ÃƒÆ’Ã‚Â¡t magÃƒÆ’Ã‚Â¡t az eltunteto fuggvÃƒÆ’Ã‚Â©nyre
			document.onclick=function()
			{
				document.onclick=funcCaller(hideAllSelect,null);		
			}
			//	hogy ezt ne csukja be, ha nyitva van, ezt itt, kulon kezeljuk
			var open_bcp=t.isOpen;
			t.isOpen=false;
			hideAllSelect();
			t.isOpen=open_bcp;
			t.ShowHide();
		}
	}
}
/**
	BeÃƒÆ’Ã‚Â¡llitja a defaultText-et, ami latszodik a becsukott selectnel
*/
JSselect.prototype.setText=function()
{
	
	for(o=0; o<this.options.length; o++)
		if(this.options[o].selected) this.selectedOpt=o;
	if(this.selectedText!=null)this.mainDiv.removeChild(this.selectedText);
	this.selectedText=document.createElement("P");
	var text=this.options[this.selectedOpt].text;
	if(text.length>30)
	{
		text=text.substring(0,30);
		var words=text.split(" ");
		text="";
		for(w=0; w<words.length-1; w++)
		{
			text+=" "+words[w];
		}
	}
	
	this.selectedText.innerHTML=text;
	this.mainDiv.appendChild(this.selectedText);
	this.selectedText.className="JSselectedP";
}
/**
	Elrejti, megjeleniti az iframe-et, az isOpen tol fuggoen
*/
JSselect.prototype.ShowHide=function()
{
	if(this.isOpen==true)
	{
		this.setText();
		this.shimResize=(this.shimResize==2)?1:2;
		this.shim.style.height=parseInt(this.shim.style.height)-this.shimResize+"px";
	}
	else
	{
		this.shimResize=(this.shimResize==2)?1:2;
		this.shim.style.height=parseInt(this.shim.style.height)+this.shimResize+"px";
	}
	
	if(this.isOpen)this.shim.style.display="none";
	else
	{
		this.shim.style.display="block";
	}
	
	this.isOpen=!this.isOpen;
}

/**
elrejt egy objektumhoz tartozo iframe-et kesleletetes miatt kell, kulonben a mozilla nem nyitja ki!
*/
function hideSelect(obj)
{
	obj.shim.style.display="none";
	//obj.shim.style.visibility="visible";
	
}
/**
Meghiv egy funkciot, a megkapott parameterekkel, ÃƒÆ’Ã‚Â©s visszaadja egy uj fugvÃƒÆ’Ã‚Â©nykÃƒÆ’Ã‚Â©nt

@TODO@	Atkene tenni a common.js-be
*/
function funcCaller(func,arg)
{
	return function(){func(arg);}
}

/**	MAIN FUGGVÃƒÂ¯Ã‚Â¿Ã‚Â½NY, AMI LÃƒÂ¯Ã‚Â¿Ã‚Â½TREHOZZA A JSselect-ket

Lecsereli a selecteket, JSselect objektumokra
*/

var selects=new Array();
var length;
function replaceSelects()
{
	var tags=document.getElementsByTagName("SELECT");
	selects=new Array();

	for(t=0; t<tags.length; t++)
	{
		if((tags[t].options.length<400)&&(tags[t].parentNode.className.indexOf("SmartSelect")>-1))
		{
		    try{
			selects.push(new JSselect(tags[t],"defaultSelect",22,t));
			length++;
		    }catch(e){}
		}
		else
		{
		    tags[t].parentNode.style.backgroundImage="none";
		}
	}
}
/**
Elrejti az osszes megnyitott selectet
*/
function hideAllSelect()
{
	for(i=0; i<selects.length; i++)
		if(selects[i].isOpen)selects[i].ShowHide();
}


function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function disableSelect(select)
{
	for(s=0; s<selects.length; s++)
	{
		if(selects[s].tag==select)
		{
			selects[s].tag.disabled=(selects[s].tag.disabled==false)?true:false;
			selects[s].mainDiv.className=(selects[s].mainDiv.className=="JSelectDiv_disabled")?"JSelectDivDown":"JSelectDiv_disabled";
			selects[s].setSelected(0);
			break;
		}
	}
}