$(document).ready(function(){

	$(".footerbutton").click(function() {
		var salutation 	= $("#enewsSalutation option:selected").text();
		//alert( "dropdown4:" + $("#enewsSalutation option:selected").text() );
		var first 	= $("#enewsFirst").val();
		var last 	= $("#enewsLast").val();
		var email 	= $("#enewsEmail").val();
		var dataString = 'enewsSalutation='+ salutation + '&enewsFirst=' + first + '&enewsLast=' + last + '&enewsEmail=' + email;
		window.location = '/about/enewsletter?' + dataString;
		return false;
	});
	
	if ($('#salesforceForm').length > 0) {
		$("#salesforceForm").validate();
	}
	
	if ($('#salesforceFormFooter').length > 0) {
		$("#salesforceFormFooter").validate();
	}
	
	
	/*
	var subTableDiv = $("div.subDiv");
	var toggleCheck = $("input.toggleCheck");
	toggleCheck.is(":checked")
		? subTableDiv.show()
		: subTableDiv.hide();
	$("input.toggleCheck").click(function() {
		if (this.checked == true) {
			subTableDiv.slideDown("medium");
			
		} else {
			subTableDiv.slideUp("medium");
			$("form").valid();
		}
	}); 
	*/
	
	
	$('#news').innerfade({
		animationtype: 'slide',
		speed: 750,
		timeout: 3000,
		type: 'random',
		containerheight: '1em'
	});
	
	
	 $("a.lightbox").fancybox({
         'overlayOpacity'        : 0.9,
         'overlayColor'          : '#000'
	 });

	
	$("a.videobox").click(function() {
        $.fancybox({
         'padding'             : 0,
         'autoScale'   : false,
         'transitionIn'        : 'none',
         'transitionOut'       : 'none',
         'title'               : this.title,
         'overlayOpacity'      : 0.9,
         'overlayColor'        : '#000',
         'width'               : 680,
         'height'              : 495,
         'href'                : this.href = this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
         'type'                : 'swf',    // <--add a comma here
         'swf'                 : {'allowfullscreen':'true'} // <-- flashvars here
         });
        return false;

   }); 
	
	
	$("a[rel=image_group]").fancybox({
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'titlePosition' 	: 'over',
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		},
		'onComplete'	:	function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			});
		}
	});
	
	
	var windW = (document.documentElement.clientWidth);
	var windH = (document.documentElement.scrollHeight);
	//alert(windW + " " + windH);
	
	var bottomP = windH - 425 - 1000 - 122;
	var leftP = -153;
	//.css({'margin-left': winW + 'px'});
	//$('#body').css({backgroundPosition: leftP + 'px ' + bottomP + 'px'});
	
	
	//$('#js-news').ticker();
	
	//var speed = 200;
	/*
	var pause = 5000;
	
	function newsticker()
	{
		//alert("tick...");
	    last = $('ul#listticker li:last').hide().remove();
	    $('ul#listticker').prepend(last).hide().fadeIn();
        //$('ul#listticker li:first').slideDown();
	    $('ul#listticker li:first').fadeOut().slideDown();
	}
	
	var intervalTicker = setInterval(newsticker, pause);
	
	
	$('ul#listticker li a').live("mouseover", function(evt) {
		//alert("over ticker li a");
		clearInterval(intervalTicker);
	}).live("mouseout", function(evt) {
		//alert("out ticker li a");
		intervalTicker = setInterval(newsticker, pause);
	});
	*/
	
	
	/************ SEARCH *************/
	
	$(".searchbutton").click(function() {
		if(this.id == 'submitResidential') {
			var location 	= $("input#aLocationInput").val().toLowerCase();
			if(location == 'all locations') location = 'all';
			else if(location == 'cbd and docklands') location = 'cbd';
			else if(location == 'inner east') location = 'ie';
			else if(location == 'north west') location = 'nw';
			else if(location == 'south east') location = 'se';
			
			var type 		= $("input#aTypeInput").val().toLowerCase();
			var size 		= $("input#aSizeInput").val().toLowerCase();
			if(size == '1 bedroom') size = '1';
			else if(size == '2 bedroom') size = '2';
			else if(size == '3 bedroom') size = '3';
			else if(size == '4 bedroom') size = '4';
			
			var minprice 	= $("input#mPriceInput").val().toLowerCase();
			if(minprice == 'min') minprice = 'all';
			else if(minprice == '$100,000') minprice = '100000';
			else if(minprice == '$200,000') minprice = '200000';
			else if(minprice == '$300,000') minprice = '300000';
			else if(minprice == '$400,000') minprice = '400000';
			else if(minprice == '$500,000') minprice = '500000';
			else if(minprice == '$600,000') minprice = '600000';
			else if(minprice == '$700,000') minprice = '700000';
			else if(minprice == '$800,000') minprice = '800000';
			else if(minprice == '$900,000') minprice = '900000';
			else if(minprice == '$1m') 		minprice = '1000000';
			else if(minprice == '$1.25m') 	minprice = '1250000';
			else if(minprice == '$1.5m')	minprice = '1500000';
			else if(minprice == '$1.75m') 	minprice = '1750000';
			else if(minprice == '$2m+') 	minprice = '2000000';
			
			var maxprice 	= $("input#maxPriceInput").val().toLowerCase();
			if(maxprice == 'max') maxprice = 'all';
			else if(maxprice == '$100,000') maxprice = '100000';
			else if(maxprice == '$200,000') maxprice = '200000';
			else if(maxprice == '$300,000') maxprice = '300000';
			else if(maxprice == '$400,000') maxprice = '400000';
			else if(maxprice == '$500,000') maxprice = '500000';
			else if(maxprice == '$600,000') maxprice = '600000';
			else if(maxprice == '$700,000') maxprice = '700000';
			else if(maxprice == '$800,000') maxprice = '800000';
			else if(maxprice == '$900,000') maxprice = '900000';
			else if(maxprice == '$1m') 		maxprice = '1000000';
			else if(maxprice == '$1.25m') 	maxprice = '1250000';
			else if(maxprice == '$1.5m')	maxprice = '1500000';
			else if(maxprice == '$1.75m') 	maxprice = '1750000';
			else if(maxprice == '$2m+') 	maxprice = '2000000';
			
			var dataString = 'category=residential&location='+ location + '&type=' + type + '&size=' + size+ '&min=' + minprice + '&max=' + maxprice;
		} else if(this.id == 'submitCommercial') {
			var location 	= $("input#aCLocationInput").val().toLowerCase();
			if(location == 'all locations') location = 'all';
			else if(location == 'cbd and docklands') location = 'cbd';
			else if(location == 'inner east') location = 'ie';
			else if(location == 'north west') location = 'nw';
			else if(location == 'south east') location = 'se';
			
			var type 		= $("input#aCTypeInput").val().toLowerCase();
			var size 		= $("input#aCSizeInput").val().toLowerCase();
			if(size == '1-100sqm') size = '1-100';
			else if(size == '101-500sqm') 	size = '101-500';
			else if(size == '500-1000sqm')	size = '500-1000';
			else if(size == '1,000sqm +') size = '1001';
			
			var minprice 	= $("input#mCPriceInput").val().toLowerCase();
			if(minprice == 'min') minprice = 'all';
			else if(minprice == '$100,000') minprice = '100000';
			else if(minprice == '$200,000') minprice = '200000';
			else if(minprice == '$300,000') minprice = '300000';
			else if(minprice == '$400,000') minprice = '400000';
			else if(minprice == '$500,000') minprice = '500000';
			else if(minprice == '$600,000') minprice = '600000';
			else if(minprice == '$700,000') minprice = '700000';
			else if(minprice == '$800,000') minprice = '800000';
			else if(minprice == '$900,000') minprice = '900000';
			else if(minprice == '$1m') 		minprice = '1000000';
			else if(minprice == '$1.25m') 	minprice = '1250000';
			else if(minprice == '$1.5m')	minprice = '1500000';
			else if(minprice == '$1.75m') 	minprice = '1750000';
			else if(minprice == '$2m+') 	minprice = '2000000';
			
			var maxprice 	= $("input#maxCPriceInput").val().toLowerCase();
			if(maxprice == 'max') maxprice = 'all';
			else if(maxprice == '$100,000') maxprice = '100000';
			else if(maxprice == '$200,000') maxprice = '200000';
			else if(maxprice == '$300,000') maxprice = '300000';
			else if(maxprice == '$400,000') maxprice = '400000';
			else if(maxprice == '$500,000') maxprice = '500000';
			else if(maxprice == '$600,000') maxprice = '600000';
			else if(maxprice == '$700,000') maxprice = '700000';
			else if(maxprice == '$800,000') maxprice = '800000';
			else if(maxprice == '$900,000') maxprice = '900000';
			else if(maxprice == '$1m') 		maxprice = '1000000';
			else if(maxprice == '$1.25m') 	maxprice = '1250000';
			else if(maxprice == '$1.5m')	maxprice = '1500000';
			else if(maxprice == '$1.75m') 	maxprice = '1750000';
			else if(maxprice == '$2m+') 	maxprice = '2000000';
			var dataString = 'category=commercial&location='+ location + '&type=' + type + '&size=' + size+ '&min=' + minprice + '&max=' + maxprice;
		} else if(this.id == 'submitIndustrial') {
			var location 	= $("input#aILocationInput").val().toLowerCase();
			if(location == 'all locations') location = 'all';
			else if(location == 'cbd and docklands') location = 'cbd';
			else if(location == 'inner east') location = 'ie';
			else if(location == 'north west') location = 'nw';
			else if(location == 'south east') location = 'se';
			
			var type 		= $("input#aITypeInput").val().toLowerCase();
			var size 		= $("input#aISizeInput").val().toLowerCase();
			if(size == '1-100sqm') size = '1-100';
			else if(size == '101-500sqm') 	size = '101-500';
			else if(size == '500-1000sqm')	size = '500-1000';
			else if(size == '1,000sqm +') size = '1001';
			
			var minprice 	= $("input#mIPriceInput").val().toLowerCase();
			if(minprice == 'min') minprice = 'all';
			else if(minprice == '$100,000') minprice = '100000';
			else if(minprice == '$200,000') minprice = '200000';
			else if(minprice == '$300,000') minprice = '300000';
			else if(minprice == '$400,000') minprice = '400000';
			else if(minprice == '$500,000') minprice = '500000';
			else if(minprice == '$600,000') minprice = '600000';
			else if(minprice == '$700,000') minprice = '700000';
			else if(minprice == '$800,000') minprice = '800000';
			else if(minprice == '$900,000') minprice = '900000';
			else if(minprice == '$1m') 		minprice = '1000000';
			else if(minprice == '$1.25m') 	minprice = '1250000';
			else if(minprice == '$1.5m')	minprice = '1500000';
			else if(minprice == '$1.75m') 	minprice = '1750000';
			else if(minprice == '$2m+') 	minprice = '2000000';
			
			var maxprice 	= $("input#maxIPriceInput").val().toLowerCase();
			if(maxprice == 'max') maxprice = 'all';
			else if(maxprice == '$100,000') maxprice = '100000';
			else if(maxprice == '$200,000') maxprice = '200000';
			else if(maxprice == '$300,000') maxprice = '300000';
			else if(maxprice == '$400,000') maxprice = '400000';
			else if(maxprice == '$500,000') maxprice = '500000';
			else if(maxprice == '$600,000') maxprice = '600000';
			else if(maxprice == '$700,000') maxprice = '700000';
			else if(maxprice == '$800,000') maxprice = '800000';
			else if(maxprice == '$900,000') maxprice = '900000';
			else if(maxprice == '$1m') 		maxprice = '1000000';
			else if(maxprice == '$1.25m') 	maxprice = '1250000';
			else if(maxprice == '$1.5m')	maxprice = '1500000';
			else if(maxprice == '$1.75m') 	maxprice = '1750000';
			else if(maxprice == '$2m+') 	maxprice = '2000000';
			var dataString = 'category=industrial&location='+ location + '&type=' + type + '&size=' + size+ '&min=' + minprice + '&max=' + maxprice;
		} else if(this.id == 'submitRetail') {
			var location 	= $("input#aRLocationInput").val().toLowerCase();
			if(location == 'all locations') location = 'all';
			else if(location == 'cbd and docklands') location = 'cbd';
			else if(location == 'inner east') location = 'ie';
			else if(location == 'north west') location = 'nw';
			else if(location == 'south east') location = 'se';
			
			var type 		= $("input#aRTypeInput").val().toLowerCase();
			var size 		= $("input#aRSizeInput").val().toLowerCase();
			if(size == '1-100sqm') size = '1-100';
			else if(size == '101-500sqm') 	size = '101-500';
			else if(size == '500-1000sqm')	size = '500-1000';
			else if(size == '1,000sqm +') size = '1001';
			
			var minprice 	= $("input#mRPriceInput").val().toLowerCase();
			if(minprice == 'min') minprice = 'all';
			else if(minprice == '$100,000') minprice = '100000';
			else if(minprice == '$200,000') minprice = '200000';
			else if(minprice == '$300,000') minprice = '300000';
			else if(minprice == '$400,000') minprice = '400000';
			else if(minprice == '$500,000') minprice = '500000';
			else if(minprice == '$600,000') minprice = '600000';
			else if(minprice == '$700,000') minprice = '700000';
			else if(minprice == '$800,000') minprice = '800000';
			else if(minprice == '$900,000') minprice = '900000';
			else if(minprice == '$1m') 		minprice = '1000000';
			else if(minprice == '$1.25m') 	minprice = '1250000';
			else if(minprice == '$1.5m')	minprice = '1500000';
			else if(minprice == '$1.75m') 	minprice = '1750000';
			else if(minprice == '$2m+') 	minprice = '2000000';
			
			var maxprice 	= $("input#maxRPriceInput").val().toLowerCase();
			if(maxprice == 'max') maxprice = 'all';
			else if(maxprice == '$100,000') maxprice = '100000';
			else if(maxprice == '$200,000') maxprice = '200000';
			else if(maxprice == '$300,000') maxprice = '300000';
			else if(maxprice == '$400,000') maxprice = '400000';
			else if(maxprice == '$500,000') maxprice = '500000';
			else if(maxprice == '$600,000') maxprice = '600000';
			else if(maxprice == '$700,000') maxprice = '700000';
			else if(maxprice == '$800,000') maxprice = '800000';
			else if(maxprice == '$900,000') maxprice = '900000';
			else if(maxprice == '$1m') 		maxprice = '1000000';
			else if(maxprice == '$1.25m') 	maxprice = '1250000';
			else if(maxprice == '$1.5m')	maxprice = '1500000';
			else if(maxprice == '$1.75m') 	maxprice = '1750000';
			else if(maxprice == '$2m+') 	maxprice = '2000000';
			var dataString = 'category=retail&location='+ location + '&type=' + type + '&size=' + size+ '&min=' + minprice + '&max=' + maxprice;
		}
		//alert(dataString);
		window.location = '/property/search?' + dataString;
		return false;
	});
	
	
	$('#searchSlider').css('display', 'block');
	
	// Get natural height.
	var displacement = $('#searchSlider .container').outerHeight();
	
	// Set negative top margin based on evaluated height.
	$('#searchSlider').css('height', 0).data('natural-height', displacement);
	$('#searchSlider .contentHolder').css(
	{
		position: 'absolute', 
		left: 0, 
		bottom: 0, 
		width: '100%'
	});
	
	// Toggle event.
	$('.quote-trigger').click(function(e)
	{
		
		e.preventDefault();
		
		var jtriggers = $('.quote-trigger');

		var displacement = $('#searchSlider').data('natural-height');
		if($('#btn-click').hasClass('maximised'))
		{
			oe_overlay.stop(true,true).fadeOut(200, function(){ oe_overlay.css('height','0%').css('width','0%'); });
			$('#searchSlider').animate({height: 0}, 700, function(){ opaque.css('display', 'block'); jtriggers.removeClass('maximised');});
		}
		else
		{
			oe_overlay.stop(true,true).css('width','100%').css('height','100%').fadeTo(200, 0.6);
			opaque.css('display', 'none');
			// Maximise.
			$('#searchSlider').animate(
			{
				height: displacement
			}, 700, function()
			{
				jtriggers.addClass('maximised');
			});
		}
	});
	
	$('#closeButSearch').click(function(e)
	{
		oe_overlay.stop(true,true).fadeOut(200, function(){ oe_overlay.css('height','0%').css('width','0%'); });
		var jtriggers = $('.quote-trigger');
		$('#searchSlider').animate({height: 0}, 700, function(){ opaque.css('display', 'block'); jtriggers.removeClass('maximised');});
	});
	
	
	
	/******* end SEARCH *******/
	
	var oe_overlay		= $('#oe_overlay');
	
	if ($('#tj_container').length > 0) {
		$('#tj_container').gridnav({
			type	: {
				mode		: 'seqfade', 	// use def | fade | seqfade | updown | sequpdown | showhide | disperse | rows
				speed		: 500,			// for fade, seqfade, updown, sequpdown, showhide, disperse, rows
				easing		: '',			// for fade, seqfade, updown, sequpdown, showhide, disperse, rows	
				factor		: 100,			// for seqfade, sequpdown, rows
				reverse		: ''			// for sequpdown
			}
		});
	}
	

	
	$('.overlay a').hover(function () {
	        $(this).find(":eq(2)").css({"color":"#ccc"}).animate({
	                'margin-left': '10px'
	        }, 200);
	}, function () {
			$(this).find(":eq(2)").css({"color":"#fff"}).animate({
	                'margin-left': '0px'
	        }, 200);
	});
	
	
	$('.mabButton').hover(function () {
	        $(this).animate({
	                'background-position': '-4px -23px'
	        }, 200);
	}, function () {
	        $(this).animate({
	                'background-position': '0px -23px'
	        }, 200);
	});
	
	$('#projectTabs a').hover(function () {
	        $(this).animate({
	                'background-position': '95% 50%'
	        }, 200);
	}, function () {
	        $(this).animate({
	                'background-position': '100% 50%'
	        }, 200);
	});
	
	
	$('input.mabBut').hover(function () {
	        $(this).animate({
	                'background-position': '-4px -22px'
	        }, 200);
	}, function () {
	        $(this).animate({
	                'background-position': '0px -22px'
	        }, 200);
	});
	
	
	
	$('#projectSidebarMenu li:not(.active)').hoverIntent(function () {
	        $(this).animate({
	                'background-position': '4% 50%'
	        }, 200);
	}, function () {
	        $(this).animate({
	                'background-position': '0% 50%'
	        }, 200);
	});
	
	

	$("label.infield").inFieldLabels();

	
	$("#tabs" ).tabs();
	
	
	// ---------- Search Dropdowns --------- //
	var locationDDown = $('ul.locationDDown'), typeDDown = $('ul.typeDDown'), sizeDDown = $('ul.sizeDDown'), minPriceDDown = $('ul.mPriceDDown'), maxPriceDDown = $('ul.maxPriceDDown') ;
	var lDDown = 0,tDDown = 0,sDDown = 0,mPriceDDown = 0,mxPriceDDown = 0;
	
	$('div.locationDDown > div').click(function () {
        if (lDDown) {
            esclocationDDown();
        } else {
        	//var heighter = $('ul.locationDDown li').size() * 24;
        	var heighter = $(this).next().children().length * 24;
        	locationDDown.css({ 'height': 0, 'z-index' : '10000'  });
            lDDown = 1;
            locationDDown.stop().show().animate({height: heighter}, 300);
        }
    });
    $('div.locationDDown').mouseleave(function () {
    	esclocationDDown();
    });
    $('ul.locationDDown li').each(function () {
        $(this).click(function () {
        	//var txt = $(this).text();
        	$(this).parent().prev().children(":input").val($(this).text());
            esclocationDDown();
        });
    });
    function esclocationDDown() {
    	lDDown = 0;
    	locationDDown.stop().animate({ height: 0 }, 300, "easeOutSine", function () { locationDDown.hide(); locationDDown.css({ 'z-index' : 1  }); });
    }
    
    // ----- type
    
    $('div.typeDDown > div').click(function () {
        if (tDDown) {
            esctypeDDown();
        } else {
        	var heighter = $(this).next().children().length * 24;
        	typeDDown.css({ 'height': 0  });
            tDDown = 1;
            typeDDown.stop().show().animate({height: heighter}, 300);
        }
    });
    $('div.typeDDown').mouseleave(function () {
    	esctypeDDown();
    });
    $('ul.typeDDown li').each(function () {
        $(this).click(function () {
            //if($(this).text() == 'Serviced Apartments') $(this).parent().prev().children(":input").val('Serviced'); //$('#typeInput').val('Serviced');
            //else $(this).parent().prev().children(":input").val($(this).text()); //else $('#typeInput').val($(this).text());
        	$(this).parent().prev().children(":input").val($(this).text());
            esctypeDDown();
        });
    });
    function esctypeDDown() {
    	tDDown = 0;
    	typeDDown.stop().animate({ height: 0 }, 300, "easeOutSine", function () { typeDDown.hide(); });
    }
    
    // ----- size
    
    $('div.sizeDDown > div').click(function () {
        if (sDDown) {
            escsizeDDown();
        } else {
        	var heighter = $(this).next().children().length * 24;
        	sizeDDown.css({ 'height': 0  });
            sDDown = 1;
            sizeDDown.stop().show().animate({height: heighter}, 300);
        }
    });
    $('div.sizeDDown').mouseleave(function () {
    	escsizeDDown();
    });
    $('ul.sizeDDown li').each(function () {
        $(this).click(function () {
            
        	/*
        	// for apartments...
        	if( $(this).parent().hasClass('bedrooms') ) {
        		if($(this).text().length > 4) $(this).parent().prev().children(":input").val($(this).text().substring(0,1)); 
        		else $(this).parent().prev().children(":input").val($(this).text());
        	} else{ //for all others...
        		$(this).parent().prev().children(":input").val($(this).text()); 
        	}
            */
        	$(this).parent().prev().children(":input").val($(this).text()); 
        	escsizeDDown();
        });
    });
    function escsizeDDown() {
    	sDDown = 0;
    	sizeDDown.stop().animate({ height: 0 }, 300, "easeOutSine", function () { sizeDDown.hide();  });
    }
    
    // ----- mPrice
    
    $('div.mPriceDDown > div').click(function () {
        if (mPriceDDown) {
            escmPriceDDown();
        } else {
        	var heighter = $(this).next().children().length * 24;
        	minPriceDDown.css({ 'height': 0  });
            mPriceDDown = 1;
            minPriceDDown.stop().show().animate({height: heighter}, 300);
			
        }
    });
    $('div.mPriceDDown').mouseleave(function () {
    	escmPriceDDown();
    });
    $('ul.mPriceDDown li').each(function () {
        $(this).click(function () {
            
        	//if($(this).text().length > 6) $(this).parent().prev().children(":input").val($(this).text().substring(0,4) + 'k'); //$('#mPriceInput').val( $(this).text().substring(0,4) + ' k' ) ;
        	//else $(this).parent().prev().children(":input").val($(this).text());
        	$(this).parent().prev().children(":input").val($(this).text()); 
            escmPriceDDown();
        });
    });
    function escmPriceDDown() {
    	mPriceDDown = 0;
    	minPriceDDown.stop().animate({ height: 0 }, 300, "easeOutSine", function () { minPriceDDown.hide(); });
    }
    
    // ----- maxPrice
    
    $('div.maxPriceDDown > div').click(function () {
        if (mxPriceDDown) {
            escmaxPriceDDown();
        } else {
        	var heighter = $(this).next().children().length * 24;
        	maxPriceDDown.css({ 'height': 0  });
            mxPriceDDown = 1;
            maxPriceDDown.stop().show().animate({height: heighter}, 300);
			
        }
    });
    $('div.maxPriceDDown').mouseleave(function () {
    	escmaxPriceDDown();
    });
    $('ul.maxPriceDDown li').each(function () {
        $(this).click(function () {
            
        	//if($(this).text().length > 6) $(this).parent().prev().children(":input").val($(this).text().substring(0,4) + 'k'); //$('#mPriceInput').val( $(this).text().substring(0,4) + ' k' ) ;
        	//else $(this).parent().prev().children(":input").val($(this).text());
        	$(this).parent().prev().children(":input").val($(this).text()); 
            escmaxPriceDDown();
        });
    });
    function escmaxPriceDDown() {
    	mxPriceDDown = 0;
    	maxPriceDDown.stop().animate({ height: 0 }, 300, "easeOutSine", function () { maxPriceDDown.hide(); });
    }

	
    
    
    
	var opaque		= $('#opaque');
	
	/************** MENU *************/
					   
	var oe_menu		= $('#oe_menu');
	var oe_menu_items	= oe_menu.children('li');
	
	
	/*
	oe_menu_items.bind('mouseenter',function(){
		if(!$('#btn-click').hasClass('maximised')) {
			var jthis = $(this);
			opaque.css('display', 'none');
			jthis.addClass('slided selected');
			//$this.children('div').css('z-index','9999').stop(true,true).slideDown(200,function(){
			jthis.children('div').css('z-index','9999').stop(true,true).fadeIn(200,function(){																					 
				oe_menu_items.not('.slided').children('div').hide();
				jthis.removeClass('slided');
				
			});
			$("#arrows .rightArrow").css('display', 'none');
			$("#arrows .leftArrow").css('display', 'none');
		}
	}).bind('mouseleave',function(){
		if(!$('#btn-click').hasClass('maximised')) { opaque.css('display', 'block'); }
		$("#arrows .rightArrow").css('display', 'block');
		$("#arrows .leftArrow").css('display', 'block');
		var jthis = $(this);
		jthis.removeClass('selected').children('div').css('z-index','1000');
	});*/
	
	
	/*
	 * background:transparent url(/images/dropdownSymbol.png) no-repeat scroll 50% 100% ;
	 */
	
	oe_menu_items.hoverIntent(function () {
		if(!$('#btn-click').hasClass('maximised')) {
			var jthis = $(this);
			//alert($(window).width());
			var diff = ($(window).width() - 992)/2;
			jthis.children('div').css('width',$(window).width());
			jthis.children('div').css('left',-diff);
			
			jthis.addClass('slided selected');
			//$this.children('div').css('z-index','9999').stop(true,true).slideDown(200,function(){
			jthis.children('div').css('z-index','9999').stop(true,true).fadeIn(200,function(){																					 
				oe_menu_items.not('.slided').children('div').hide();
				jthis.removeClass('slided');
				
			});
			
		}
	}, function () {
		//if(!$('#btn-click').hasClass('maximised')) { opaque.css('display', 'block'); }
		
		var jthis = $(this);
		jthis.removeClass('selected').children('div').css('z-index','1000');
	});
	
	oe_menu.hoverIntent(function () {
		opaque.css('display', 'none');
		var jthis = $(this);
		//oe_overlay.css('width','100%').css('height','100%');
		oe_overlay.stop(true,true).css('width','100%').css('height','100%').fadeTo(200, 0.6);
		
		jthis.addClass('hovered');
		$("#arrows .rightArrow").css('display', 'none');
		$("#arrows .leftArrow").css('display', 'none');
	}, function () {
		var jthis = $(this);
		jthis.removeClass('hovered');
		if(!$('#btn-click').hasClass('maximised')) { opaque.css('display', 'block'); }
		
		//oe_overlay.css('width','100%')
		if(!$('#btn-click').hasClass('maximised')) oe_overlay.stop(true,true).fadeTo(200, 0).css('height','0%').css('width','0%');
		
		oe_menu_items.children('div').fadeOut(100);
		$("#arrows .rightArrow").css('display', 'block');
		$("#arrows .leftArrow").css('display', 'block');
	});
	
	
	
	/*
	oe_menu.bind('mouseenter',function(){
		var jthis = $(this);
		//$oe_overlay.stop(true,true).fadeTo(200, 0.6);
		jthis.addClass('hovered');
		$("#arrows .rightArrow").css('display', 'none');
		$("#arrows .leftArrow").css('display', 'none');
	}).bind('mouseleave',function(){
		var jthis = $(this);
		jthis.removeClass('hovered');
		//$oe_overlay.stop(true,true).fadeTo(200, 0);
		oe_menu_items.children('div').fadeOut(100);
		$("#arrows .rightArrow").css('display', 'block');
		$("#arrows .leftArrow").css('display', 'block');
	});
	*/	 
	
	/************** END: MENU *************/
						   
						   
						   
	/************** HOMEPAGE SLIDER *************/				   
													 						
	var bannerPause = 7000;
	var bannerTimer;
	
	var bannerIsSliding;
	var bannerNumber;
	var bannerWidth = 1600;
	var bannerHolderLength = $(".bannerSlider .banner");
	var bannerHolderHeight = 200 * bannerHolderLength;
	var animationSpeed = 300;
	var animationSpeedOverlay = 900;
	var currentBanner, currentBannerLink;

	// init
	$(".bannerSlider .banner").css({"display":"none", "position":"absolute", "width":"100%", "opacity":"0"});
	//$(".bannerSlider .banner").css({"display":"none", "position":"absolute", "opacity":"0"});
	$(".bannerSlider .banner:first").css({"display":"block", "opacity":"1"}).addClass("active");
	$(".bannerNum ul a:first").addClass("active");
	$(".bannerNum ul a:last").addClass("last");
	
	$("#bannerOverlay .overlay").css({"display":"none", "opacity":"0"});
	$("#bannerOverlay .overlay:first").css({"display":"block", "opacity":"1"}).addClass("active");
	
	// initialise
	if ($(".bannerSlider .banner").length > 0) { 
			bannerTimer = setTimeout(function() {
				autoBannerSlide();
			},bannerPause);
	}

	// auto select the next button
	function autoBannerSlide() {
		var button;
		if ($(".bannerSlider .banner:animated").length == 0) {
			if ( $(".bannerNum ul a.active").hasClass("last") ) {
				button = $(".bannerNum ul a:first");
			} else {
				button = $(".bannerNum ul a.active").parent().next().find("a");
			}
			
			doBannerSlide(button);
		}
	}

	// do on click
	$(".bannerNum ul a").bind("click", function() {
		var button;
		if ($(".bannerSlider .banner:animated").length == 0) {
			if ( $(".bannerNum ul a.active").hasClass("last") ) {
				button = $(".bannerNum ul a:first");
			} else {
				button = $(".bannerNum ul a.active").parent().next().find("a");
			}
		doBannerSlide($(this));	
		}
	});
	
	$("#arrows .rightArrow").bind("click", function() {
		var button;
		if ($(".bannerSlider .banner:animated").length == 0) {
			if ( $(".bannerNum ul a.active").hasClass("last") ) {
				button = $(".bannerNum ul a:first");
			} else {
				button = $(".bannerNum ul a.active").parent().next().find("a");
			}
			
			doBannerSlide(button);
		}
		
	});	
	
	$("#arrows .leftArrow").bind("click", function() {
		var button;
		if ($(".bannerSlider .banner:animated").length == 0) {
			if ( $(".bannerNum ul a.active").hasClass("first") ) {
				button = $(".bannerNum ul a:last");
			} else {
				button = $(".bannerNum ul a.active").parent().prev().find("a");
			}
			
			doBannerSlide(button);
		}
		
	});	
	
	
	function doBannerSlide(clickedButton) {
		clearTimeout(bannerTimer);
			
		var previousBanner = $(".bannerSlider #bannerContainer .active");
		//var previousOverlay = $("#bannerOverlay div.overlay.active");
		
		$("#bannerOverlay .overlay").css({"display":"none", "opacity":"0"});
		
		
		bannerNumber = clickedButton.attr("rel");
		currentBanner = $(".bannerSlider #banner"+bannerNumber);
		currentOverlay = $("#bannerOverlay #overlay"+bannerNumber);
		
		currentBannerLink = clickedButton;
		// if it's not current item
		if ( !currentBanner.hasClass("active") && $(".bannerSlider .banner:animated").length==0) {
			// clear all buttons
			$(".bannerNum ul a").removeClass("active");
			
			
			
			// fade previous slide out
			previousBanner.css({"display":"block"})
				.animate({
					opacity: 0
				},animationSpeed,'easeInExpo',function(){
					previousBanner.css("display","none").removeClass("active");
					
					//previousOverlay.css({"display":"none", "opacity":"0"}).removeClass("active");
					
					
					
					// fade current slide in
					currentBannerLink.addClass("active");
					currentBanner.css({"display":"block"})
						.animate({
							opacity: 1
						},animationSpeed,'easeOutExpo', function(){
							currentBanner.addClass("active");

							// reset timer
							bannerTimer = setTimeout(function() {
								autoBannerSlide();
							},bannerPause);
							
							//fade in overlay
							currentOverlay.css({"display":"block"})
								.animate({
									opacity: 1
								},animationSpeedOverlay,'easeOutExpo', function(){
									currentOverlay.addClass("active");
							});
					});
					
			});	
		}
	} /******* end doBannerSlide *******/
	
	if ($('#projectSidebar').length > 0) {
		$('#projectSidebar').portamento({wrapper: $('#bottomShadow')});	// set #wrapper as the bottom boundary
	} 	
	
	/*
	if ($('#projectSidebarContainer').length > 0) {
		var nav = $('#projectSidebarContainer'),
		content = $('#mainContent'),
		sharesHeight = nav.outerHeight(true),
		sharesLeft = nav.offset().left,
		navHeight = nav.outerHeight(true),
		navLeft = nav.offset().left,
		//header = $('.h1').outerHeight(true);
		yMin = nav.offset().top - parseInt(nav.css('margin-top'), 10),
		navFix = navHeight + content.offset().top,
		yMax = content.offset().top + content.outerHeight(),
		position = 'default',
		positionCSS = {
			'default': {position: 'relative', top: 0},
			'fixed': {position: 'fixed', top: 0}, 
			'bottom': {position: 'absolute', top: yMax - content.offset().top - navHeight - 10}
		};
		positionCSSMail = {
				'default': {position: 'relative', top: 0},
				'fixed': {position: 'fixed', top: 0}, 
				'bottom': {position: 'absolute', top: yMax - content.offset().top - navHeight - 10}
		};
		
		function setSharesPosition() {
			
			alert("navHeight: " + navHeight + " ,sharesHeight: " + sharesHeight);
			
			var w = $(this), x = w.scrollLeft(), y = w.scrollTop();
			
			if (y > yMin) {
				if (y + sharesHeight < yMax) {
					position = 'fixed';	
				}
				else {
					position = 'bottom';
				}
			}
			else {
				position = 'default';
			}
			// Clear all styles, then set appropriately.
			nav.removeAttr('style');
			
			if(position == 'fixed' && navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
			{
				nav.css("position", "fixed");
				nav.css("top", y + 10);
			} else {
				if(nav.hasClass('mailManage')) nav.css(positionCSSMail[position]);
				else nav.css(positionCSS[position]);
			}
			// Adjust for horizontal scroll.
			if (position === 'fixed' && x > 0) {
				nav.css({left: sharesLeft - x});
			}
			
			
			
			
		}
		// Only slide the shares box on articles that are long enough.
		if (yMax - sharesHeight > yMin) {
			$(window).scroll(setSharesPosition);
			setSharesPosition();
		}
	}
	
	//if ($('#projectSidebarContainer').length > 0) {setTimeout(function(){shareBox();}, 500);}
	*/
	
	if ($('#homeSlideshow').length == 0) {
		$(window).scroll(function() {
			if($(this).scrollTop() != 0) {
				//alert("fadeIN");
				$('#toTop').fadeIn();	
			} else {
				$('#toTop').fadeOut();
			}
		});
	}
 
	$('#toTop').click(function() {
		$('html, body').animate({scrollTop: '0px'}, 500, "easeOutSine", function () { 
			if ($('#projectSidebarContainer').length > 0) {
				$('#projectSidebarContainer').css("position", "relative");
				$('#projectSidebarContainer').css("top", 0);
			}
		});
		return false;
	});	
	
});

/*
function shareBox() {
	
	var nav = $('#projectSidebarContainer'),
	content = $('#mainContent'),
	sharesHeight = nav.outerHeight(true),
	sharesLeft = nav.offset().left,
	navHeight = nav.outerHeight(true),
	navLeft = nav.offset().left,
	//header = $('.h1').outerHeight(true);
	yMin = nav.offset().top - parseInt(nav.css('margin-top'), 10),
	navFix = navHeight + content.offset().top,
	yMax = content.offset().top + content.outerHeight(),
	position = 'default',
	positionCSS = {
		'default': {position: 'relative', top: 0},
		'fixed': {position: 'fixed', top: 10}, 
		'bottom': {position: 'absolute', top: yMax - content.offset().top - navHeight - 10}
	};
	positionCSSMail = {
			'default': {position: 'relative', top: 0},
			'fixed': {position: 'fixed', top: 0}, 
			'bottom': {position: 'absolute', top: yMax - content.offset().top - navHeight - 10}
	};
	
	function setSharesPosition() {
		
		var w = $(this), x = w.scrollLeft(), y = w.scrollTop();
		
		if (y > yMin) {
			if (y + sharesHeight < yMax) {
				position = 'fixed';	
			}
			else {
				position = 'bottom';
			}
		}
		else {
			position = 'default';
		}
		// Clear all styles, then set appropriately.
		nav.removeAttr('style');
		
		if(position == 'fixed' && navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
		{
			nav.css("position", "fixed");
			nav.css("top", y + 10);
		} else {
			if(nav.hasClass('mailManage')) nav.css(positionCSSMail[position]);
			else nav.css(positionCSS[position]);
		}
		// Adjust for horizontal scroll.
		if (position === 'fixed' && x > 0) {
			nav.css({left: sharesLeft - x});
		}
		
		
		
		
	}
	// Only slide the shares box on articles that are long enough.
	if (yMax - sharesHeight > yMin) {
		$(window).scroll(setSharesPosition);
		setSharesPosition();
	}
	
};

//Grayscale w canvas method
function grayscale(src){
	var canvas = document.createElement('canvas');
	var ctx = canvas.getContext('2d');
	var imgObj = new Image();
	imgObj.src = src;
	canvas.width = imgObj.width;
	canvas.height = imgObj.height; 
	ctx.drawImage(imgObj, 0, 0); 
	var imgPixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
	for(var y = 0; y < imgPixels.height; y++){
		for(var x = 0; x < imgPixels.width; x++){
			var i = (y * 4) * imgPixels.width + x * 4;
			var avg = (imgPixels.data[i] + imgPixels.data[i + 1] + imgPixels.data[i + 2]) / 3;
			imgPixels.data[i] = avg; 
			imgPixels.data[i + 1] = avg; 
			imgPixels.data[i + 2] = avg;
		}
	}
	ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width, imgPixels.height);
	return canvas.toDataURL();
}

*/



