// Login Form
$(function() {
    var button = $('#loginButton');
    var box = $('#loginBox');
    var form = $('#loginForm');
    button.removeAttr('href');
    button.mouseup(function(login) {
        box.toggle();
        button.toggleClass('active');
    });
    
	form.mouseup(function() { 
        return false;
    });
	
    $(this).mouseup(function(login) {
        if(!($(login.target).parent('#loginButton').length > 0)) {
            button.removeClass('active');
            box.hide();
        }
    });
	
	$('#forms div.buyer').hide();
	$('#choices li#seller').removeClass('focused');
			$('#choices li').click(
			   	function(){		
					var el = $(this).attr('ID');
					var thisId = "#" + el;
					var thisClass = "." + el;
					var target = '#forms div' + thisClass;
					var divfocus = '#choices li' + thisId;
					$(target).show();				
					$('#forms div').not(thisClass).hide();
					$('#choices li').not(thisId).addClass('focused');
					$('#choices li' + thisId).removeClass('focused');
				}				
			);
});


// Properties
$(function() {
    // hides the slickbox as soon as the DOM is ready
  $('#propBox').hide(); 
 // toggles the slickbox on clicking the noted link  
  $('#propBox-show').click(function() {
    $('#propBox').toggle(400);
    return false;
  });
  $('#propBox a').attr({ target: "_self"});
});

// Poll
$(function() {
    // hides the slickbox as soon as the DOM is ready
  $('#pollBox').hide(); 
 // toggles the slickbox on clicking the noted link  
  $('#pollBox-show').click(function() {
    $('#pollBox').toggle(400);
    return false;
  });
});

//careers
$(function() {
	$('#seasoned-professionals').hide();
	$('.optionbox').click(function (event) { 
		event.preventDefault();
		var target = "#" + $(this).attr("title");		
		$(target).show();
		$('.contentbox2').not(target).hide();
		$('.optionbox').removeClass('optionActive')
		$(this).addClass('optionActive');	
		
		if(target == '#seasoned-professionals'){
			$('#career-btns').addClass('career-btns_activate');
		}else{
			$('#career-btns').removeClass('career-btns_activate');
		}
	});  
});

//downloads
$(function() {
	$('#flyers').hide();
	$('.optionbox').click(function (event) { 
		event.preventDefault();
		var target = "#" + $(this).attr("title");	
		$(target).show();
		$('.contentbox3').not(target).hide();
		$('#downloads-btns').toggleClass('downloads-btns_activate');
		
		if(target == '#flyers'){
			$('#downloads-btns').addClass('downloads-btns_activate');
		}else{
			$('#downloads-btns').removeClass('downloads-btns_activate');
		}
	});  
}); 


//learn more
$(function() {
	$('#more').click(function() {
		$('.p013').toggleClass('extended').animate();
		
		if($('.p013').hasClass('extended')) {
			$('.p013').stop().animate({"height": "80px"});
			$('#more p').replaceWith('<p>Learn More -</p>');
		}else{
			$('.p013').stop().animate({"height": "40px"});
			$('#more p').replaceWith('<p>Learn More +</p>');
		}			
	});
});

//map
$(function() {
	$('div.bubble').hide();
	$('.map a').hover(
		function(){
			$('div').filter(this.hash).addClass('highlight');
			$(this).find("span").fadeIn();
		},
		function(){
			$('div').removeClass('highlight');
			$(this).find("span").fadeOut();
		});
});


//custom form inputs
//custom file input
var SITE = SITE || {};

SITE.fileInputs = function() {
var $this = $(this),
$val = $this.val(),
valArray = $val.split('\\'),
newVal = valArray[valArray.length-1],
$button = $this.siblings('.button'),
$fakeFile = $this.siblings('.file-holder');

if(newVal !== '') {
	$button.text('Resume Attached');
	if($fakeFile.length === 0) {
		$button.after('<span class="file-holder">' + newVal + '</span>');
	} else {
		$fakeFile.text(newVal);
	}
}
};
$('.file-wrapper input[type=file]').bind('change focus click', SITE.fileInputs);

////amenities slideshow
//$(function() {
//	$(".slidetabs").tabs(".images > div", {
//	 
//		// enable "cross-fading" effect
//		effect: 'fade',
//		fadeOutSpeed: "slow",
//	 
//		// start from the beginning after the last tab
//		rotate: true
//	 
//	// use the slideshow plugin. It accepts its own configuration
//	}).slideshow();	
//});

////homepage
//$(function() {
//	$(".slidetabs").tabs(".images2 > div", {	 
//				// enable "cross-fading" effect
//				effect: 'fade',
//				fadeOutSpeed: "slow",		 
//				rotate: true
//				 
//				// use the slideshow plugin. It accepts its own configuration
//	}).slideshow();
//});
