/*!
* @version cbscs.js v1.00.001 09.11.2009
* @author Jacques Dupoux
* @comment
*/


var CBSCS = CBSCS || {};


CBSCS.collegesports = (function() {



	jQuery(document).ready(function(){
	
		jQuery('#logo-link').click(
			function(){
	    		location.href='/';
		});
	



		/* sliding boxes */
		$('.module-2.caption').hover(function(){

			$('.cover',this).stop().animate({top:'55px'},{queue: false, duration:300});	

		}, function(){

			$('.cover',this).stop().animate({top:'138px'},{queue: false, duration:300});		

		});
				





		/* mailing list */
		jQuery('#mailing_list h3').toggle(
			function(){
				$('#mailing_list form').fadeIn('fast');
				return false;
			},
					
			function(){
				$('#mailing_list form').fadeOut('fast');
				return false;
			}
			
	
		);
		
	
		/*email form*/            
		$('#mailing_list #email').focus(function(){
	       if ($(this).val() == 'Email') {
	           $(this).val('');
	       }
	    }).blur(function(){
		       if ($(this).val() == '') {
		           $(this).val('Email');
		       }
	    });		

		$('#mailing_list #zipcode').focus(function(){
	       if ($(this).val() == 'Zipcode') {
	           $(this).val('');
	       }
	    }).blur(function(){
		       if ($(this).val() == '') {
		           $(this).val('Zipcode');
		       }
	    });		



	    jQuery('#mailing_list').submit(
			
			// do check
			
	        function() {
	            if (jQuery('#mailing_list #email').val().length < 5) {
	                //alert("D'oh! You forgot to enter your email address.");
	                jQuery('#mailing_list #getCSTVForm').hide();
	                jQuery('#message').html("<p class='error'>Please enter your email address.</p>").show();
	            	t=setTimeout("jQuery('#message').hide();jQuery('#mailing_list #getCSTVForm').fadeIn()",2000);

	                return false;
	            }
	 
	            if (jQuery('#mailing_list #zipcode').val().length != 5) {
	                //alert("Oops! You didn't enter a 5 digit zipcode.");

	                jQuery('#mailing_list #getCSTVForm').hide();
	                jQuery('#message').html("<p class='error'>Please enter a 5 digit zipcode.</p>").show();
	            	t=setTimeout("jQuery('#message').hide();jQuery('#mailing_list #getCSTVForm').fadeIn()",2000);

	                return false;
	            }
	            
	            else{

					$.post("inc/signup/add_to_list.php",{ email_address: jQuery('#mailing_list #email').val(), postal_code: jQuery('#mailing_list #zipcode').val() }, function(data){
						//alert("Data Loaded: " + data);
						
						
						//check for 409 status in message
						if(data.match("409")){
							//duplicate email message then fadeout
			            	jQuery('#mailing_list #getCSTVForm').hide();
			            	jQuery('#message').html("<p class='error'>Looks like this email address is already on our mailing list.</p>").show();
			            	t=setTimeout("jQuery('#message').fadeOut('slow');",3000);
						}else{
							//thank you message then fadeout
			            	jQuery('#mailing_list #getCSTVForm').hide();
			            	jQuery('#message').html("<p>Thank you for joining!</p>").show();
			            	t=setTimeout("jQuery('#message').fadeOut('slow');",10000);
		            	
		            	}
					   
					   
					 });
	            }
	            
	            return false;
	            
	        }
	 
	    );


    jQuery('#mailing_list submit').click(function(){
    	jQuery('#getCSTVForm').submit();
    });



		
		
		// link for get cbs //
		jQuery('#nav-getcbscollege').click(
			function(){
	    		location.href='/getcbscollegesports/';
		});
		    	
	});




})();