$(document).ready(function() {
	if($('select.category-selector').length) {
		categorySelect();
	}
	if($('a.revealer').length) {
		reveal();
		conceal();
	}
    if ($('.real-estate-listing-widget-holder').length) {
        $('.real-estate-listing-widget-holder').jScrollPane({
          verticalDragMinHeight: 105,
          verticalDragMaxHeight: 105,
          contentWidth: 300,
          hideFocus: true
        });
    }
	/* the path below might need to be dynamic. -nils*/
    if(typeof profileManager!='undefined'){
    	profileManager.init('http://members.princeofpetworth.com/');
    }
});

function categorySelect() {
	$('select.category-selector').change(function() {
		var category = $('select.category-selector option:selected').val();
		if(window.location != category) {
			window.location = category;
		}
	});
}

function sreveal() {
	$('.revealer').live('click', function() {
		$(this).siblings('a.hidden').each(function(index) {
			$(this).addClass('revealed').removeClass('hidden');
		});
		
		$(this).addClass('concealer').removeClass('revealer').html('See Less');
		return false;
	});
}

function reveal() {
	$('.revealer').live('click', function() {
		$(this).siblings('div.hidden').slideDown('slow');
		
		$(this).addClass('concealer').removeClass('revealer').html('See Less');
		
		return false;
	});
}

function conceal() {
	$('.concealer').live('click', function() {
		$(this).siblings('div.hidden').slideUp('slow');
		
		$(this).addClass('revealer').removeClass('concealer').html('See More');
		
		return false;
	});	
}
(function($){
	jQuery.fn.clearDefault = function(){
	return this.each(function(){
		var default_value = $(this).val();
		$(this).focus(function(){
			if (jQuery(this).val() == default_value) $(this).val("");
		});
		$(this).blur(function(){
			if (jQuery(this).val() == "") $(this).val(default_value);
		});
		});
	};
})($);
function clearField(form) {
	$(form).find("input.text, textarea").each(function(){ 
			this.defaultValue = this.value;
			$(this).click(function(){
					if(this.value == this.defaultValue){
							$(this).val("");
					}
					return false;
			});
			$(this).blur(function(){
					if(this.value == ""){
							$(this).val(this.defaultValue);
					}
			});
	});
}
$('.clear-default').clearDefault();
$("#submit").live('click', function(){
	id = $(this).attr('rel');
	textarea = $("#comment");
	comment = textarea.val();
	if (comment === "" || comment=='Add your comment') {
	  comment_warning = '<div class="warning comment">Please enter something in the comment box.</div>';
	  $('#commentform').before(comment_warning);
	  setTimeout(removeCommentWarnings, 2500);
	  return false;
	}
	
});	
