var $maxClick;

function updateHomeLeftPanel() {
	//$('#specialMsg').height($('.gladWrap').height());	
	if($('#specialBox').height() > $('#mainText').height()){
		$('#mainText').height($('#specialBox').outerHeight(true));
	}else{
		$('#specialBox').height($('#mainText').outerHeight(true));
	}
}
function updateLeftPanel() {
	$('.leftPanel').height($('.contentWrapper').height());
}
$(document).ready(function(){
/*////////////////////////////////////////////////////////////////*/
/* Pay Rent Online */
/*////////////////////////////////////////////////////////////////*/
	$('div#rightTopNav li#rent').click(function(){
		var $url = "https://property.onesite.realpage.com/templates/template_08residentportal/login/login.asp?w=thebarons";
		window.open($url,'','toolbar=no, location=no, status=yes, menubar=no, scrollbars=yes, resizable=yes, width=640 ,height=600');
	});

/*////////////////////////////////////////////////////////////////*/
/* Social stuff like Facebook and Twitter */
/*////////////////////////////////////////////////////////////////*/
	$('img.social').hover(function(){
		var thisId = $(this).attr('id');
		switch (thisId){
			case 'facebook':
				var src = ($(this).attr('src') === 'images/icon-F.jpg')
				? 'images/icon-F2.jpg'
				: 'images/icon-F.jpg';
			break;
			case 'twitter':
				var src = ($(this).attr('src') === 'images/icon-T.jpg')
				? 'images/icon-T2.jpg'
				: 'images/icon-T.jpg';
			break;
		};
		
		$(this).attr('src',src);		
	});
	$('#imgContainer ol li:first-child img').css({
		borderColor:'#313133'
	})
	
	$('#nextBtn').click(function(){
		
		$currentSet++;
		
		if($currentSet <= $maxClicks){
		$("#imgContainer ol").animate({"right": '+='+$displayWidth+'px'}, "slow");
		}else{
		$("#imgContainer ol").animate({"right": '-='+$fullWidth+'px'}, "slow");
		$currentSet = 0;
		}

	});
	
	$('#prevBtn').click(function(){
		if($currentSet >= 1){
		$currentSet--;
		$("#imgContainer ol").animate({"right": '-='+$displayWidth+'px'}, "slow");
		}else{
		$("#imgContainer ol").animate({"right": '+='+$fullWidth+'px'}, "slow");
		$currentSet = $maxClicks;
		}

	});
	
	$('.tours img').hover(function(){			
		$(this).css({'borderColor':'#313133'});
	},function(){
		$(this).css({'borderColor':'#c0c0c0'});
	});
	
	$('#imgContainer li img').click(function(){
		$('#imgContainer li img').css({'borderColor':'#c0c0c0'});
		$(this).css({'borderColor':'#313133'});
	});

/*////////////////////////////////////////////////////////////////*/
/* floorplan table */
/*////////////////////////////////////////////////////////////////*/	
	$('table#floorplansTable tr:not([th]):odd').css({'background-color':'#c5aa8f'});
	$('table#floorplansTable tr:not([th]):even').css({'background-color':'#d68533'});
	
	
	$('table#floorplansTable tr').hover(function(){
		$('td', this).addClass('trOver');
		}, function() {
		$('td',this).removeClass('trOver');
	}).click(function() {
		$('td').removeClass('trClick');
		$('td', this).toggleClass("trClick");
		$('#fpNameLabel').html($('td.modelName',this).text());
		showFloorPlan(this);
	});

/*////////////////////////////////////////////////////////////////*/
/* Show the starting address box for point-to-point direction  */
/*////////////////////////////////////////////////////////////////*/
	$('#directionLink').click(function(){
		$('#getDirection').slideDown('slow');
		$('input#saddr').focus();
	});
	
	$('img#walkIcon').click(function(){
		$('form#getDirection').attr({ 
			action: 'http://maps.google.com/maps'
		});		
		$('form#getDirection').submit();
	});
	$('#closer').hover(function()
		{
		$(this).css({
			'backgroundColor': '#cdb376',
			'color': '#4a3e32'
		});
		},function()
		{
		$(this).css({
			'backgroundColor':'#4a3e32',
			'color': '#ffffff'
		});					
	});

	$('#closer').click(function(){
		$('input#saddr').val('');
		$('#getDirection').slideUp('slow');
	});

/*////////////////////////////////////////////////////////////////*/
/* Neigborhood Information */
/*////////////////////////////////////////////////////////////////*/
	$('#neigborhoodInfo .heading:not(:first-child)').css('margin-top', '30px');

});

/*////////////////////////////////////////////////////////////////*/
/* Display floorplan image */
/*////////////////////////////////////////////////////////////////*/
function showFloorPlan(plans){
	//var imagePath = "http://app.resiteit.com/control/marketing/displayfloorpic.php?";
	var fpImg = "<a href='floorplandetail.php?UType"+plans.id+"&cid="+$cid+"' target='_block'><img style='display:block;' src='"+$imageRoot+plans.id+"' /></a>"
	prntBtn = "<a href='floorplandetail.php?UType"+plans.id+"&cid="+$cid+"' target='_block'><img src='images/print-btn.jpg' /></a>";
	
	$('#plans').empty();
	$('#plans').append(fpImg);
	$('#prntButton').empty().append(prntBtn);
	
	$('#plans a img').load(function(){
		if($('#plans a img').width() > 608){	
			$('#plans a img').css({
					width: 609
			});
		} else {
			var here = parseInt((609-$('#plans a img').width())/2);
			$('#plans a img').css({
					'margin-left': here
			});
		}
	});
	$('html, body').animate({scrollTop:0}, 'slow');
};


