        function clearText(thefield){
            if (thefield.defaultValue==thefield.value){
            thefield.value = ""
            }
        }


        function weddingAlert(interest) {
            setDisplay('weddingWarn','none');
            // check if weddings has been selected and if so, ask for postal address
            if (interest == "Weddings") {
                setDisplay('weddingWarn','block');
            }
        }


		function checkEmail(email) {
			var invalidChars = " /:,;{";
            // cannot be empty
			if (email == "") {
				return false;
		    }
            // does it contain any invalid characters?
			for (i=0; i<invalidChars.length; i++) {
				badChar = invalidChars.charAt(i);
				if (email.indexOf(badChar,0) > -1) {
					return false;
				}
			}
            // there must be one "@" symbol
			atPos = email.indexOf("@",1);
			if (atPos == -1) {
				return false;
			}
            // and only one "@" symbol
			if (email.indexOf("@",atPos+1) != -1) {
				return false;
			}
			periodPos = email.indexOf(".",atPos);
            // and at least one "." after the "@"
			if (periodPos == -1) {
				return false;
			}
            // must be at least 2 characters after the "."
			if (periodPos+3 > email.length)	{
				return false;
			}
            //alert ("got to end of email check");
			return true;
		}

		function checkName(name) {
			var invalidChars = "/:,;{" ;
            // cannot be empty
			if (name == "") {
				return false;
			}
            // does it contain any invalid characters?
			for (i=0; i<invalidChars.length; i++) {
				badChar = invalidChars.charAt(i);
				if (name.indexOf(badChar,0) > -1) {
					return false;
				}
			}
            //alert ("got to end of name check");
			return true;
		}

        function checkMessage(message) {
			var invalidChars = "{}" ;
            // cannot be empty
			if (message == "") {
				return false;
			}
            // does it contain any invalid characters?
			for (i=0; i<invalidChars.length; i++) {
				badChar = invalidChars.charAt(i);
				if (message.indexOf(badChar,0) > -1) {
					return false;
				}
			}
			return true;
		}

        function DaysArray(n) {
	        for (var i = 1; i <= n; i++) {
    		this[i] = 31;
      		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
     		if (i==2) {this[i] = 29;}
            }
            return this;
        }

        function daysInFebruary (year){
        	// February has 29 days in any year evenly divisible by four,
            // EXCEPT for centurial years which are not also divisible by 400.
            return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
        }

        function setDisplay(objectID,state) {
        	var object = document.getElementById(objectID);
        	object.style.display = state;
        }

        function checkDate() {
            var strDay=document.form2.DD.value;
            var dt=document.form2.MY.value;
            var stMonth=dt.substring(0,3);
            var strMonth;
            var strYear=(dt.substring(3)-0)+2000;
            var daysInMonth = new Array();
            daysInMonth = DaysArray(12);
            var months = new Array ("" , "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
            //alert (dt);
            for (i = 1; i <=12; i++) {
                if (months[i] == stMonth) {
		            strMonth = i;
                }
                //alert (daysInMonth[i]);
                }
                //alert (strDay);
                //alert (strMonth);
                //alert (strYear);
                // Checking number of days in month and that it is within required parameters
                if ((strMonth==2 && strDay>daysInFebruary(strYear)) || strDay > daysInMonth[strMonth]){
		        //alert("Please enter a valid day");
                return false;
	            }
            //alert ("got to end of date check");
            return true;
        }

        function checks(form) {
            var err = false;
            setDisplay('dateError','none');
            setDisplay('emailError','none');
            setDisplay('nameError','none');
            // check to see if the date is valid
			if (!checkDate()) {
                setDisplay('dateError','block');
                err = true;
			}
            //alert (form.email.value);
            // check to see if the email's valid
			if (!checkEmail(form.email.value)) {
                setDisplay('emailError','block');
				form.email.focus();
				form.email.select();
                err = true;
			}
            // check to see if the name is valid
			if (!checkName(form.Name.value)) {
            setDisplay('nameError','block');
				form.Name.focus();
				form.Name.select();
                err = true;
			}
            //alert (err);
            if (err == true) {
            return false;
			}
            else {
            return true;}
        }

        function checkgen(form) {
            var err = false;
            setDisplay('emailError','none');
            setDisplay('nameError','none');
            setDisplay('enquiryError','none');
            // check to see if the email's valid
			if (!checkEmail(form.email.value)) {
                setDisplay('emailError','block');
				form.email.focus();
				form.email.select();
                err = true;
			}
            // check to see if the name is valid
			if (!checkName(form.Name.value)) {
            setDisplay('nameError','block');
				form.Name.focus();
				form.Name.select();
                err = true;
			}
            // check to see if there is a message
			if (!checkMessage(form.Enquiry.value)) {
            setDisplay('enquiryError','block');
				form.Enquiry.focus();
				form.Enquiry.select();
                err = true;
			}
            //alert (err);
            if (err == true) {
            return false;
			}
            else {
            return true;}
        }