	var url = window.location.pathname;
	
	//for multiple page articles, only write it as first page
	if(url.lastIndexOf("_1.html") == -1) {
		url = url.replace(/_(\d+)\.html/, '_1.html');	
	}

	//Event.observe(window, 'load', determineLoginStatus, false);
	//addEvent(window, 'DOMContentLoaded', determineLoginStatus);

	//this will need to be re-coded for Articles only
	//if(url.indexOf("/baldwin/comments/") != -1 || url.indexOf("/baldwin/article/") != -1)
		//addEvent(window, 'DOMContentLoaded', init);

	//if(url.indexOf("/baldwin/comments/") != -1 || url.indexOf("/baldwin/article/") != -1)
		//Event.observe(window,'load', init, false);
		//Event.observe(emptycomments, 'load', init, false);

//	if(url.indexOf("/baldwin/comments/") != -1 || url.indexOf("/baldwin/article/") != -1)
	//     addEvent(window, 'DOMContentLoaded', init);			

	function init() {
		ArticleComments.getComments(url, {
		callback: function(data) {
			for(var key = 0; key < data.length; key++) {
				//simple string for now
				if(data[key] != null) {
					var commentBlock = '<div class=\"commentPost story\"><div class=\"commentID\"><b>'+data[key].userName+'</b> ' + '<font color=#999999>'+data[key].modifiedDate + '</font> &nbsp;&nbsp;<a id=\"lightbox_'+data[key].id+'\" class=\"lbOn\" href=\"/account/flagit.html?id=' + data[key].id + '\">flag as inappropriate</a> </div>'+data[key].comments+'</div>';
					new Insertion.Bottom('emptycomments', commentBlock);
					//this should allow lightbox to work
					//new lightbox(document.getElementById('lightbox_'+data[key].id));
				}
			}
		},
		errorHandler:function(message) {alert(message);}
		});
				
	}
			
	function exposeCommentsForm() {
		Element.show('commentsDiv');
		//reset everything first
		Element.hide('postButton');
		Element.hide('requireLogin');
		var cookievalue = Cookie.get('IFWUSER');
		if(cookievalue != null && cookievalue.length > 0) {
			Element.show('postButton');
		} else {
			Element.show('requireLogin');
		}
	}



	function submitComment() {
		//assuming no checking yet
		//three things to do here,
		//1.  if Cookie available, just post
		//2.  if cookie is not available, prompt login
		//3.  if need to register, register, and post
		//ArticleComments.insertComment(processPost, Cookie.get('IFWUSER'), $F('commentsField'), url);
		
		var cookievalue = Cookie.get('IFWUSER');
		var commentsField = $F('commentsField');
			
		ArticleComments.insertActiveComment(Cookie.get('IFWUSER'), $F('commentsField'), url, {
			callback: function(data) {
				var date = new Date();
				var month = eval(date.getMonth()+1);
				if(month < 10)
					month = "0"+month;
				var minutes = date.getMinutes();
				if(minutes < 10)
					minutes = "0"+minutes;
				var seconds = date.getSeconds();
				if(seconds < 10)
					seconds = "0"+seconds;
				var formattedDate = date.getFullYear() + "-"+month+"-"+date.getDate()+" "+date.getHours()+":"+minutes+":"+seconds;
				var commentBlock = '<div class=\"commentPost story\"><div class=\"commentID\"><b>'+Cookie.get('IFWUSER')+'</b> <font color=\"#999999\">' + formattedDate + '</font></div>'+$F('commentsField')+'</div>';
				new Insertion.Bottom('emptycomments', commentBlock);
				Form.reset('postComment');
			},
			errorHandler:function(message) {alert(message);}
		});
	}
