// JavaScript document

function init() {
    autofocus();
    email_decode();
}

function autofocus() {
    var item=document.getElementById("q");
    if (item) {
        item.focus();
        }
}

function email_decode() {
    var items=document.getElementsByTagName("span");
    for(i in items) {
        if (items[i].className) {
            if (items[i].className.match("email_code")) {
                var email=unescape(items[i].innerHTML);
                email=email.replace("[at]", "@");
                email=email.replace("[dot]", ".");
                items[i].innerHTML="<a href='mailto:" + email + "'>" + email + "</a>";
                }
            }
        }
}

function display(name) {
    var item=document.getElementById(name);
    if (item) {
        if (item.style.display=='none') {
            item.style.display='';
            } else {
                    item.style.display='none';
                    }
        }
}

function resize(name, to) {
    var item=document.getElementById(name);
    if (item) {
        if (to=="-") {
            item.className='scroll';
            } else {
                    item.className='large_scroll';
                    }
        }
}

function adult() {
    var xxx=document.getElementById("xxx");
    var div=document.getElementById("adult");
    if (xxx) {
        xxx.style.display="none";
        }
    if (div) {
        div.style.display="";
        }
    set_cookie("adult", "1", 2050, 12, 31, "/");
}

function flash_write(src, w, h, id) {
    if (! id) {
        id="flash_"+Math.round(10000*Math.random());
        }
    document.write("<object id='"+id+"' type='application/x-shockwave-flash' data='"+src+"' width='"+w+"' height='"+h+"'>");
    document.write("<param name='movie' value='"+src+"' />");
    document.write("<param value='high' name='quality' />");
    document.write("</object>");
}

function mail_write(name, site, caption) {
    if (! caption) {
        caption = name + "@" + site;
        }
    document.write("<a href='mailto:" + name + "@" + site + "'>" + caption + "</a>");
}

/* -------------------------------------------------------------------------- */

function homepage_link(text) {
    if (! text) {
        text="Kezdőlapnak";        
        }
    if (navigator.appName.match("Internet Explorer")) {
        document.write("<small><a href='javascript:void(0);' onclick=\"this.style.behavior='url(#default#homepage)'; this.setHomePage(window.location);\" title='Beállítás kezdőlapnak'>"+text+"</a></small> | ");
        }
}

function addbookmark(title, url, error_msg){
    if (! title) {
        title=document.title;
        }
    if (! url) {
        url=window.location.href;
        }
    if (! error_msg) {
        error_msg="A böngészője nem támogatja az oldal címének automatikus elhelyezését a kedvencek közé.\nKérem próbálja meg manuálisan.";
        }

    if (window.sidebar) {
        window.sidebar.addPanel(title, url,"")
        }
    else if( window.opera && window.print ) {
        var mbm = document.createElement('a');
        mbm.setAttribute('rel','sidebar');
        mbm.setAttribute('href',url);
        mbm.setAttribute('title',title);
        mbm.click();
        }
    else if( document.all ) {
        window.external.AddFavorite( url, title)
        }
    else if(error_msg!="") {
        alert(error_msg);
        }
}

/* -------------------------------------------------------------------------- */

function set_cookie ( name, value, exp_y, exp_m, exp_d, path, domain, secure ) {
    var cookie_string = name + "=" + escape (value);
    if (exp_y) {
        var expires = new Date ( exp_y, exp_m, exp_d );
        cookie_string += "; expires=" + expires.toGMTString();
        }
    if (path) {
        cookie_string += "; path=" + escape (path);
        }
    if (domain) {
        cookie_string += "; domain=" + escape (domain);
        }
    if (secure) {
        cookie_string += "; secure";
        }
    document.cookie = cookie_string;
}

function get_cookie (cookie_name) {
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );
  if ( results ) return ( unescape ( results[2] ) );
      else return null;
}
