	$(document).ready(function() {
		$('#date2').datepicker({ dateFormat: 'dd-mm-yy' });
		$('#date').datepicker({ dateFormat: 'dd-mm-yy' });				   
		

		$('ul#portfolio').innerfade({
			speed: 1000,
			timeout: 5000,
			type: 'sequence',
			containerheight: '281px'
		});
	
		$('.tabs .tab-active').show(); // show default content
		$('.tabs .header ul a').click(function(){
			$('.tabs .header ul li').removeClass('active');
			$(this).parent().addClass('active'); // make clicked tab active
			$('.tabs .tab').hide(); // hide all content
			$('.tabs').find('#' + $(this).attr('rel')).show(); // and show content related to clicked tab
			return false;
		});
		
		$("a.lightview").fancybox({'overlayShow': true, overlayOpacity:0.9,frameWidth:600,frameHeight:400 });
		
		$("a").focus(function () {
        	$(this).blur();
		});
		$("img.rollover").hover(function () {
			newsrc=$(this).attr('src').replace('.jpg','-over.jpg').replace('.png','-over.png');
        	$(this).attr('src',newsrc);
		},function () {
			newsrc=$(this).attr('src').replace('-over.jpg','.jpg').replace('-over.png','.png');
        	$(this).attr('src',newsrc);
		});
		$('.refno').Watermark('Reference Number');
		$('#visitor_subject').Watermark('Subject');
		$('.wysiwyg-full').ckeditor();
		var config = {
				toolbar:
					[
						['Format','TextColor','Bold','Italic','Underline','Strike'],
						['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
						['Link','Unlink'],['Maximize'],
						['NumberedList','BulletedList','Outdent','Indent'],
						['Undo','Redo','-','RemoveFormat'],
						['Cut','Copy','Paste','PasteText','PasteFromWord'],
					    ['Table','HorizontalRule','SpecialChar']
					],
				uiColor: '#dddddd'
				};
		$('.wysiwyg').each(function(index) {
			config.width=$(this).css('width');
			config.height=$(this).css('height');
			$(this).ckeditor(config);
		});
		
		
		$('#banner').corner('21px');
		$('.company-menu').corner('5px top');
		$('#link-left').corner('5px');
		$('.link-cat-inner-selected').corner('5px');
		
		setInterval( "slideSwitch()", 5000 );
		
		$('#visitor_fullname').Watermark('Name');
		$('#visitor_telephone').Watermark('Telephone');
		$('#visitor_email').Watermark('Email');
		$('#visitor_message').Watermark('Message');
		$('#feusers_signupform_name').Watermark('Name');
		$('#feusers_signupform_email').Watermark('Email');
		
		$("#footer-over").hover(function() {
	        $(this).animate({ left:"0", width:"900", padding:"10px 0 0 100px" }, 250);
	    }, function() {
	        $(this).animate({ left:"280px", width:"437", padding:"10px 0 0 0" }, 250);
	    });
	    
	    $('#visitor_email').focus(function(){$(this).css({'border':'#8F8F8F 1px solid'});});

	});
	
	function slideSwitch() {
		var $active = $('#slideshow IMG.active');

		if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

	    // use this to pull the images in the order they appear in the markup
		var $next =  $active.next().length ? $active.next()
				: $('#slideshow IMG:first');

	    // uncomment the 3 lines below to pull the images in random order
	    
	    // var $sibs  = $active.siblings();
	    // var rndNum = Math.floor(Math.random() * $sibs.length );
	    // var $next  = $( $sibs[ rndNum ] );


		$active.addClass('last-active');

		$next.css({opacity: 0.0})
			.addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
				$active.removeClass('active last-active');
		});
	}
	
	function clickSub(thediv){
		$.each($('.subs'),function(){				   
			if(this.id==thediv){
				if(this.style.display=='none')
				{
					$('#'+this.id).slideDown();
				}
				else
				{
					$('#'+this.id).slideUp();
				}
			}else{
				$('#'+this.id).slideUp();
			}
		});
	}
	
	function clickSub2(thediv,thetitle){
		$.each($('.link-title'),function(){			
			$('.link-title').css('color','#666666');
		});
		$.each($('.subs'),function(){				   
			if(this.id==thediv){
				if(this.style.display=='none')
				{
					$('#'+this.id).slideDown();
					$('#'+thetitle).css('color','#000');
				}
				else
				{
					$('#'+this.id).slideUp();
					$('#'+thetitle).css('color','#666666');
				}
			}else{
				$('#'+this.id).slideUp();
			}
		});
	}
	
	function sendEmail() {
		
		var x=$('#visitor_email').val();
		var atpos=x.indexOf("@");
		var dotpos=x.lastIndexOf(".");
		if (!isValidEmailAddress(x))
	 	{
	  		$('#visitor_email').css({'border':'#ff0000 1px solid'});
	  		return false;
	  	}
	  	else
	  	{	  	
			$('#submitbutton').attr("disabled","true");
			$.post('form-contactus.php?r='+Math.random(),{
				visitor_fullname: $('#visitor_fullname').val(),
				visitor_email: $('#visitor_email').val(),
				visitor_message: $('#visitor_message').val(),
				visitor_telephone: $('#visitor_telephone').val(),
				visitor_subject: $('#visitor_subject').val(),
				visitor_property: $('#visitor_property').val()
				},
				function (data) {
					if($('#visitor_property').val()!="")
					{
						window.top.location="http://www.simonmamo.com/en/property-thank-you.htm"
					}
					else
					{
						window.top.location="http://www.simonmamo.com/en/thank-you.htm"
					}
					$('#submitbutton').attr("disabled",false);
					$('#contactForm').html("");
				}
			);
			return false;
		}
	}
	
	
	
	function showcat(divid){
		$.each($('.categoriesselect'),function(){
			if(this.id!=divid){
				$('#'+this.id).css('display','none');
				$('#'+this.id).removeAttr('name','');
			}
			else{
				$('#'+this.id).css('display','block');
				if(this.id =="selected-cat6")
				{
					$('#'+this.id).attr('name','type1');
				}
				else
				{
					$('#'+this.id).attr('name','type');
				}
			
			}
		});
		
		
	}
	
	function showlocation(catid){
		$.each($('.locations'),function(){			
				$('#'+this.id).css('display','none');
				$('#'+this.id).attr('name','');
		});
		$.each($('.locations'),function(){
			if(this.id==catid){
				$('#'+this.id).css('display','block').attr('name','location');
			}
		});
		
		
	}
	
	function hideLocations(){
		$('.mapPopup').hide();
	
	}
	
	function showprice(from,to){
		$.each($('.from'),function(){
			if(this.id!=from){
				$('#'+this.id).css('display','none');
			}
			else{
				$('#'+this.id).css('display','block');
			}
		});
		$.each($('.to'),function(){
			if(this.id!=to){
				$('#'+this.id).css('display','none');
			}
			else{
				$('#'+this.id).css('display','block');
			}
		});
		
	}
	
	function processSubmit(){
		if ($('#location-1').is(':visible')){
			showlocation('location-1');
		}
	}
