var BrowserDetect = {
    init: function () {
	  this.family  = "{Unknown}";
	  this.browser = "{Unknown}";
	  this.version = "0";
	/*  alert(navigator.userAgent); */
	  var ver = "";
	  var known=new Array("America Online Browser","Maxthon","MSIE","Navigator","SeaMonkey","K-Meleon","Konqueror","Iceweasel","Epiphany","Firefox","Flock","Chrome","Opera","Safari","ICab","Camino","Omniweb","Lynx");
	  for (i=0; i<known.length; i++) {
	      if (navigator.userAgent.indexOf(known[i])>=0) {
	         j=navigator.userAgent.indexOf(known[i])+known[i].length+1;
	         while (navigator.userAgent.substr(j,1)!=" " && navigator.userAgent.substr(j,1)!=";" && navigator.userAgent.substr(j,1)!=")" && j<navigator.userAgent.length) {
	               ver+=navigator.userAgent.substr(j,1);
	               j++;
	         }
	         if (ver!="") { 
	            this.browser=known[i];
	            this.version=ver;
	            break;
	         }
	      }
	  }
	  if (this.browser=="MSIE" || 
	      this.browser=="America Online this.browser" || 
	      this.browser=="Maxthon") {
	     family="MSIE";
	  } else {
	     if (this.browser=="SeaMonkey" || 
	         this.browser=="Iceweasel" || 
	         this.browser=="Epiphany" || 
	         this.browser=="Firefox" ) {
	        this.family="Firefox";
	     } else {
	        if (this.browser=="Chrome" || 
	            this.browser=="Flock" ) {
	           this.family="Chrome";
	        } else {
	           this.family=this.browser;
	       }
	     }
	  } 
    }  /* init */
};

function bizttorol(question, where) {
  temp = window.confirm(question);
  if (temp) {
     window.location=where;
  }
}

function valasztin(question, where) {
  temp = window.confirm(question);
  if (temp) {
     window.location=where;
  }
}

function fullreplace(miben,mit,mire) { 
  temp = miben+""; 
  ijkujikoi = temp.indexOf(mit); 
  while(ijkujikoi > -1) { 
    temp = temp.replace(mit, mire); 
    ijkujikoi = temp.indexOf(mit); 
  } 
  return temp;
}

function open_windowrs(link,w,h) {
  if (w > screen.width)
      w = screen.width-60;
  if (h > screen.height)
      h = screen.height-100;
  var wleft = (screen.width-w)/2;
  var wtop = ((screen.height-h)/2)-15;
  
  if (typeof(wishWin)!="undefined")
     wishWin.close();
  var win = "width="+w+",height="+h+",menubar=no,top="+wtop+",left="+wleft+",location=no,resizable=yes,scrollbars=yes";
  wishWin = window.open(link,"winrs",win);
}

function open_windowsc(link,w,h) {
  if (w > screen.width)
      w = screen.width-60;
  if (h > screen.height)
      h = screen.height-100;
  var wleft = (screen.width-w)/2;
  var wtop = ((screen.height-h)/2)-15;
  
  if (typeof(wishWin)!="undefined")
     wishWin.close();
  var win = "width="+w+",height="+h+",menubar=no,top="+wtop+",left="+wleft+",location=no,resizable=no,scrollbars=yes";
  wishWin = window.open(link,"winsc",win);
}

function open_window(link,w,h) {
  if (BrowserDetect.browser=="Safari") w+=15;
  if (BrowserDetect.browser=="Chrome") h+=22;
  if (BrowserDetect.browser=="Konqueror") h+=13;
  if (BrowserDetect.browser=="Konqueror") w+=4;
  var wleft = (screen.width-w)/2;
  var wtop = ((screen.height-h)/2)-30;

  if (typeof(wishWin)!="undefined")
     wishWin.close();
  var win = "width="+w+",height="+h+",menubar=no,top="+wtop+",left="+wleft+",location=no,directories=no,status=no,resizable=no,scrollbars=no";
  wishWin = window.open(link,"wnn",win);
}

function open_window2(link,w,h) {
  if (BrowserDetect.browser=="Safari") w+=15;
  if (BrowserDetect.browser=="Chrome") h+=22;
  if (BrowserDetect.browser=="Konqueror") h+=13;
  if (BrowserDetect.browser=="Konqueror") w+=4;
  var wleft = (screen.width-w)/2;
  var wtop = ((screen.height-h)/2)-30;

  if (typeof(wishWin)!="undefined")
     wishWin.close();
  var win = "width="+w+",height="+h+",menubar=no,top="+wtop+",left="+wleft+",location=no,directories=no,status=no,resizable=no,scrollbars=no";
  wishWin = window.open(link,"wnn2",win);
}

function open2_windowrs(link,w,h) {
  if (w > screen.width)
      w = screen.width-60;
  if (h > screen.height)
      h = screen.height-100;
  var wleft = (screen.width-w)/2;
  var wtop = ((screen.height-h)/2)-15;
  
  if (typeof(wishWin)!="undefined")
     wishWin.close();
  var win = "width="+w+",height="+h+",menubar=no,top="+wtop+",left="+wleft+",location=no,resizable=yes,scrollbars=yes";
  wishWin = window.open(link,"winrs2",win);
}

function open2_windowsc(link,w,h) {
  if (w > screen.width)
      w = screen.width-60;
  if (h > screen.height)
      h = screen.height-100;
  var wleft = (screen.width-w)/2;
  var wtop = ((screen.height-h)/2)-15;
  
  if (typeof(wishWin)!="undefined")
     wishWin.close();
  var win = "width="+w+",height="+h+",menubar=no,top="+wtop+",left="+wleft+",location=no,resizable=no,scrollbars=yes";
  wishWin = window.open(link,"winsc2",win);
}

function open2_window(link,w,h) {
  if (BrowserDetect.browser=="Safari") w+=15;
  if (BrowserDetect.browser=="Chrome") h+=22;
  if (BrowserDetect.browser=="Konqueror") h+=13;
  if (BrowserDetect.browser=="Konqueror") w+=4;
  var wleft = (screen.width-w)/2;
  var wtop = ((screen.height-h)/2)-30;

  if (typeof(wishWin)!="undefined")
     wishWin.close();
  var win = "width="+w+",height="+h+",menubar=no,top="+wtop+",left="+wleft+",location=no,directories=no,status=no,resizable=no,scrollbars=no";
  wishWin = window.open(link,"wnn2",win);
}

function csakszam(xevent) {
  if (window.event) {
     var key = xevent.keyCode;
     if ((key<48 || key>57) && key!=44 && key!=45 && key!=8)
        xevent.returnValue = false;
  } else {
     var key = xevent.which;
     if ((key<48 || key>57) && key!=0 && key!=44 && key!=45 && key!=8) {
        xevent.returnValue = false;
        xevent.preventDefault();
     }
  }
}

function RRObject() {
      http_request = false;
      if (window.XMLHttpRequest) { /* Mozilla, Safari,... */
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { /* IE */
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      return http_request;
}

function leftbe(p_elm) {
    var x = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      x+= elm.offsetLeft;
      elm = elm.offsetParent;
    }
    return parseInt(x);
}

function topbe(p_elm) {
    var y = 0;
    var elm;
    if(typeof(p_elm) == "object") {
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      y+= elm.offsetTop;
      elm = elm.offsetParent;
    }
    return parseInt(y);
}

function dly(millis) {
   var date = new Date();
   var curDate = null;

   do { curDate = new Date(); } 
   while(curDate-date < millis);
} 

function semmi() {
 semmi=0;
}

function isie() {
 return navigator.appName=="Microsoft Internet Explorer";
}

function emailell(str) {
  var at="@";
  var dot=".";
  var lat=str.indexOf(at);
  var lstr=str.length;
  var ldot=str.indexOf(dot);
  
  if (str.indexOf(at)==-1) return false;
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
  if (str.indexOf(at,(lat+1))!=-1) return false;
  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
  if (str.indexOf(dot,(lat+2))==-1) return false;
  if (str.indexOf(" ")!=-1) return false;
  return true;
}

function gI(xobj) {
  return document.getElementById(xobj);
}

function iif(xfelt,xi,xh) {
  if (xfelt)
     return xi;
  else
     return xh;
}

function vIN(question, where) {
  temp = window.confirm(question);
  if (temp) {
     window.location=where;
  }
}

function biztment() {
  return window.confirm("Biztosan rendben vannak az adatok?");
}

function ma() {
  datum=new Date();
  return datum.getFullYear()+"."+iif(datum.getMonth()<+1<10,"0","")+(datum.getMonth()+1)+"."+iif(datum.getDate()<10,"0","")+datum.getDate();
}

function n2s(xs) {
  return fullreplace(xs,".",",");
}

function s2n(xs) {
  if (xs=="") {
     return 0;
  } else {
     return parseFloat(fullreplace(xs,",","."));
  }
}

function getvisiblesize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    /*Non-IE */
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    /*IE 6+ in 'standards compliant mode' */
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    /*IE 4 compatible */
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [myWidth,myHeight];
}

function CToD(xc) {
  return new Date(parseFloat(xc.substring(0,4)),parseFloat(xc.substring(5,7))-1,parseFloat(xc.substring(8,10)));
}

function DToC(xd) {
  return xd.getFullYear()+"."+iif(xd.getMonth()+1<10,"0","")+(xd.getMonth()+1)+"."+iif(xd.getDate()<10,"0","")+xd.getDate();
}

function dEll(xdo) {
/*  9999.99.99 */
/*  0123456789  */
/*  1234567890 */
  if (xdo.value.length==8) {
     xdo.value=xdo.value.substring(0,4)+"."+xdo.value.substring(4,6)+"."+xdo.value.substring(6,8);
  }
  dteYear  = parseInt(xdo.value.substring(0,4),10);
  dteMonth = parseInt(xdo.value.substring(5,7),10)-1;
  dteDay   = parseInt(xdo.value.substring(8,10),10);
  dteDate  = new Date(dteYear,dteMonth,dteDay);
  dteDOK   = (xdo.value=="") || (xdo.value[4]=="." && xdo.value[7]=="." && dteDay==dteDate.getDate() && dteMonth==dteDate.getMonth() && dteYear==dteDate.getFullYear());
  if (!dteDOK) {
     setTimeout(function(){xdo.focus();},0);
     alert("Érvénytelen dátum.");
  }
  return dteDOK;
}

function dEll2(xdat) {
  dteYear  = parseInt(xdat.substring(0,4),10);
  dteMonth = parseInt(xdat.substring(5,7),10)-1;
  dteDay   = parseInt(xdat.substring(8,10),10);
  dteDate  = new Date(dteYear,dteMonth,dteDay);
  dteDOK   = (xdat=="") || (xdat[4]=="." && xdat[7]=="." && dteDay==dteDate.getDate() && dteMonth==dteDate.getMonth() && dteYear==dteDate.getFullYear());
  return dteDOK;
}

function dCToD(xdtm) {
  cToDViss="";
  if (dEll2(xdtm)) {
     dteYear  = parseInt(xdtm.substring(0,4),10);
     dteMonth = parseInt(xdtm.substring(5,7),10)-1;
     dteDay   = parseInt(xdtm.substring(8,10),10);
     cToDViss = new Date(dteYear,dteMonth,dteDay);
  }
  return cToDViss;
}

function dMuv(xdtm,xmuv,xmit) {
  /* dMuv("2009.11.06","+","8") */
  dMuvViss="";
  if (dEll2(xdtm)) {
     idgdtm=dCToD(xdtm);
     if (xmuv=="-") {
        if (dEll2(xmit)) {
           idgmit=dCToD(xmit);
           ONE_DAY = 1000*60*60*24;
           difference_ms = Math.abs(idgdtm.getTime() - idgmit.getTime());
           dMuvViss=Math.round(difference_ms/ONE_DAY)
        } else {
           idgdtm.setDate(idgdtm.getDate()-parseInt(xmit,10));
           dMuvViss=DToC(idgdtm);
        }
     } else {  /* + */
       idgdtm.setDate(idgdtm.getDate()+parseInt(xmit,10));
       dMuvViss=DToC(idgdtm);
     }
  }
  return dMuvViss;
}

function ztrans(nStr) {
  nStr += '';
  x = nStr.split('.');
  x1 = x[0];
  x2 = x.length > 1 ? '.' + x[1] : '';
  var rgx = /(\d+)(\d{3})/;
  while (rgx.test(x1)) {
        x1 = x1.replace(rgx, '$1' + ' ' + '$2');
  }
  idg=x1+x2;
  return idg.replace(".",",");
}

function ztransar(nStr) {
  vix=ztrans(nStr);
  if (vix.indexOf(",")==vix.length-2 && vix.indexOf(",")>-1 && vix!="0") {
     vix+="0";
  }
  return vix;
}

function pm(xn1,xm,xn2) {
  xn1s = xn1+'';
  xn2s = xn2+'';
  t1 = xn1s.split('.');
  t2 = xn2s.split('.');
  if (t1.length>1) {
     tj1=t1[1].length;
  } else {
     tj1=0;
  }
  if (t2.length>1) {
     tj2=t2[1].length;
  } else {
     tj2=0;
  }
  erdm=eval(xn1s+xm+xn2s);
  return erdm.toFixed(Math.max(tj1,tj2));
}

function blur_nem0(xobj) {
  if (xobj.value=="" || xobj.value=="-") {
     xobj.value="0";
  }
}

function rochg(xobj,xro) {
  if (xro) {
     xobj.disabled=true;
/*     xobj.style.borderColor="#808080"; */
/*     xobj.style.backgroundColor="#F5F5F5"; */
     xobj.style.color="#707070";
     xobj.style.cursor="default";
  } else {
     xobj.disabled=false;
/*     xobj.style.borderColor="31302E"; */
/*     xobj.style.backgroundColor="#FFFFFF"; */
     xobj.style.color="31302E";
     xobj.style.cursor="text";
  }
}

function rochg2(xobj,xro) {
  if (xro) {
     xobj.disabled=true;
     xobj.style.opacity=0.2;
     xobj.style.filter="alpha(opacity=20)";
  } else {
     xobj.disabled=false;
     xobj.style.opacity=1;
     xobj.style.filter="alpha(opacity=100)";
  }
}

function getcursorposition(e) {
    if (!e) {
       e = window.event;
    }
    var cursor = {x:0, y:0};
    if (e.pageX || e.pageY) {
        cursor.x = e.pageX;
        cursor.y = e.pageY;
    } else {
        var de = document.documentElement;
        var b = document.body;
        cursor.x = e.clientX + 
            (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
        cursor.y = e.clientY + 
            (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
    }
    return cursor;
}

function sI(xobj) {
  return xobj.options[xobj.selectedIndex].value;
}

