  var slideNumber;
  var chat_timeout;
  var t;
  //var gotham_bold = { src: '/media/fonts/gothamrnd-bold.swf', ratios: [6, 1.24, 7, 1.21, 8, 1.18, 10, 1.16, 11, 1.13, 12, 1.12, 13, 1.11, 15, 1.1, 17, 1.09, 19, 1.08, 22, 1.07, 26, 1.06, 32, 1.05, 41, 1.04, 58, 1.03, 97, 1.02, 1.01] };
  //var gotham_medium = { src: '/media/fonts/gothamrnd-medium.swf', ratios: [6, 1.24, 7, 1.21, 8, 1.18, 10, 1.16, 11, 1.13, 12, 1.12, 13, 1.11, 15, 1.1, 17, 1.09, 19, 1.08, 22, 1.07, 26, 1.06, 32, 1.05, 41, 1.04, 58, 1.03, 97, 1.02, 1.01] };

  var gotham_bold = { src: 'http://static.europenethotels.com/gothamrnd-bold.swf', ratios: [6, 1.24, 7, 1.21, 8, 1.18, 10, 1.16, 11, 1.13, 12, 1.12, 13, 1.11, 15, 1.1, 17, 1.09, 19, 1.08, 22, 1.07, 26, 1.06, 32, 1.05, 41, 1.04, 58, 1.03, 97, 1.02, 1.01] };
  var gotham_medium = { src: 'http://static.europenethotels.com/gothamrnd-medium.swf', ratios: [6, 1.24, 7, 1.21, 8, 1.18, 10, 1.16, 11, 1.13, 12, 1.12, 13, 1.11, 15, 1.1, 17, 1.09, 19, 1.08, 22, 1.07, 26, 1.06, 32, 1.05, 41, 1.04, 58, 1.03, 97, 1.02, 1.01] };
  
  sIFR.useStyleCheck = true;
  sIFR.fixWrap = true;
  sIFR.forceWidth  = true;
  sIFR.useDomLoaded = true;
  sIFR.activate(gotham_bold, gotham_medium);

  
  
  sIFR.replace(gotham_bold, {
    selector: '.header, #page_right .header_small',
    css: ['.sIFR-root { color: #2b2a2a; font-size: 16px; }'],
    forceSingleLine: true,
    preventWrap: true,
    sharpness: -100,
    offsetTop: 3,
    wmode: 'transparent'
  });
  sIFR.replace(gotham_medium, {
    selector: '#vorstag h1',
    css: ['.sIFR-root { color: #2b2a2a; }',
          '.red { color: #f23502; }'],
    forceSingleLine: true,
    preventWrap: true,
    sharpness: -100,
    offsetTop: 3,
    wmode: 'transparent'
  });

	setHeaderSIFR();
	setPriceSIFR();
  
  $(function() {
    $('#menubar img').hover(function() {
      var img = this.src;
      this.src = img.replace(/_off/,'_on');
    }, function() {
      var img = this.src;
      this.src = img.replace(/_on/,'_off');
    });

    if (jQuery.isFunction(jQuery.fn.datePicker)) {
      date  = new Date();
      day   = (date.getDate()<10) ? '0'+date.getDate() : date.getDate();
      month = (date.getMonth()<9) ? '0'+(date.getMonth()+1) : date.getMonth()+1;
      $('.date-pick').datePicker({startDate: day+'/'+month+'/'+date.getFullYear(), endDate: '31/12/'+(date.getFullYear()+5), clickInput: true});
      $('.checkin').bind('dpClosed',
        function(e, selectedDates) {
          var ci = selectedDates[0];
          var co = $('.checkout').dpGetSelected();
          if (ci>=co) {
            ci = new Date(ci);
            $('.checkout').dpSetSelected(ci.addDays(1).asString()).val(ci.asString());
          }
        }
      );
      $('.checkout').bind('dpClosed',
        function(e, selectedDates) {
          var co = selectedDates[0];
          var ci = $('.checkin').dpGetSelected();
          if (co<=ci) {
            co = new Date(co);
            $('.checkin').dpSetSelected(co.addDays(-1).asString()).val(co.asString());
          }
        }
      );
    }
	/*
	$('#cities input[type="checkbox"]').change(function(){
	
		var li = $(this).parent('li');
		
		if ($(li).hasClass('active')) {
		
			$(li).removeClass('active').find('label.active').html('');
		}
		else{
			$(li).addClass('active').find('label.active').html('active');
		}
		
	});
	
	//Last minute apartment refreshing
	$("#lastMinuteSorting, #cities input[type='checkbox']").change(function(){
	
		getLmApartments();
	});
	*/
	
  });

  openChat = function() {
    $.get('chat?cmd=askname',function(data) {
      $('#window').remove();
      $('body').append('<div id="window"></div>');
      $('#window').html(data);
      $('#window').dialog({autoOpen: true, draggable: true, width: 'auto', height: 'auto', title: 'Customer chat', modal: true, overlay: {opacity: 0.5, background: 'black'} });
    });
  }

  sendName = function() {
    chat_name = $('#chat_name').val();
    $.get('chat?cmd=connect&name='+chat_name,function(data) {
      $('#window').dialog('close');
      $('#window').remove();
      $('body').append('<div id="window"></div>');
      $('#window').html(data);
      $('#window').dialog({autoOpen: true, draggable: true, width: 'auto', height: 'auto', title: 'Customer chat', modal: true, overlay: {opacity: 0.5, background: 'black'} });
    });
  }

  updateConnect = function(session) {
    chat_timeout = setTimeout(function() {
      $.get('chat?cmd=update&session='+session,function(data) {
        if (data) {
          $('#window').dialog('close');
          $('#window').remove();
          $('body').append('<div id="window"></div>');
          $('#window').html(data);
          $('#window').dialog({autoOpen: true, draggable: true, width: 'auto', height: 'auto', title: 'Customer chat', modal: true, overlay: {opacity: 0.5, background: 'black'} });
        } else updateConnect(session);
      });
    },1000);
  }

  updateConversation = function() {
    conversation_timeout = setTimeout(function() {
      $.get('chat?cmd=getmsgs&session='+current_session,function(data) {
        $('#conversation').html(data);
        if ($("#conversation").attr("scrollTop") > $("#conversation").attr("scrollHeight")-460)
          $("#conversation").attr({ scrollTop: $("#conversation").attr("scrollHeight") });
        updateConversation();
      });
    },1000);
  }

/*
  getLmApartments = function(){
  
	var sort = $("#lastMinuteSorting").val();
	var cities = [];
	var citynames = [];
	
	$('#cities.checkboxlist li.active').each(function(){
		cities.push($(this).find('input.id').val());
		citynames.push(($(this).find('label.city').text()).toLowerCase());
	});
	
	cities = cities.join(',');
	
	if (citynames.length == 1){
	
		$('#page_lastminutecities img:eq(0)')[0].src = 'http://images.europenethotels.com/cities/'+citynames[0]+'_header_big.jpg';
	}
	
	$.get('requests?cmd=getlmbycities&sort=' + sort + "&cities=" + cities, function(data) {

		var data = eval( "(" + data + ")" );
		var cities = eval(data.Cities);
		var headerHtml = data.HeaderHtml;
		
		$('.apartment-list').html('');
		$('.apartment-list').append(data.Html)
	
		setPriceSIFR();	
		
		if (cities.length > 0){
		
			if (cities.length == 1){
			
				$("#page_lastminutecities .price-group .price").html('- ' +cities[0].percent+ "%");
				$("#page_lastminutecities h2.cityname").html(cities[0].city);

				sIFR.replace(gotham_medium, {
					selector: '#page_lastminutecities .cityname',
					css: ['.sIFR-root{ color: #ffffff; font-size: 36px; text-transform:capitalize; }'],
					forceSingleLine: true,
					preventWrap: true,
					sharpness: -0,
					wmode: 'transparent'
				});
			
				if (cities[0].percent && cities[0].minprice){
				
					$("#page_lastminutecities .price-group").show();
					$("#page_lastminutecities .price-group .percent").html().replace(/[0-9]/, cities[0].percent);
					$("#page_lastminutecities .price-group .number").html().replace(/[0-9]/, cities[0].minprice);
				}
				else{
					$("#page_lastminutecities .price-group").hide();
				}
			}
			else{
			
				//var lmcities = [];
			
				//for (var i in cities){
				
					//if (cities[i].percent && cities[i].minprice){
					
						//lmcities.push(cities[i]);
					//}
				//}
				
				
				$("#page_lastminutecities ul.slides").html(headerHtml);
				$("#gallery li:gt(0)").css({opacity:0});
				slideNumber =  0;
				setHeaderSIFR();
				clearTimeout(t);
				t = setTimeout(rotateImage, 4000);
			}
		}
	});	  
  }
  */
  
  
function rotateImage(){

	$("#page_lastminutecities ul.slides li:eq("+slideNumber+")").animate({opacity:0}, 750);
	var count = $("#page_lastminutecities ul.slides li").length;
	slideNumber = (++slideNumber) % count;
	$("#page_lastminutecities ul.slides li:eq("+slideNumber+")").show().animate({opacity:1}, 750);
	setHeaderSIFR();
	t = setTimeout(rotateImage, 5000);
}

function setPriceSIFR(){

/*
  sIFR.replace(gotham_medium, {
    selector: ' .price >div, .price .text',
    css: ['.sIFR-root{ color: #ffffff; }'],
    forceSingleLine: true,
//    preventWrap: true,
    sharpness: -0,
    wmode: 'transparent',
	filters: {
        DropShadow: {
           distance: 1
          ,color: '#666'
          ,strength: 2
          ,alpha: .5
          ,blurX: 0
          ,blurY: 0
        }
    }
  });
*/
  sIFR.replace(gotham_medium, {
    selector: '.apartment-list .price .number',
    css: ['.sIFR-root{ color: #fbec71; }'],
    forceSingleLine: true,
//    preventWrap: true,
    sharpness: -0,
    wmode: 'transparent',
	filters: {
        DropShadow: {
           distance: 2
          ,color: '#666'
          ,strength: 3
          ,alpha: .5
          ,blurX: 0
          ,blurY: 0
        }
    }
  });


}

function setHeaderSIFR(){

  sIFR.replace(gotham_medium, {
    selector: '#page_lastminutecities .cityname',
    css: ['.sIFR-root{ color: #ffffff; font-size: 36px; text-transform:capitalize; }'],
    forceSingleLine: true,
    preventWrap: true,
    sharpness: -0,
    wmode: 'transparent'
  });
  
  sIFR.replace(gotham_medium, {
    selector: '.price-group .text1, .price-group .text, .price-group .percent',
    css: ['.sIFR-root{ color: #ffffff;}'],
    forceSingleLine: true,
    sharpness: -0,
	marginTop:0,
	marginBottom:0,
    wmode: 'transparent',
	filters: {
        DropShadow: {
           distance: 2
          ,color: '#666'
          ,strength: 3
          ,alpha: .5
          ,blurX: 0
          ,blurY: 0
        }
    }
  });
  
  sIFR.replace(gotham_medium, {
    selector: '.price-group .number',
    css: ['.sIFR-root{ color: #fbec71; }'],
    forceSingleLine: true,
//    preventWrap: true,
    sharpness: -0,
    wmode: 'transparent',
	filters: {
        DropShadow: {
           distance: 2
          ,color: '#666'
          ,strength: 3
          ,alpha: .5
          ,blurX: 0
          ,blurY: 0
        }
    }
  });

}