/*
function isFormOk(form)
{
	if (!IsAddressInfoOk(form)) return false;
	if (!areEmailsSame(form)) return false;
	if (form.CCType.value != '' && !IsCreditCardOk(form)) return false;

	var forceNewPw = parseInt(form.ForceNewPw.value);
	if (forceNewPw == 1)
	{
		if (form.oldPw.value.length < 4)
		{
			alert ('Old password must have at least 4 characters!');
			form.oldPw.focus();
			return false;
		}
		if (!IsPasswordOk(form.NewPw, form.NewPwV)) return false;
	}
	else
	{
		if (form.oldPw.value != '' || form.NewPw.value != '' || form.NewPwV.value != '')
		{
			if (form.oldPw.value.length < 4)
			{
				alert ('Old password must have at least 4 characters!');
				form.oldPw.focus();
				return false;
			}
			else if (!IsPasswordOk(form.NewPw, form.NewPwV))
				return false;
		}
	}
	return true;
}
*/
function areEmailsSame(form)
{
	if (form.EmailConf.value == '')
	{
		alert ('Please provide Confirm Email Address!');
		form.EmailConf.focus();
		return false;
	}
	if (form.Email.value != form.EmailConf.value)
	{
		alert ('Emails do not match!');
		form.EmailConf.select();
		return false;
	}
	return true;
}

/*function validNSaveCustAccountForm()
{
	var form = document.getElementById('AccountForm');
	if (!isFormOk(form)) return false;
	saveCustAccountForm(form);
}

function saveCustAccountForm(form)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert (ajaxErrMsg);
		return false;
	}
	var postVars = makeCustAccPostVars(form);
	document.getElementById('statusSaveAccForm').innerHTML = '&nbsp;';
	document.getElementById('btnSaveAccount').disabled = true;
	document.getElementById('statusLoader').style.display = '';
	var url = 'ajax.php?purpose=saveCustAccountForm&'+Math.random();
	xmlHttp.onreadystatechange = stateChanged_saveCustAccountForm;
	xmlHttp.open('POST', url, true);
	xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
	xmlHttp.setRequestHeader('Content-length', postVars.length);
	xmlHttp.setRequestHeader('Connection', 'close');
	xmlHttp.send(postVars);
}
function stateChanged_saveCustAccountForm()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{
		document.getElementById('btnSaveAccount').disabled = false;
		document.getElementById('statusLoader').style.display = 'none';
		if (xmlHttp.responseText.indexOf('E~R~R~O~R') != -1)
			document.getElementById('statusSaveAccForm').innerHTML = '<font class="errMsg">' + xmlHttp.responseText.split('HAM~JAM')[1] + '</font>';
		else
		{
			document.getElementById('statusSaveAccForm').innerHTML = xmlHttp.responseText;
			document.getElementById('ForceNewPw').value = 0;
		}
		resetAccForm();
	}
}

function makeCustAccPostVars(form)
{
	var postVars = '';
	var shipToSame = form.ShipToSame.checked ? 1 : 0;
	var subscribe = document.getElementById('subscribe1').checked ? 1 : 0;
	postVars += '&FirstNameB='+form.FirstNameB.value;
	postVars += '&LastNameB='+form.LastNameB.value;
	postVars += '&Email='+form.Email.value;
	postVars += '&Phone='+form.Phone.value;
	postVars += '&Mobile='+form.Mobile.value;
	postVars += '&CompanyB='+form.CompanyB.value;
	postVars += '&Address1B='+form.Address1B.value;
	postVars += '&Address2B='+form.Address2B.value;
	postVars += '&CityB='+form.CityB.value;
	postVars += '&StateB='+form.StateB.value;
	postVars += '&ZipB='+form.ZipB.value;
	postVars += '&CountryB='+form.CountryB.value;
	postVars += '&shipToSame='+shipToSame;
	postVars += '&FirstNameS='+form.FirstNameS.value;
	postVars += '&LastNameS='+form.LastNameS.value;
	postVars += '&CompanyS='+form.CompanyS.value;
	postVars += '&Address1S='+form.Address1S.value;
	postVars += '&Address2S='+form.Address2S.value;
	postVars += '&CityS='+form.CityS.value;
	postVars += '&StateS='+form.StateS.value;
	postVars += '&ZipS='+form.ZipS.value;
	postVars += '&CountryS='+form.CountryS.value;
	postVars += '&oldPw='+form.oldPw.value;
	postVars += '&NewPw='+form.NewPw.value;
	postVars += '&subscribe='+subscribe;
	postVars += '&CCType='+form.CCType.value;
	postVars += '&CCNumber='+form.CCNumber.value;
	postVars += '&CCMonth='+form.CCMonth.value;
	postVars += '&CCYear='+form.CCYear.value;
	postVars += '&CCOwner='+form.CCOwner.value;
	postVars += '&CCBankPhone='+form.CCBankPhone.value;
	postVars += '&custId='+form.custId.value;
	return postVars;
}
*/
function resetAccForm()
{
	document.getElementById('oldPw').value = '';
	document.getElementById('NewPw').value = '';
	document.getElementById('NewPwV').value = '';
}
/*
function setShipToSame()
{
	var form = document.getElementById('AccountForm');
	if (form.ShipToSame.checked)
	{
		form.FirstNameS.value = form.FirstNameB.value;
		form.LastNameS.value = form.LastNameB.value;
		form.CompanyS.value = form.CompanyB.value;
		form.Address1S.value = form.Address1B.value;
		form.Address2S.value = form.Address2B.value;
		form.CityS.value = form.CityB.value;
		form.StateS.value = form.StateB.value;
		form.ZipS.value = form.ZipB.value;
		form.CountryS.options[0].text = form.CountryB.options[form.CountryB.selectedIndex].text;
		form.CountryS.options[0].value = form.CountryB.options[form.CountryB.selectedIndex].value;
		form.CountryS.options[0].selected = true;
	}
}

function uncheckSameB()
{
	document.getElementById('AccountForm').ShipToSame.checked = false;
}

function showOrders()
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert (ajaxErrMsg);
		return;
	}
	loadAccPage(true, null);
	var url = 'account_ajax.php?purpose=showOrders&'+Math.random();
	xmlHttp.onreadystatechange = stateChanged_showOrders;
	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);
}
function stateChanged_showOrders()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{
		if (xmlHttp.responseText.indexOf('E~X~P~I~R~E~D') != -1)
			window.location = 'login.php?m=2';
		else
			loadAccPage(false, xmlHttp.responseText);
	}
}

function showCustData()
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert (ajaxErrMsg);
		return;
	}
	loadAccPage(true, null);
	var url = 'account_ajax.php?purpose=showCustData&'+Math.random();
	xmlHttp.onreadystatechange = stateChanged_showCustData;
	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);
}
function stateChanged_showCustData()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{
		if (xmlHttp.responseText.indexOf('E~X~P~I~R~E~D') != -1)
			window.location = 'login.php?m=2';
		else
		{
			loadAccPage(false, xmlHttp.responseText);
			setShipToSame();
		}
	}
}
*/
function loadAccPage(isLoading, ajaxResponse)
{
	/*document.getElementById('btnShowOrders').value = 'View Order Information';
	document.getElementById('btnShowOrders').disabled = isLoading ? true : false;
	document.getElementById('btnUpdateAccPass').disabled = isLoading ? true : false;
	document.getElementById('btnLogOut').disabled = isLoading ? true : false;*/
	document.getElementById('statusLoaderAcc').style.display = isLoading ? '' : 'none';
	document.getElementById('mainAccountArea').innerHTML = isLoading ? '' : ajaxResponse;
}
function loadAccPageSearch(isLoading, ajaxResponse)
{
	//document.getElementById('trMain').style.display = '';
	document.getElementById('statusLoaderAcc').style.display = 'none';
	document.getElementById('mainAccountArea').innerHTML = '';
	document.getElementById('statusLoaderAccSearch').style.display = isLoading ? '' : 'none';
	document.getElementById('mainAccountAreaSearch').innerHTML = isLoading ? '' : ajaxResponse;
}
/*function showOrderDetail(OrderId)
{
	xmlHttp = GetXmlHttpObject();
	if (xmlHttp == null)
	{
		alert (ajaxErrMsg);
		return;
	}
	document.getElementById('statusLoaderOrderData').style.display = '';
	document.getElementById('orderDataArea').innerHTML = '';
	var url = 'account_ajax.php?OrderId='+OrderId+'&purpose=showOrderDetail&'+Math.random();
	xmlHttp.onreadystatechange = stateChanged_showOrderDetail;
	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);
}
function stateChanged_showOrderDetail()
{
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 'complete')
	{
		if (xmlHttp.responseText.indexOf('E~X~P~I~R~E~D') != -1)
			window.location = 'login.php?m=2';
		else
		{
			document.getElementById('statusLoaderOrderData').style.display = 'none';
			document.getElementById('orderDataArea').innerHTML = xmlHttp.responseText;
		}
	}
}

function closeOrderDetail()
{
	document.getElementById('orderDataArea').innerHTML = '';
}*/
