$.fn.ExternalLinks = function() 
{
    $("a[rel]").each(function() 
	{
        if (this.getAttribute("rel").indexOf("external") > -1) {
            this.target = "_blank";
        }
    });
};

$.fn.IE6FlickerFix = function() 
{
    try { document.execCommand("BackgroundImageCache", false, true); } 
    catch(err) {}
};

$.fn.ToggleText = function(textToToggle)
{
	return this.each(function()
	{
		$(this).focus(function()
		{			
			if ($(this).val() == textToToggle)
				$(this).val('');
		});
		$(this).blur(function()
		{
			if ($(this).val() == '')
				$(this).val(textToToggle);
		});
	});
};

$(document).ready(function() 
{
	$().ExternalLinks();
    $().IE6FlickerFix();
	LeftHandNavigation();
	CPQuestionnaireSlider();
	CPQuestionnaireValidation();
        
        $("#FrmSUB").validate({
            errorLabelContainer: $("#FrmSUB div.error")
        });         
});

function CPQuestionnaireSlider()
{
	$('#v_slidein').click(function() {
		$('#vertical_slide').slideDown(1000);
	});
	$('#v_slideout').click(function() {
		$('#vertical_slide').slideUp(1000);
	});	
}

function CPQuestionnaireValidation()
{
		$("#form1").validate({
			rules: {
				area_of_practice_other: {required: '#area_of_practice_13:checked'}
			},
			errorPlacement: function(error, element){
				error.insertBefore(element);
			}
		});
}

function LeftHandNavigation()
{
	if ($('.inThisSectionInfo').find('h3').text().indexOf("In the Current Work Section") > -1)
	{
		$('.inThisSectionInfo > ul > li').each(function() 
		{
			if (!$(this).hasClass('current_page_item')) 
				$(this).find('ul').hide();
			
			if ($(this).hasClass('current_page_ancestor')) 
				$(this).find('ul').show();
		});
	}
}

function BannerRotatorIn()
{
	$('.create').fadeTo('slow',0);
	// Loop around and call this method again
	setTimeout('BannerRotatorOut()', 6000);
};

function BannerRotatorOut()
{
	$('.create').fadeTo('slow',1);
	// Loop around and call this method again
	setTimeout('BannerRotatorIn()', 6000);
};


