//functions to be executed on page load
$(function(){
	
	//Open all links with rel="external" in new window
	$(function(){
		$('a').filter(function(){
			return (!this.target && (this.href.indexOf(window.location.hostname) == -1 || this.href.match(/\.pdf$/i)));
		}).attr('target', '_blank');
	});
	
	var zIndexNumber = 1000;
		
		
	$("#therapies,#therapies-sub").hover(function() {
		$("#therapies").css({"height":"56px","z-index":"100000","background":"url(images/clear.gif) repeat-x 0 0"});
		$("#therapies").children().addClass("current");
		$("#therapies-sub").css({"background":"url(images/clear.gif) repeat-x 0 0"}).show();
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
	}, function() {
		$("#therapies").css({"height":"26px","background-color":"#fff"});
		$("#therapies").children().removeClass("current");		
		$("#therapies-sub").hide();
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber += 10;
		});
	});	
	
	$("#personal,#personal-sub").hover(function() {
		$("#personal").css({"height":"46px","z-index":"100000","background":"url(images/clear.gif) repeat-x 0 0"});
		$("#personal").children().addClass("current");
		$("#personal-sub").css({"background":"url(images/clear.gif) repeat-x 0 0"}).show();
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
	}, function() {
		$("#personal").css("height","26px");
		$("#personal").children().removeClass("current");		
		$("#personal-sub").hide();
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber += 10;
		});
	});	
	
	$("#about,#about-sub").hover(function() {
		$("#about").css({"height":"46px","z-index":"100000","background":"url(images/clear.gif) repeat-x 0 0"});
		$("#about").children().addClass("current");
		$("#about-sub").css({"background":"url(images/clear.gif) repeat-x 0 0"}).show();
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
	}, function() {
		$("#about").css("height","26px");
		$("#about").children().removeClass("current");		
		$("#about-sub").hide();
		$('div').each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber += 10;
		});
	});		

	$(".back-link").click(function() {
		var referrer = document.referrer;
		window.location = referrer;
	});

	//Clear value in search input box
	swapValues = [];
	$("#T_EMAIL").each(function(i){
		swapValues[i] = $(this).val();
		$(this).focus(function(){
			if ($(this).val() == swapValues[i]) {
				$(this).val("");
			}
		}).blur(function(){
			if ($.trim($(this).val()) == "") {
				$(this).val(swapValues[i]);
			}
		});
	});
	
});

//functions to be executed inline
var mylib =
{
	function_name :
	{
		init : function()
		{
			alert('First Function Initialized');
		}
	},
	another_function_name :
	{
		init : function()
		{
			alert('Second Function Initialized');
		}
	}
}
