// JavaScript Project Document

function actCity() {
	var $actCity = $('#tmpFilterCity').attr('value');
	cityGuide($actCity);
	return $actCity;
	
}
function cityGuide($actCity) {
		
	switch($actCity)
		{
			case "london":
				$('div.small-block.cityGuide').show();
				$('div.small-block.cityGuide .inner.img .img-block img').attr('src','/images/project/LondonGuide.jpg');
				$('div.small-block.cityGuide .inner.img .img-block a').attr('href','http://in2days.projects42.de');
		    break;
		    case "paris":
				$('div.small-block.cityGuide').show();
				$('div.small-block.cityGuide .inner.img .img-block img').attr('src','/images/project/ParisGuide.jpg');
				$('div.small-block.cityGuide .inner.img .img-block a').attr('href','http://in2days.projects42.de');
		    break;
		    case "rom":
				$('div.small-block.cityGuide').show();
				$('div.small-block.cityGuide .inner.img .img-block img').attr('src','/images/project/RomGuide.jpg');
				$('div.small-block.cityGuide .inner.img .img-block a').attr('href','http://in2days.projects42.de');
		    break;
			case "new york":
				$('div.small-block.cityGuide').show();
				$('div.small-block.cityGuide .inner.img .img-block img').attr('src','/images/project/NewyorkGuide.jpg');
				$('div.small-block.cityGuide .inner.img .img-block a').attr('href','http://in2days.projects42.de');
		    break;
			case "wien":
				$('div.small-block.cityGuide').show();
				$('div.small-block.cityGuide .inner.img .img-block img').attr('src','/images/project/WienGuide.jpg');
				$('div.small-block.cityGuide .inner.img .img-block a').attr('href','http://in2days.projects42.de');
		    break;
			default: $('div.small-block.cityGuide').hide();
		}
	}
$(document).ready(function() {
	
	/* zeige lange Beschreibung bei Hover */
	
	$('.hotel-title').hover(
		function(){$(this).parent('.hotel-block').find('.longDescCont .longDesc').css('display','block').fadeIn()},
		function(){$(this).parent('.hotel-block').find('.longDesc').hide()}
	)

	$('#hotelListCities').change(function() {
		 $("#hotelListCities option:selected").each(function () {
               setTimeout("actCity()",300);
          });
	}).change();
	
	

	
    var $nSpan = $('.footer-menu span').length;
    var $iOne = 1;
    $('.footer-menu span').each(function(){
            if($iOne==$nSpan) {
                $(this).addClass('last');
            }
            $iOne++;
    });
    /* weiterempfehlen */
    $('.popup-open').click(function(){
          if($.browser['msie'] === true && $.browser.version < 9){
            $('.exposeMask, .popup').show();
          }
          else{
            $('.exposeMask').fadeIn(100);
            $('.popup').fadeIn(400);
          }
          return false;
        });
        $('.exposeMask').click(function(){
          if($.browser['msie'] === true && $.browser.version < 9) $('.exposeMask, .popup').hide();
          else $('.exposeMask, .popup').fadeOut(100);
          return false;
        });
        
        $('.hided-text').focus(function(){
          if($(this).val() == $(this).data('empty')) $(this).val('');
        })
        $('.hided-text').blur(function(){
          if($(this).val() == '') $(this).val($(this).data('empty'));
        });
        
    /* slider */
    $(".slider").jCarouselLite({
            btnNext: ".next",
            btnPrev: ".prev",
            auto: 6000,
            speed: 0,
                beforeStart: function(a) {
                $(a).parent().fadeTo(100, 0);
                var bg = $(a).find('img').attr('src');
                $('.anyClass').css({
                backgroundImage: "url("+bg+")"
                }, 1000);
                },
                afterEnd: function(a) {
                $(a).parent().fadeTo(1000, 1);
                }
        });
    $('.map-link').click(function(){
        if($.browser['msie'] === true && $.browser.version < 9){
            $(this).parents('.hotel-block').children('.hotel-map').toggle();
            $(this).parents('.event-block').children('.event-map').toggle();
        }
        else {
            $(this).parents('.hotel-block').children('.hotel-map').slideToggle();
            $(this).parents('.event-block').children('.event-map').slideToggle();
        }
        if($(this).text() === $(this).data('opened')){
          $(this).text($(this).data('closed'));
        }
        else{
          $(this).text($(this).data('opened'));
        }
        return false;
      });
	  
	  
        $('.popup-open').click(function(){
          if($.browser['msie'] === true && $.browser.version < 9){
            $('.exposeMask, .popup').show();
          }
          else{
            $('.exposeMask').fadeIn(100);
            $('.popup').fadeIn(400);
          }
          return false;
        });
        $('.exposeMask').click(function(){
          if($.browser['msie'] === true && $.browser.version < 9) $('.exposeMask, .popup').hide();
          else $('.exposeMask, .popup').fadeOut(100);
          return false;
        });
        
        
        $('.hided-text').focus(function(){
          if($(this).val() == $(this).data('empty')) $(this).val('');
        })
        $('.hided-text').blur(function(){
          if($(this).val() == '') $(this).val($(this).data('empty'));
        });
        
        /* list sort */
        $('.sort .act').toggle(
          function(){$(this).find('span').removeClass().addClass('arrow-up');},
          function(){$(this).find('span').removeClass().addClass('arrow-down');}
        );
        redirectToSplendia();
		
		$('.popup .closeBtn').click(function() {
			$('.exposeMask').hide();
			$(this).parent().hide();
		});
		
});

function redirectToSplendia() {
    var aHref;
    $('#redirectContainer').dialog({
        autoOpen: false,
        closeOnEscape: false,
        width: 795,
        height: 320,
        modal: true,
        resizable: false,
        zIndex: 2000,
        closeText: ''
    });
    
    $('a.redirect').click(function(){
        
        aHref = $(this).attr('href');
        var content = $(this).parents('.hotel-block').html();
        $('#redirectContainer').html(content + '<p class="loading">Sie werden gleich weitergeleitet...<small>Falls Sie nicht weitergeleitet werden klicken Sie <a href="'+aHref+'">hier</a></small></p><img src="/images/project/loading.gif" alt="loading..." />');
        $('#redirectContainer').dialog('open');
        setTimeout(function(){linking(aHref)}, 5000);
        $('#redirectContainer').dialog('close');
        return false;
    });
}
