
function check_irsz(input, target) {
  if ( (input == parseInt(input) ) && document.getElementById(target) ) {
    if (input.length == 4) {
    	new Ajax.Request('/site/ajax_irszam.php',
        {
          method:'post',
          onSuccess: function(transport){
            var response = transport.responseText;// || "no response text";
            if (response != '') document.getElementById(target).value = response;
          },
          parameters: {zip: input, limit: 12},
          onFailure: function(){ alert('Something went wrong...') }
        });
    }
  }
}


/*
 * ezt majd db-ből --------------------------------------------------------
 */

var szallashely_cat = {};

/*
szallashely_cat[0] = new Array(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17); //mind
szallashely_cat[1] = new Array(1,2,3,4,5); //szálloda
szallashely_cat[2] = new Array(6,7,8); //panzió
szallashely_cat[3] = new Array(1,2,3,4,5); //kemping
szallashely_cat[4] = new Array(6,7,8); //üdülőház
szallashely_cat[5] = new Array(9,10,11); //ifjúsági szállás
szallashely_cat[6] = new Array(9,10,11); //turistaszállás -- ez a kódtáblából hiányzik
szallashely_cat[7] = new Array(12,13); //fizetővendéglátó szálláshely
szallashely_cat[8] = new Array(14,15,16,17); //falusi szálláshely
*/

/*
(1-5)*: 432,433,434,435,436
(6-8) osztaly: 437,438,439
(9-11) kateg: 440,441,442
(12-13) apartman: 443,444
(14-17) napra: 445,446,447,448
*/

/*
szallashely_cat["0"] = new Array(0,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448); //mind
szallashely_cat["417"] = new Array(432,433,434,435,436); //szálloda
szallashely_cat["424"] = new Array(437,438,439); //panzió
szallashely_cat["425"] = new Array(432,433,434,435,436); //kemping
szallashely_cat["426"] = new Array(437,438,439); //üdülőház
szallashely_cat["427"] = new Array(440,441,442); //ifjúsági szállás
szallashely_cat["428"] = new Array(440,441,442); //turistaszállás -- ez a kódtáblából hiányzik
szallashely_cat["429"] = new Array(443,444); //fizetővendéglátó szálláshely
szallashely_cat["430"] = new Array(445,446,447,448); //falusi szálláshely
*/
szallashely_cat[0] = new Array(0,432,433,434,435,436,437,438,439,440,441,442,443,444,445,446,447,448); //mind
szallashely_cat[1] = new Array(432,433,434,435,436); //szálloda
szallashely_cat[2] = new Array(437,438,439); //panzió
szallashely_cat[3] = new Array(432,433,434,435,436); //kemping
szallashely_cat[4] = new Array(437,438,439); //üdülőház
szallashely_cat[5] = new Array(440,441,442); //ifjúsági szállás
szallashely_cat[6] = new Array(440,441,442); //turistaszállás -- ez a kódtáblából hiányzik
szallashely_cat[7] = new Array(443,444); //fizetővendéglátó szálláshely
szallashely_cat[8] = new Array(445,446,447,448); //falusi szálláshely

/*
 * eddig ------------------------------------------------------------------
 */


function select_szallas_cat_types(index) {

	var szallas_cat_select = $('szallas_cat');

  //var szhely_options = '';
  if (szallas_cat_select) {
		var szallas_type = szallas_cat_select.options[index].value;

    for (var i = 0; i< szallas_cat_select.options.length; i++ ) {
      szallas_cat_select.options[i].style.display = 'none';
      szallas_cat_select.options[i].style.visibility = 'hidden';
      
      //while ($('szallas_cat').firstChild) {
      //  $('szallas_cat').removeChild($('szallas_cat').firstChild);
      //}
      
      //alert($('szallas_cat_' + i ).style.display);
      for (var j = 0; j<szallashely_cat[index].length; j++) {
        if (szallas_cat_select.options[i].value == szallashely_cat[index][j]) {
          //szhely_options += szallashely_options[ i ]; 
          szallas_cat_select.options[i].style.display = 'block';
          szallas_cat_select.options[i].style.visibility = 'visible';
          
          //var newNode = document.createElement('option');
          //newNode.setAttribute('id', 'szallas_cat_'+szallashely_cat[szallas_type][j]);
          //newNode.setAttribute('value', szallashely_cat[szallas_type][j]);
          //newNode.textContent = szallashely_texts[szallas_type][j];
          //$('szallas_cat').appendChild(newNode);
          break;
        }
      }
    }
    //alert($('szallas_cat').children.length);
    $('szallas_cat_' + szallashely_cat[index][0]).selected = true;
    
  }

}
