/***********************************************
***  GET INVOLVED FORM TABS MENU  **************
************************************************/

/*
$(function(){
	if ($('#tabs a') != null) {		
		$('#tabs a').click(function(){
			if (!$(this).is('.selected')){
				$(this).addClass('selected');
				$(this).parent().siblings().children('a').removeClass('selected');
				if ($(this).is('#personalTab')){
					$('#corporate').hide();
					$('#advertising').hide();
					$('#personal').show();
				}
				if ($(this).is('#corporateTab')){
					$('#personal').hide();
					$('#advertising').hide();
					$('#corporate').show();
				}
				if ($(this).is('#advertisingTab')){
					$('#personal').hide();
					$('#corporate').hide();
					$('#advertising').show();
				}
			}
			return false;
		});
	}
});
*/

$(function(){
		$('#tabs a').click(function() {
				$('#left').attr('class', $(this).attr('href').substr(1));
			});
		var a = window.location.hash.substr(1);
		if(a)
			$('#left').attr('class', a);
	});

/***********************************************
***  BUTTON ROLLOVER & PRELOAD  ****************
************************************************/

$(function(){
	// button rollover
	if ($('.imgBtn') != null) {
		$('.imgBtn').hover(function(){
				if(!$(this).is('.disabled'))
					$(this).attr("src", $(this).attr("src").replace(/^(.*?)(?:-hover)?(\..*?)$/i,'$1-hover$2'));
			},
			function(){
					if(!$(this).is('.disabled'))
						$(this).attr("src", $(this).attr("src").replace(/^(.*)-hover(\..*?)$/i, '$1$2'));
				});
	}
	// preload image rollovers
	if ($("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']") != null) {
	    $("img.imgBtn, img[src^='images/buttons/btn'], input[src^='images/buttons/btn']").each(function(){
			    $("<img>").attr("src", $(this).attr("src").replace(/(btn-.*)(\..*?)/i, '$1-hover$2'));
		    });
	}
});

/***********************************************
***  EXTERNAL LINKS  ***************************
************************************************/

$(document).ready(function() {
	$("a[rel=external]").each(function() {
		$(this).addClass('external');
		$(this).attr({
			title: "Open this page in a new window",
			target: "_blank"
		});
	})
	
	
});


/***********************************************
***  COMPACT FORM (LABEL OVER INPUT)  **********
************************************************/

$(function(){
	$('form.compact input, form.compact select, form.compact textarea').focus(function(){
			$('label[for=' + $(this).attr('id') + ']').hide();
		});
	$('form.compact input, form.compact select, form.compact textarea').each(function(ele){
			if($(this).val().length > 0)
				$('label[for=' + $(this).attr('id') + ']').css({ display: "none" });
		});
	$('form.compact input, form.compact select, form.compact textarea').blur(function(){
			if($(this).val().length == 0)
				$('label[for=' + $(this).attr('id') + ']').show();
		});
	$('form.compact').removeClass('compact');
});



/***********************************************
***  CUFON  ***************************
************************************************/

$(function() {
	Cufon.replace('ul#menu li a', { hover: true });
	Cufon.replace('#headline h1');
	Cufon.replace('#headline h2');
	Cufon.replace('#homePromo h1');
	Cufon.replace('.social');
	Cufon.replace('#rch1000 h1');
	Cufon.replace('#left h1');
	Cufon.replace('#left h2');
	Cufon.replace('blockquote');
	Cufon.replace('#rchDinner h3');
	Cufon.replace('#featuredMember h3');
   	Cufon.now();
});



/***********************************************
***  Newsletter Signup  ************************
************************************************/

$(document).ready(function() {	
						   
	$('#signup').click(function() {		
		var email = $('#newsletterEmail').val();
				if(email) {
					if((/^[A-Z0-9._-]+@[A-Z0-9-]+(\.[A-Z0-9-]{2,})*(\.[A-Z0-9]{2,4}){1,2}$/i).test(email)) {
						$.ajax({
								data: $("form").serialize(),
								success: function(){
										var k = $('input[name="fontColor"]').val();
										if (k == "yes" ) {
											$('.inputContainer').html('<p style="color:#1458B4;">Thank you for registering.</p>')
											}
										else {
											$('.inputContainer').html('<p style="color:#FFB400;">Thank you for registering.</p>')										
										}
										$('#signup').hide();
									},
								type: 'POST',
								url: 'signup_ajax.asp'
							});
					}
					else {
						alert('Email format unrecognised.')
					}
				}
				else {
					alert('Please enter your email address.');
				}
				return false;
		
		
		
		
	});					   
	
	
	
});




