$(document).ready(function() {

	// field focus
	$('.ffocus').each(function() {
		$(this).val($(this).attr('title'));
		$(this).css({ color: '#999999' });
	});
	$('.ffocus').focus(function() {
		if ($(this).val() == $(this).attr('title')) {
			$(this).val('');
			$(this).css({ color: '#666666' });
		}
		}).blur(function() {
		if ($(this).val() == '') {
			$(this).val($(this).attr('title'));
			$(this).css({ color: '#999999' });
		}
	});
	
	if ($("#rbtp-options .wa-options .wa-editbtn").length == 0) {
		$("#rbtp-options .wa-createbtn, #rbtp-create-form").show();
		$("#rbtp-options .wa-options, #rbtp-options .tp-exists").hide();
	}
	else {
		$("#rbtp-options .wa-createbtn, #rbtp-create-form").hide();
		$("#rbtp-options .wa-options, #rbtp-options .tp-exists").show();
		$("#rbtp-options .wa-options .wa-editbtn a").text("Edit My Page");
	}

		$(".tpitem").hide();
		$(".subject-wrap .tpitem:nth-child(2)").show();

		$(".tpbrowse input[type=text]").each(function(){
	 		if ($(this).val() != "") {
				$(this).parent().parent().show();
			}
	 		if ($(this).parent().parent().next("div.tpitem").find("input").val() == "") {
				$(this).parent().parent().addClass("nxtblank");
			}
			else {
				$(this).parent().parent().addClass("nxtexists");
			}
		});

	$(".tpitem a").click(function() {
		$(this).parent().parent().next("div.tpitem").show();
		$(this).parent().parent().addClass("nxtexists");
		return false;
	});
	
	$(".tpfilename").each(function(){
		if (!$(this).text().trim().length) {
		$(this).addClass("empty");
		}
	});
	
	$("#rbtp-detail .tp-files h4:empty").each(function(){
		$(this).parent().hide();
	});

	$(".tppubitem").each(function(){
		$(".tppubfile a",this).text($(".tplinkname",this).text());	
		$(".tplinkname",this).hide();	
	});


        $("ul#topnav").supersubs({ 
            minWidth:    10,	// min width 
            maxWidth:    16,   		// max width 
            extraWidth:  1			// extra width can ensure lines don't sometimes turn over 
									// due to slight rounding differences and font-family 
        }).superfish({ 
            delay:       500,                       // one second delay on mouseout 
            animation:   {opacity:'show'},  		// fade-in and slide-down animation 
            speed:       'fast',                  // faster animation speed 
            autoArrows:  false,	                  	// disable generation of arrow mark-up  
     		dropShadows: true 
		});

	$('#homepanel1').after('<div id="navhp1" class="hpanel-nav">').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 6000, 
		pager:  '#navhp1' 
	});
	
	$('#homepanel2').after('<div id="navhp2" class="hpanel-nav">').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 6000, 
		pager:  '#navhp2' 
	});
	
	
	$('#homepanel3').after('<div id="navhp3" class="hpanel-nav">').cycle({ 
		fx:     'fade', 
		speed:  'slow', 
		timeout: 6000, 
		pager:  '#navhp3' 
	});

	//home site alert
	if ($('#site-alert').html() != 'No announcements found.') {
		$('#site-alert').addClass('active-alert');
	}
	$('#site-alert div.announcement-list h2').prepend('<span class="sa-title">SPECIAL ANNOUNCEMENT:</span> ');
		
});
