function ValidateForm(frm) {
	if(frm.name == "frmConsult") {
		if(document.getElementById("Name").value.length==0) {
			alert("You must enter your name in the provided field.  Please correct the error and submit the request again.");
			document.getElementById("Name").focus();
			return false;
		}
		if(document.getElementById("Main Phone Number").value.length==0) {
			alert("You must provide a main contact phone number.  Please correct the error and submit the request again.");
			document.getElementById("Main Phone Number").focus();
			return false;
		}
		if(document.getElementById("Email Address").value.length==0) {
			alert("You must enter your email address where you want the order confirmation sent in the provided field.  Please correct the error and submit the request again.");
			document.getElementById("Email Address").focus();
			return false;
		}
		if(document.getElementById("Email Address").value.indexOf("@")<0) {
			alert("You must enter a valid email address in the form of <address>@<domain name>.  Please correct the error and submit the request again.");
			document.getElementById("Email Address").focus();
			return false;
		}
		if(document.getElementById("Event Date").value.length==0) {
			alert("You must enter an event date in the provided field.  Please correct the error and submit the request again.");
			document.getElementById("Event Date").focus();
			return false;
		}
		var today=new Date();
		var DelDate=new Date(document.getElementById("Event Date").value);
		if(DelDate < today) {
			alert("You must enter an event date in the past.  Please enter a future date and submit the request again.");
			document.getElementById("Event Date").focus();
			return false;
		}
		if(document.getElementById("Consult Date").value.length==0) {
			alert("You must enter a desired consultation date in the provided field.  Please correct the error and submit the request again.");
			document.getElementById("Consult Date").focus();
			return false;
		}
		var today=new Date();
		var DelDate=new Date(document.getElementById("Consult Date").value);
		if(DelDate < today) {
			alert("You must enter a desired consultation date in the past.  Please enter a future date and submit the request again.");
			document.getElementById("Consult Date").focus();
			return false;
		}
		if(document.getElementById("Description").value.length==0) {
			alert("You must enter a description of your event in the provided field.  Please correct the error and submit the request again.");
			document.getElementById("Description").focus();
			return false;
		}
	}
	if(frm.name == "frmContactUs") {
		if (frm.FromName.value.length == 0) {
			alert("Your name is a required field.  Please enter your name and resubmit your question or comment.");
			frm.FromName.focus();
			return false;
		}
		if (frm.FromAddress.value.length == 0) {
			alert("Your e-mail address is a required field.  Please enter your email address in the Email Address field.");
			frm.FromAddress.focus();
			return false;
		}
		if (frm.Body.value.length == 0) {
			alert("The Body is a required field.  Please enter your question or comment in the body field.");
			frm.Body.focus();
			return false;
		}
	}
	return true;
}

function keypressCheck(e,checkString) {
	var mChar;
	
	if (e.keyCode == 13) return true;	// pass return key through
	mChar = String.fromCharCode(e.keyCode);
	if (checkString.indexOf(mChar) < 0) return false;
	else return true;
}

function keypressExclude(e,checkString) {
	var mChar;
	
	if (e.keyCode == 13) return true;	// pass return key through
	mChar = String.fromCharCode(e.keyCode);
	if (checkString.indexOf(mChar) > -1) return false;
	else return true;
}

function keypressUCase(e) {
	if ((e.keyCode >= 97) && (e.keyCode <= 122)) e.keyCode -=32;
	return true;
}

function setCookie (fld, value) {
	var expDate = new Date();

	futureDate = 1000 * 60 * 60 * 24 * 7 * 2;
	expDate.setTime (expDate.getTime() + futureDate);
	document.cookie = "AlexanderDesigns_"+fld+"=" + escape(value) + "; expires='" + expDate.toGMTString() + "'";
}

function getCookie(fld) {
	var result = "";
	var myCookie = " " + document.cookie + ";";
	var searchName = "AlexanderDesigns_" + fld + "=";
	var startPos = myCookie.indexOf(searchName);
	var endPos;
	if (startPos != -1) {
		startPos += searchName.length;
		endPos = myCookie.indexOf(";", startPos);
		result = unescape(myCookie.substring(startPos, endPos));
	}
	return result;
}

function checkTextAreaLength(obj, vLen) {
	if (obj.value.length >= vLen) {
		obj.value = obj.value.substring(0,vLen-1);
	}
	return true;
}

function updCharUsed(label, obj) {
	label.innerText = obj.value.length;
}

function Compress(stringIn, charlist, remove)
{
    var oldstring = new String();
    var newstring = "";
    var foundit = 0;
    oldstring = stringIn;
    for (var charcnt=0; charcnt < oldstring.length; charcnt++)
    {
        aChar = oldstring.substring(charcnt,charcnt+1);
        foundit = charlist.indexOf(aChar);
        // remove will be 0 if you want to leave those listed in the var
        // and will be 1 if you want to remove those characters listed
        if (((remove == 0) && (foundit > -1)) ||
            ((remove != 0) && (foundit == -1)))
        {
            newstring = newstring + aChar;
        }
    }
    return newstring;   
}

function UCase(objText)
{
    var strText = objText.value;
    objText.value = strText.toUpperCase();
}

function toDigits(objText)
{
    objText.value = Compress(objText.value, "01234567890", 0);
}

function toFloat(objText)
{
    var strText = objText.value;
    if (strText.length >= 1)
    {
        objText.value = Math.round(parseFloat(Compress(objText.value, "0123456789.-", 0))*100.00)/100;
    }
    else
    {
        objText.value = 0;
    }
}

function toCurrency(objText)
{
    var strText = new String;
    var pos = 0;
    strText = Compress(objText.value, "01234567890.-", 0);
    var len = strText.length;
    if (len >= 1)
    {
        pos = strText.indexOf(".");
        if (pos == -1)
        {
            if (len < 2)
            {
                strText = parseFloat(strText)*.01 + " ";
            }
            else
            {
                strText = strText.substring(0,len-2) + "." + strText.substring(len-2,len);
            }
        }
        else
        {
            strText = strText;
        }
        objText.value = strText;
    }
    else
    {
        objText.value = "0.00";
    }
}

function isDate(objBillDate)
{
    var BillDate = new Date(objBillDate.value);
    var today = new Date();
    var strBillDate = objBillDate.value;

    
    if (strBillDate.length > 0)
    {
    if ((BillDate.getMonth() >= 0) && (BillDate.getMonth() <= 11) &&
        (getFullYear(BillDate) != ""))
    {
    }
    else
    {
        confirm(objBillDate.value + " is an invalid date.  Please enter a valid date.");
        BillDate = today;
        objBillDate.focus();
    }
    // objBillDate.value = (BillDate.getMonth()+1)+"/"+(BillDate.getDate())+"/"+(getFullYear(BillDate));
    objBillDate.value = (BillDate.getMonth()+1)+"/"+(BillDate.getDate())+"/"+(BillDate.getYear());
    }
}

function getFullYear(objDate)
{
    var yyyy = objDate.getYear();
    if (yyyy < 70) {
        if (yyyy < 10) {
            yyyy = "200" + yyyy;
        }
        else {
            yyyy = "20" + yyyy;
        }
    }
    else 
    {
        if (yyyy < 100) {
            yyyy = "19" + yyyy;
        }
        else
        {
            if ((yyyy < 1900) || (yyyy > 2010)) {
                yyyy = "";
            }
        }
    }
    return yyyy;
}

function GetCurrentDate(objDate) {
    var today = new Date();
    objDate.value = (today.getMonth()+1)+"/"+(today.getDate())+"/"+(today.getYear());
}

