
var window2

function fixwidthandheight()
{
	nWidth = document.getElementById("i").width+25;
	nHeight = document.getElementById("i").height+90;
	if (screen.availWidth-10 < nWidth) {nWidth = screen.availWidth-10; sScroll = "yes";}
	if (screen.availHeight-10 < nHeight) {nHeight = screen.availHeight-10; sScroll = "yes"; }

	window.resizeTo(nWidth,nHeight);
	nLeft = (screen.availWidth - nWidth) / 2;
	nTop = (screen.availHeight - nHeight) / 2;
	window.moveTo(nLeft, nTop);
}

function fixwidth()
{
	nWidth = 536;
	nHeight = document.body.scrollHeight+20;
	if (screen.availWidth-10 < nWidth) {nWidth = screen.availWidth-10; sScroll = "yes";}
	if (screen.availHeight-10 < nHeight) {nHeight = screen.availHeight-10; sScroll = "yes"; }

	window.resizeTo(nWidth,nHeight);
	nLeft = (screen.availWidth - nWidth) / 2;
	nTop = (screen.availHeight - nHeight) / 2;
	window.moveTo(nLeft, nTop);
}

function onOpenFreetext(base, inbase, nWidth, nHeight, whiteyellow)
{
	var nWidth;
	var nHeight;
	var sScroll;

	nWidth = 536;
	nHeight = 218;
	
	if (screen.availWidth-10 < nWidth) {nWidth = screen.availWidth-10; sScroll = "yes";}
	if (screen.availHeight-10 < nHeight) {nHeight = screen.availHeight-10; sScroll = "yes"; }

	nLeft = (screen.availWidth - nWidth) / 2;
	nTop = (screen.availHeight - nHeight) / 2;

	// Kill old window if it's still opened - no need
	
//	if (typeof(window2)!="undefined") window2.close();
	
	sFilePath="mtt.exe?FILE=freetext.htm&Base="+base+"&Inbase="+inbase+"&wy="+whiteyellow;
	
	// Open new one
	window2=window.open(sFilePath, 
		"mainscreen",
		"location=no,scrollbars=no,status=no,menubar=no,toolbar=no,resizable=yes,width="+nWidth+",height="+nHeight+",left="+nLeft+",top="+nTop);
	
	// Put focus to the window
	window2.focus();
}
function onOpenAD(sFilePath)
{

	// Open new one
	nWidth=10;
	nHeight=10;
	nLeft = (screen.availWidth - nWidth) / 2;
	nTop = (screen.availHeight - nHeight) / 2;

	window2=window.open(sFilePath, 
		"mainscreen",
		'location=no,scrollbars=no,status=yes,menubar=no,toolbar=no,resizable=no,width='+nWidth+',height='+nHeight+',left='+nLeft+',top='+nTop);
	
	// Put focus to the window
	window2.focus();
}

function onOpenADS(sFilePath, nWidth, nHeight)
{
	var nWidth;
	var nHeight;
	var sScroll;

	if (nWidth == 0 || nHeight == 0)
	{
		// Èe se narobe izraèuna...
		nWidth = 300;
		nHeight = 200;
		sScroll = "yes";
	} else {
		nWidth = nWidth + 25;
		nHeight = nHeight + 30;
		sScroll = "no";
	}
	
	if (screen.availWidth-10 < nWidth) {nWidth = screen.availWidth-10; sScroll = "yes";}
	if (screen.availHeight-10 < nHeight) {nHeight = screen.availHeight-10; sScroll = "yes"; }

	nLeft = (screen.availWidth - nWidth) / 2;
	nTop = (screen.availHeight - nHeight) / 2;

	// Kill old window if it's still opened - no need
	
//	if (typeof(window2)!="undefined") window2.close();
	
	// Open new one
	window2=window.open(sFilePath, 
		"mainscreen",
		"location=no,scrollbars="+sScroll+",status=yes,menubar=no,toolbar=no,resizable=no,width="+nWidth+",height="+nHeight+",left="+nLeft+",top="+nTop);
	
	// Put focus to the window
	window2.focus();
}

function onTest(nIndex)
{
	var objDIV = document.getElementById("DIV" + nIndex);
	var objIFRAME = document.getElementById("IFRAME1");
	objIFRAME.location = "Loaded.htm";	
}

function onOpenSubRecord(nIndex, base, inbase)
{
	var sDIV = "DIV" + nIndex;
	var sIMG = "IMG" + nIndex;
	objDIV=document.getElementById(sDIV);
	objIMG=document.getElementById(sIMG);
	objTEMPDIV=document.getElementById("TEMPDIV");
	objTEMPDIV.value = objDIV.id;
//	alert ("["+objDIV.innerHTML+"]");
//	alert ("["+objDIV.innerHTML.substring(3,19)+"]");
	var comp=objDIV.innerHTML.search("<!--expand me-->")!=-1;
//	var comp=objDIV.innerHTML.substring(3,19)=="<!--expand me-->"||objDIV.innerHTML.substring(0,16)=="<!--expand me-->";
//	alert(comp);
	if (objDIV.style.display == "none"||comp)
	{	
		// Open the DIV block and download if it's necessary!

//		alert(objDIV.innerHTML);
		if (objDIV.innerHTML.length <= 1||comp)
		{
			if (document.getElementById) //netscape 6
			{
				y = document.getElementById("temp");
//				alert (y);
				y.src="mtt.exe?FILE=Sub.htm&Base="+base+"&Inbase="+inbase;				
			}
			else if (document.all) //ie
			{
				y = document.all["temp"];
//				alert(y);
				y.src="mtt.exe?FILE=Sub.htm&Base="+base+"&Inbase="+inbase;
			}

		}
		objDIV.style.display = "block";
		objIMG.src = "bitmaps/minus.gif";
	} else {
		objDIV.style.display = "none";
		objIMG.src = "bitmaps/plus.gif";
	}
}

function onOpenFolder(nIndex, nBrIndex, sBannerImg, sBannerURL, nLevel)
{
	var objDIV = document.getElementById("DIV" + nIndex);
	var objIMG = document.getElementById("IMG" + nIndex);
	var objTMP = document.getElementById("TEMPDIV");
	var objBannerImg = document.getElementById("banner_img");
	var objBannerURL = document.getElementById("banner_URL");
	var t=document.getElementById("temp");

//	window.open("SubBrowsing.asp?PARENTID="+nBrIndex+"&ANCESTORS="+nIndex);

	if (objDIV.style.display=="none")
	{	
		// Open the DIV block and download if it's necessary!
		if (objDIV.innerHTML.length <= 1)
		{
			objTMP.value = objDIV.id;
			t.src="SubBrowsing.asp?PARENTID="+nBrIndex+"&ANCESTORS="+nIndex+"&level="+nLevel;
		}
		objDIV.style.display = "block";
		objIMG.src = "bitmaps/minus.gif";
	} 
	else 
	{
		objDIV.style.display = "none";
		objIMG.src = "bitmaps/plus.gif";
	}

	if (objBannerImg)
	if (sBannerURL!="")
	{
		objBannerImg.src=sBannerImg;
		objBannerURL.href=sBannerURL;
	}
}

function IFrameToDiv(){
	topdoc=window.parent.document;
	if (topdoc.getElementById)
	{
		bu = topdoc.getElementById("TEMPDIV");
		y=topdoc.getElementById(bu.value);
		y.innerHTML=document.body.innerHTML;
	}
	else if (topdoc.all)
	{
//			y = topdoc.all["TEMPDIV"];						
		y=topdoc.all[topdoc.TEMPDIV.value];
		y.innerHTML=document.body.innerHTML;
	}
}

function onSendActivity(sActivity,sActivityIndex)
{
	if(opener)
	{	
		if (opener.document.Searchform.Activity)	
			var s = opener.document.Searchform.Activity.value;
		else
			var s = opener.document.Searchform.General.value;
		var si = opener.document.Searchform.AI.value;
		if (s == "")
		{
			s = sActivity
			si = sActivityIndex
		} else {
			if (s.indexOf(sActivity) == -1)
				s = s + ", " + sActivity;
				si = si +", " + sActivityIndex;
		}
		if (opener.document.Searchform.Activity)
			opener.document.Searchform.Activity.value=s;
		else
			opener.document.Searchform.General.value=s;
		opener.document.Searchform.ActOld.value=s;
		opener.document.Searchform.AI.value=si;
		if (opener.frames.topactivities)
			opener.frames.topactivities.document.location="topactivities.asp?act="+sActivity+"&actid="+sActivityIndex;
		window.close();
	} else
	{
		sActivity=sActivity.replace(/Á/g,"%C1");
		sActivity=sActivity.replace(/É/g,"%C9");
		sActivity=sActivity.replace(/Í/g,"%CD");
		sActivity=sActivity.replace(/Ó/g,"%D3");
		sActivity=sActivity.replace(/Ö/g,"%D6");
		sActivity=sActivity.replace(/Ú/g,"%DA");
		sActivity=sActivity.replace(/Ü/g,"%DC");
		sActivity=sActivity.replace(/á/g,"%E1");
		sActivity=sActivity.replace(/é/g,"%E9");
		sActivity=sActivity.replace(/í/g,"%ED");
		sActivity=sActivity.replace(/ó/g,"%F3");
		sActivity=sActivity.replace(/ö/g,"%F6");
		sActivity=sActivity.replace(/ú/g,"%FA");
		sActivity=sActivity.replace(/ü/g,"%FC");
		window.location = "mtt.exe?FILE=Advanced.htm&Search=NO&AI=" + sActivityIndex + "&Activity=" + sActivity;
	}
}

function onSendActivityFromTopActivities(sActivity,sActivityIndex)
{
	if (parent.document.Searchform.Activity)	
		var s = parent.document.Searchform.Activity.value;
	else
		var s = parent.document.Searchform.General.value;
	var si = parent.document.Searchform.AI.value;
	s = sActivity
	si = sActivityIndex
	if (parent.document.Searchform.Activity)
		parent.document.Searchform.Activity.value=s;
	else
		parent.document.Searchform.General.value=s;
	parent.document.Searchform.ActOld.value=s;
	parent.document.Searchform.AI.value=si;

	document.location="topactivities.asp?act="+sActivity+"&actid="+sActivityIndex;
}

function onSendMultipleActivities(sActivity,sActivityIndex,sActivities)
{
//	alert("mtt.exe?FILE=Advanced.htm&Alist="+sActivities);
	if(opener)
	{
		if (opener.document.Searchform.Activity)	
			var s = opener.document.Searchform.Activity.value;
		else
			var s = opener.document.Searchform.General.value;
		var sh = opener.document.Searchform.ActivityList.value;
		var si = opener.document.Searchform.AI.value;
		if (s == "") 
		{
			s = sActivity
			sh = sActivities
			si = sActivityIndex
		} else {
			if (s.indexOf(sActivity) == -1)
				s = s + ", " + sActivity;
				sh = sh +", " + sActivities;
				si = si +", " + sActivityIndex;
		}
		if (opener.document.Searchform.Activity)
			opener.document.Searchform.Activity.value=s;
		else
			opener.document.Searchform.General.value=s;
		opener.document.Searchform.ActOld.value=s;
		opener.document.Searchform.AI.value=si;
		opener.document.Searchform.ActivityList.value=sh;
		window.close();
	} else
	{
		sActivity=sActivity.replace(/Á/g,"%C1");
		sActivity=sActivity.replace(/É/g,"%C9");
		sActivity=sActivity.replace(/Í/g,"%CD");
		sActivity=sActivity.replace(/Ó/g,"%D3");
		sActivity=sActivity.replace(/Ö/g,"%D6");
		sActivity=sActivity.replace(/Ú/g,"%DA");
		sActivity=sActivity.replace(/Ü/g,"%DC");
		sActivity=sActivity.replace(/á/g,"%E1");
		sActivity=sActivity.replace(/é/g,"%E9");
		sActivity=sActivity.replace(/í/g,"%ED");
		sActivity=sActivity.replace(/ó/g,"%F3");
		sActivity=sActivity.replace(/ö/g,"%F6");
		sActivity=sActivity.replace(/ú/g,"%FA");
		sActivity=sActivity.replace(/ü/g,"%FC");
		window.location = "mtt.exe?FILE=Advanced.htm&Search=NO&AI=" + sActivityIndex + "&Activity=" + sActivity+ "&actOld=" + sActivity + "&ActivityList=" + sActivities;
	}
}

function onSendCity(sCity)
{
	if(opener){
		var s = opener.document.Searchform.City.value;
		if (s == "") 
		{
			s = sCity
		} else {
			if (s.indexOf(sCity) == -1)
				s = s + ", " + sCity;
		}
		opener.document.Searchform.City.value=s;
		window.close();
	} else
	{
		sCity=sCity.replace(/Á/g,"%C1");
		sCity=sCity.replace(/É/g,"%C9");
		sCity=sCity.replace(/Í/g,"%CD");
		sCity=sCity.replace(/Ó/g,"%D3");
		sCity=sCity.replace(/Ö/g,"%D6");
		sCity=sCity.replace(/Ú/g,"%DA");
		sCity=sCity.replace(/Ü/g,"%DC");
		sCity=sCity.replace(/á/g,"%E1");
		sCity=sCity.replace(/é/g,"%E9");
		sCity=sCity.replace(/í/g,"%ED");
		sCity=sCity.replace(/ó/g,"%F3");
		sCity=sCity.replace(/ö/g,"%F6");
		sCity=sCity.replace(/ú/g,"%FA");
		sCity=sCity.replace(/ü/g,"%FC");
		window.location = "mtt.exe?FILE=Advanced.htm&Search=NO&City=" + sCity;
	}
}

function onSendKomitat(sCounty)
{
	if(opener){
		var s = opener.document.Searchform.County.value;
		if (s == "") 
		{
			s = sCounty
		} else {
			if (s.indexOf(sCounty) == -1)
				s = s + ", " + sCounty;
		}
		opener.document.Searchform.County.value=s;
		window.close();
	} else
	{
		sCounty=sCounty.replace(/Á/g,"%C1");
		sCounty=sCounty.replace(/É/g,"%C9");
		sCounty=sCounty.replace(/Í/g,"%CD");
		sCounty=sCounty.replace(/Ó/g,"%D3");
		sCounty=sCounty.replace(/Ö/g,"%D6");
		sCounty=sCounty.replace(/Ú/g,"%DA");
		sCounty=sCounty.replace(/Ü/g,"%DC");
		sCounty=sCounty.replace(/á/g,"%E1");
		sCounty=sCounty.replace(/é/g,"%E9");
		sCounty=sCounty.replace(/í/g,"%ED");
		sCounty=sCounty.replace(/ó/g,"%F3");
		sCounty=sCounty.replace(/ö/g,"%F6");
		sCounty=sCounty.replace(/ú/g,"%FA");
		sCounty=sCounty.replace(/ü/g,"%FC");
		window.location = "mtt.exe?FILE=Advanced.htm&Search=NO&County=" + sCounty;
	}
}

function openDialog(url)
{
	window.open(url, "_blank", "width=825,height=625,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes")
}

function CheckIfActivityDeleted()
{
	if (document.searchform.activity=="")
	{
		document.searchform.activityOld="";
		document.searchform.activityList="";
		document.searchform.AI="";
	}
}
function ResetUpperForm()
{
	if (document.Searchform.ActivityList)
		document.Searchform.ActivityList.value="";
	if (document.Searchform.Activity)
		document.Searchform.Activity.value="";
	if (document.Searchform.AI)
		document.Searchform.AI.value="";
	if (document.Searchform.ActOld)
		document.Searchform.ActOld.value="";
	if (document.Searchform.General)
		document.Searchform.General.value="";
}
function ResetLowerForm()
{
	if (document.Searchform.Name)
		document.Searchform.Name.value="";
	if (document.Searchform.County)
		document.Searchform.County.value="";
	if (document.Searchform.City)
		document.Searchform.City.value="";
	if (document.Searchform.Street)
		document.Searchform.Street.value="";
	if (document.Searchform.HN)
		document.Searchform.HN.value="";
	if (document.Searchform.Post)
		document.Searchform.Post.value="";
	if (document.Searchform.PhoneO)
		document.Searchform.PhoneO.value="";
	if (document.Searchform.Phone)
		document.Searchform.Phone.value="";
	if (document.Searchform.Net)
		document.Searchform.Net.value="";
	if (document.Searchform.Mail)
		document.Searchform.Mail.value="";
	if (document.Searchform.FirstName)
		document.Searchform.FirstName.value="";
	if (document.Searchform.Profession)
		document.Searchform.Profession.value="";	
	if (document.Searchform.District)
	document.Searchform.District.disabled=true;	
}
function ResetSimpleForm()
{
	if (document.Searchform.ActivityList)
		document.Searchform.ActivityList.value="";
	if (document.Searchform.AI)
		document.Searchform.AI.value="";
	if (document.Searchform.ActOld)
		document.Searchform.ActOld.value="";
	if (document.Searchform.General)
		document.Searchform.General.value="";
	if (document.Searchform.Activity)
		document.Searchform.Activity.value="";
	if (document.Searchform.City)
		document.Searchform.City.value="";
	if (document.Searchform.Place)
		document.Searchform.Place.value="";
}
function checkCity()
{	
	if (document.Searchform.City.value.toLowerCase()=="budapest")
	{
		document.Searchform.District.selectedIndex=0;
		document.Searchform.District.disabled=false;
	}
	else
		document.Searchform.District.disabled=true;
}