
// Global script that handles standard BC features
var $j = jQuery.noConflict();

$j.fn.noContentData = function() {
	// Shout out to Michael Leung (http://michaelleung.us) on the javascript iteration below.
	var messages = [ ["Forum has no topics.", "This forum has no topics yet.  Write the first one!"], ["No announcements found.", "No recent announcements were found.  We're still hard at work so check back later."]];
	if ( $j(this).size() ) {
		for (i = 0; i < messages.length; i++) {
			if ($j(this).text().trim() == messages[i][0]) {	
				$j(this).addClass("noData");
				$j(this).html(messages[i][1]);
																	
			}
		}
	}
}
$j.fn.addPageLike = function() {
	$j(this).each(function() {
		var pageURL = window.location;
		
		if ( $j(this).html("") ) {
			if (/\/post\//.test(window.location) || /AnnouncementRetrieve.aspx/.test(window.location)) {
				$j(this).html('<iframe id="pageLike" src="http://www.facebook.com/plugins/like.php?href='+pageURL+'&amp;layout=button_count&amp;show_faces=false&amp;width=450&amp;action=like&amp;font=lucida+grande&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>');
			}
		}
		else {}
	});
}
$j.fn.hideFacebox = function() {
	if ( $j("#faceBox").html().trim() != "" ) {
	}
	else {
		$j("#faceBox").html("<a id='closeFacebox' class='btn' href='#top' title='Close'>Close</a><iframe src='http://www.facebook.com/plugins/likebox.php?id=185946386449&amp;width=550&amp;connections=18&amp;stream=true&amp;header=false&amp;height=555' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:550px; height:555px;' allowTransparency='true'></iframe>");
	}
	
	if ( $j("#faceBox").is(":hidden") ) {
		$j("#faceBox").fadeIn();	
		$j(window).scrollTo("#faceBox", 500);
		$j("#toggleFaceBox").html("Show <strong>less</strong> from Facebook").attr("title", "Show less from Facebook");
	}
	else {
		$j("#faceBox").fadeOut();
		$j(window).scrollTo("#top", 500);
		$j("#toggleFaceBox").html("Show <strong>more</strong> from Facebook").attr("title", "Show more from Facebook");
	}
}

$j(document).ready(function() {

// Show / hide Facebook Fan Page info

	if ( $j("#faceBoxLight").size() ) {
		$j("#faceBox").hide();
	}

	$j("#toggleFaceBox, #closeFacebox").live('click', function() {
		$j.fn.hideFacebox();		
		return false;
	});

// Blog Settings
   
	// Gather all comment links and assign click function to toggle corresponding div
  $j(".post-body .links a.commentToggle").click(function () { 
      var thisTarget = $j(this).attr('href');
      $j(thisTarget).slideToggle(); 
      $j(this).blur();
      return false;
    });

  // Do the same for trackback links
  $j(".post-body .links a.trackbackToggle").click(function () { 
      var thisTarget = $j(this).attr('href');
      $j(thisTarget).slideToggle(); 
      $j(this).blur();
      return false;
    });
    
	$j("#placeholder-box1 .announcement-list span.date").bcBlogDates(false, true);
// End Blog Settings

	//Remove the {module_fullname} from comment form 
		//$j(".form input").each(function (i) {
			//if (this.val == '{module_fullname}') {
				//$j(this).val('');
			//}
			//});

// Superfish Main Menu

	$j("ul#nav_537728").superfish(); 
								
	//$j("#ul_nav_537728").hoverIntent(addtabHighlight,removetabHighlight);

	//function addtabHighlight(){ 
		//$j(this).addClass('highlight');
	//}
	//function removetabHighlight(){ 
		//$j(this).removeClass('highlight');
	//}

// Cancer Facts Web App Slideshow

	$j("ul.cancerFacts").children("li").each(function() {
		var SourceLink = $j(this).find("span.link a").attr("href");
		var SourceName = $j(this).find("span.name").text();
		var textSize = $j(this).find("input.factTextSize").attr("value");
		var imageSat = $j(this).find("input.imageSat").attr("value");
		
		$j(this).addClass("text"+textSize+" img"+imageSat);
		$j(this).find("span.link").remove();

		if ( $j(this).find("cite span.name").text().trim() == "" ) {
			$j(this).find("cite span.name").remove();	
			$j(this).find("a.citeShow").remove();
		}
		else {
			$j(this).find("a.citeShow").attr("href", SourceLink);
		}
});
	$j("a.citeShow").hover(
			function () {
				$j(this).siblings("cite").show();
			}, 
			function () {
				$j(this).siblings("cite").hide();
			}
	);


	$j("#catforumoutput, #placeholder-box1").noContentData();
	//$j("#pageLike").addPageLike();
	
//Featured Announcements

	//$j('.featuredAnnouncements').children('div').addClass('featuredItem');
	
	//$j(window).load(function () {
		//var announceText = $j('.featuredAnnouncements').text();
		//if (announceText == "No announcements found.") {
			//$j('.featuredAnnouncements').hide();
		//}
	//});

// Detect if forums are empty and add padding to the innerHTML

// Empty cart message 

  
}); 


function launchWS(winName) {

//window height and width
myHeight = screen.height*.80;
myWidth = 784;

//widow height bounds
if ( myHeight < 556 ) {
myHeight = 556;
} else if (myHeight>700) {
myHeight = 700;
}

//get screen size, and cacl center screen positioning
var height = screen.height;
var width = screen.width;
var leftpos = width / 2 - myWidth / 2;
var toppos = (height / 2 - myHeight / 2) - 40;

//open window
msgWindow=window.open(winName,"ws_window","toolbar=no,location=no,directories=no,resizable=yes,menubar=no,scrollbars=no,status=yes,width=" + myWidth + ",height="+ myHeight + ", left=" + leftpos + ",top=" + toppos);

//focus window
setTimeout('msgWindow.focus()',1);
}// JavaScript Document