(function ($) { 


	   
		   
		   
$("#submitbt").live("click", function() {

var cat = $("#searchfor-text1").html();
var state = $("#searchfor-text2").html();
	if(cat!="Boot camps, boarding schools, etc." && state != "Utah, nebraska, etc.")
	{
		cat = cat.replace(/\s+$/,'');	
		state = state.replace(/\s+$/,'');
		
		cat = cat.replace(/^\s+/,'');
		state = state.replace(/^\s+/,'');
	
		cat=cat.split(' ').join('-')
		state=state.split(' ').join('-')
		window.open( "http://www.troubledteens.net/TeensHelp/"+cat+"/"+state+".html" );
	}
});

		   
$("div.middle-tabs").live("click", function() {
	if($(this).html()=="Random")
		{
			$("div.middle-tab-border").children("h2:first").html("90 Randomly Selected Schools and Programs");
			$.ajax({    
		   
		   	type:"POST",
				url:"ajaxschoolslist.php",
				data:"string="+$(this).html(),
		   	beforeSend: function(XMLHttpRequest) {
			   // Show the div before sending the request
			    $('#hp-schools').html("<BR><BR><BR><b>Please wait... </b> <img src='ajax-loader.gif' border='0'><BR><BR><BR>");},
			success: function(html) {
			   // if the request succeeds do something with the received XML 
			   // Get the contents of the first List Item within the Unordered List having a classname of "std"
				$('#hp-schools').html(html);
				}
			});
						
		}
	});

$("div.middle-tabs1").live("click", function() {
	if($(this).html()=="Reviewed")
		{
			$("div.middle-tab-border").children("h2:first").html("Recently " + $(this).html() + " Schools and Programs");			
		}
		else
		{
			$("div.middle-tab-border").children("h2:first").html($(this).html() + " Schools and Programs");
		}
		$.ajax({    
		   
		   	type:"POST",
				url:"ajaxschoolslist.php",
				data:"string="+$(this).html(),
		   	beforeSend: function(XMLHttpRequest) {
			   // Show the div before sending the request
			   $('#hp-schools').html("<BR><BR><BR><b>Please wait... </b> <img src='ajax-loader.gif' border='0'><BR><BR><BR>");},
			success: function(html) {
			   // if the request succeeds do something with the received XML 
			   // Get the contents of the first List Item within the Unordered List having a classname of "std"
				$('#hp-schools').html(html);
				}
			});
	});

$("#js-catlist_item").live("click", function() {
	var title1 = $(this).attr('title');
	$("#searchfor-text1").html(title1);
	$('#js_search_dropdowns').hide();
								   
	});

$("#search-cats").live("click", function() {
	var p = $("#searchfor-text1");
	
	var position = p.position();
	var top = position.top;
	top = top + 25;
	var left = position.left;
	$('#js_search_dropdowns').show();
	$("#js_search_dropdowns").css( { "left":+ left + "px", "top": + top + "px" } );
	$('#js_search_dropdowns').load('categories.htm',null);
								   
	});
 

$("#search-stats").live("click", function() {
	var p = $("#searchfor-text2");
	var position = p.position();
	var top = position.top;
	top = top + 25;
	var left = position.left;
	$('#js_search_dropdowns').show();
	$("#js_search_dropdowns").css( { "left":+ left + "px", "top": + top + "px" } );
	$('#js_search_dropdowns').load('se-states.htm',null);
								   
	});

 

$("#js-catlist_item1").live("click", function() {
	$("#searchfor-text2").html($(this).html());
	$('#js_search_dropdowns').hide();
								   
	});

$("div.discusscomboarrow").live("click", function() {
	var p = $("div.discusscatcontent");
	var position = p.position();
	var top = position.top;
	top = top + 25;
	var left = position.left;
	left = left - 360;
	$('#js_teenageproblems_select').show();
	$("#js_teenageproblems_select").css( { "left":+ left + "px", "top": + top + "px" } );
	$('#js_teenageproblems_select').load('teenageproblems.htm',null);
								   
	});

$("#js-catlist_item2").live("click", function() {
	$("div.discusscatcontent").html($(this).html());
	$('#js_teenageproblems_select').hide();
	
	$.ajax({    
		   
		   	type:"POST",
				url:"ajaxteenageproblemsbasedoncategory.php",
				data:"string="+$(this).html(),
		   	beforeSend: function(XMLHttpRequest) {
			   // Show the div before sending the request
			    $('#teenageproblemsbasedoncategory').html("<div class='questionbox'><BR><BR><BR><b>Please wait... </b> <img src='ajax-loader.gif' border='0'><BR><BR><BR></div>");},
			success: function(html) {
			   // if the request succeeds do something with the received XML 
			   // Get the contents of the first List Item within the Unordered List having a classname of "std"
				$('#teenageproblemsbasedoncategory').html(html);
				}
			});
	
								   
	});



})(jQuery);
