
$(document).ready(function() {
		$('.hide').hide();
		
		$('.send_friend').lightBox();
		
  		$('.bookmark').click(function() {
  			var $t = $(this);
  			var pcode = $t.attr('rel');
  			var $img = $('<img/>');
  			var $photo = $('#photo_'+pcode+' img');
  			$img.attr('src',$photo.attr('src'));
  			var offset = $photo.offset();
  			$('body').append($img);
  			$img.css({position:'absolute',top:offset.top,left:offset.left});
  			
  			var no = $('#my_properties_link').offset();
  			$img.animate({width:$('#my_properties_link').width()},{duration:2000,easing:'easeInOutSine',queue:false});
  			$img.animate({left:no.left,opacity:0},{duration:2500,easing:'easeInOutCubic',queue:false});
  			$img.animate({top:no.top},{duration:2500,easing:'easeInOutSine'}).remove();
  			
  			$t.fadeOut();
  		//	$img.hide();
  			$.get($t.attr('href'), function(data) {
 				$t.parent().find('.remove').fadeIn();
			});
  			
  			
  			return false;
  		});
  		
  		$('.remove').click(function() {
  			var $t = $(this);
  			$t.fadeOut();
  			$.get($t.attr('href'), function(data) {
 				var $b = $t.parent().find('a.bookmark');
 				$b.animate({width:$b.width()},1000).fadeIn();
			});
  			return false;
  			
  		})
  

		$('hr').each(function() {
			var $t = $(this);
			var $d = $('<div/>');
			$d.addClass('hr');
			$d.html('<hr/>');
			$t.after($d).remove();
		});



		$('#lettingsSearchForm').hide();
		$('#to_toggle').hide();

		$('#footer-more-toggle').click(function(){
			$('#to_toggle').slideToggle('slow');
		})

		var pictures = $('#s1').children("img");

		if (pictures.length > 1) {
			$('#s1').height( 320 );

			// The menu doesn't display properly in IE6. So disable the image rolling and only display the first image to fix.
			if ($.browser.msie && parseInt($.browser.version) <= 6) {
				$('#s1').children("img").filter(function (index) {return index > 0}).css('display', 'none');
			} else {

				$('#s1').cycle({
					fx: 'fade',
					speed: 2500
				});



			}
		}

		$('div.mainmenu ul').css('position','relative').css('z-index',999);


		switchSearch = function(which) {
			//alert("hallo "+which);
			if (which == "buy"){
				//alert("remove rent add buy")#;
				$('#searchBarTabRent').removeClass('selected');
				$('#searchBarTabBuy').addClass('selected');
				$('#salesSearchForm').show();
				$('#lettingsSearchForm').hide();
			} else if (which == "rent"){
				//alert("remove buy add rent");
				$('#searchBarTabBuy').removeClass('selected');
				$('#searchBarTabRent').addClass('selected');
				$('#salesSearchForm').hide();
				$('#lettingsSearchForm').show();
			}
		}

		

		$('.popup').click( function() {
			window.open( $(this).attr('href'), 'harrods' );
			return false;
		});

		var options = {
		imageLoading: '/assets/images/loading.gif',
		imageBtnClose: '/assets/images/lightbox-btn-close.gif',
		imageBtnPrev: '/assets/images/lightbox-btn-prev.gif',
		imageBtnNext: '/assets/images/lightbox-btn-next.gif',
		fixedNavigation:true
		}
		$('.detailsImageBox a, .lightbox').lightBox( options ); // Select all links in object with gallery ID

	
		$('.mainMenu ul > li').hover(function(){
		$(this).children('ul').css('display', 'block');
	},
function() { $(this).children('ul').css('display', 'none');
});
});
