window.addEvent('domready', function() {
	var showSection = $('itemToShow').value;
	try{
	 showSection = parseInt(showSection);
	} catch (err){
		showSection = 999;
	}
	//create our Accordion instance
	/*
	var myAccordion = new Accordion($('accordion'), 'h5.toggler', 'div.element', {
		opacity: true,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#41464D');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#528CE0');
		},
		alwaysHide: true,
		show: parseInt(showSection)
	});
	*/	
		// method stub to expand upon if we want to make 
		// comments an ajax feature...
		$('commentForm').addEvent('submit', function(e) {
		new Event(e).stop();
		//alert('form submission taking place!');	
		$('commentForm').submit();
		});
		
			//var myDrag = new Drag('flagThisCommentFormHouse');
	$('closeFlag').addEvent('click', function(e){
		$('flagThisCommentFormHouse').fade(0);
	});
	$('flagComment').addEvent('submit', function(e) {
		e.stop();  
		var req = new Request({  
		method: 'get',  
		url: $('flagComment').get('action'),  
		data: { 'commentFlagReason' : $('commentFlagReason').value,
				'flaggedArticle': $('flaggedArticle').value  },  
		onRequest: function() { 
		
		// clear the initial message:
		$('flagComentFormTable').style.display = 'none';
		
		// show the 'thanks' message:
		$('flagThanksMessage').style.display = 'inline';
		},  
		onComplete: function(response) { }}).send();  
		
		});
		
});

function showFlagForm(article_id, xPos, yPos){
	// position the box:
	positionModalBox($('flagThisCommentFormHouse'),xPos, yPos);
	
	// set the hidden field with the article_id
	$('flaggedArticle').value = article_id;
	
	// clear out the (old) flag:
	$('commentFlagReason').value = '';
	
	// clear the 'thanks' message:
	$('flagThanksMessage').style.display = 'none';
	
	// show the initial message:
	$('flagComentFormTable').style.display = 'inline';
	
	// show the box:
	$('flagThisCommentFormHouse').fade('show');
	
	// focus on the input:
	$('commentFlagReason').focus();
}

/**
 * Sets the position of a div; 
 */
function positionModalBox(obj,xPos, yPos){
	obj.style.position = 'absolute';
	obj.style.top  = ((yPos - 160) + 'px');
	obj.style.left = (xPos + 'px');
}

