// JavaScript Document

function pfImpersonating(data)
{
	if (data == '')
		location.href = '/';
}

function pfImpersonate(custid)
{
	ccConnect('search_ajax.asp', 'action=doimpersonate&custid=' + custid, pfImpersonating);
}

function pfSavedCustomer(data)
{
	if (data == '')
		alert('Saved!');
	else
		alert(data);
}

function pfSaveCustomer(custid)
{
	var company = document.getElementById('pf_company').value;
	var firstname = document.getElementById('pf_firstname').value;
	var lastname = document.getElementById('pf_lastname').value;
	var custtypex = document.getElementById('pf_custtype');
	var custtype = custtypex.options[custtypex.selectedIndex].value;
	var taxable = document.getElementById('pf_taxable').checked?'1':'0';
	var discounttypex = document.getElementById('pf_discounttype');
	var discounttype = discounttypex.options[discounttypex.selectedIndex].value;
	
	if (firstname == '')
	{
		alert('First name cannot be blank.');
		return;
	}
	
	if (lastname == '')
	{
		alert('First name cannot be blank.');
		return;
	}
	
	ccConnect('search_ajax.asp', 'action=savecustomer&custid=' + custid + '&company=' + escape(company) + '&firstname=' + escape(firstname) + '&lastname=' + escape(lastname) + '&custtype=' + escape(custtype) + '&taxable=' + escape(taxable) + '&discounttype=' + escape(discounttype), pfSavedCustomer);
}

function bsDisplayCustomerInfo(custid)
{
	location.href = 'profile.asp?action=editcust&custid=' + custid;
}

function ccLookupResults(data)
{
	document.getElementById('bs_search_results').innerHTML = data;
}

function bsDoLookup(keywords)
{
	ccConnect('search_ajax.asp', 'action=lookup&keywords=' + escape(keywords), ccLookupResults);
}
