jQuery(document).ready(function() {
	jQuery("#pagination").pagination(jQuery('#totalResults').html(), {
		items_per_page:20, 
		callback:handlePaginationClick,
		next_text: '>',
		prev_text: '<',
		num_edge_entries: 1,
		num_display_entries: 8
	});
	
	// for the tab drop downs at the top
    // ----------------------------------
	
	if (jQuery('#contact-us')[0]) {
		jQuery('#contact-us').hoverIntent({
			over: function(){
				jQuery('#show-contact').slideDown('fast');
			},
			out: function() {
				//jQuery('#show-contact').slideUp('fast');	
			}
		});
	}
	
	if (jQuery('#newsletter')[0]) {
		jQuery('#newsletter').hoverIntent({
			over: function(){
				jQuery('#show-newsletter').slideDown('fast');
				
			},
			out: function() {
				//jQuery('#show-planner').slideUp('fast');	
			}
		});
	}
	
	//hide the package when they click on it.
	if (jQuery('#show-contact')[0]) {
		jQuery('#show-contact a.button').click(function(){
			jQuery('#show-contact').slideUp('fast');
			return false;
		});
	}
	//hide the package when the mouse leaves
	if (jQuery('#show-contact')[0] && !(jQuery.browser.msie && (jQuery.browser.version <= 7))) {
		// on mouse leave
		jQuery('#show-contact').mouseleave(function(){
			jQuery('#show-contact').slideUp('fast');
			return false;
		});
	}
	
	//hide the planner when they click on it.
	if (jQuery('#show-newsletter')[0]) {
		jQuery('#show-newsletter a.button').click(function(){
			jQuery('#show-newsletter').slideUp('fast');
			return false;
		});
	}
	//hide the planner when the mouse leaves.
	if (jQuery('#show-newsletter')[0] && !(jQuery.browser.msie && (jQuery.browser.version <= 7))) {
		jQuery('#show-newsletter').mouseleave(function(){
			jQuery('#show-newsletter').slideUp('fast');
			return false;
		});
	}
	if(jQuery.browser.msie && (jQuery.browser.version <= 7)){
		jQuery('#show-newsletter a.button').show();
		jQuery('#show-contact a.button').show();
	}
	//show the close button if it's IE7
	
	if (jQuery('.socialMedia').length > 0){
		jQuery('.socialMedia').click(function() {
			s=s_gi(s_account);
			s.linkTrackVars = 'events,prop13';
			s.linkTrackEvents = 'event15';
			s.prop13 = jQuery(this).attr('rel').toLowerCase(); 
			s.events = 'event15';
			s.tl(this, 'o', 'social media link clicks');
		});
	}
	
	
	// ----------------------------------
});

var handlePaginationClick = function(newPageIndex, paginationContainer) {
	var lastName = jQuery('#datalastname').val();
	var city = jQuery('#datacity').val();
	var state = jQuery('#datastate').val();
	var country = jQuery('#datacountry').val();
    // call the ajax thing to get our data
    jQuery.ajax({
    	url		:	'playerSearchResults.cfm',
    	data	:	'lastname=' + lastName + '&city=' + city + '&state=' + state + '&country=' + country + '&page=' + (newPageIndex+1),
    	async	:	false,
    	success	:	function(html) {
    		jQuery('#searchResultsContainer').html(html);
    	}
    })
    return false;
}