function OpenNewWindow(url, x, y) {
	var options = "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=" + x + ",height=" + y;
		msgWindow=window.open(url,"", options);
}

function OpenNewWindowNoScroll(url, x, y) {
	var options = "toolbar=no,menubar=no,scrollbars=no,resizable=yes,width=" + x + ",height=" + y;
		msgWindow=window.open(url,"", options);
}

// ----------------------------------------------------------------------------------------------

function kartyareg() {
    var filter = /^.+@.+\..{2,6}$/;
    var kell = new Array('nev','varos','email');
    var hiba = false;
    var mailhiba = false;
    var hibaado = false;
    
    for(i=0;i<kell.length;i++) {
       if (document.getElementById(kell[i]).value=="") {
           document.getElementById(kell[i]).style.border= "1px red solid";
           hiba = true;
       } else {
           if (kell[i] == 'email' && !filter.test(document.getElementById(kell[i]).value)) {
               document.getElementById(kell[i]).style.border= "1px red solid";
               mailhiba = true;
           } else {
               document.getElementById(kell[i]).style.border= "1px gray solid"; 
           }
       }
    }
    
    if (document.getElementById('adoig').checked && document.getElementById("adoszam").value == "") {
        document.getElementById("adoszam").style.border= "1px red solid";
        hibaado = true;   
    } else document.getElementById("adoszam").style.border= "1px gray solid";
   
    if (!hiba) {
        if (mailhiba) {
            window.alert('A beírt email cím formátuma nem megfelelő!');
            return false;
        } else {
            if (hibaado) {
                window.alert('Az adóigazoláshoz szükséges az adószám kitöltése!');
                return false;
            } else return true;
        }
    } else {
        window.alert('A csillagozott mezők kitöltése kötelező!');
        return false;
    }
   
}

function printDiv (div) {
    var a = window.open('','','width=800,height=600');
    a.document.open("text/html");
    a.document.write('<html><head><link rel="stylesheet" href="/css/index.css"></link><link rel="stylesheet" href="/css/base.css"></link></head><body style="padding-left:20px;background-image:none;background-color:#FFFFFF;">');
    a.document.write(document.getElementById(div).innerHTML);
    a.document.close();
    a.print();
    a.close();
}

function sender(link){
    //window.alert(id+ "  " +quant);
    var url = BASEURL+"send.php?link="+link;
    xmlHttp=GetXmlHttpObject(responsed);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
}

function getAjaxContent(id){
    //window.alert(id+ "  " +quant);
    var url = BASEURL+"getcontent.php?id="+id;
    xmlHttp=GetXmlHttpObject(resp_cont);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
} 
function hidePopup(){
    //window.alert(id+ "  " +quant);
    document.getElementById('popup').style.display='none';
}
function preview(form){
    //window.alert(id+ " _ " +quant);
    valami= "rec_nm="+form.rec_nm.value;
    valami += "&rec_em="+form.rec_em.value;
    valami += "&send_nm="+form.send_nm.value;
    valami += "&send_em="+form.send_em.value;
    valami += "&privmsg="+form.privmsg.value;
    valami += "&pre="+form.pre.value;
    valami += "&link="+form.link.value;
    xmlHttp=GetXmlHttpObject(responsed);
    //xmlHttp.setRequestHeader('Content-Type','multipart/form-data');
    xmlHttp.open("GET", BASEURL+"send.php?"+valami , false);
    xmlHttp.send(null);
}
function sendLink(form){
    //window.alert(form);
    valami= "rec_nm="+form.rec_nm.value;
    valami += "&rec_em="+form.rec_em.value;
    valami += "&send_nm="+form.send_nm.value;
    valami += "&send_em="+form.send_em.value;
    valami += "&privmsg="+form.privmsg.value;
    valami += "&send="+form.send.value;
    valami += "&link="+form.link.value;
    xmlHttp=GetXmlHttpObject(responsed);
    //xmlHttp.setRequestHeader('Content-Type','multipart/form-data');
    xmlHttp.open("GET", BASEURL+"send.php?"+valami , false);
    xmlHttp.send(null);
}

function responsed() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        res=xmlHttp.responseText;
        if (res.indexOf('1') == 0) {
            res=res.substr(1);
            setTimeout('hidePopup()', 3000);
        }
        document.getElementById('popup_content').innerHTML = res;
        document.getElementById('popup').style.display='block';
        //window.location.reload();
    } 
} 

function resp_cont() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
        res=xmlHttp.responseText;
        if (res.indexOf('1') == 0) {
            res=res.substr(1);
            setTimeout('hidePopup()', 3000);
        }
        document.getElementById('popup_content').innerHTML = res;
        document.getElementById('popup').style.display='block';
        //window.location.reload();
    } 
}  

function GetXmlHttpObject(handler)
{
    var objXmlHttp=null

    if (navigator.userAgent.indexOf("MSIE")>=0)
    { 
        var strName="Msxml2.XMLHTTP"
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP"
        } 
        try
        { 
            objXmlHttp=new ActiveXObject(strName)
            objXmlHttp.onreadystatechange=handler
            return objXmlHttp
        } 
        catch(e)
            { 
                alert("Error. Scripting for ActiveX might be disabled") 
                return 
            } 
    } 
    if (navigator.userAgent.indexOf("Mozilla")>=0 || navigator.userAgent.indexOf("Opera")>=0 || navigator.userAgent.indexOf("Safari")>=0)
    {
        objXmlHttp=new XMLHttpRequest()
        objXmlHttp.onload=handler
        objXmlHttp.onerror=handler 
        return objXmlHttp
    }
}
