// Jay Whitman wrote the original Valid_Date, which has been modified.
// All other JavaScript code is (c) 1999 Rainbow Software Solutions Inc.


function Valid_Date(datein)
    {
    var indate=datein;

    if (indate.indexOf("/")!=-1)
        var sdate = indate.split("/")
        else
        return(0);

    var chkDate=new Date(Date.parse(indate))

    if (chkDate.getFullYear() < 1000)
        return(0);
    if (chkDate.getFullYear() > 9999)
        return(0);

    var cmpDate=(chkDate.getMonth()+1)+"/"+(chkDate.getDate())+"/"+(chkDate.getFullYear())
    var indate2=(Math.abs(sdate[0]))+"/"+(Math.abs(sdate[1]))+"/"+(Math.abs(sdate[2]))

    if (cmpDate=="NaN/NaN/NaN")
        return(0);

    if (indate2!=cmpDate)
        return(0);

    return(1);

}


function check_date(formpart)
    {
    if (Valid_Date(formpart["value"]) == 0)
        {
        alert("Date must be in MM/DD/YYYY format.");
        formpart.focus();
        return(0);
        }
    return(1);
    }


function shortdesc_check(sd,maxwords,namething)
    {
    
    var nuse=" " + document.editform[sd].value + " ";
    var ssd=nuse.split(/\s+/);
    if (ssd.length>(maxwords+2))
        {
        alert(namething + " may have no more than " + maxwords + " words.");
        document.editform[sd].focus();
        return(0);
        }
    

    return(1);
    }


function validateforms()
    {
    var good=1;
    var error="The field(s) ";
    var highlight;

    
        if (document.editform["firstname"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "First Name";
            if (good==1)
                highlight="firstname";
            good=0;
            }
        
        if (document.editform["lastname"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Last Name";
            if (good==1)
                highlight="lastname";
            good=0;
            }
			
        if (document.editform["company"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Company";
            if (good==1)
                highlight="company";
            good=0;
            }
        
    
        if (document.editform["email"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Email";
            if (good==1)
                highlight="email";
            good=0;
            }
    
        if (document.editform["address"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Address";
            if (good==1)
                highlight="address";
            good=0;
            }
        
    
        if (document.editform["city"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "City";
            if (good==1)
                highlight="city";
            good=0;
            }
        
    
        if (document.editform["state"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "State";
            if (good==1)
                highlight="state";
            good=0;
            }
        
    
        if (document.editform["zipcode"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Zip";
            if (good==1)
                highlight="zipcode";
            good=0;
            }
        
    
        if (document.editform["country"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Country";
            if (good==1)
                highlight="country";
            good=0;
            }
        
    
        if (document.editform["comments"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Message";
            if (good==1)
                highlight="comments";
            good=0;
            }    
			
			
        if (document.editform["telephone"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Telephone";
            if (good==1)
                highlight="telephone";
            good=0;
            }
        
    
        
    

    error=error + " are missing, please fill them in."

    

    if (good==1)
        {
    if (good==1)
            document.editform.submit();
        }
        else
        {
        alert(error);
        document.editform[highlight].focus();
        }
    }


function validatetourform()
    {
    var good=1;
    var error="The field(s) ";
    var highlight;

    
        if (document.editform["firstname"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "First Name";
            if (good==1)
                highlight="firstname";
            good=0;
            }
        
        if (document.editform["lastname"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Last Name";
            if (good==1)
                highlight="lastname";
            good=0;
            }
			
        if (document.editform["email"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Email";
            if (good==1)
                highlight="email";
            good=0;
            }
    
        if (document.editform["address"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Address";
            if (good==1)
                highlight="address";
            good=0;
            }
        
    
        if (document.editform["city"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "City";
            if (good==1)
                highlight="city";
            good=0;
            }
        
    
        if (document.editform["state"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "State";
            if (good==1)
                highlight="state";
            good=0;
            }
        
    
        if (document.editform["zipcode"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Zip";
            if (good==1)
                highlight="zipcode";
            good=0;
            }
        
    
        if (document.editform["country"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Country";
            if (good==1)
                highlight="country";
            good=0;
            }
        
    
        if (document.editform["comments"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Message";
            if (good==1)
                highlight="comments";
            good=0;
            }    
			
			
        if (document.editform["telephone"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Telephone";
            if (good==1)
                highlight="telephone";
            good=0;
            }
        
    
        
    

    error=error + " are missing, please fill them in."

    

    if (good==1)
        {
    if (good==1)
            document.editform.submit();
        }
        else
        {
        alert(error);
        document.editform[highlight].focus();
        }
    }

function validateregform()
    {
    var good=1;
    var error="The field(s) ";
    var highlight;

    
        if (document.editform["event"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Event";
            if (good==1)
                highlight="event";
            good=0;
            }
    
        if (document.editform["firstname"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "First Name";
            if (good==1)
                highlight="firstname";
            good=0;
            }
        
        if (document.editform["lastname"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Last Name";
            if (good==1)
                highlight="lastname";
            good=0;
            }
        
        
        if (document.editform["company"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Company";
            if (good==1)
                highlight="company";
            good=0;
            }
        
    
        if (document.editform["email"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Email";
            if (good==1)
                highlight="email";
            good=0;
            }
        
    
     
        if (document.editform["telephone"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Telephone";
            if (good==1)
                highlight="telephone";
            good=0;
            }
		
    
        if (document.editform["number_attending"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Number Attending";
            if (good==1)
                highlight="number_attending";
            good=0;
            }
      

    error=error + " are missing, please fill them in."

    

    if (good==1)
        {
    if (good==1)
            document.editform.submit();
        }
        else
        {
        alert(error);
        document.editform[highlight].focus();
        }
    }
	
function edit_check_date(formpart)
    {
    return(check_date(document.editform[formpart]));
    }

function validate_addeventform()
    {
    var good=1;
    var error="The field(s) ";
    var highlight;

    
        if (document.editform["contactname"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Contact Name";
            if (good==1)
                highlight="contactname";
            good=0;
            }
        
        if (document.editform["eventname"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Event Name";
            if (good==1)
                highlight="eventname";
            good=0;
            }
			
        if (document.editform["town"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Town";
            if (good==1)
                highlight="town";
            good=0;
            }
			
        if (document.editform["contact_email"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Contact Email";
            if (good==1)
                highlight="contact_email";
            good=0;
            }
			
        if (document.editform["description"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Description";
            if (good==1)
                highlight="description";
            good=0;
            }
    	
        if (document.editform["mini_description"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Mini Description";
            if (good==1)
                highlight="mini_description";
            good=0;
            }
			
			if (document.editform["city"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "City";
            if (good==1)
                highlight="city";
            good=0;
            }
			
        if (document.editform["telephone"].value == "")
            {
            if (good==0)
                error=error + ", ";
            error=error + "Telephone";
            if (good==1)
                highlight="telephone";
            good=0;
            }
        
    
        
    

    error=error + " are missing, please fill them in."

    

    if (good==1)
        {
    if (good==1)
            document.editform.submit();
        }
        else
        {
        alert(error);
        document.editform[highlight].focus();
        }
    }
