function DisableButton(b){
	b.disabled = true;
	b.value = 'Submitting';
	b.form.submit();
}

function validateForm()
{

if(document.frmAdd.fname.value==""){

		alert("Please Enter first name.");
		document.frmAdd.fname.focus();
		return false;
	}

if(document.frmAdd.lname.value==""){

		alert("Please Enter Last name.");
		document.frmAdd.lname.focus();
		return false;
	}
	
if(document.frmAdd.Address.value==""){

		alert("Please Enter your Address.");
		document.frmAdd.Address.focus();
		return false;
	}	
if(document.frmAdd.city.value==""){

		alert("Please Enter your city.");
		document.frmAdd.city.focus();
		return false;
	}	
if(document.frmAdd.county.value==""){

		alert("Please Enter your county.");
		document.frmAdd.county.focus();
		return false;
	}		
if(document.frmAdd.postcode.value==""){

		alert("Please Enter your postcode.");
		document.frmAdd.postcode.focus();
		return false;
	}	
if(document.frmAdd.phone.value==""){

		alert("Please Enter your phone.");
		document.frmAdd.phone.focus();
		return false;
	}	
if(document.frmAdd.email.value==""){

		alert("Please Enter your email.");
		document.frmAdd.email.focus();
		return false;
	}		
		
	}



function newWindow(strURL,strName,intWidth,intHeight) {
	intXOffset = (screen.width - intWidth) / 2; 
	intYOffset = (screen.height - intHeight) / 2;
	window.open(strURL,strName,'left='+intXOffset+',top='+intYOffset+',alwaysRaised=yes,status=no,toolbars=yes,width='+intWidth+',height='+intHeight);
}

function fnClearText(strOriginal,objTextField){
	if (objTextField.value == strOriginal)
	{
		objTextField.value = '';
	}
}

function fnReplaceText(strOriginal,objTextField){
	if (objTextField.value == '')
	{
		objTextField.value = strOriginal;
	}
}

function openAddress(intAddressID){
	newWindow('_label.asp?a='+intAddressID,"address",350,150)
}

function imageDetail(intProductID){
	newWindow('image.asp?a='+intProductID,"image",215,260)
}

function fnDeleteAddress(strAddressID,strAction){
	if (confirm("Are you sure you want to delete this address?\n\nWARNING: This operation cannot be undone.")){
		document.location = "useradmin.asp?a=" + strAction + "&i=" + strAddressID;
	}
	else{
		return false;
	}
}

function fnDeleteMessage(strMessageID,strAction,intType){
	if (confirm("Are you sure you want to delete this message?\n\nWARNING: This operation cannot be undone.")){
		document.location = "useradmin.asp?a=" + strAction + "&i=" + strMessageID + "&t=" + intType;
	}
	else{
		return false;
	}
}

function fnValidateForm(strFormName,strCompulsoryFields){

	objForm = document.forms[strFormName]
	
	strMessage = "Please complete all fields marked with an asterisk (*)"
	
	if (strFormName == "frmPromo"){
		strMessage = "Please enter a discount code"
	}
	

	if (strCompulsoryFields.indexOf("*") != 0){
		arrCompulsoryFields = strCompulsoryFields.split("*")
	}
	else{
		arrCompulsoryFields[0] = strCompulsoryFields
	}	

	var blnSubmit = true;

	for (x=0; x < objForm.length; x++){

		var strType = objForm.elements[x].type
		
		if (strType == "text" || strType == "textarea" || strType == "file" || strType == "password"){
			
			for (i=0; i < arrCompulsoryFields.length; i++){
				
				if (objForm.elements[x].name == arrCompulsoryFields[i]){
					
					if (objForm.elements[x].value == "" || objForm.elements[x].value == "enter promo code..."){
						blnSubmit = false
					}

				}

			}

		}

	}

	if (blnSubmit){
		objForm.submit();
	}
	else{
		window.alert (strMessage);
		return false;
	}

}
