/* Author: 

*/

  function initialize() {
    var latlng = new google.maps.LatLng(51.4926406357673,-0.14077541993339);
    var myOptions = {
      zoom: 14,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("google-map"),
        myOptions);

	var image = new google.maps.MarkerImage('img/map-icon.png',
      // This marker is 20 pixels wide by 32 pixels tall.
      new google.maps.Size(40, 57),
      // The origin for this image is 0,0.
      new google.maps.Point(0,0),
      // The anchor for this image is the base of the flagpole at 0,32.
      new google.maps.Point(20, 56));
      
	var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        icon: image
    });

    $('#full-screen-image').css('position','absolute');
  }

  jQuery(function($){
  	/*if ($('#contact').size()>0) {
  		initialize();
  	};*/

  	if ($('#floor-hover').size()>0) {
	  	$('#floor-hover a').live('mouseenter', function(){
	  		hoverSrc = $(this).attr('href');
	  		if (hoverSrc != $('#floor-image img').attr('src')) {
		  		$('#floor-image img').fadeOut(function(){
		  			$(this).attr('src', hoverSrc).load(function(){
		  				$(this).fadeIn();
		  			})
		  		})
	  		}

	  		if ($(this).hasClass('renaissance')) {
	  			$('.block1:visible').hide();
	  			$('.block1#renaissance').show();
	  		} else {
	  			$('.block1:not(":visible")').show();
	  			$('.block1#renaissance').hide();
		  	};

	  	})
  	};
	
/* IMAGE-ROTATION */	
	
	var sliderWidth = 0;
	var imageWidth = $('#image-slider img:first').width();
	var count = 0;
	var imageCount = 0;
	var imageLeft = 0;
	resizeOverlay();
	repositionImages();
	
	setInterval(function(){
		$('a.move-right').trigger('click');
	},6000)
	
	$('#image-slider img').each(function(){
		sliderWidth = sliderWidth + $(this).width();
//		$(this).addClass('move-'+count);
	//	count++;
	});

	$('#image-slider').width(sliderWidth);
	
	function resizeOverlay() {
		var overlayWidth = ($(window).width() - 932) / 2; // CHANGE THE 960 TO THE SIZE YOU WISH YOUR VIEWING WINDOW TO BE
		$('#left-overlay, #right-overlay').css({
			'opacity':'0.5',
			'width':overlayWidth
		});
	}
	
	function repositionImages() {
		imageLeft = 932 - (($(window).width() - 932) / 2); // CHANGE BOTS 960'S TO THE SIZE YOU WISH YOUR VIEWING WINDOW TO BE
		$('#image-slider img').css('left','-'+imageLeft+'px');
	}

	$('a.move-left').click(function(){
		if($('#image-slider img:not(":animated")').length != 0) {
			$('#image-slider img:first').addClass('move-0');
			firstImage = $('#image-slider').children('img.move-0').clone();
			$('#image-slider').width(sliderWidth+imageWidth);
			$('#image-slider').append(firstImage);
			$('#image-slider img').animate({'left':'-='+imageWidth}, 500 ,function(){
				$('#image-slider img:last').removeClass('move-0');
				$('#image-slider').children('img.move-0').remove();
				$('#image-slider img').css('left','-'+imageLeft+'px');
				$('.move-0').removeClass('move-0');
			})
		}
		return false;
	});

	$('a.move-right').click(function(){
		if($('#image-slider img:not(":animated")').length != 0) {
			$('#image-slider img:last').addClass('move-5');
			firstImage = $('#image-slider').children('img.move-5').clone();
			$('#image-slider').width(sliderWidth+imageWidth);
			$('#image-slider').prepend(firstImage);
			$('#image-slider img').css('left','-'+(imageLeft+imageWidth)+'px');
			$('#image-slider img').animate({'left':'+='+imageWidth}, 500 ,function(){
				$('#image-slider img:first').removeClass('move-5');
				$('#image-slider').children('img.move-5').remove();
				$('#image-slider img').css('left','-'+imageLeft+'px');
				$('.move-5').removeClass('move-5');
			})
		}
		return false;
	});
	
	$(window).resize(function(){
		repositionImages();
		resizeOverlay();
	})
	
/* DROP DOWN */

	if (!$.browser.opera) {

        $('select.select').each(function(){
            var title = $(this).attr('title');
            if( $('option:selected', this).val() != ''  ) title = $('option:selected',this).text();
            $(this)
                .css({'z-index':10,'opacity':0,'-khtml-appearance':'none'})
                .after('<span class="select">' + title + '</span>')
                .change(function(){
                    val = $('option:selected',this).text();
                    $(this).next().text(val);
                    })
        });

    };
	
	//DROPDOWN ERROR
	$('select').each(function () {
		if($(this).hasClass('serror')) {
			$(this).siblings('span.select').addClass('error-select');
		} 								   
	});
	

// FANCYBOX MAGNIFY

	$('ul.gallery li a').attr('rel','');	
	$("ul.gallery li a").append("<img src='img/bg/magnify.jpg' class='magnify' />");
	$(".magnify").css({"opacity": 0});
	
	$("ul.gallery li a").hover(function(){
		$(this).children(".magnify").stop(true, true).animate({"opacity": 0.77});						
	}, function(){
		$(this).children(".magnify").stop(true, true).animate({"opacity": 0});	
	});
	
// GALLERY PRETTYPHOTO
	
	$('ul.gallery a').attr('rel','prettyPhoto[gallery]');
	$("a[rel^='prettyPhoto']").prettyPhoto({
		theme: 'facebook',
		slideshow:5000,
		autoplay_slideshow:true,
		deeplinking: false
	});


/* END OF SCRIPT */
  })
