var tabs, $tabs;

jQuery(function() {

tabs    = jQuery("#tabs").tabs();
$tabs   = tabs;

jQuery('#condo-tabs-1').click(function() { $tabs.tabs('select', 0);  return false; })
jQuery('#condo-tabs-2').click(function() { $tabs.tabs('select', 1);  return false; })
jQuery('#condo-tabs-3').click(function() { $tabs.tabs('select', 2);  return false; })
jQuery('#condo-tabs-4').click(function() { $tabs.tabs('select', 3);  return false; })
jQuery('#condo-tabs-5').click(function() { $tabs.tabs('select', 4);  return false; })
jQuery('#condo-tabs-6').click(function() { $tabs.tabs('select', 5);  return false; })
jQuery('#condo-tabs-7').click(function() { $tabs.tabs('select', 6);  return false; })
jQuery('#condo-tabs-8').click(function() { $tabs.tabs('select', 7);  return false; })
jQuery('#condo-tabs-9').click(function() { $tabs.tabs('select', 8);  return false; })
jQuery('#condo-tabs-10').click(function() { $tabs.tabs('select', 9);  return false; })
jQuery('#condo-tabs-11').click(function() { $tabs.tabs('select', 10); return false; })
jQuery('.condo-tabs-12').click(function() { $tabs.tabs('select', 11); scroll_to_top(); return false; })

    jQuery(".ui-tabs-panel").each(function(i)
    {
      var totalSize = jQuery(".ui-tabs-panel").size() - 1;
      if (i != totalSize)
      {
          next = i + 2;
          jQuery(this).append("<a href='#' class='next-tab mover' rel='" + next + "'>Next Page &#187;</a>");
      }

      if (i != 0)
      {
          prev = i;
          jQuery(this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'>&#171; Prev Page</a>");
      }
    });

    jQuery('.next-tab, .prev-tab').click(function()
    {
        $tabs.tabs('select', jQuery(this).attr("rel"));
        scroll_to_top();
        return false;
    });

});

function scroll_to_top()
{
    jQuery('html, body').animate({scrollTop:0}, 'slow');
}


/*
	var cfg = (jQuery.hoverintent = {
		sensitivity: 12,
		interval: 100
	});

	jQuery.event.special.hoverintent = {
		setup: function() {
			jQuery(this).bind("mouseover", jQuery.event.special.hoverintent.handler);
		},
		teardown: function() {
			jQuery(this).unbind("mouseover", jQuery.event.special.hoverintent.handler);
		},
		handler: function(event) {
			event.type = "hoverintent";
			var self = this,
				args = arguments,
				target = jQuery(event.target),
				cX, cY, pX, pY;

			function track(event) {
				cX = event.pageX;
				cY = event.pageY;
			};
			pX = event.pageX;
			pY = event.pageY;
			function clear() {
				target.unbind("mousemove", track).unbind("mouseout", arguments.callee);
				clearTimeout(timeout);
			}
			function handler() {
				if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
					clear();
					jQuery.event.handle.apply(self, args);
				} else {
					pX = cX; pY = cY;
					timeout = setTimeout(handler, cfg.interval);
				}
			}
			var timeout = setTimeout(handler, cfg.interval);
			target.mousemove(track).mouseout(clear);
			return true;
		}
	};

	jQuery(function() {
		jQuery("#tabs").tabs({
			event: "click hoverintent"
		});
	});
*/
