
  function createXmlHttp() {
	    var request = null;
      request = (window.XMLHttpRequest)? new XMLHttpRequest(): new ActiveXObject("MSXML2.XMLHTTP");
	    return request;
	}

	var ajaxRequest = null;


  function requestData(program, val1, val2, val3, val4, val5, program2, func2) {
	    ajaxRequest = createXmlHttp();
      var contentFunc = eval(val1);
	    if (ajaxRequest) {
           var url = program+'?ajax=1&val2='+val2+'&val3='+val3+'&val4='+val4+'&val5='+val5;
	         ajaxRequest.open('get', url , true);

           ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
           ajaxRequest.onreadystatechange = contentFunc;
	         ajaxRequest.setRequestHeader("Connection", "close");

           ajaxRequest.send(null);

        if (program2 && func2) {
             ajaxRequest2 = createXmlHttp();
             var contentFunc2 = eval(func2);
             var url2 = program2+'?ajax=1&val2='+val2+'&val3='+val3+'&val4='+val4+'&val5='+val5;
	           ajaxRequest2.open('get', url2 , true);
	           //var target = 'teszt';
	           ajaxRequest2.onreadystatechange = contentFunc2;
             ajaxRequest2.send(null);
  	    }

	    }
	}

	function updateCart() {
	    var divContentInfo =  document.getElementById('leftCart');
	    //var divContentLoad =  document.getElementById('portalContentLoader');
      if(ajaxRequest.readyState < 4) {
	      //divContentLoad.style.display='block';
	    }
      if (ajaxRequest.readyState == 4){
	      divContentInfo.innerHTML = ajaxRequest.responseText;
	      //divContentLoad.style.display='none';
      }
	}
	function updateSearch() {
	    var divContentInfo =  document.getElementById('left_top_search');
	    //var divContentLoad =  document.getElementById('portalContentLoader');
      if(ajaxRequest.readyState < 4) {
	      //divContentLoad.style.display='block';
	    }
      if (ajaxRequest.readyState == 4){
	      divContentInfo.innerHTML = ajaxRequest.responseText;
	      //divContentLoad.style.display='none';
      }
	}

	function getReg() {
	    var divContentInfo =  document.getElementById('reg-holder');
	    //var divContentLoad =  document.getElementById('portalContentLoader');
      if(ajaxRequest.readyState < 4) {
	      //divContentLoad.style.display='block';
	    }
      if (ajaxRequest.readyState == 4){
	      divContentInfo.innerHTML = ajaxRequest.responseText;
	      //divContentLoad.style.display='none';
      }
	}
	function postForm (obj,action,func,callback) {
      var params="";
      var spr="";
      for(var i=0;i<obj.elements.length;i++){
       if(obj.elements[i].name!=''){
        if(i>0) spr="&"; else spr="";

        obj.elements[i].value = obj.elements[i].value.replace(/&/,"%26");

        if(obj.elements[i].disabled==false){
         if(obj.elements[i].type=='checkbox'){
           if(obj.elements[i].checked)
            params += spr+obj.elements[i].name+"="+obj.elements[i].value;
           //else
           // params += spr+obj.elements[i].name+"=";
         }else if(obj.elements[i].type=='radio'){
           if(obj.elements[i].checked)
            params += spr+obj.elements[i].name+"="+obj.elements[i].value;
         }else{
          params += spr+obj.elements[i].name+"="+obj.elements[i].value;
         }
        }

       }
      }
	    ajaxRequest = createXmlHttp();
      var contentFunc = eval(func);
      var contentCallBack = eval(callback);
	    if (ajaxRequest) {
         ajaxRequest.open('post', action , true);
         ajaxRequest.onreadystatechange = contentFunc;
         contentCallBack;
         ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
         ajaxRequest.send(params);
      }
  }
  


function intCheck() {
var nav=navigator.appName;
var ns=(nav.indexOf("Netscape")!=-1);

if(ns){
 if(document.layers){
  document.captureEvents(Event.KEYPRESS);
  document.onkeypress = subIntCheck;
 }
 if(document.getElementById){
  document.onkeypress = subIntCheck;
 }
}else{
 //var key = window.event.keyCode;
 return subIntCheck();
}

}

function subIntCheck(keyStroke) {

 var nav=navigator.appName;
 var ns=(nav.indexOf("Netscape")!=-1);

 //var eventChooser = (ns)?keyStroke.which: window.event.keyCode;
 try {
   var eventChooser = keyStroke.which;
  // FIX: document.attachEvent("onkeypress", Key);
 } catch(e){
   var eventChooser = window.event.keyCode;
 }

 var chare = String.fromCharCode(eventChooser);
 //alert(eventChooser+" + "+chare+": "+is_int(chare));
 //alert(eventChooser);
 //var which = String.fromCharCode(eventChooser).toLowerCase();
 if( (
     is_int(chare)
     || eventChooser == 8
     || eventChooser == 0
     || eventChooser == 9
     || eventChooser == 37
     || eventChooser == 39
     || eventChooser == 46
     || (eventChooser >= 96 && eventChooser <= 105 && ns==false)
     )
     && eventChooser != 32
 ){
  return true;
 }else{
  return false;
 }
}

function intCheckDel(){
 var nav=navigator.appName;
 var ns=(nav.indexOf("Netscape")!=-1);
 if(ns) document.onkeypress = false;
}

function is_int(c){
    return !isNaN(c);
}

  function loadPartnersList(q) {

  	var url       = 'http://'+window.location.hostname+'/partners.xml.php';
    var pars      = 'name='+q.value;
    var selectDiv = getObj(q.id+'_Select');

  	if( q.value.length==0 ){
     selectDiv.style.display = 'none';
     return false;
    }
  	if(q.value.length>=1){

	    ajaxRequest = createXmlHttp();
	    if (ajaxRequest) {
         ajaxRequest.open('post', url , true);
         ajaxRequest.onreadystatechange = function () {
            if (ajaxRequest.readyState == 4){
           		xmlobject = ajaxRequest.responseXML;
         	   	var root = xmlobject.getElementsByTagName('data')[0];
         	  	var items = root.getElementsByTagName('row');
              var htmlTmp = '';

         		  for (var i=0; i<items.length; i++) {
         		  	var item            = items[i];
         		  	var pid             = item.getAttribute('id');
         		  	var partner_name    = item.getAttribute('partner_name');
                htmlTmp += '<li class="selectLi">';
                if(partner_name){

                 var onclick =  'getObj(\''+q.id+'_Select\').style.display=\'none\';'
                               +'getObj(\''+q.id+'\').value=\''+partner_name+'\';'
                               +'document.searchForm.submit();';
                 htmlTmp += '<a href="#this" onclick="'+onclick+'" title="'+partner_name+'">'+partner_name+'</a>';
                 selectDiv.style.height='400px';
                }else{
                 selectDiv.style.height='40px';
                 htmlTmp += pid;
                }
                htmlTmp += '</li>';
              }

              var iFrameH = Math.round((items.length*18));
              if(iFrameH<200)
               iFrameH = 200;

              selectDiv.innerHTML     = '<iframe src="http://www.adatbank.hu/blank.html" frameborder="0" style="filter:alpha(opacity=0);z-index:-1;display:block;position:absolute;width:500px;height:'+iFrameH+'px;top:0;left:0;"></iframe><ul class="selectUl">'+htmlTmp+'</ul>';
              selectDiv.style.left    = getLeftPos(getObj(q.id))+'px';
              selectDiv.style.top     = (getTopPos(getObj(q.id)) + getObj(q.id).offsetHeight) + 'px';

              selectDiv.style.display = 'block';

         		  return false;
            }else{
              return false;
            }
         };
         ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
         ajaxRequest.send(pars);
      }
    }
  }
  
  function loadServiceList(q,l) {

  	var url       = 'http://'+window.location.hostname+'/service.xml.php';
    var pars      = 'name='+q.value+'&l='+l;
    var selectDiv = getObj(q.id+'_Select');

  	if( q.value.length==0 ){
     selectDiv.style.display = 'none';
     return false;
    }
  	if(q.value.length>=1){

	    ajaxRequest = createXmlHttp();
	    if (ajaxRequest) {
         ajaxRequest.open('post', url , true);
         ajaxRequest.onreadystatechange = function () {
            if (ajaxRequest.readyState == 4){
           		xmlobject = ajaxRequest.responseXML;
         	   	var root = xmlobject.getElementsByTagName('data')[0];
         	  	var items = root.getElementsByTagName('row');
              var htmlTmp = '';

         		  for (var i=0; i<items.length; i++) {
         		  	var item              = items[i];
         		  	var pid               = item.getAttribute('id');
         		  	var service_name      = item.getAttribute('service_name');
         		  	var service_name_full = item.getAttribute('service_name_full');
                htmlTmp += '<li class="selectLi">';
                if(service_name){

                 var onclick =  'getObj(\''+q.id+'_Select\').style.display=\'none\';'
                               +'getObj(\''+q.id+'\').value=\''+service_name+'\';'
                               +'document.searchForm.submit();';
                 htmlTmp += '<a href="#this" onclick="'+onclick+'" title="'+service_name_full+'">'+service_name+'</a>';
                 selectDiv.style.height='400px';
                }else{
                 selectDiv.style.height='40px';
                 htmlTmp += pid;
                }
                htmlTmp += '</li>';
              }

              var iFrameH = Math.round((items.length*18));
              if(iFrameH<200)
               iFrameH = 200;

              selectDiv.innerHTML     = '<iframe src="http://www.adatbank.hu/blank.html" frameborder="0" style="filter:alpha(opacity=0);z-index:-1;display:block;position:absolute;width:500px;height:'+iFrameH+'px;top:0;left:0;"></iframe><ul class="selectUl">'+htmlTmp+'</ul>';
              selectDiv.style.left    = getLeftPos(getObj(q.id))-75+'px';
              selectDiv.style.top     = (getTopPos(getObj(q.id)) + getObj(q.id).offsetHeight) + 'px';

              selectDiv.style.display = 'block';

         		  return false;
            }else{
              return false;
            }
         };
         ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
         ajaxRequest.send(pars);
      }
    }
  }

	function getLeftPos(inputObj)
	{
	  var returnValue = inputObj.offsetLeft;
	  while((inputObj = inputObj.offsetParent) != null)returnValue += inputObj.offsetLeft;

	  return returnValue;
	}
  function getTopPos(inputObj)
	{

	  var returnValue = inputObj.offsetTop;
	  while((inputObj = inputObj.offsetParent) != null){
	  	returnValue += inputObj.offsetTop;
	  }
	  return returnValue;
	}
  function hideAddressSelect(i) {
   var selectDiv = getObj(i);
   setTimeout(
    function(){
     selectDiv.style.display='none';
    }
    ,500
   );
  }

