function customerValidate()
{
	var name = document.getElementById('fullname');
	var company = document.getElementById('companyname');
	var phone = document.getElementById('phoneno');
	var email = document.getElementById('email');
	var service = document.getElementById('service_no1');
	var password = document.getElementById('password');
	var fields = '';
	if (isWhitespace(name.value))
	{
		fields += (fields.length > 0) ? ', name' : 'Full Name';
	}
	if (isWhitespace(company.value))
	{
		fields += (fields.length > 0) ? ', company' : 'Company Name';
	}
	if (isWhitespace(phone.value))
	{
		fields += (fields.length > 0) ? ', phone' : 'Phone Number';
	}
		if (isWhitespace(email.value))
	{
		fields += (fields.length > 0) ? ', email' : 'Email';
	}
	if (isWhitespace(service.value))
	{
		fields += (fields.length > 0) ? ', service' : 'Service Number';
	}
	if (isWhitespace(password.value))
	{
		fields += (fields.length > 0) ? ', password' : 'Password';
	}


	if (fields.length > 0)
	{
		var msg = 'Please provide the following information: ' + fields;
		alert(msg);
		return false;
	}
	return true;
	
}

function faultValidate()
{
	var faulty = document.getElementById('faulty_no');
	var bend = document.getElementById('b_end');
	var calltime = document.getElementById('call_time');
	var calldate = document.getElementById('call_date');
	var contactname = document.getElementById('contact_name');
	var companyname = document.getElementById('company_name');
	var email = document.getElementById('email');
	var accountno = document.getElementById('account_no');

	var fields = '';
	if (isWhitespace(faulty.value))
	{
		fields += (fields.length > 0) ? ', faulty' : 'Faulty Number';
	}
	if (isWhitespace(bend.value))
	{
		fields += (fields.length > 0) ? ', Bend' : 'bend';
	}
	if (isWhitespace(calltime.value))
	{
		fields += (fields.length > 0) ? ', Call Time' : 'calltime';
	}
	if (isWhitespace(calldate.value))
	{
		fields += (fields.length > 0) ? ', Call Date' : 'calldate';
	}

	if (isWhitespace(contactname.value))
	{
		fields += (fields.length > 0) ? ', Contact Name' : 'contactname';
	}
	if (isWhitespace(companyname.value))
	{
		fields += (fields.length > 0) ? ', Company Name' : 'companyname';
	}
	if (isWhitespace(email.value))
	{
		fields += (fields.length > 0) ? ', Email' : 'email';
	}
	if (isWhitespace(accountno.value))
	{
		fields += (fields.length > 0) ? ', Account Number' : 'accountno';
	}


	if (fields.length > 0)
	{
		var msg = 'Please provide the following information: ' + fields;
		alert(msg);
		return false;
	}
	return true;
	
}

function serviceValidate()
{
	var customername = document.getElementById('customer_name');
	var accountno = document.getElementById('account_no');
	var sitename = document.getElementById('site_contactname');
	var sitecontactno = document.getElementById('site_contactno');
	var date = document.getElementById('date_required');

	var fields = '';
	if (isWhitespace(customername.value))
	{
		fields += (fields.length > 0) ? ', customername' : 'Customer Name';
	}
	if (isWhitespace(accountno.value))
	{
		fields += (fields.length > 0) ? ', Account Number' : 'accountno';
	}
	if (isWhitespace(sitename.value))
	{
		fields += (fields.length > 0) ? ', Site Contact Name' : 'sitename';
	}
	if (isWhitespace(sitecontactno.value))
	{
		fields += (fields.length > 0) ? ', Site Contact Number' : 'sitecontactno';
	}

	if (isWhitespace(date.value))
	{
		fields += (fields.length > 0) ? ', Date Required' : 'date';
	}


	if (fields.length > 0)
	{
		var msg = 'Please provide the following information: ' + fields;
		alert(msg);
		return false;
	}
	return true;
	
}

function billingValidate()
{
	var name = document.getElementById('customer_name');
	var acno = document.getElementById('account_no');
	var inno = document.getElementById('invoice_no');
	var cname = document.getElementById('contact_name');
	var cno = document.getElementById('contact_no');
	var ctype = document.getElementById('charge_type');
	var camt = document.getElementById('charge_amt');
	var bissue = document.getElementById('billing_issue');
	var fields = '';
	if (isWhitespace(name.value))
	{
		fields += (fields.length > 0) ? ', name' : 'Full Name';
	}
	if (isWhitespace(acno.value))
	{
		fields += (fields.length > 0) ? ', Account No' : 'acno';
	}
	if (isWhitespace(inno.value))
	{
		fields += (fields.length > 0) ? ', Invoice No' : 'inno';
	}
		if (isWhitespace(cname.value))
	{
		fields += (fields.length > 0) ? ', Contact Name' : 'cname';
	}
	if (isWhitespace(cno.value))
	{
		fields += (fields.length > 0) ? ', Contact No' : 'cno';
	}
	if (isWhitespace(ctype.value))
	{
		fields += (fields.length > 0) ? ', Charge Type' : 'ctype';
	}
	if (isWhitespace(camt.value))
	{
		fields += (fields.length > 0) ? ', Charge Amount' : 'camt';
	}
	if (isWhitespace(bissue.value))
	{
		fields += (fields.length > 0) ? ', Bill Issue' : 'bissue';
	}


	if (fields.length > 0)
	{
		var msg = 'Please provide the following information: ' + fields;
		alert(msg);
		return false;
	}
	return true;
	
}



function salesValidate()
{
	var edate = document.getElementById('edate');
	var caseno = document.getElementById('caseno');
	var fullname = document.getElementById('fullname');
	var phoneno = document.getElementById('phoneno');
	
	var otherno = document.getElementById('otherno');
	var fixedline = document.getElementById('fixedline');
	var fax = document.getElementById('fax');
	
	var company = document.getElementById('company');
	var email = document.getElementById('email');
	var nsuburb = document.getElementById('nsuburb');
	var	naddline1 = document.getElementById('naddline1');
	var npostcode = document.getElementById('npostcode');
	
	var fields = '';
	if (isWhitespace(caseno.value))
	{
		fields += (fields.length > 0) ? ', Case Number' : 'Case Number';
	}
	if (isWhitespace(fullname.value))
	{
		fields += (fields.length > 0) ? ', Full Name' : 'Full Name';
	}
	if (isWhitespace(phoneno.value))
	{
		fields += (fields.length > 0) ? ', Phone No' : 'Phone';
	}else if (isNaN(phoneno.value))
	{
		fields += (fields.length > 0) ? ', Numeric Phone No' : 'Numeric Phone No';
	}else if (trim(phoneno.value).length != 10)
	{
		fields += (fields.length > 0) ? ', Valid Phone No' : 'Phone No must be 10 digit';
	}
	if(otherno.value!="")
	{
		if (isNaN(otherno.value))
		{
			fields += (fields.length > 0) ? ', Numeric Other No' : 'Numeric Other No';
		}else
		if (trim(otherno.value).length != 10)
		{
			fields += (fields.length > 0) ? ', Other No must be 10 digit' : 'Other No must be 10 digit';
		}
	}
	if(fixedline.value!="")
	{
		if (isNaN(fixedline.value))
		{
			fields += (fields.length > 0) ? ', Numeric Fixed Line No' : 'Numeric Fixed Line No';
		}else
		if (trim(fixedline.value).length != 10)
		{
			fields += (fields.length > 0) ? ', Fixed Line No must be 10 digit' : 'Fixed Line No must be 10 digit';
		}
	}
	if(fax.value!="")
	{
		if (isNaN(fax.value))
		{
			fields += (fields.length > 0) ? ', Numeric Fax No' : 'Numeric Fax No';
		}else
		if (trim(fax.value).length != 10)
		{
			fields += (fields.length > 0) ? ', Fax No must be 10 digit' : 'Fax No must be 10 digit';
		}
	}
	if (isWhitespace(company.value))
	{
		fields += (fields.length > 0) ? ', Company' : 'Company';
	}
	if (isWhitespace(nsuburb.value))
	{
		fields += (fields.length > 0) ? ', Suburb' : 'Suburb';
	}
	if (isWhitespace(naddline1.value))
	{
		fields += (fields.length > 0) ? ', New Address' : 'New Address';
	}
	if (isWhitespace(npostcode.value))
	{
		fields += (fields.length > 0) ? ', Post Code' : 'Post Code';
	}
	if (isWhitespace(email.value) || (!isEmail(email.value)))
	{
		fields += (fields.length > 0) ? ', Email' : 'Email';
	}
	if (fields.length > 0)
	{
		var msg = 'Please provide the following information: ' + fields;
		alert(msg);
		return false;
	}
	return checkUSPhone(phoneno);
}
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
