/**
* BSkyB Community JS
* Gets and sets the Community DHTML
* Requires: Pluck SiteLife DAAPI
* About: Pluck Community functions
*/

var skyCommunity = {};

//selected link needs className adding to it
skyCommunity.setCommunityLinks = function(noLink) {
	if(document.cookie.indexOf('at=') != -1) {
		if(document.getElementById('contentProfile')) {
			var chkUser = " hant=" + _userId;
			var chkUserUpper = chkUser.toUpperCase();
			var ca = document.cookie.split(';');
			for(var i=0; i<ca.length; i++) {
				var caItem = ca[i];
				var caItemUpper = caItem.toUpperCase();
				if(caItemUpper == chkUserUpper && noLink == 4) {
					noLink = 5;
				};
			}
		}
	} 
	if(document.getElementById('items')) {
		var ulEle = document.getElementById('items');
		var links = ulEle.getElementsByTagName('a');
		links[noLink].className = "selected";
	}
};

//function transforms pluck sitelife dates into nicely rendered dates
skyCommunity.formatDateStamp = function(stamp) {
	var date = new Date(stamp);

	var month = date.getMonth(),
		day = date.getDate(),
		year = date.getFullYear(),
		hours = date.getHours(),
		mins = date.getMinutes()

	if (mins < 10) {mins = "0" + mins;}
	month = month + 1;
	return [day, "\/", month, "\/", year, " ", hours, ":", mins, " "].join("");
}