(function($){
	$(document).ready(function() {
		$('div.portlet_content:visible').hide();
		//$(':input','#articlesAdvSearch').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked').removeAttr('selected');

		//on new page load or back button
		
		// Toggle Single Portlet
		$('a.toggle').click(function()
			{
				$(this).parent('div').next('div').toggle();
				return false;
			}
		);

		// Invert All Portlets
		$('a#all_invert').click(function()
			{
				$('div.portlet_content').toggle();
				return false;
			}
		);

		// Expand All Portlets
		$('a#all_expand').click(function()
			{
				$('div.portlet_content:hidden').show();
				return false;
			}
		);

		// Collapse All Portlets
		$('a#all_collapse').click(function()
			{
				$('div.portlet_content:visible').hide();
				return false;
			}
		);

		// Open All Portlets
		$('a#all_open').click(function()
			{
				$('div.portlet:hidden').show();
				$('a#all_open:visible').hide();
				$('a#all_close:hidden').show();
				return false;
			}
		);

		// Close All Portlets
		$('a#all_close').click(function()
			{
				$('div.portlet:visible').hide();
				$('a#all_close:visible').hide();
				$('a#all_open:hidden').show();
				return false;
			}
		);
		
		$("#submit_partner2").live("click", function () {
			//$('tr.current').toggleClass("current");								   
			//$(this).closest('tr').toggleClass("current");
			//var request_ID = this.id.replace("request_", "");
			$("#divFindapartner").html('<p id="ajax_loading">Loading&hellip;<br /><img src="images/loader.gif" alt="" /></p>');
			$("#divFindapartner").load("cfcs/searches.cfc?method=findapartner_search", 
			{	
				radius: $("#radius").val(),
				zipcode: $("#zipcode").val()
			},
			function() {
				//requestDetailsInit();
				//formHelpersInit();
			});
			return false;
		});
		
		// find a place to play , facility name / city / state 
		$("#searchButton1").live("click", function () {
	    	var checking_html = 'Good to go, please Wait...';
			
			if($('#city').val().length > 0 && $('#state').val().length > 0){  
				//else show the cheking_text and run the function to check  
				$('#Note1').addClass('green');
				$('#Note1').html(checking_html);

	            $('#CommentForm').submit();
	        }else{  
				
				if($('#city').val().length == 0){
	            	//if it's below the minimum show characters_error text '
					$('#Note1').addClass('red');
	            	$('#Note1').html('<div class="message error" style="width:250px;"><p>Please enter city.</p></div>'); 
					return false;
				}
				if($('#state').val().length == 0){
					
	            	//if it's below the minimum show characters_error text '
					$('#Note1').addClass('red');
	            	$('#Note1').html('<div class="message error" style="width:250px;"><p>Please select a state</p></div>'); 
					return false;
				}
				
	        }  
		});
		// find a place to play , radius / zip code 
		$("#searchButton2").live("click", function () {
			//result texts  
	    	var checking_html = 'Good to go, please Wait...';
			
			//alert($('#radius').val().length);
			//alert($('#zipcode').val().length);
			if($('#radius').val().length > 0 && $('#zipcode').val().length > 0){  
				//else show the cheking_text and run the function to check  
				//alert('click 2');
				$('#Note2').addClass('green');
				$('#Note2').html(checking_html);

	            $('#CommentForm2').submit();
				//$(":submit").attr('disabled', 'disabled');
	        }else{  
				//alert('click 2...');
				
				if($('#radius').val().length == 0){
				
	            	//if it's below the minimum show characters_error text '
					$('#Note2').addClass('red');
	            	$('#Note2').html('<div class="message error" style="width:250px;"><p>Please select radius.</p></div>'); 
					return false;
				}
				if($('#zipcode').val().length == 0){
				
	            	//if it's below the minimum show characters_error text '
					$('#Note2').addClass('red');
	            	$('#Note2').html('<div class="message error" style="width:250px;"><p>Please enter a zip code</p></div>'); 
					return false;
				}
				
	        }  

		});
		
		$("#under10_link").live("click", function () {
			var show_program = '#under10_details';
			//$('#programDetails').show(500);
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=under10");
		});
		
		$("#over10_link").live("click", function () {
			var show_program = '#over10_details';
			//$('#programDetails').show(500);
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=over10");
		});
		
		$("#over18_link").live("click", function () {
			var show_program = '#over18_details';
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=over18");
		});
		
		$("#over25_link").live("click", function () {
			var show_program = '#over25_details';
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=over25");
		});
		
		$("#over50_link").live("click", function () {
			var show_program = '#over50_details';
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=over50");
		});
		
		$("#over70_link").live("click", function () {
			var show_program = '#over70_details';
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=over70");
		});
		
		$("#findlocation_link").live("click", function () {
			var show_program = '#findlocation_details';
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=findlocation");
		});
		
		$("#findapartner_link").live("click", function () {
			var show_program = '#findapartner_details';
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=findapartner");
		});
		
		$("#findinstruction_link").live("click", function () {
			var show_program = '#findinstruction_details';
			$('#programDetails').load("modules/inc_programdetails.cfm?mode=findinstruction");
		});
		//$("#over70_link").live("click", function () {
		//	var show_program = '#over70_details';
		//	$('#programDetails').load("modules/inc_programdetails.cfm?mode=over70");
		//});
		
		// find instruction / zipcode / radius
		$("#searchCoachButton2").live("click", function () {
			//result texts  
	    	var checking_html = 'Good to go, please Wait...';
			
			//alert($('#radius').val().length);
			//alert($('#zipcode').val().length);
			if($('#radius').val().length > 0 && $('#zipcode').val().length > 0){  
				//else show the cheking_text and run the function to check  
				//alert('click 2');
				$('#Note2').addClass('green');
				$('#Note2').html(checking_html);
				
				$('#city').val("");
				$('#state').val("");

	            $('#CommentForm').submit();
				//$(":submit").attr('disabled', 'disabled');
	        }else{  
				//alert('click 2...');
				
				if($('#radius').val().length == 0){
				
	            	//if it's below the minimum show characters_error text '
					$('#Note2').addClass('red');
	            	$('#Note2').html('<div class="message error" style="width:250px;"><p>Please select radius.</p></div>'); 
					return false;
				}
				if($('#zipcode').val().length == 0){
				
	            	//if it's below the minimum show characters_error text '
					$('#Note2').addClass('red');
	            	$('#Note2').html('<div class="message error" style="width:250px;"><p>Please enter a zip code</p></div>'); 
					return false;
				}
	        } 
		});
		
		// find instruction / city / state
		$("#searchCoachButton1").live("click", function () {
			//result texts  
	    	var checking_html = 'Good to go, please Wait...';
			
			//alert($('#city').val().length);
			//alert($('#state').val().length);
			if($('#city').val().length > 0 || $('#state').val().length > 0){  
				//else show the cheking_text and run the function to check  
				//alert('click  line 228');
				$('#Note1').addClass('green');
				$('#Note1').html(checking_html);
				
				$('#zipcode').val("");
				$('#radius').val("");
				
	            $('#CommentForm').submit();
				//$(":submit").attr('disabled', 'disabled');
	        }else{  
				//alert('click 2...line 238');
				
				$('#Note1').addClass('red');
	            $('#Note1').html('<div class="message error" style="width:250px;"><p>Please enter a city and/or select state.</p></div>'); 
				return false;
	        } 
		});
		
		// find a partner / city / state
		$("#searchPartnerButton1").live("click", function () {
			//result texts  
	    	var checking_html = 'Good to go, please Wait...';
			
			//alert($('#city').val().length);
			//alert($('#state').val().length);
			if($('#city').val().length > 0 || $('#state').val().length > 0){  
				//else show the cheking_text and run the function to check  
				//alert('click  line 228');
				$('#Note1').addClass('green');
				$('#Note1').html(checking_html);
				
				$('#zipcode').val("");
				$('#radius').val("");
				
	            $('#CommentForm').submit();
				//$(":submit").attr('disabled', 'disabled');
	        }else{  
				//alert('click 2...line 238');
				
				$('#Note1').addClass('red');
	            $('#Note1').html('<div class="message error" style="width:250px;"><p>Please enter a city and/or select state.</p></div>'); 
				return false;
	        } 
		});
		
		// find instruction / zipcode / radius
		$("#searchPartnerButton2").live("click", function () {
			//result texts  
	    	var checking_html = 'Good to go, please Wait...';
			
			//alert($('#radius').val().length);
			//alert($('#zipcode').val().length);
			if($('#radius').val().length > 0 && $('#zipcode').val().length > 0){  
				//else show the cheking_text and run the function to check  
				//alert('click 2');
				$('#Note2').addClass('green');
				$('#Note2').html(checking_html);
				
				$('#city').val("");
				$('#state').val("");

	            $('#CommentForm').submit();
				//$(":submit").attr('disabled', 'disabled');
	        }else{  
				//alert('click 2...');
				
				if($('#radius').val().length == 0){
				
	            	//if it's below the minimum show characters_error text '
					$('#Note2').addClass('red');
	            	$('#Note2').html('<div class="message error" style="width:250px;"><p>Please select radius.</p></div>'); 
					return false;
				}
				if($('#zipcode').val().length == 0){
				
	            	//if it's below the minimum show characters_error text '
					$('#Note2').addClass('red');
	            	$('#Note2').html('<div class="message error" style="width:250px;"><p>Please enter a zip code</p></div>'); 
					return false;
				}
	        } 
		});
		
		$(".closePrograms").live("click", function () {
			$('#programDetails').hide(500);
		});
		
	});  
})(jQuery);




