var same =  Math.floor(Math.random()*1000000);
    
var size = 0;

function AdLoaded(zonaId) {
	//alert(zonaId);
	$("#"+zonaId ).prepend("<sub>hirdetés</sub>");
}

function setCookie(name, value, path, expire) {
  document.cookie = name + "=" + escape(value) +
  ( ( path ) ? ";path=" + path : "")
  + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));
}
	
function AddCookie(strName, strValue)
{	
	strCookieSettings = strName + "=" + strValue + ";path=/";
	
	document.cookie = strCookieSettings;
}	
	
function DeleteCookie(strName)
{	
	AddCookie(strName, "not_set");
}	
	
// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) 
{	
    if ( Get_Cookie( name ) ) 
    {	
	document.cookie = name + "=" +
    	    ( ( path ) ? ";path=" + path : "") +
	    ( ( domain ) ? ";domain=" + domain : "" ) +
	    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
    }	
}	
    
// this function gets the cookie, if it exists
function GetCookie( name ) 
{	
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    
    if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )
    {
	return null;
    }
    
    if ( start == -1 ) return null;
    
    var end = document.cookie.indexOf( ";", len );
    
    if ( end == -1 ) end = document.cookie.length;
    
    return unescape( document.cookie.substring( len, end ) );
}	
    
function changeFul(strFulId) {
	
	var objFuls = document.getElementsByName("ful");
	for ( var i = 0; i < objFuls.length; i++) {
		if ( objFuls[i].className == 'aktiv' ) {
			if ( objFuls[i].id != strFulId ) {
				objFuls[i].className = '';
				document.getElementById(strFulId).className = 'aktiv';
				
				var oldContentId= objFuls[i].id + 'content';
				var newContentId= strFulId + 'content';
				
				document.getElementById(oldContentId).style.display  = 'none';
				document.getElementById(newContentId).style.display  = 'block';
			}
		}
	}
}

function toggle (id) { 
	if (document.getElementById(id).className == "none") {
		 document.getElementById(id).className = "aktiv";
		 document.getElementById(id + '_menu').className = "none";
	} else {
		document.getElementById(id).className = "none";
		document.getElementById(id + '_menu').className = "hide";
	}

	if (document.getElementById('belep').className == "aktiv" && document.getElementById('keres').className == "aktiv") {
		document.getElementById('belep').className = "none";
		document.getElementById('belep_menu').className = "hide";
		document.getElementById('keres').className = "none";
		document.getElementById('keres_menu').className = "hide";
		toggle (id);
	}
}

function incsize() {
var cikk = document.getElementById("lead");
//alert(cikk.className);
if ( cikk.className == "" ) {
	cikk.className = "nagybetu"
} else if ( cikk.className == "kisbetu" ) {
	cikk.className = ""
}
}

function decsize() {
var cikk = document.getElementById("lead");
//alert(cikk.className);
if ( cikk.className == "" ) {
	cikk.className = "kisbetu"
} else if ( cikk.className == "nagybetu" ) {
	cikk.className = ""
}
}

function NewsPager(intPage) {
    var strURL = new String(window.location);
    var arrURL = strURL.split('/');
    var newURL = '';
    for ( var i = 0; i < arrURL.length; i++) {
	curPage = parseInt(arrURL[i]);
	if ( curPage != NaN && curPage > 0 && curPage < 100 ) {
	    newURL += (intPage + '/');
	} else {
    	    newURL += (arrURL[i] + '/');
        }
    }
    document.location = newURL.substr(0,newURL.length-1);
}

function LocateChildren(objParent, strNodeName, strName, arrFound)
{	
	var objFound = null;
	var objCurrent = null;
	var arrChildren = objParent.childNodes;
	
	
	for (var i = 0; i < arrChildren.length && objFound == null; i++)
	{	
		objCurrent = arrChildren[i];
		
		if (objCurrent.nodeName == strNodeName && objCurrent.name.indexOf(strName) > -1)
		{	
			arrFound[arrFound.length] = objCurrent;
		}	
		
		LocateChildren(objCurrent, strNodeName, strName, arrFound);
	}	
}	
	
	function RemainderFormValidatorStep1(regForm)
	{
		if (!js_StringValidator(regForm.nick, 2, 20, false, /^[^<>\|\*\/\\]*$/gi, "Nick"))
		{	
			return(false);
		}	
	}
	
	function RegFormValidatorStep1(regForm)
	{
		if (
		!js_StringValidator(regForm.nev,5,60,true,/^[^<>\|\*\/\\]*$/gi,"Valódi név") ||
		!js_StringValidator(regForm.nick,2,20,false,/^[^<>\|\*\/\\]*$/gi,"Nick") ||
		!js_StringValidator(regForm.pw1,5,20,false,"","Jelszó") ||
		!js_StringValidator(regForm.pw2,5,20,false,"","Jelszó mégegyszer") ||
		!js_EmailValidator(regForm.email,false,"E-mail") ||
		!js_StringValidator(regForm.remind,2,100,true,"","Emlékeztető") ||
		!js_EqPassword(regForm.pw1,regForm.pw2) ||
		!js_StringValidator(regForm.honlap,4,200,true,"","Honlap") ||
		!js_StringValidator(regForm.tel,7,20,true,/^[0123456789 \/\-\(\)\\]*$/gi,"Telefonszám") ||
		!js_NumValidator(regForm.szev, 1900, 2004, true, "Születési év") ||
		!js_DateValidator(regForm.szev, regForm.szho, regForm.sznap, true, "Születési idő") || 
		!CheckValidator(regForm.moderalas, "Moderálási alapelvek") ||
		!ExpRegFormValidatorStep1(regForm)
		)
		{
			return(false);
		}
		return(true);
	}
	
	function ExpRegFormValidatorStep1(regForm)
	{	
		/*
		if(regForm.nyeremeny[0].checked)
		{	
			if (
			!js_NumValidator(regForm.szev, 1900, 2004, false, "Születési év") ||
			!js_DateValidator(regForm.szev, regForm.szho, regForm.sznap, false, "Születési idő") || 
			!RadioValidator(regForm.nem, "Nem(férfi/nő)") ||
			!js_StringValidator(regForm.orszag, 2, 60, false, /^[^<>\|\*\/\\]*$/gi, "Ország") ||
			!js_StringValidator(regForm.irsz, 4, 4,false, /^[0123456789]*$/gi, "Irányítószám") ||
			!js_StringValidator(regForm.hely, 4, 60, false, /^[^<>\|\*\/\\]*$/gi, "Helység") ||
			!js_StringValidator(regForm.utca, 4, 100, false, /^[^<>\|\*\/\\]*$/gi, "Közterület neve") ||
			!SelectValidator(regForm.koztjelleg, "Közterület jellege") ||
			!js_StringValidator(regForm.hsz, 1, 40, false, /^[^<>\|\*\/\\]*$/gi, "Házszám") ||
			!js_StringValidator(regForm.emeletajto, 1, 60, true, /^[^<>\|\*\/\\]*$/gi, "Emelet/ajtó") ||
			!js_StringValidator(regForm.tel, 7, 20, false, /^[0123456789 \/\-\(\)\\]*$/gi, "Telefonszám") ||
			!SelectValidator(regForm.iskolai, "Végzettség") ||
			!SelectValidator(regForm.beosztas, "Foglalkozás") ||
			!SelectValidator(regForm.munkaterulet, "Munkaterület") ||
			!SelectValidator(regForm.fizetes, "Havi jövedelem") ||
			!SelectValidator(regForm.haztartas, "Háztartás jövedelme") ||
			!SelectValidator(regForm.internet, "Internetezés helye") ||
			!SelectValidator(regForm.internetgyakran, "Internetezés gyakorisága") ||
			!FavoriteCheck() ||
			(regForm.mahu_kezd != undefined && !CheckValidator(regForm.mahu_kezd, "ma.hu kezdőlap"))
			)
			{
				return(false);
			}
		}	
		*/
		
		return(true);
	}	
	
	function FavoriteCheck()
	{	
		var trMain = document.getElementById("erd_inputs");
		var arrChecks = new Array();
		var blnFound = false;
		
		
		LocateChildren(trMain, "INPUT", "erd_", arrChecks);
		
		for (i=0; i < arrChecks.length && !blnFound; i++)
		{	
			blnFound = arrChecks[i].checked;
		}	
		
		if (!blnFound)
		{	
			alert("Kérem legalább egy területet válasszon ki az <<Érdeklődési kör>> mezőkből!");
			
			return(false);
		}	
		
		
		return(true);
	}	
	
	function SelectValidator(selTest, strName)
	{	
		if (selTest.value < 1)
		{	
			alert("A(z) <<" + strName + ">> mezőt ki kell tölteni!");
			
			return(false);
		}	
		
		return(true);
	}	
	
	function CheckValidator(chkTest, strName)
	{	
		if (!chkTest.checked)
		{	
			alert("A(z) <<" + strName + ">> mezőt ki kell tölteni!");
			
			return(false);
		}	
		
		return(true);
	}	
	
	function CheckInit(chkTest, strValue)
	{	
		if (chkTest.value == strValue)
		{	
			chkTest.checked = true;
		}	
		else
		{	
			chkTest.checked = false;
		}	
	}	
	
	function RadioValidator(radTest, strName)
	{	
		var blnFound = false;
		
		
		for (i=0; i < radTest.length && !blnFound; i++)
		{	
			blnFound = radTest[i].checked;
		}	
		
		if (!blnFound)
		{	
			alert("A(z) <<" + strName + ">> mezőt ki kell tölteni!");
			
			return(false);
		}	
		
		
		return(true);
	}	
	
	function RadioInit(radTest, strValue)
	{	
		for (i=0; i < radTest.length; i++)
		{	
			if (radTest[i].value == strValue)
			{	
				radTest[i].checked = true;
			}	
			else
			{	
				radTest[i].checked = false;
			}	
		}	
	}	
	
	function ModRegFormValidatorStep1(regForm)
	{
		if (
		!js_StringValidator(regForm.nev,5,60,true,/^[^<>\|\*\/\\]*$/gi,"Valódi név") ||
		!js_StringValidator(regForm.pw1,5,20,true,"","Jelszó") ||
		!js_StringValidator(regForm.pw2,5,20,true,"","Jelszó mégegyszer") ||
		!js_StringValidator(regForm.remind,2,100,true,"","Emlékeztető") ||
		!js_EqPassword(regForm.pw1,regForm.pw2) ||
		!js_StringValidator(regForm.honlap,4,200,true,"","Honlap") ||
		!js_StringValidator(regForm.tel,7,20,true,/^[0123456789 \/\-\(\)\\]*$/gi,"Telefonszám") ||
		!js_NumValidator(regForm.szev, 1900, 2002, true, "Születési év") ||
		!js_DateValidator(regForm.szev, regForm.szho, regForm.sznap, true, "Születési idő") || 
		!ExpRegFormValidatorStep1(regForm)
		)
		{
			return(false);
		}
		return(true);
	}
	
	function CallAdvice()
	{	
		var winAdvice = window.open("/forms/exp-advice.html", "winAdvice", "width=320,height=240");
		
		
		winAdvice.focus();
	}	
	
	function OnHomePage(objCtl)
	{	
		if ((document.all)&&(document.getElementById)&&(objCtl.checked))
		{	
			objCtl.style.behavior='url(#default#homepage)';
			objCtl.setHomePage('http://www.ma.hu');
		}	
	}	
	
// TODO: chop
// URL validator SimpleChecker?

// szám ellenőrzése, ha allowEmpty true, akkor a mező lehet üres
// ha max és min is = 0 akkor nem vizsgálja a szám nagyságát
function js_NumValidator(field, min, max, allowEmpty, text) {
  if (field.value != "") {
    var numre = new RegExp(/^[0-9]+$/);
    if ( ! numre.test(field.value) ) {
      alert("A(z) <<" + text + ">> mezőbe csak szám írható!");
      field.focus();
      return(false);
    }
    if ( (field.value < min || field.value > max) && max != 0 && min != 0 ){
      alert("A(z) <<" + text + ">> mezőbe " + min + " és " + max + " közé eső szám írható!");
      field.focus();
      return(false);
    }
    return(true);
  } else {
    if ( allowEmpty ) {
      return(true);
    } else {
      alert("A(z) <<" + text + ">> mezőt ki kell tölteni.");
      field.focus();
      return(false);
    }
  }
  return(true);
}

function js_SzintValidator(field1,field2,text1,text2){
  var a = field1.value;
  var b = field2.value;
  a++; b++;
  if ( a > b ) {
    alert("<<" + text1 + ">> nem lehet nagyobb, mint <<" + text2 + ">>" );
    return(false);
  }
  return(true);
}

function js_StringValidator(field, minLength, maxLength, allowEmpty, regexp, text){
  if (field.value != ""){
    if ( regexp != "" ){
      var reg = new RegExp(regexp);
      if ( ! reg.test(field.value) ) {
        alert("<<" + text + ">> : nem megengedett karakter a szövegben.");
        field.focus();
        return(false);
      }
    }
    if ( field.value.length < minLength ) {
      alert("A(z) <<" + text + ">> mező tartalma minimum "+ minLength + " hosszú lehet!");
      field.focus();
      return(false);
    } else {
      if ( field.value.length > maxLength && maxLength != 0 ) {
        alert("A(z) <<" + text + ">> mező tartalma maximum "+ maxLength + " hosszú lehet!");
        field.focus();
        return(false);
      } else {
       return(true);
      }
    }    
  } else {
    if ( allowEmpty ) {
      return(true);
    } else {
      alert("A(z) <<" + text + ">> mezőt ki kell tölteni.");
      field.focus();
      return(false);
    }
  }
  return(true);
}

function js_EmailValidator(field, allowEmpty, text){
  if (field.value != ""){
    var emailre = new RegExp(/^[A-Z0-9][\-\._A-Z0-9]*\@\[?[\-\.A-Z0-9]+\.([A-Z]{2,4}|[0-9]{1,4})\]?$/gi);
    if ( emailre.test(field.value) ) {
      return(true);
    } else {
      alert("Hibás e-mail cím a(z) <<" + text + ">> mezőben.");
      field.focus();
      return(false);
    }
  } else {
    if ( allowEmpty ) {
      return(true);
    } else {
      alert("A(z) <<" + text + ">> mezőt ki kell tölteni.");
      field.focus();
      return(false);
    }
  }
  return(true);
}

function js_ReplaceEnter(textEl) {
  textEl.value = textEl.value.replace(/\r\n/gi,"<br>");
  textEl.value = textEl.value.replace(/\n/gi,"<br>");
  textEl.focus();
}

function js_RemoveEnter(field) {
  field.value = field.value.replace(/\r\n/gi," ");
  field.value = field.value.replace(/\n/gi," ");
  return(true);
}

function js_EqPassword(pw1,pw2){
  if (pw1.value == pw2.value ) {
    return(true);
  } else {
    alert("A két jelszó nem egyezik meg.");
    pw2.focus();
    return(false);
  }
}

//
//az év hó nap biztosan számok
//
function js_DateValidator(ev, ho, nap, allowEmpty, text) {
  if (ev.value != ""){
    if ( ho.value < 1 || ho.value > 12 ) {
      alert("Érvénytelen hónap.");
      ho.focus();
      return(false);
    }
    if ( nap.value < 1 ) {
      alert("Érvénytelen nap.");
      nap.focus();
      return(false);
    }
    if ( ( ho.value == 1 || ho.value == 3 || ho.value == 5 || ho.value == 7 ||
           ho.value == 8 || ho.value == 10 || ho.value == 12 ) && nap.value > 31 ){
      alert("Érvénytelen nap.");
      nap.focus();
      return(false);
    }
    if ( ( ho.value == 4 || ho.value == 6 || ho.value == 9 || ho.value == 11 ) 
         && nap.value > 30 ){
      alert("Érvénytelen nap.");
      nap.focus();
      return(false);
    }
    isLeap = false;
    if ( ev.value % 400 == 0 ) {
      isLeap = true;
    } else {
      if ( ev.value % 100 == 0 ) {
        isLeap = false;
      } else {
        if ( ev.value % 4 == 0 ) {
          isLeap = true;
        }
      }
    }
    if ( ( isLeap && ho.value == 2 && nap.value > 29 ) ||
         ( !isLeap && ho.value == 2 && nap.value > 28 ) ) {
      alert("Érvénytelen nap.");
      nap.focus();
      return(false);
    }
    return(true);
  } else {
    if ( allowEmpty ) {
      return(true);
    } else {
      alert("A(z) <<" + text + ">> dátumot ki kell tölteni.");
      ev.focus();
      return(false);
    }
  }
  return(true);
}

function js_Confirm(text) {
  return confirm(text);
}

function js_TextAreaLength(ta,tal,maxLength) {
  if (ta.value.length > maxLength) {
    ta.value = ta.value.substring(0,maxLength);
    tal.value = 0;
  } else {
    tal.value = maxLength - ta.value.length;
  }
  return(true);
}

function js_ReplaceUnicode(text) {
  var kotoTxt = String.fromCharCode(8209)+'|'+String.fromCharCode(8211)+'|'+String.fromCharCode(8212)+'|'+String.fromCharCode(8213);
  var kotoRe  = new RegExp(kotoTxt,"g");
  text.value = text.value.replace(kotoRe,'-');
  
  var idezoTxt = String.fromCharCode(8220)+'|'+String.fromCharCode(8221)+'|'+String.fromCharCode(8222)+'|'+String.fromCharCode(8243);
  var idezoRe  = new RegExp(idezoTxt,"g");
  text.value = text.value.replace(idezoRe,'"');
  
  var apostrTxt = String.fromCharCode(8216)+'|'+String.fromCharCode(8217)+'|'+String.fromCharCode(8219)+'|'+String.fromCharCode(8242);
  var apostrRe  = new RegExp(apostrTxt,"g");
  text.value = text.value.replace(apostrRe,"'");
  
  var egyebTxt = String.fromCharCode(8215);
  var egyebRe  = new RegExp(egyebTxt,"g");
  text.value = text.value.replace(egyebRe,"_");
  
  var egyebTxt = String.fromCharCode(8218);
  var egyebRe  = new RegExp(egyebTxt,"g");
  text.value = text.value.replace(egyebRe,",");
  
  var egyebTxt = String.fromCharCode(8230);
  var egyebRe  = new RegExp(egyebTxt,"g");
  text.value = text.value.replace(egyebRe,"...");
  
  var egyebTxt = String.fromCharCode(8260);
  var egyebRe  = new RegExp(egyebTxt,"g");
  text.value = text.value.replace(egyebRe,"/");
  
  var egyebTxt = String.fromCharCode(8364);
  var egyebRe  = new RegExp(egyebTxt,"g");
  text.value = text.value.replace(egyebRe,"&euro;");
  
  var egyebTxt = String.fromCharCode(8482);
  var egyebRe  = new RegExp(egyebTxt,"g");
  text.value = text.value.replace(egyebRe,"<small><sup>TM</sup></small>");
}

function js_WordLength(text,maxLength) {
  var re = /\s*-+\s*|\s+/;
  var list = text.value.split(re);
  var i = 0; 
  while ( i < list.length) {
    if ( list[i].length > maxLength ) {
      alert("\""+list[i]+"\" \nszó lehet, hogy szétnyomja a jobb oldali\ndobozokat. Használjon elválasztójelet.");
      text.focus();
      return(false);
    }
  i++;
  }
  return(true);
}

function js_TextLength(text,maxLength) {
  if ( text.value.length > maxLength ) {
    alert("A szöveg hosszabb, mint " + maxLength + " karakter.");
    text.focus();
    return(false);
  }
  return(true);
}

function storeCaret (textEl) {
  if (textEl.createTextRange) {
    textEl.caretPos = document.selection.createRange().duplicate();
  }
}
 
function insertAtCaret(textEl, text) {
  if ( document.selection.type == "None" && textEl.caretPos && textEl.caretPos.text != "" ) {
    textEl.value += text; 
  } else {
    if (textEl.createTextRange && textEl.caretPos) {
      var caretPos = textEl.caretPos;
      caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
    } else {
      textEl.value  = text;
    }
  }
  textEl.focus();
}

function addText(tArea,ic1,ic2) { 
  if ( document.selection.type == "None" ) {
    if ( tArea.caretPos && tArea.caretPos.text != "" ) {
      tArea.value += ic1+ic2; 
    } else {
      insertAtCaret(tArea,ic1+ic2);
    }
  } else {
    var sel = document.selection.createRange();
  	if (sel.parentElement().name == tArea.name ) {
			sel.text = ic1+sel.text+ic2;	
    } else {
			tArea.value += ic1+ic2; 
    }
  }
  tArea.focus();
} 

function removeNoSpam(a) { 
  a.href=a.href.replace(/No-SpaM./g, ""); 
  return true; 
}

function statNoSpam(a, b) {
  if (b) { 
    window.status=a.href.replace(/No-SpaM./g, ""); 
  } else { 
    window.status=""; 
  }
}

function forum_redirToLap(url) {
  document.location=url;
  return(true)
}	

function TemaFormValidator(temaForm){
  js_ReplaceUnicode(temaForm.cim);
  js_ReplaceUnicode(temaForm.szov);
  if ( 
     !js_StringValidator(temaForm.cim,2,100,false,/^[^<>\|\*\\]*$/gi,"Téma címe") ||
     !js_StringValidator(temaForm.frnick,2,60,false,/^[^<>\|\*\\]*$/gi,"nick") ||
     !js_EmailValidator(temaForm.email,true,"E-mail") ||
     !js_StringValidator(temaForm.szov,2,3000,false,/^[^<>\|\*\\]*$/gi,"Üzenet")
  )
  {
     return(false);
  }
    return(true);
}

function forum_goToLap(doc,name,val,basePorp) {
  eval(doc+".location='/tart/forum"+basePorp+"&"+name+"="+val+"'");
  document.forum_goToLap_returnValue = true;
}


function SelectItem(objCtl, strVal)
{	
    if (navigator.appName == "Netscape")
    {
	for (var i = 0; i < objCtl.options.length; i++)
	{
	    if (objCtl.options[i].value == strVal)
		objCtl.options[i].selected = true;
	}
    }
    else
    {
	objCtl.value = strVal;
    }
}	

// ====================================================================
//       URLEncode and URLDecode functions
//
// Copyright Albion Research Ltd. 2002
// http://www.albionresearch.com/
// http://www.albionresearch.com/misc/urlencode.htm
// You may copy these functions providing that 
// (a) you leave this copyright notice intact, and 
// (b) if you use these functions on a publicly accessible
//     web site you include a credit somewhere on the web site 
//     with a link back to http://www.albionresarch.com/
//
// If you find or fix any bugs, please let us know at albionresearch.com
//
// SpecialThanks to Neelesh Thakur for being the first to
// report a bug in URLDecode() - now fixed 2003-02-19.
// ====================================================================
function URLEncode(plaintext)
{
    // The Javascript escape and unescape functions do not correspond
    // with what browsers actually do...
    var SAFECHARS = "0123456789" +					// Numeric
		    "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
		    "abcdefghijklmnopqrstuvwxyz" +
		    "-_.!~*'()";					// RFC2396 Mark characters
    var HEX = "0123456789ABCDEF";

    var encoded = "";
    for (var i = 0; i < plaintext.length; i++ ) {
	var ch = plaintext.charAt(i);
        if (ch == " ") {
	    encoded += "+";				// x-www-urlencoded, rather than %20
	} else if (SAFECHARS.indexOf(ch) != -1) {
	    encoded += ch;
	} else {
	    var charCode = ch.charCodeAt(0);

	    if(charCode == 337) {
                               encoded += "%F5";
                       } else if(charCode == 369) {
                               encoded += "%FB";
                       } else if(charCode == 336) {
                               encoded += "%D5";
                       } else if(charCode == 368) {
                               encoded += "%DB";
                       }
	       else if (charCode > 255) {
	        alert( "Unicode Character '" + ch + "' cannot be encoded using standard URL encoding.\n" +
		        "(URL encoding only supports 8-bit characters.)\n" +
			"A space (+) will be substituted." );
		encoded += "+";
	    } else {
		encoded += "%";
		encoded += HEX.charAt((charCode >> 4) & 0xF);
		encoded += HEX.charAt(charCode & 0xF);
	    }
	}
    } // for

    return encoded;
};

function URLDecode(encoded)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   encoded = encoded.replace(/%C3%A9/gi, "é");
   encoded = encoded.replace(/%C3%A1/gi, "á");
   encoded = encoded.replace(/%C3%B3/gi, "ó");
   encoded = encoded.replace(/%C5%91/gi, "ő");
   encoded = encoded.replace(/%C5%B1/gi, "ű");
   encoded = encoded.replace(/%C3%BA/gi, "ú");
   encoded = encoded.replace(/%C3%B6/gi, "ö");
   encoded = encoded.replace(/%C3%BC/gi, "ü");
   encoded = encoded.replace(/%C3%AD/gi, "í");

   encoded = encoded.replace(/%C3%89/gi, "É");
   encoded = encoded.replace(/%C3%81/gi, "Á");
   encoded = encoded.replace(/%C3%93/gi, "Ó");
   encoded = encoded.replace(/%C5%90/gi, "Ő");
   encoded = encoded.replace(/%C5%B0/gi, "Ű");
   encoded = encoded.replace(/%C3%9A/gi, "Ú");
   encoded = encoded.replace(/%C3%96/gi, "Ö");
   encoded = encoded.replace(/%C3%9C/gi, "Ü");
   encoded = encoded.replace(/%C3%8D/gi, "Í");

   while (i < encoded.length) {
       var ch = encoded.charAt(i);
       if (ch == "+") {
           plaintext += " ";
	   i++;
       } else if (ch == "%") {
	    if (i < (encoded.length-2) 
		    && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
		    && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
		if ( encoded.substr(i,3) == "%F5") {
		    plaintext += "ő";
		} else if ( encoded.substr(i,3) == "%FB" ) {
		    plaintext += "ű";
		} else if ( encoded.substr(i,3) == "%D5" ) {
		    plaintext += "Ő";
		} else if ( encoded.substr(i,3) == "%DB" ) {
		    plaintext += "Ű";
		} else {
		    plaintext += unescape( encoded.substr(i,3) );
		}
		i += 3;
	    } else {
		alert( 'Bad escape combination near ...' + encoded.substr(i) );
		plaintext += "%[ERROR]";
		i++;
	    }
	} else {
	   plaintext += ch;
	   i++;
	}
    } // while
   return plaintext;
};	
    
function addBookmark(title, url){
if (window.sidebar) { // Firefox 2
} else if (window.opera) { //Opera
      var a = document.createElement("A");
      a.rel = "sidebar";
      a.target = "_search";
      a.title = title;
      a.href = url;
      a.click();
} else if(document.all) { //IE
      window.external.AddFavorite(url, title);
} else if (Application) { // Firefox 3
    Application.bookmarks.all.some(function(cur) {
      if ( cur.url == url )
        return true;
      }) || Application.bookmarks.add( title, url );
    }
}

function addHomePage(url){
}