//jQuery
$(document).ready(function(){
	$("#real_estate_button").hover(
	  function(){
		$("#one").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#one").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#membership_button").hover(
	  function(){
		$("#two").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#two").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#events_button").hover(
	  function(){
		$("#three").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#three").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#tour_button").hover(
	  function(){
		$("#four").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#four").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#tour_course").hover(
	  function(){
		$("#tour_course_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#tour_course_button").stop().fadeTo("slow", 1);
	  }
	);

	$("#scorecard").hover(
	  function(){
		$("#scorecard_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#scorecard_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#membership").hover(
	  function(){
		$("#club_membership_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#club_membership_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#clubhouse_menu").hover(
	  function(){
		$("#clubhouse_menu_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#clubhouse_menu_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#lake_grill_menu").hover(
	  function(){
		$("#lake_grill_menu_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#lake_grill_menu_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#view_siteplan").hover(
	  function(){
		$("#view_siteplan_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#view_siteplan_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#view_listings").hover(
	  function(){
		$("#view_listings_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#view_listings_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#tour_lodge").hover(
	  function(){
		$("#tour_lodge_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#tour_lodge_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#reservations").hover(
	  function(){
		$("#reservations_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#reservations_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#newsletter").hover(
	  function(){
		$("#newsletter_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#newsletter_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#view_newsletter").hover(
	  function(){
		$("#view_newsletter_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#view_newsletter_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#member_events").hover(
	  function(){
		$("#member_events_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#member_events_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#press_kit").hover(
	  function(){
		$("#press_kit_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#press_kit_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$("#view_map").hover(
	  function(){
		$("#view_map_button").stop().fadeTo("slow", 0);
	  }, 
	  function(){
		$("#view_map_button").stop().fadeTo("slow", 1);
	  }
	);
	
	$('.main_nav').hover(function(){
	var temp=$(this).attr('src')
	temp=temp.replace('.png', '_over.png');
	$(this).attr('src', temp);
	}, 
	function() {
	var temp=$(this).attr('src')
	temp=temp.replace('_over.png', '.png');
	$(this).attr('src', temp);
	});
	
	$('.sub_nav').hover(function(){
	var temp=$(this).attr('src')
	if (temp.indexOf('_over')==-1) {
	temp=temp.replace('.gif', '_over.gif');
	$(this).attr('src', temp);
	}
	}, 
	function() {
	var temp=$(this).attr('src')
	if (temp.indexOf('_over')!=-1) {
	temp=temp.replace('_over.gif', '.gif');
	$(this).attr('src', temp);
	}
	});
	
	var qstring=location.search;
	var tabindex=0	
	if (qstring.indexOf('tab=')!=-1) {
	var temp=qstring.substring(qstring.indexOf('tab=') + 4, qstring.indexOf('tab=') + 5);
temp=parseInt(temp);
 if (isNaN(temp)) {tabindex=0;} else {tabindex=temp;}
}

	if (tabindex==1) {
	$('#weekly').attr('src', '/images/weekly_over.jpg');
	prevNextUrl();
	$('#tab_club_content').hide();
	$('#tab_mccall_content').hide();
	} else if (tabindex==2) {
	$('#mccall').attr('src', '/images/mccall_over.jpg');
	prevNextUrl();
	$('#tab_club_content').hide();
	$('#tab_weekly_content').hide();
	} else {
	$('#monthly').attr('src', '/images/monthly_over.jpg');
	$('#tab_weekly_content').hide();
	$('#tab_mccall_content').hide();
	}
	
	$('.event_tabs').hover(function(){
	if (tabindex!=$('.event_tabs').index(this)) {
	var temp=$(this).attr('src')
	if (temp.indexOf('_over')==-1) {
	temp=temp.replace('.jpg', '_over.jpg');
	$(this).attr('src', temp);
	}
	}
	}, function() {
	if (tabindex!=$('.event_tabs').index(this)) {
	var temp=$(this).attr('src')
	if (temp.indexOf('_over')!=-1) {
	temp=temp.replace('_over.jpg', '.jpg');
	$(this).attr('src', temp);
	}
	}
	});
	
	
	
	$('#tab_club').click(function() {
	// highlight tab
	tabindex=0
	prevNextUrl();
	$('#weekly').attr('src', '/images/weekly.jpg');
	$('#mccall').attr('src', '/images/mccall.jpg');
	$('#monthly').attr('src', '/images/monthly_over.jpg');
	
	// hide other tab layers and show clicked
	$('#tab_mccall_content').hide();
	$('#tab_weekly_content').hide();
	$('#tab_club_content').show();
	return false;
	});
	
	$('#tab_weekly').click(function() {
	tabindex=1
	prevNextUrl();
	
	$('#monthly').attr('src', '/images/monthly.jpg');
	$('#mccall').attr('src', '/images/mccall.jpg');
	$('#weekly').attr('src', '/images/weekly_over.jpg');
	
	$('#tab_club_content').hide();
	$('#tab_mccall_content').hide();
	$('#tab_weekly_content').show();
	return false;
	});
	
	$('#tab_mccall').click(function() {
	tabindex=2
	prevNextUrl();
	$('#monthly').attr('src', '/images/monthly.jpg');
	$('#weekly').attr('src', '/images/weekly.jpg');
	$('#mccall').attr('src', '/images/mccall_over.jpg');
		
	$('#tab_club_content').hide();
	$('#tab_weekly_content').hide();
	$('#tab_mccall_content').show();
	return false;
	});
	
	function prevNextUrl() {
	var v_n=$('#event_next').attr('href')
	if (v_n.indexOf('tab=')==-1) {
	$('#event_next').attr('href', $('#event_next').attr('href') + '&tab=' + tabindex);
	} else {
	v_n=v_n.replace(v_n.substring(v_n.indexOf('tab='), v_n.indexOf('tab=') + 5), 'tab=' + tabindex);
	$('#event_next').attr('href', v_n);
	}

	var v_p=$('#event_prev').attr('href')
	if (v_p.indexOf('tab=')==-1) {
	$('#event_prev').attr('href', $('#event_prev').attr('href') + '&tab=' + tabindex);
	} else {
	v_p=v_p.replace(v_p.substring(v_p.indexOf('tab='), v_p.indexOf('tab=') + 5), 'tab=' + tabindex);
	$('#event_prev').attr('href', v_p);
	}

}
		
});
