function OpenDialogWindow(dialog_url,dialog_name,w,h)
{
var win = null;
leftPosition = (screen.width) ? (screen.width-w)/2 : 0;
topPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+topPosition+',left='+leftPosition+'menubar=no,scrollbars=no,status=no'
win = window.open(dialog_url,dialog_name,settings)
if(win.window.focus){win.window.focus();}
}

function Confirm_Torles(kerdes, url)
{
  if (confirm(kerdes))
  {
    window.location.href=url;
  }
}

function SetHomePage(id, url, szoveg)
{
  if (window.external)
  {
    document.getElementById(id).style.behavior='url(#default#homepage)';
    document.getElementById(id).setHomePage(url);
  }
  else
  {
    alert(szoveg);
  }
}

function AddToFavorites(url, cim)
{
  if (window.external)
  {
    window.external.AddFavorite(url,cim);
  }
  else
  {
    window.sidebar.addPanel(cim, url, '');
  }
}

function Hir_Form_Add_File(id, fajl, nev, edit_url)
{
  table = document.getElementById('hir_form_hir_fajlok');
  var row = document.createElement("TR");
  row.setAttribute("id", "filerow_"+id);

  var td1 = document.createElement("TD");

  var a1 = document.createElement("A");
  a1.setAttribute("href", "../uploaded_files/hirek/"+fajl);
  a1.setAttribute("target", "_blank");
  a1.innerHTML = nev;

  td1.appendChild(a1);
  td1.appendChild(document.createTextNode(" ["));

  var a2 = document.createElement("A");
  a2.setAttribute("href", "#");
  a2.onclick=function()
	{
		if (confirm('Biztosan törli?'))
		{
			OpenDialogWindow('hir_fajlok.php?id='+id+'&del','wndDelFile',300,150);
		}
	}
  a2.innerHTML = "töröl";

  td1.appendChild(a2);
  td1.appendChild(document.createTextNode("]"));

  td1.appendChild(document.createTextNode(" ["));

  var a2 = document.createElement("A");
  a2.setAttribute("href", edit_url+"&upfile&hif_id="+id);
  a2.innerHTML = "feljebb";

  td1.appendChild(a2);
  td1.appendChild(document.createTextNode("]"));

  td1.appendChild(document.createTextNode(" ["));

  var a2 = document.createElement("A");
  a2.setAttribute("href", edit_url+"&downfile&hif_id="+id);
  a2.innerHTML = "lejjebb";

  td1.appendChild(a2);
  td1.appendChild(document.createTextNode("]"));


  row.appendChild(td1);

  table.appendChild(row);
}

function Hir_Form_Del_File(id)
{
  table = document.getElementById('hir_form_hir_fajlok');
  row = document.getElementById('filerow_'+id);
  table.removeChild(row);
}

function Hir_Form_Add_Kep(nev)
{
  image = document.getElementById('hir_form_hir_kep_img');
  image.setAttribute("src", nev);
  image_p = document.getElementById('hir_form_hir_kep_p');
  image_p.style.display = "";

  image_del = document.getElementById('hir_form_hir_kep_del');
  image_del.setAttribute("src", "../img/icon/del_pic.gif");
  image_del.style.cursor = "pointer";
  image_del.onclick=function() { OpenDialogWindow('hir_kep.php?file='+nev+'&del','wndAddKep','300','150'); }

  hir_kep = document.getElementById('hir_kep');
  hir_kep.setAttribute("value", nev);
}

function Hir_Form_Del_Kep()
{
  image = document.getElementById('hir_form_hir_kep_img');
  image.setAttribute("src", "");
  image_p = document.getElementById('hir_form_hir_kep_p');
  image_p.style.display = "none";

  image_del = document.getElementById('hir_form_hir_kep_del');
  image_del.setAttribute("src", "../img/icon/del_pic_d.gif");
  image_del.style.cursor = "default";
  image_del.onclick = function() {}

  hir_kep = document.getElementById('hir_kep');
  hir_kep.setAttribute("value", "");
}


function Required_Check(params)
{
  var ok = true;
  var n=0;

  while ((n < params.length) && (ok))
  {
    if (document.getElementById(params[n]['id']).value == '')
    {
      ok = false;
      alert("'"+params[n]['name']+"' nincs megadva!");
    }
    n++;
  }

  return ok;
}

function showLoadingPage()
{
  if (document.getElementById)
  {  // DOM3 = IE5, NS6
    document.getElementById('hidepage').style.display = '';
    document.getElementById('content').style.display = 'none';
  } else
  {
    if (document.layers)
    {  // Netscape 4
      document.hidepage.display = '';
      document.content.display = 'none';
    } else
    {  // IE 4
      document.all.hidepage.style.display = '';
      document.all.content.style.display = 'none';
    }
  }
}

function showContentPage()
{
  if (document.getElementById)
  {  // DOM3 = IE5, NS6
    document.getElementById('hidepage').style.display = 'none';
    document.getElementById('content').style.display = '';
  } else
  {
    if (document.layers)
    {  // Netscape 4
      document.hidepage.display = 'none';
      document.content.display = '';
    } else
    {  // IE 4
      document.all.hidepage.style.display = 'none';
      document.all.content.style.display = '';
    }
  }
}

function setDays(fromYearId, fromMonthId, toDayId) {

  var y = document.getElementById(fromYearId).options[document.getElementById(fromYearId).selectedIndex].value;
  var m = document.getElementById(fromMonthId).selectedIndex;
  var d;
  
  var docdays = document.getElementById(toDayId);

  // find number of days in current month
  if ( (m == 3) || (m == 5) || (m == 8) || (m == 10) ) {
    days = 30;
  }
  else if (m == 1) {
    // check for leapyear - Any year divisible by 4, except those divisible by 100 (but NOT 400)
    if ( (Math.floor(y/4) == (y/4)) && ((Math.floor(y/100) != (y/100)) || (Math.floor(y/400) == (y/400))) )
      days = 29
    else
      days = 28
  }
  else {
    days = 31;
  }


  // if (days in new month > current days) then we must add the extra days
  if (days > docdays.length) {
    for (i = docdays.length; i < days; i++) {
      docdays.length = days;
      docdays.options[i].text = i + 1;
      docdays.options[i].value = i + 1;
    }
  }


  // if (days in new month < current days) then we must delete the extra days
  if (days < docdays.length) {
    docdays.length = days;
    if (docdays.selectedIndex == -1)
      docdays.selectedIndex = days - 1;
  }

}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

