function setSearchSimpleParameters(){
	
	var ojCity                = jQuery('#city'); 
	var ojCountry             = jQuery('#country'); 
	var ojRegion              = jQuery('#region'); 
	var ojHotel               = jQuery('#hotel'); 
	var ojArrivalTime         = jQuery('#arrival_time'); 
	var ojDepartureTime       = jQuery('#departure_time'); 
	var ojMaxPers             = jQuery('#max_pers'); 
	
    Set_Cookie( 'search_city', ojCity.val() , '', '/', '', '' );
    Set_Cookie( 'search_country', ojCountry.val() , '', '/', '', '' );
    Set_Cookie( 'search_region', ojRegion.val() , '', '/', '', '' );
    Set_Cookie( 'search_hotel', ojHotel.val() , '', '/', '', '' );
    Set_Cookie( 'search_arrival_time', ojArrivalTime.val() , '', '/', '', '' );
    Set_Cookie( 'search_departure_time', ojDepartureTime.val() , '', '/', '', '' );
    Set_Cookie( 'search_max_pers', ojMaxPers.val() , '', '/', '', '' );
    Set_Cookie( 'search_parameters_saved', 1 , '', '/', '', '' );
}

/*
function changeRegions(bChangeCountry, bInicialize, sChange, bReloadPlugin){
    
    var sText = '-';
    
    if(sChange == undefined){
       sChange = false;
    }
    if(bReloadPlugin == undefined){
       bReloadPlugin = false;
    }
    
    //vars
    if(!bChangeCountry){
        var oCountry = document.getElementById('country');
        var oSelect = document.getElementById('region');
        var oHotel = document.getElementById('hotel');
        
        //clear cities too
        var oSelectCities = document.getElementById('city');
        
        oSelectCities.options.length = 0;
        oSelectCities.options[0] = new Option('-',0);
        oHotel.options.length = 0;
        oHotel.options[0] = new Option('-',0);
        
        if(bReloadPlugin){
           //$('#country').resetSS();
           //$('#region').resetSS();
	       //$('#city').resetSS();
	       //$('#hotel').resetSS();
        }
        
        //disableElement('region', true);
        //disableElement('city', true);
        //disableElement('hotel', true);
        
     } else {

        var oCountry = document.getElementById('region');
        var oSelect = document.getElementById('city');
        var oHotel = document.getElementById('hotel');
        
        //disableElement('city', true);
        //disableElement('hotel', true);
        
        oHotel.options.length = 0;
        oHotel.options[0] = new Option('-',0);
        
        //$('#' + oHotel.getAttribute('id') + '').resetSS();
        
        sText = aDictionarySearchTags[0];
     }
     
    if(sChange){
       var oCountry = document.getElementById('city');
       var oSelect = document.getElementById(sChange);
     }
    oSelect.options.length = 0;
    if(!sChange){
        oSelect.options[0] = new Option(sText,0);
        //$('#' + oSelect.getAttribute('id') + '').resetSS();
    }
    
    if(bInicialize == undefined){
       bInicialize = false; 
    }     
       
       
        //alert($('#' + oCountry.getAttribute('id') + '').getSetSSValue());
       
    //var iCountryId = oCountry.options[oCountry.selectedIndex].value;
    var iCountryId = jQuery('#' + oCountry.getAttribute('id') + '').val();
    
        //alert(jQuery("#country").val());
        
        //alert('#' + oCountry.getAttribute('id') + ' ==> ' + iCountryId)
        
        alert(oCountry.options[oCountry.selectedIndex].value);

       //alert($('#region').val()  + '===');

    var ajax = getXMLHttpRequest();
        
        if(sChange){ 
          ajax.open('POST', getHostName() + '/searcher/getHotelsByCityId/', true );
        } else {
          ajax.open('POST', getHostName() + '/searcher/getRegionsByCountryId/', true );
        }
        
        ajax.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=UTF-8");
        ajax.setRequestHeader('X_REQUESTED_WITH', "XMLHttpRequest");
        ajax.onreadystatechange = function(){
                 
             if(ajax.readyState == 4){
                
                eval(ajax.responseText)
                
                for(var i=0; i<aDataParsed.length; i++){
                     oSelect.options[(!sChange ? (i+1) : i )] = new Option(aDataParsed[i][1],aDataParsed[i][0]);
                     //$('#' + oSelect.getAttribute('id') + '').append('<option value="' + aDataParsed[i][0] +  '">' + aDataParsed[i][1] + '</option>').resetSS();
                     
                }
                
	            if(bReloadPlugin){
	              //alert(oSelect.getAttribute('id') + '<==');
	              $('#' + oSelect.getAttribute('id') + '').resetSS();
	            }
                
                if(!bChangeCountry){
                    //disableElement('region', false);
                    //disableElement('city', false);
                    //disableElement('hotel', false);
                 } else {
                    //disableElement('city', false);
                    //disableElement('hotel', false);
                 }
                
                if(bInicialize){
                     var CitiesBox = document.getElementById('city');
                         CitiesBox.options.length = 0;
                         CitiesBox.options[0] = new Option('-',0);
                         //$('#' + CitiesBox.getAttribute('id') + '').resetSS()
                } 
             }
             
        } 
        
        
        ajax.send('iCountryId=' + iCountryId);
    
}
*/

function changeRegions(bChangeCountry, bInicialize, sChange, showLoaders, bFirstPosition, onlyActive, bInsertAlsoCities){
    
    var sText = '-';
    var sText2 = '-';
    
    if(sChange == undefined){
       sChange = false;
    }
    if(showLoaders == undefined){
       showLoaders = false;
    }
    if(bFirstPosition == undefined){
       bFirstPosition = true;
    }
    if(onlyActive == undefined){
       onlyActive = 1;
    }
    if(bInsertAlsoCities == undefined){
    	bInsertAlsoCities = true;
    }
    
    //vars
    if(!bChangeCountry){
        var oCountry = document.getElementById('country');
        var oSelect = document.getElementById('region');
        var oHotel = document.getElementById('hotel');
        
        //clear cities too
        var oSelectCities = document.getElementById('city');
        
        oSelectCities.options.length = 0;
        oSelectCities.options[0] = new Option('-',0);
        oHotel.options.length = 0;
        oHotel.options[0] = new Option('-',0);
        
        disableElement('region', true);
        disableElement('city', true);
        disableElement('hotel', true);
        
     } else {
        var oCountry = document.getElementById('region');
        var oSelect = document.getElementById('city');
        var oHotel = document.getElementById('hotel');
        
        disableElement('city', true);
        disableElement('hotel', true);
        
        oHotel.options.length = 0;
        oHotel.options[0] = new Option('-',0);
        
        sText = aDictionarySearchTags[0];
        sText2 = aDictionarySearchTags[1];
     }
     
     if(sChange){
       var oCountry = document.getElementById('city');
       var oSelect = document.getElementById(sChange);
     }
     
    oSelect.options.length = 0;
    if(!sChange){
        oSelect.options[0] = new Option(sText,0);
    }
    if(bInicialize == undefined){
       bInicialize = false; 
    }     
       
    var iCountryId = oCountry.options[oCountry.selectedIndex].value;
       // alert(iCountryId)
    
    var iMaxLevelCountry = 0;
    if(parseInt($('#region').val()) > 0){
    	iMaxLevelCountry = $('#region').val();
    } else if(parseInt($('#country').val()) > 0){
    	iMaxLevelCountry = $('#country').val();
    }

    var ajax = getXMLHttpRequest();
        
        if(sChange){ 
          ajax.open('POST', getHostName() + '/searcher/getHotelsByCityId/', true );
        } else {
          ajax.open('POST', getHostName() + '/searcher/getRegionsByCountryId/', true );
        }
        
        if(showLoaders){
           jQuery('#ajax_options_dialog_box_loader').show();
        }
        
        ajax.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=UTF-8");
        ajax.setRequestHeader('X_REQUESTED_WITH', "XMLHttpRequest");
        ajax.onreadystatechange = function(){
                 
             if(ajax.readyState == 4){
                
                eval(ajax.responseText)
                
                for(var i=0; i<aDataParsed.length; i++){
                     oSelect.options[(!sChange ? (i+1) : i )] = new Option(aDataParsed[i][1],aDataParsed[i][0]);
                }
                if((!bChangeCountry || iCountryId != iMaxLevelCountry )&& typeof aDataParsedCities != 'undefined'){
                	for(var i=0; i<aDataParsedCities.length; i++){
                		document.getElementById('city').options[(!sChange ? (i+1) : i )] = new Option(aDataParsedCities[i][1],aDataParsedCities[i][0]);
                	}
                }
                
                
                //pokazujemy hotele
                oHotel.options.length = 0;
                if(bFirstPosition && !sChange){
			        oHotel.options[0] = new Option(sText2,0);
			    }
                if(aDataHotelParsed.length > 0){
                    
                    for(var i=0; i<aDataHotelParsed.length; i++){
                         oHotel.options[(bFirstPosition && !sChange ? (i+1) : i )] = new Option(aDataHotelParsed[i][1],aDataHotelParsed[i][0]);
                    }
                }
                //pokazujemy hotele
                
                
                
                
                
                if(!bChangeCountry){
                    disableElement('region', false);
                    disableElement('city', false);
                    disableElement('hotel', false);
                 } else {
                    disableElement('city', false);
                    disableElement('hotel', false);
                 }
                 
                 if(showLoaders){
		           jQuery('#ajax_options_dialog_box_loader').hide();
		        }
                
                if(bInicialize){
                     var CitiesBox = document.getElementById('city');
                         CitiesBox.options.length = 0;
                         CitiesBox.options[0] = new Option('-',0);
                } 
             }
             
        } 
        
        ajax.send('iCountryId=' + iCountryId 
        			+ '&onlyActive=' + onlyActive 
        			+ '&is_app_cms=' + (parseInt($('#is_app_cms').val()) == 1 ? 1 : 0) 
        			+ '&max_region_id=' + (iMaxLevelCountry)
        );
    
} 

function getHotelAjax(bFirst, showLoaders, onlyActive){
        
    if(bFirst == undefined){
       bFirst = true; 
    }
    if(onlyActive == undefined){
       onlyActive = 1; 
    }
    
    if(showLoaders == undefined){
       showLoaders = false;
    }
        
    var sText = '-';    
        disableElement('hotel', true);
        sText = aDictionarySearchTags[1];
        
    var oSelectCities = document.getElementById('hotel');
        oSelectCities.options.length = 0;
        oSelectCities.options[0] = new Option('-', 0);
       
    var oCity = document.getElementById('city');   
    var oRegion= document.getElementById('region');   
       
    var iRegion = parseInt(oCity.options[oCity.selectedIndex].value);    
    if(iRegion  == 0){
       iRegion = parseInt(oRegion.options[oRegion.selectedIndex].value);    
    }   
    
     if(showLoaders){
        jQuery('#ajax_options_dialog_box_loader').show();
     }
    
   
    var ajax = getXMLHttpRequest();
        ajax.open('POST', getHostName() + '/searcher/getComplexBylocationId/', true );

        ajax.setRequestHeader('Content-Type', "application/x-www-form-urlencoded; charset=UTF-8");
        ajax.setRequestHeader('X_REQUESTED_WITH', "XMLHttpRequest");
        
        ajax.onreadystatechange = function(){
             if(ajax.readyState == 4){
                eval(ajax.responseText);
                
                if(aDataParsed.length > 0){
                
                    oSelectCities.options.length = 0;
                    if(bFirst){
                       oSelectCities.options[0] = new Option(sText, 0);
                    }
                    
                    for(var i=0; i<aDataParsed.length; i++){
                         oSelectCities.options[(bFirst ? (i+1) : i)] = new Option(aDataParsed[i][1],aDataParsed[i][0]);
                    }
                }
                if(showLoaders){
                   jQuery('#ajax_options_dialog_box_loader').hide();
                }
                disableElement('hotel', false);
             }
        } 
        
        ajax.send('iLocationId=' + iRegion + '&onlyActive=' + onlyActive + '&is_app_cms=' + (parseInt($('#is_app_cms').val()) == 1 ? 1 : 0) );

}

function getHotelApartaments(showLoaders, bSelect, sHotel, bOmit){
    
    if(showLoaders == undefined){
       showLoaders = false;
    }
    if(bSelect == undefined){
       bSelect = true;
    }
    if(bOmit == undefined){
    	bOmit = false;
    }
    if(sHotel == undefined){
    	sHotel = 'hotel';
    }
    
    var aApartamentsId = new Array();
    var apartaments_list_hotel = document.getElementById('apartaments_list_hotel');
    
    var aApartametnsTypesId = new Array();
    jQuery('#apartaments_list_types option:selected').each(function(){
            aApartametnsTypesId.push(jQuery(this).val());
    });
    
    jQuery('#'  + sHotel + ' option:selected').each(function(){
        aApartamentsId.push(jQuery(this).val());
    });
    
    if(showLoaders){
           jQuery('#ajax_options_dialog_box_loader').show();
    }
    
    
    jQuery.post(getHostName() + "/searcher/getApartamentsByHotelsId", { hotels: "" + aApartamentsId.toString(), 
    																	types: "" + aApartametnsTypesId.toString()  + "", 
    																	bOmit: "" + (bOmit ? 1 : 0)    + "", 
    																	iFeature: ("" +  jQuery('#features_ap').length > 0 ? jQuery('#features_ap').val() : '') + ""  
    																}, function(data){
           apartaments_list_hotel.options.length = 0;
           eval(data);
           for(var i=0; i<aApartamentsData.length; i++){
                   apartaments_list_hotel.options[((i))] = new Option(aApartamentsData[i][1],aApartamentsData[i][0]);
                   if(bSelect){
                    apartaments_list_hotel.options[((i))].setAttribute('selected', 'selected');
                   }
                   
           }
           
           checkParamInfo();
           
            if(showLoaders){
		       jQuery('#ajax_options_dialog_box_loader').hide();
		    }
            
    });

}

function checkParamInfo(){
    
    if($('#apartaments_list_hotel option:selected').length == $('#apartaments_list_hotel option').length){
       $('#all_info_calendar').show();
       
       $('.bulk_row_hotel').addClass('row_el_red');
       $('.bulk_row_apartament').removeClass('row_el_red');
       
     } else {
       $('#all_info_calendar').hide();
       $('.bulk_row_hotel').removeClass('row_el_red');
       $('.bulk_row_apartament').addClass('row_el_red');
     }
    

}


function getClassNameDisplayEvent(promotion, first_minute, last_minute){
    
    if(parseInt(promotion)){
       return 'fc-promotion';
    } else if(parseInt(first_minute)){
       return 'fc-first_minute';
    } else if(parseInt(last_minute)){
       return 'fc-last_minute';
    } else {
       return '';
    }
    
}

function copyPasteDateSearch(){
    
    var sArrivalTime = jQuery('#arrival_time').val();
    var sDepartureTime= jQuery('#departure_time').val();
    var myDate=new Date();
   var sDate         = /(.*)-(.*)-(.*)/i;
    
      sDepartureTime = sDepartureTime.replace(/^\s+|\s+$/g, '') ; 
      aMatches  = sArrivalTime.match(sDate);
     
      myDate.setFullYear(aMatches[1]);
      myDate.setMonth((aMatches[2] -1));
      myDate.setDate((parseInt(aMatches[3]) + 7));
      
      //checkformat
      var iNewMonth = myDate.getMonth()+1;
      if(iNewMonth<10){
      
        iNewMonth = '0' + iNewMonth;
      }
      
      var iNewDay = myDate.getDate();
      if(iNewDay<10){
      
        iNewDay = '0' + iNewDay;
      }
      
        
      jQuery('#departure_time').val(myDate.getFullYear() + '-' + (iNewMonth) + '-' + iNewDay);
}

function changeSearcherTitle(){
        
        var iCountry = parseInt(jQuery('#country').val());
        if(iCountry  > 0){
           jQuery('#title_searcher_apartament_js').html('' + aDictionarySearchTags[3].replace('%1', document.getElementById('country').options[document.getElementById('country').selectedIndex].text) + '') 
        } else {
           jQuery('#title_searcher_apartament_js').html('' + aDictionarySearchTags[2] + '') 
        }
}

function changeOnlineOfflineDetailsInfo(){
    
    var bAdd = false;
      $('#info_on_of').html('');
    
    if($('#online').attr('checked')){
       $('#info_on_of').html(aDictionarySearchTags[2]);
       bAdd = true;
    }
    if($('#offline').attr('checked')){
        if(!bAdd){
	       $('#info_on_of').html(aDictionarySearchTags[3]);
        }else {
	       $('#info_on_of').append('<br />' + aDictionarySearchTags[3]);
        }
    }

}
