/*/**
 * Convert linebreaks to html breaks
 * http://stackoverflow.com/questions/2919337/jquery-convert-line-breaks-to-br-nl2br-equivalent
 */
/*$.nl2br = function(str, is_xhtml) {
	var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
	return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
};

/**
 * Convert date object to ISO8601 UTC
 * http://delete.me.uk/2005/03/iso8601.html
 */
 /*
Date.prototype.setISO8601 = function (string) {
    var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
        "(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
        "(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
    var d = string.match(new RegExp(regexp));

    var offset = 0;
    var date = new Date(d[1], 0, 1);

    if (d[3]) {date.setMonth(d[3] - 1);}
    if (d[5]) {date.setDate(d[5]);}
    if (d[7]) {date.setHours(d[7]);}
    if (d[8]) {date.setMinutes(d[8]);}
    if (d[10]) {date.setSeconds(d[10]);}
    if (d[12]) {date.setMilliseconds(Number("0." + d[12]) * 1000);}
    if (d[14]) {
        offset = (Number(d[16]) * 60) + Number(d[17]);
        offset *= ((d[15] == '-') ? 1 : -1);
    }

    offset -= date.getTimezoneOffset();
    time = (Number(date) + (offset * 60 * 1000));
    this.setTime(Number(time));
}

/**
 * Month names for Javascript's Date
 */
 /*
var monthNames = ["January", "February", "March", "April", "May", "June","July","August","September","October","November","December"];

/**
 * Object for dealing with facebook functionality
 */
 /*
var facebook =
{
	/**
	 * With the the facebook user's profile id or group_id and a suitable div to serve
	 * as the user's wall, get the facebook feed and write wall comments
	 * @param Integer options.id User's facebook profile id
	 * @param jQuery options.type Whether individual or group profile
	 * @param jQuery options.wall A jquery div to append wall posts to
	 * @param Integer options.num_wall_posts Number of posts to display
	 * @param String options.template HTML string of the container for each post, to be appended to the $wall
	 * @param String options.scripturl The url of the ajax script
	 */
	 /*
	writeWall : function(options){

		options.id = options.id;
		if (options.id)
		{
			$.ajax({
				url: options.scripturl,
				dataType: 'json',
				data: { "id" : options.id, "type" : options.type },
				success: function (data){
					var dataObj = eval(data);
					var feed = dataObj.data;

					if ($.isArray(feed))
					{
						for (var i=0, filterCounter=0;
							filterCounter < ((options.num_wall_posts < feed.length) ? options.num_wall_posts : feed.length);
							i++)
						{
							var item = feed[i];
//							var fromUser = item.from.name.match(/sharon/i);
							if (/*$.isArray(fromUser) && typeof item.message != "undefined")
							{
								filterCounter++;
								var post = decodeURI(options.template);//template contains urls
								post = post.replace(/\{\$name\}/gi, item.from.name);
								post = post.replace(/\{\$sef_name\}/gi, item.from.name.replace(/\s/ig,"-"));
								post = post.replace(/\{\$id\}/gi, item.from.id);
								post = post.replace(/\{\$message\}/gi, $.nl2br(item.message));
								var updated = new Date();
								updated.setISO8601(item.updated_time);
								if ((updated.getHours()>=12))
								{
									var hour = (updated.getHours() % 12 > 0)? updated.getHours() % 12 : "12";
									var afterNoon = true;
								}
								else
									var hour = updated.getHours();
								updated.time = hour+":"+updated.getMinutes()+((afterNoon)?" p.m.":" a.m.")

								post = post.replace(/\{\$datetime\}/gi, monthNames[updated.getMonth()] + " " + updated.getDay() + " at " + updated.time);

								options.wall.append(post);
							}
						}
					}					
				}
			});
		}
	}
}*/
