function sendDeptEmail(nonProductOID, email){
	document.DeptDetailForm.nonProductOid.value = nonProductOID;
	document.DeptDetailForm.emailID.value = email;
	document.DeptDetailForm.submit();
}
function contact_togPhone(phoneBlockID)
{
	$(phoneBlockID).toggleClassName('activePhoneNumber');
	$(phoneBlockID+'Link').toggleClassName('activePhoneLink');
	//Insert back-end call for tracking purposes
}
function closeCAN()
{
	$('CANLocation').setStyle({'display':'none'});
	$('CANOverlay').setStyle({'display':'none'});
	allDropDowns.invoke('setStyle','{visibility:visible}');
}
function showCAN()
{
	allDropDowns.invoke('setStyle','{visibility:hidden}');
	$('CANOverlay').setStyle({'display':'block'});
	$('CANLocation').setStyle({'display':'block'});
}
function checkProducts()
{
	var curCat=$F('category');
	switch(curCat)
	{
		case '1':
			$('products_category_5').setStyle({'display': 'none'});
			$('products_category_1').setStyle({'display': 'block'});
			$('productPair').setStyle({'display': 'block'});
		break;
		case '5':
			$('products_category_1').setStyle({'display': 'none'});
			$('products_category_5').setStyle({'display': 'block'});
			$('productPair').setStyle({'display': 'block'});
		break;
		default:
			$('productPair').setStyle({'display': 'none'});
		break;
	}
}
function validateContactForm(whichForm,departmentName)
{
	numReg = /^[0-9.,-]*$/g;
	emailReg = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var fieldErrors=$(whichForm).select('span.fieldError');
	fieldErrors.each(function(curBlock)
	{
		curBlock.innerHTML='';
	});
	var formErrors=[];
	// Validate standard fields required by all forms
	var nonBlanks=[
		{id:'firstName',label:'First Name'},
		{id:'lastName',label:'Last Name'},
		{id:'companyName',label:'Company Name'},
		{id:'message',label:'message'},
		{id:'emailAddress',label:'Email Address'},
		{id:'accountNumber',label:'Account Number'}
	];
	nonBlanks.each(function(curField){
		if ($F(curField.id).empty()) formErrors.push({id:curField.id,error:curField.label+' cannot be left blank.'});
	});
	// Validate non-standard fields requires by all forms
	// Phone
	if (($F('phone_areaCode').length<3)||($F('phone_prefix').length<3)||($F('phone_lastFour').length<4)||(!(($F('phone_areaCode').match(numReg))&&($F('phone_prefix').match(numReg))&&($F('phone_lastFour').match(numReg))&&($F('phone_extension').match(numReg)))))
	{
		formErrors.push({id:'phone',error:'Please provide your phone number using only numbers.'});
	}
	// Email address
	if (! $F('emailAddress').match(emailReg)) formErrors.push({id:'emailAddress',error:'The e-mail address you have entered is invalid.'});
	// Account Number - optional
	if ((! $F('accountNumber').empty())&&(! $F('accountNumber').match(numReg)))
	{	
		formErrors.push({id:'accountNumber',error:'The account number you have entered contains invalid characters.'});
		
	}

	// Handle form-specific requirements
	switch(departmentName)
	{	
		case 'Postage':
			
			 if($F('product')=='select')
				{
				formErrors.push({id:'product',error:'Please select a product.'});
				}
						
		break;

		case 'Equipment Installation/Service':

			if($F('category')=='select')
			{	
				formErrors.push({id:'category',error:'Please select a category.'});

			}
			if($F('category')=='Mail Machines')
				{	
					if(($F('product')=='select'))
					{	
						formErrors.push({id:'product',error:'Please select a product.'});
					}
				}
			if($F('category')=='Software')
				{
					if($F('products')=='select')
					{
					formErrors.push({id:'products',error:'Please select a product.'});
					}
				}
			
			break;

		case "Rate Change Hotline":
		
			if($F('category')=='select')
			{
				formErrors.push({id:'category',error:'Please select a category.'});

			}else if($F('category')=='Mail Machines')
				{
					if($F('product')=='select')
					{		
						formErrors.push({id:'product',error:'Please select a product.'});
					}
			}
			break;

		default:
					
		break;
	}

	// Toss errors and redraw or submit if okay
	if (formErrors.length)
	{
		$('errorSummary').innerHTML='<div id="errorSummary"></div>';
		formErrors.each(function(curField){
			$(curField.id+'_errorMsg').innerHTML=curField.error;
		});
	}
	else
	{
		document.forms[whichForm].submit();
	}
}
