      function checkEmail(field){
      	apos=field.value.indexOf("@");
      	dotpos=field.value.lastIndexOf(".");
      	if (apos<1||dotpos-apos<2){
      		alert('Helytelen email címet adott meg.');
      		field.focus();
      		return false;
      	}else{
      		return true;
      	}
      }

      function checkReg(form){
        if(form.email.value.replace(/^\s+|\s+$/g, '')==''){
      		alert('Nem adta meg az email címét. A regisztrációhoz ezt az adatot meg kell adnia.');
      		form.email.focus();
      		return false;
      	}
        if(!checkEmail(form.email)){
          return false;
        }
      	if(form.passwd1.value.replace(/^\s+|\s+$/g, '')==''){
      		alert('Nem adta meg a jelszavát. A regisztrációhoz ezt az adatot meg kell adnia.');
      		form.passwd1.focus();
      		return false;
      	}
      	if(form.passwd1.value!=form.passwd2.value){
      		alert('A megadott jelszó nem egyezik a megerősítéssel. A két jelszó mezőbe azonos jelszót kell írnia a sikeres regisztrációhoz.');
      		form.passwd2.focus();
      		return false;
      	}
      	if(!form.accept_rules.checked){
          alert('A sikeres regisztrációhoz el kell fogadni oldalunk felhasználási feltételeit és az adatkezelési nyilatunkat.');
      		form.accept_rules.focus();
      		return false;
        }
      	return true;
      }
      
      function checkLogin(form){
        if(form.email.value.replace(/^\s+|\s+$/g, '')==''){
      		alert('Nem adta meg az email címét. Email cím nélkül nem tud bejelentkezni.');
      		form.email.focus();
      		return false;
      	}
        if(!checkEmail(form.email)){
          return false;
        }
      	if(form.passwd.value.replace(/^\s+|\s+$/g, '')==''){
      		alert('Nem adta meg a jelszavát. Jelszó nélkül nem tud bejelentkezni.');
      		form.passwd.focus();
      		return false;
      	}
      	return true;
      }

      function createXmlHttp(){
				var request=null;
				if (window.XMLHttpRequest){
					request=new XMLHttpRequest();
				}
				else if (typeof ActiveXObject != undefined){
					request=new ActiveXObject('Microsoft.XMLHTTP');
				}
				return request;
			}
			
			function loadContent(url, params, DOM_element){
				var ajaxRequest = createXmlHttp();

				if (ajaxRequest) {
					ajaxRequest.open("POST", url, true);
					ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
					ajaxRequest.setRequestHeader("Content-length", params.length);
					ajaxRequest.setRequestHeader("Connection", "close");
					ajaxRequest.onreadystatechange=function loadAjaxData() {
																					if (ajaxRequest.readyState != 4) { return; }
																					var d=document.getElementById(DOM_element);
																					d.innerHTML=ajaxRequest.responseText;
																					loadedChar=document.getElementById('kw_input').value.charAt(0);
																					loadRequest(document.getElementById('kw_input').value);
																					if(matched){
                                            d.style.display='inline';
                                          }else{
                                            d.style.display='none';
                                          }
                                          document.getElementById('kw_input').style.background = '#fff';
																				}
				  ajaxRequest.send(params);
				}
			}

    	function init() {
    		var inputs = document.getElementsByTagName("input"), span = Array(), textnode, option, active;
    		for(a = 0; a < inputs.length; a++) {
    			if((inputs[a].type == "checkbox" || inputs[a].type == "radio") && inputs[a].className == "styled") {
    				span[a] = document.createElement("span");
    				span[a].className = inputs[a].type;
    				if(inputs[a].checked == true) {
    					position = "0 -" + (checkboxHeight*2) + "px";
    					span[a].style.backgroundPosition = position;
    				}
    				inputs[a].parentNode.insertBefore(span[a], inputs[a]);
    				inputs[a].onchange =
              function clear(e){
                inputs = document.getElementsByTagName("input");
            		for(var b = 0; b < inputs.length; b++) {
            			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
            				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
            			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
            				inputs[b].previousSibling.style.backgroundPosition = "0 0";
            			}
            		}
              }
    				span[a].onmousedown = 
    				  function pushed(e) {
            		element = this.nextSibling;
            		if(element.checked == true && element.type == "checkbox") {
            			this.style.backgroundPosition = "0 -" + checkboxHeight*3 + "px";
            		} else if(element.checked != true && element.type == "checkbox") {
            			this.style.backgroundPosition = "0 -" + checkboxHeight + "px";
            		}
            	}
    				span[a].onmouseup = 
    				  function check(e) {
            		element = this.nextSibling;
            		if(element.checked == true && element.type == "checkbox") {
            			this.style.backgroundPosition = "0 0";
            			element.checked = false;
            		} else {
            			if(element.type == "checkbox") {
            				this.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
            			}
            			element.checked = true;
            		}
          	  }
            span[a].onmouseout =
              function clear(e){
                inputs = document.getElementsByTagName("input");
            		for(var b = 0; b < inputs.length; b++) {
            			if(inputs[b].type == "checkbox" && inputs[b].checked == true && inputs[b].className == "styled") {
            				inputs[b].previousSibling.style.backgroundPosition = "0 -" + checkboxHeight*2 + "px";
            			} else if(inputs[b].type == "checkbox" && inputs[b].className == "styled") {
            				inputs[b].previousSibling.style.backgroundPosition = "0 0";
            			}
            		}
              }
    			}
    		}
    	}

      function changeBgColor(element, color){
  			element.style.backgroundColor=color;
      }

      var matched=0;
      var loadedChar='';

      function loadRequest(request){
        //var regexp = /[A-Za-z0-9]/;
        //var regexp = /”\.\,\:\;\(\)\"\-\'\s]/;
        //request = request.replace(/[^a-záéíóőöűúü0-9\s-]/ig,'');
        //console.warn(regexp.test(request))
        //if(regexp.test(request) !== true) return false;
        
        if(request.length==1&&request.charAt(0)!=loadedChar){
          document.getElementById('kw_input').style.background = '#fff url(/images/ajax-loader.gif) no-repeat center right';
          loadContent('ajax.php', 'keyword='+request, 'popup_list_holder');
        }else if(document.getElementById('kw_input').value.length>0){
          var a=document.getElementById('popup_list_holder').getElementsByTagName('a');
          var smallR=request.toLowerCase();
          var smallR=smallR.replace('"', '');
          matched=0;
          for(var i=0;i<a.length;i++){
            smallA=a[i].innerHTML.toLowerCase();
            smallA=smallA.replace('"', '');
            if(smallA.indexOf(smallR)){
              a[i].parentNode.style.display='none';
            }else{
              a[i].parentNode.style.display='block';
              matched++;
            }
          }
          var s=document.getElementById('popup_list_holder').style;
          var pl=document.getElementById('popup_list');
          if(matched==0){
            s.display='none';
          }else if(pl!=null){
            if(matched>10){
              pl.style.height='241px';
            }else{
              pl.style.height=24*matched+'px';
            }
          }
          return matched;
        }
      }

      function filterDivs(allDivs){
        var divs=new Array();
        for(i=0;i<allDivs.length;i++){
          if(allDivs[i].id=="popup_list"||allDivs[i].style.display!='none'){
            divs.push(allDivs[i]);
          }
        }
        return divs;
      }
