function confirmDelete() { return confirm("Are you sure you want to delete this item?"); }

function toggleCompanyNumber() {
	var el = document.editForm.short_text;
	el.disabled = document.editForm.auto_gen.checked;

	if (el.style.backgroundColor == "white" || el.style.backgroundColor == "")
		el.style.backgroundColor = "darkgray";
	else
		el.style.backgroundColor = "white";
}






//-----------------------------------------------------------------------------------------------------------------
// This function is used on the Customer Summary Report - OPTIONS page.  It loads in the appropriate jobs for 
// the report.
//-----------------------------------------------------------------------------------------------------------------
function customerSummaryOptions_loadJobs()
{
	$('generatePDFbtn').hide();
	$('quotelist').addClassName('loading').update('Loading...');

	$('filterForm').request({
		onComplete: function (resp) {
			$('quotelist').removeClassName('loading').update(resp.responseText);
		}
	});
	
	return false;
}





//-----------------------------------------------------------------------------------------------------------------
// This function is used on the Customer Summary Report - OPTIONS page.  It triggers the PDF being generated by 
// submitting the form on that page.
//-----------------------------------------------------------------------------------------------------------------
function customerSummaryOptions_openPDF()
{
	$('generatePDFform').submit();
}





function manufacturersSpecified_categorySelected()
{
	var	list = $('manufacturer').down('select'),
		category = $('category').down('select');
	
	$('manufacturer').setStyle({'visibility':'hidden'});	
	
	if (category.value == "")
		return;
	
	new Ajax.Request(location.href, {
		method: 'post',
		postBody: 'get_manufacturers=' + category.value,
		onComplete: function (response) {
			var resp = response.responseText.evalJSON();
			list.update();

			var obj = new Element('option', {value: ''});
			
			obj.text = 'Please select a manufacturer';
			obj.update('Please select a manufacturer');
			
			list.insert({'bottom': obj});
			
			for (id in resp)
			{
				var obj = new Element('option', {value: id});
				
				obj.text = resp[id];
				obj.update(resp[id]);
				
				list.insert({'bottom': obj});
			}

			$('manufacturer').setStyle({'visibility':'visible'});
		}
	 });
}

function manufacturersSpecified_manufacturerSelected()
{
	$('filterForm').down('button').setStyle({
		'visibility': ($('manufacturer').down('select').selectedIndex == 0) ? 'hidden' : 'visible'
	});
}

function manufacturersSpecified_getReport()
{
	$('report').update('Loading...');
		
	$('filterForm').request({
		onComplete: function (response) {
			$('report').update(response.responseText);
		}
	});
}

