
      $(document).ready(function() {
          jQuery('.bron_active').click(function () { })
          jQuery('.bron_inactive').click(function () { swtitch_left_pane(this)})
          jQuery('.bron_btn').click(function () { click_bron()})
          jQuery('.podobr_btn').click(function () { click_podbor()})
          
          
            
		jQuery("#bron_start_day").datepicker(
		jQuery.extend({}, 
		jQuery.datepicker.regional["ru"], { 
		    showStatus: true, 
		    showOn: 'button',
		    buttonImage: "/DESIGN/SITE/images/uhotel/icon_calendar.gif", 
		    buttonImageOnly: true,
		    dateFormat: 'dd.mm.yy',
		    yearRange: '2009:2014'
		    
		})
		);
		jQuery("#bron_end_day").datepicker(
		jQuery.extend({}, 
		jQuery.datepicker.regional["ru"], { 
		    showStatus: true, 
		    showOn: "button", 
		    buttonImage: "/DESIGN/SITE/images/uhotel/icon_calendar.gif", 
		    buttonImageOnly: true,
		    dateFormat: 'dd.mm.yy',
		    yearRange: '2009:2014'
		})
		);
		
		init_panel();
                                           
  
      });
      
      
      function init_panel(){
      	var obj = new Object();
      	
//      	if( set_pane == 1 ){
//      		obj.id = 'podbor_c';
//      		swtitch_left_pane(obj);
//      		
//      		if( sort == 2 ) document.getElementById('podbor_sort').value = 2;
//      		
//      		hotels = explode(',', hotel);
//      		if(in_array('36', hotels)) document.getElementById('hotel_36').checked=true;
//      		if(in_array('45', hotels)) document.getElementById('hotel_45').checked=true;
//      		if(in_array('26', hotels)) document.getElementById('hotel_26').checked=true;
//      		
//      	}      	
      }
      
      
      
      function swtitch_left_pane(obj){
          //alert(obj.id)
          active = jQuery('.bron_active')
          inactive = jQuery('.bron_inactive')
          active.removeClass('bron_active').addClass('bron_inactive');
          inactive.removeClass('bron_inactive').addClass('bron_active');
          if( jQuery('.head2').length > 0 ){
              jQuery('.head').removeClass('head2');
          }else{
              jQuery('.head').addClass('head2');
          }
         
          if( obj.id == 'bron_c' ){
              jQuery('.bron_c').show();
              jQuery('.podbor_c').hide();
          }else{
               jQuery('.podbor_c').show();
               jQuery('.bron_c').hide();
          }
          
          $(".bron_active").unbind("click");
          jQuery('.bron_inactive').click(function () { swtitch_left_pane(this)})
          
      }
      
      
      function click_bron(site){
          var url = '/'+jQuery('#bron_hotel')[0].value+'/nomera/reserv/';
          url +='?start='+jQuery('#bron_start_day')[0].value+' '+jQuery('#bron_start_time')[0].value;
          url +='&end='+jQuery('#bron_end_day')[0].value+' '+jQuery('#bron_end_time')[0].value;
          document.location = url;
      }
      jQuery.prototype.toArray = function() {
        return [].concat(this);
        }
        
      function click_podbor(){
            var hotels = '';     
            var sort = '';       
            var url = '/uh/nomera';
            jQuery('input.podbor_check:checked').each( 
                function(){
                    hotels=hotels+this.value+','
                }
            )

          if(hotels=='')hotels='36,26,45,';
          url = url+'/'+hotels+'/'+jQuery('#podbor_sort')[0].value+'/';
          document.location = url;
 
      }

      function explode( delimiter, string ) {    // Split a string by string
    // 
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: kenneth
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 
    var emptyArray = { 0: '' };
 
    if ( arguments.length != 2
        || typeof arguments[0] == 'undefined'
        || typeof arguments[1] == 'undefined' )
    {
        return null;
    }
 
    if ( delimiter === ''
        || delimiter === false
        || delimiter === null )
    {
        return false;
    }
 
    if ( typeof delimiter == 'function'
        || typeof delimiter == 'object'
        || typeof string == 'function'
        || typeof string == 'object' )
    {
        return emptyArray;
    }
 
    if ( delimiter === true ) {
        delimiter = '1';
    }
 
    return string.toString().split ( delimiter.toString() );
}



function in_array(needle, haystack, strict) {    // Checks if a value exists in an array
    // 
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
 
    var found = false, key, strict = !!strict;
 
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
 
    return found;
}
