/* share config */
var addthis_config = {
    "data_track_clickback":true,
    ui_header_color: "#000",
    ui_click:true}

//var $j = jQuery.noConflict();

//-----------------
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
$(document).ready(function() {


    $('.edit-link').hover(function(){
        $('span',this).fadeIn('slow')
    }, function(){
        $('span',this).fadeOut('slow')
    });
	
	//------------------ For Bottom Signupbox ------------------
	

	
	$('.mustFields').focus(function() { 

		if($(this).val() == 'Please enter...')
		{
			$(this).val('');
		}
	});

	$('.mustFields').blur(function() { 

		if($(this).val() == '')
		{
			$(this).val('Please enter...');
		}
	});
	$('.signup_1').click(function() { 
		var valid = true;
		$('.mustFields').each(function() { 		
			if($(this).val() == '' || $(this).val() == 'Please enter...')
			{
				$(this).val('Please enter...');
				valid = false;
			}
			else if($(this).attr('id') == 'formEmail_1'){
				if (!filter.test($(this).val())) {
					valid = false;
					alert('Please enter a valid email address...');
				}
			}
		});
		if(valid)
		{
			var msgbody = 
						'Email: ' + 	$('#formEmail_1').val(); 	
			$.post("signup-1.php", {emailFrom: $('#formEmail_1').val(), subject: 'Signup by ' + $('#formEmail_1').val(), message: msgbody},
				function(data){
					$('.signup_form_1').hide().html("<div class=\"block\"><p class=\"main_content_13_yellow\"><strong>Thank you for signing up.</strong></div>").fadeIn('fast');
					$(".signup_events_a").click();
				}
			);	
		}

		return false;
	});
	
	//---------------- For Lightbox Signupbox --------------------
	
	$('.mustFields').focus(function() { 

		if($(this).val() == 'Please enter...')
		{
			$(this).val('');
		}
	});

	$('.mustFields').blur(function() { 

		if($(this).val() == '')
		{
			$(this).val('Please enter...');
		}
	});
	$('.signup_2').click(function() { 
		var valid = true;
		$('.mustFields').each(function() { 		
			if($(this).val() == '' || $(this).val() == 'Please enter...')
			{
				$(this).val('Please enter...');
				valid = false;
			}
			else if($(this).attr('id') == 'formEmail_2'){
				if (!filter.test($(this).val())) {
					valid = false;
					alert('Please enter a valid email address...');
				}
			}
		});
		if(valid)
		{
			var msgbody = 
						'Email: ' + 	$('#formEmail_2').val(); 	
			$.post("signup-1.php", {emailFrom: $('#formEmail_2').val(), subject: 'Signup by ' + $('#formEmail_2').val(), message: msgbody},
				function(data){
					$('.signup_form_2').hide().html("<div class=\"block\"><p class=\"main_content_13_yellow\"><strong>Thank you for signing up.</strong></div>").fadeIn('fast');		
				}
			);	
		}

		return false;
	});
	
	//-------------- feed back form --------------------
	
	
	$('.givemefeedback').click(function(){
				
		var firstname = $("#firstname").val();
		var lastname  = $("#lastname").val();
		var emailadd  = $("#emailadd").val();
		
		if (!filter.test(emailadd)) {
			
			$("#emailadd").css("border" ,'1px dashed #C00');
			return false;
			
		}else{
			
			$("#emailadd").css("border" ,'1px solid #000000');
		}
		
		var streetaddress = $("#streetaddress").val();
		var city = $("#city").val();
		var state = $("#state").val();
		var zipcode = $("#zipcode").val();
		var phnumber = $("#phnumber").val();
		var mm = $("#mm").val();
		var dd = $("#dd").val();
		var yy = $("#yy").val();
		 var dob = mm+'/'+dd+'/'+yy;
		
		var gender = ($('#maleradio:checked').val()=='on')?'Male':'Female';
		var previousvisits  = $("#previousvisits").val();
		var comments  = $("#comments").val().replace(/\r|\n|\r\n/g, '\r\n ');
		var dofutureemails  = ($('#dofutureemails:checked').val()=='on')?'Yes':'No';
		var emailFrom = emailadd;
		var subject   = "FEEDBACK from "+emailFrom;
		var message   = " FirstName : "+firstname+"\r\n Last Name : "+lastname+"\r\n Email Address : "+emailadd+"\r\n Street Address : "+streetaddress;
		message		  = message+"\r\n City : "+city+"\r\n State : "+state+"\r\n Zip Code : "+zipcode+"\r\n Phone Number : "+phnumber+"\r\n DOB : "+dob;
		message		  = message+"\r\n gender : "+gender+"\r\n Previous visits : "+previousvisits+"\r\n Future Emails From us : "+dofutureemails+"\r\n \r\n Comments : \r\n \r\n"+ " " +comments+"\r\n";
		//$(".footer_pages_r").html(message);
		
		var msgbody = message;
			$.post("signup-1.php", {emailFrom: emailFrom, subject:subject, message: msgbody},
				function(data){
					$(".main_content_table").hide('fast');					
					$('.resulthead').html("Thank you for your feedback...");					
					return false;					
				}
			);	
				
		return false;
					
	});
	//End feedback form
	
	
	
	//-------------------------------------
	
	/*if($.browser.msie && jQuery.browser.version < 7){
		
		$('.home_1 > img').css('position', 'absolute').hide();
		$($('.home_1 > img').get(0)).show();
		window.setTimeout('rotateImages(0, \'.home_1\', 8000);', 8000);
		
		$('.home_2 > img').css('position', 'absolute').hide();			
		$($('.home_2 > img').get(0)).show();
		window.setTimeout('rotateImages(0, \'.home_2\', 11000);', 11000);
		
		$('.home_3 > img').css('position', 'absolute').hide();			
		$($('.home_3 > img').get(0)).show();
		window.setTimeout('rotateImages(0, \'.home_3\', 14000);', 14000);
		
		$('.join_club').hover(function() {	
			$(this).css('cursor', 'pointer');					   
			$(this).html('<img src="images/summer_sp_2.png" alt="Summer Specials" width="184" height="181" id="imgCenterAd" />  ');
		},
	   	function() {
			$(this).css('cursor', 'default');	
			$(this).html('<img src="images/summer_sp_1.png" alt="Summer Specials" width="184" height="181" id="imgCenterAd" />  ');
	   }).click(function(){
		   window.location.href = 'menu-summer-specials.php';
		   });
		$('.achiev_txt_wrap').css('background-position', '571px 0px');
		var hhsel = null;
		$('.maroon_tab_2 > a').click(function(){
			$('.maroon_tab_2 > a').css('background-position', '0 0');
			$(this).css('background-position', 'bottom left');
			hhsel = $(this).get(0);
		 });
		$('.maroon_tab_2 > a').hover(function() {	
			$(this).css('background-position', 'bottom left');
		},
	   	function() {
			if($(this).get(0).className.indexOf('active', 0) == -1 ){
				$(this).css('background-position', '0 0');
			}	
	   })		
	
		$('.maroon_tab > a').click(function(){
			$('.maroon_tab > a').css('background-position', '0 0');
			$(this).css('background-position', 'bottom left');
			hhsel = $(this).get(0);
		 });
		$('.maroon_tab > a').hover(function() {	
			$(this).css('background-position', 'bottom left');
		},
	   	function() {
			if($(this).get(0).className.indexOf('active', 0) == -1 ){
				$(this).css('background-position', '0 0');
			}		
	   })
		
		
		$('.legend_vid_tab_cont > a').click(function(){
			$('.legend_vid_tab_cont > a').css('background-position', '0 0');
			$(this).css('background-position', 'right top');
			hhsel = $(this).get(0);
		 });
		$('.legend_vid_tab_cont > a').hover(function() {	
			$(this).css('background-position', 'right top');
		},
	   	function() {
			if($(this).get(0).className.indexOf('active', 0) == -1 ){
				$(this).css('background-position', '0 0');
			}		
	   })
		
	} else {	*/
	
		$('.home_3').cycle({
			fx: 'cover',
			speed: 800,
			timeout: 14000
		});	
		$('.home_1').cycle({
			fx: 'cover',
			speed: 800,
			timeout: 8000
		});
		$('.home_2').cycle({
			fx: 'cover',
			speed: 800,
			timeout: 11000
		});
		
//	}
	
	//----------------------
	$('.add_active a').each(function() {
		$(this).hover(function() {							
			$(this).children('.home_img_hover').show();
		},
	   function() {
		   $(this).children('.home_img_hover').hide();
	   });
	});
	
	//---------------------------
	
	$(".join_club_63").colorbox({width:"425", inline:true, href:"#join_club_content", opacity : 0.7});
	
	//----------------------------
	
	//---------------------------
	
	$(".signup_events_a").colorbox({width:"425", inline:true, href:"#signup_events", opacity : 0.7});
	
	//----------------------------
	
	$('.new_window').attr('target', '_blank');
	

});
//---------------------
$('#tailgating').cycle({ 
    fx:     'turnDown', 
    speed:  500, 
    timeout: 0, 
    pager:  '#tail_nav', 
	
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
		return '#tail_nav div:eq(' + idx + ') a'; 
    }
	//Below - Code for making the container height equal to the changing slides
	//,
	//after:function (curr, next, opts, fwd){
		//get the height of the current slide
		//var $ht = $(this).height();
		//set the container's height to that of the current slide
		//$(this).parent().css("height", $ht);
	//}	
});

//-----------------------

$('#legend_videos').cycle({ 
    fx:     'none', 
    speed:  500, 
    timeout: 0, 
    pager:  '#legend_videos_nav', 
	
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
		return '#legend_videos_nav a:eq(' + idx + ')'; 
    }
	//Below - Code for making the container height equal to the changing slides
	//,
	//after:function (curr, next, opts, fwd){
		//get the height of the current slide
		//var $ht = $(this).height();
		//set the container's height to that of the current slide
		//$(this).parent().css("height", $ht);
	//}	
});

//-----------------------

$('#achievements').cycle({ 
    fx:     'none', 
    speed:  500, 
    timeout: 0, 
    pager:  '#achiev_nav', 
	
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
		return '#achiev_nav div:eq(' + idx + ') a'; 
    }
	//Below - Code for making the container height equal to the changing slides
	//,
	//after:function (curr, next, opts, fwd){
		//get the height of the current slide
		//var $ht = $(this).height();
		//set the container's height to that of the current slide
		//$(this).parent().css("height", $ht);
	//}	
});

//-----------------------

function RemoveText(defaulttext, id) {
    if ($(id).attr("value") == defaulttext) {
        $(id).attr("value", "");
    }
}
function ResetText(defaulttext, id) {
    if ($(id).attr("value") == "") {
        $(id).attr("value", defaulttext);
    }
}

//-----------------------

function ChangeImage()
{
	$('#imgCenterAd').attr("src","images/summer_sp_2.png");
}
function ChangeImageReset()
{
	$('#imgCenterAd').attr("src","images/summer_sp_1.png");
}

function rotateImages(currentPos, allImageSel, speed){
	var nextPos = currentPos+1;
	if(nextPos >= $(allImageSel + ' > img').size()){
		nextPos = 0;
	}
	$( $(allImageSel + ' > img').get(currentPos) ).fadeOut('slow');   
	$( $(allImageSel + ' > img').get(nextPos) ).fadeIn('slow');
	
	window.setTimeout('rotateImages('+nextPos+', "'+allImageSel+'", '+speed+');', speed);
}

//-------------------



