function formatItem(row) {
	return "<b>" + row[0] + "</b> <i>" + row[1] + "</i>";
}

function submitForm() {
	document.forms[0].submit();
}

$(document).ready(function() {
	$('.rounded, #banner, #borderI, #borderO, .fp_box, #welcome_pic, .pbox, #apt_deposit, #apt_applink, #apt_petpolicy, #apt_floorplans, #apt_map').corners("5px");
	$('.tabs li, #share li').corners("5px transparent");
	$('#nav_left li a, #nav_right li a').corners("5px top transparent");
	$('#welcome, #inner_content, .rounded_top, #apt_more, #apt_schools, #apt_amenities, #apt_showaddr').corners("5px top");
	$('#fp_left, #footer, .rounded_bottom, #apt_column1, #apt_column2, #apt_column3, #apt_showform').corners("5px bottom");
	$('#searchIcon, .round_left').corners("5px left");
	$('#searchIcon, .round_right').corners("5px right");
	$("#searchField").autocomplete("/autocomplete.asp",{delay:10,minChars:5,matchSubset:0,matchContains:1,cacheLength:1,formatItem:formatItem,onItemSelect:submitForm,autoFill:true,width:410,maxItemsToShow:20});
	$(".fp_box").vjustify();
	$("#fp_left,#fp_right").vjustify();
	$("#column_left,#column_right").vjustify();
	$("#apt_column1,#apt_column2,#apt_column3").vjustify();
	$("#apt_pictures,#apt_contact").vjustify();
	$('#holder').scrollFollow({offset: 15});
	$("a.tooltip").jHelperTip({trigger: "hover", source: "attribute", attrName: "title", opacity: 1, autoClose:true});
	$("#searchField").focus();
});

function showForm(){
	$('#searchFrm').show();
	$('#searchIcon').hide();
	$('#searchField').focus();
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+30);
    document.cookie = "b=true; expires="+exdate.toGMTString()+"; path=/;";
}

function hideForm(){
	$('#searchFrm').hide();
	$('#searchIcon').show();
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+30);
	document.cookie = "b=false; expires="+exdate.toGMTString()+"; path=/;";
}

/*function tab(abj,obj) {
	$('#tabs li').removeClass('selected');
	$('#boxes div').hide();
	$(abj).addClass('selected');
	$(obj).show();
}*/

function tab(tgt,abj) {
	$(tgt).removeClass('selected');
	$(abj).parent().addClass('selected');
}
function reveal(tgt,abj) {
	$(tgt).hide();
	$(abj).show();
}


function modifyBg(obj) {
	if (obj.value.length > 0) {
		obj.style.background='#ffffff';
	} else {
		obj.style.background='#fff url(/images/searchbg.gif) 3px 3px no-repeat';
	}
}

jQuery.fn.vjustify=function() {
    var maxHeight=0;
    this.each(function(){
        if (this.offsetHeight>maxHeight) {maxHeight=this.offsetHeight;}
    });
    this.each(function(){
        $(this).height(maxHeight + "px");
        if (this.offsetHeight>maxHeight) {
            $(this).height((maxHeight-(this.offsetHeight-maxHeight))+"px");
        }
    });
};