$(document).ready(function() {
	var tooltipDefaults = {className: "tooltip", cornerRadius: 5, orient: "above", width: 200, arrowHeight: 7, arrowInset: 15}
	$("#text").autocomplete("/autocomplete.asp",{delay:10,minChars:3,matchSubset:0,matchContains:1,cacheLength:1,formatItem:formatItem,onItemSelect:submitForm,autoFill:true,maxItemsToShow:20});
	$("tr[class^='tooltip']").hover(function(){$(this).addClass("hover")}, function(){$(this).removeClass("hover");});
	$(".footer_tip").hover(function(){$(this).addClass("hover")}, function(){$(this).removeClass("hover");});
	$("#tooltip_link").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "A hyperlink straight to your website. We'll even record the number of clicks per day for statistics.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_desc").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "A one or two paragraph description which you can login and change at anytime.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_email").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "Receive emails without having to disclose your true email address. Good for preventing spam.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_logo").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "Put your logo on your listing page as well as all search result pages.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_photos").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "Upload up to 30 high-resolution photos of your business and change them whenever you want.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_categories").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "Put your business in up to 3 categories on the site.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_locations").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "If you business has multiple locations within the city, you can add up to 10.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_map").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "Shows a map on the listing page with a link to get directions.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_login").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "Login and change your listing whenever you want. Good for frequently changing promotions.", align: "left"}));},function() {$(this).closeCallout();});
	$("#tooltip_hours").hover(function() {$(this).callout($.extend({}, tooltipDefaults, {text: "Display business hours and other misc. details about your business.", align: "left"}));},function() {$(this).closeCallout();});
	$("#rss").hover(function() {$(this).callout($.extend({}, {className: "rss_tip", cornerRadius: 5, orient: "above", width: 210, arrowHeight: 7, arrowInset: 15}, {text: "Subscribe to our Blog and get the latest news, specials, and upcoming events!", align: "right"}));},function() {$(this).closeCallout();});
	$("#facebook").hover(function() {$(this).callout($.extend({}, {className: "facebook_tip", cornerRadius: 5, orient: "above", width: 200, arrowHeight: 7, arrowInset: 15}, {text: "Join our Facebook page and get the latest news and special deals!", align: "right"}));},function() {$(this).closeCallout();});
	$("#twitter").hover(function() {$(this).callout($.extend({}, {className: "twitter_tip", cornerRadius: 5, orient: "above", width: 200, arrowHeight: 7, arrowInset: 15}, {text: "Follow us on twitter and get the latest news and special deals!", align: "right"}));},function() {$(this).closeCallout();});
	$("#share").hover(function() {$(this).callout($.extend({}, {className: "share_tip", cornerRadius: 5, orient: "above", width: 200, arrowHeight: 7, arrowInset: 15}, {text: "ShareThis via email, AIM, social bookmarking and networking sites, etc.", align: "right"}));},function() {$(this).closeCallout();});
	$("#upgrade_btn").hover(function() {$(this).callout($.extend({}, {className: "enhance_tip", cornerRadius: 5, orient: "top", width: 300, arrowHeight: 7, arrowInset: 15}, {text: "Enhanced listings include: your website, logo, description, photos, menus, multiple locations, self-administration, and much more! Click for more information.", align: "right"}));},function() {$(this).closeCallout();});
	$("#text").focus();
	$(".news_date,.rounded,.blog_left,.blog_right").corners("10px");
	$("#upgrade_btn").corners("5px");
	$(".jqColumn").vjustify(); 
	$("#map").scrollFollow({offset: 10});
});

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");
        }
    });
};

function tab(abj,obj) {
	$('#tabs li').removeClass('selected');
	$('#containers div').hide();
	$(abj).parent().addClass('selected');
	$(obj).show();
	$('#text').focus();
}

function formatItem(row) {
	return "<b>" + row[0] + "</b> <i>" + row[1] + "</i>";
}

function submitForm() {
	document.forms[0].submit();
}