ATI.RFQ = {};

ATI.RFQ.ClearServiceCategory = function(image)
{
	// Detach and hide tooltip, so it doesn't get stuck.
	ATI.UI.Tips.detach(image);
	$$('.mTip').each(function(item, index) { item.hide(); } );
	
	// Get both the label and the div.formControl.
	var label = $('serviceLabel');
	var div = $('serviceDiv');
	
	// Remove both elements from the form.
	label.dispose();
	div.dispose();
};

ATI.RFQ.AddDrawingOrPicture = function(type)
{
	var ul = $(type);
	
	if (ul != null)
	{
		// Create list item.
		var li = new Element('li');
		
		// Create file input element.
		var file = new Element('input', { 'type': 'file', 'size': 41, 'name': type + '[]' });
		
		// Create delete image.
		var image = new Element('img', {
				'src': 'images/quote-minus.png',
				'title': 'Delete This' + (type == 'pictures' ? ' Picture' : ' Drawing'),
				'alt': '-',
				'class': 'icon plusminus addTip'
			});
		image.addEvent('click', function() { ATI.RFQ.DeleteDrawingOrPicture(image, image.getParent()); });
		
		// Append elements to list item.
		file.inject(li);
		image.inject(li);
		
		// Append list item to list.
		li.inject(ul);
		
		// Fix layout and process new tips.
		ATI.UI.Layout();
		ATI.UI.Tips.attach(image);
	}
};

ATI.RFQ.DeleteDrawingOrPicture = function(image, li)
{
	// Detach and hide tooltip, so it doesn't get stuck.
	ATI.UI.Tips.detach(image);
	$$('.mTip').each(function(item, index) { item.hide(); } );
	
	// Get the list and remove the list item.
	li.dispose();
	
	// Fix layout.
	ATI.UI.Layout();
};