var v = navigator.userAgent;
var isIE  = (v.indexOf("MSIE 4") != -1 || v.indexOf("MSIE 5") != -1 || v.indexOf("MSIE 6") != -1);
var isNS4 = (!isIE && v.indexOf("Mozilla/4") != -1);
var isNS6 = document.getElementById&&!document.all;
var isOpera  = (v.indexOf("Opera") != -1);

function getobj(o) {
    if (document.getElementById) {
	obj = document.getElementById(o);
    } else if (document.all) {
	eval("obj = document.all." + o);
    } else if (isNS4) {
	eval("obj = document." + o);
    } else {
        obj = false;
    }
    return obj;
}

function openwin(name, url, w, h, param) {
    wtop  = 10;
    wleft = 10;

    if (!param) {
	param = "status=0, menubar=0, resizable=1, copyhistory=no, directories=no, scrollbars=auto";
    }                                                                                                                               
    var popup = window.open(url, name, param + ", width=" + w + ", height=" + h + ", top=" + wtop + ", left=" + wleft);
    popup.focus();                                                                                                                   
}                                                                                                                                   

function atmeretez() {
    NS = (navigator.appName=="Netscape") ? true : false;
    iW = NS ? window.innerWidth  : document.body.clientWidth;
    iH = NS ? window.innerHeight : document.body.clientHeight;
    iW = document.images[0].width  - iW;
    iH = document.images[0].height - iH;
    window.resizeBy(iW, iH);
    self.focus();
}

//    alert(navigator.appName + "\n innerwidth: " + window.innerWidth  + ", clientwidth: " +  document.body.clientWidth + "\n innerheight: " + window.innerHeight  + ", clientheight: " +  document.body.clientHeight + "\n w: " + w + ", h: " + h);
//    alert("iW: " + iW + ", iH: " + iH);
//    alert("W: " + W + ", H: " + H);

function fixmeret(w, h) {
    NS = (navigator.appName=="Netscape") ? true : false;
    iW = NS ? window.innerWidth  : document.body.clientWidth;
    iH = NS ? window.innerHeight : document.body.clientHeight;
    W = w - iW;
    H = h - iH;
    window.resizeBy(W, H);
    self.focus();
}

function showitem(o) {
    getobj(o).style.display = "";
}

function setHomepage() {
    if(document.all) {
        this.style.behavior='url(#default#homepage)'; this.setHomePage('http://www.internetsuli.hu/');
    } else {
	alert("Ez a m&#361;velet csak Internet Explorer-ben m#&361;ködik.");
    }
}

function addToBookmarks() {
    if(document.all) {
	var url = self.location.href;
	var title = document.title;
	window.external.AddFavorite(url,title);
    } else {
	alert("Ez a m&#361;velet csak Internet Explorer-ben m#&361;ködik.");
    }
}

function printArticle() {
    if (window.print) {
        setTimeout('window.print();',200);
    } else if (agt.indexOf("mac") != -1) {
        alert("Nyomja meg a 'Cmd+p' gombokat a cikk nyomtatásához!");
    } else {
        alert("Nyomja meg a 'Ctrl+p' gombokat a cikk nyomtatásához!");
    }
}


function xmlhttp(id, url, param, method) {
    var myConn = new XHConn();
    if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");

    var fnWhenDone = function (oXML) {
	if (oXML.responseText.substring(0, 11) == "javascript:") {
	    eval(oXML.responseText.substring(11));
	} else {
	    document.getElementById(id).innerHTML=oXML.responseText;
	    if (talalt = oXML.responseText.match(/<script[^>]*>([^<]+)<\/script>/g)) {
		eval(talalt.toString().replace(/<[^>]+>/g, ""));
	    }
	}
    }
    if (!method) method = "GET";
    myConn.connect(url, "GET", param, fnWhenDone);
}

/* popup functions */
function open_popup(url, w, h) {
    open_popup_real("/popup.tdp?"+url, w, h);
}

function open_kalk(url, w, h) {
    open_popup_real(url, w, h);
    chg_layer("kalkmenu");
}

function open_popup_real(url, w, h) {
    var iTop  = (screen.height > h) ? (screen.height - h) / 2 : 0;
    var iLeft = (screen.width  > w) ? (screen.width  - w) / 2 : 0;

    var sOptions = "toolbar=no";
    sOptions += ",width=" + ((screen.width>w ? w : screen.width-20) + 20);
    sOptions += ",height=" + ((screen.height>h ? h : screen.height-100) + 20);
    sOptions += ",resizable=no";
    sOptions += ",scrollbars=yes";
    sOptions += ",left=" + iLeft;
    sOptions += ",top=" + iTop;

    var oWindow = window.open(url, "", sOptions);
    oWindow.focus();
}
