function SubmitFreeFlowers()
{
  if (document.free_flowers.name.value == "")
  {
    alert ("\n The Your Name Field Is Blank")
    return false;
  }
	
  if (emailCheck(document.free_flowers.email.value) == false)
  {
    //alert ("\n Your E-Mail Address is Incorrect")
    return false;
  }
	
  if (document.free_flowers.city.value == "")
  {
    alert ("\n The City Field Is Blank")
    return false;
  }
	
  if (document.free_flowers.state.value == "")
  {
    alert ("\n The State Field Is Blank")
    return false;
  }
	
  if (document.free_flowers.comment.value == "")
  {
    alert ("\n The Comment Is Blank")
    return false;
  }

  return true;
}











function SubmitFlowerWinner()
{

        var now    = new Date () ;
        var nday   = now.getDate () ;
        var nyear  = now.getFullYear() ;
        var nmonth = now.getMonth() + 1 ;

        if (nyear >= 100 && nyear <= 1999)
        {nyear = nyear + 1900}
        else
        {nyear = nyear}

        var Nyear = new String(nyear);
        var Nmonth = new String(nmonth);
        if (Nmonth.length < 2)
        {
        Nmonth = "0" + Nmonth;
        }
        var Nday = new String(nday);
        if (Nday.length < 2)
        {
        Nday = "0" + Nday;
        }
        var CurrentDate = Nyear + Nmonth + Nday ;


        var Eyear = document.free_flowers.year.value 
        var Emonth = document.free_flowers.month.value 
        if (Emonth.length < 2)
        {
        Emonth="0" + Emonth;
        }
        var Eday = document.free_flowers.day.value 
        if (Eday.length < 2)
        {
        Eday="0" + Eday;
        }
       
        var DateEntered = Eyear + Emonth + Eday ;

        if ( DateEntered < CurrentDate )
        {
        alert ("\n The Delivery Date is earlier than today's date \n\n Please Re-Enter The Date")
        return false;
        }
     






 //     if (document.free_flowers.year.value  < nyear )
 //     {
 //       alert ("\n The Date to Be Delivered (Year) Is Incorrect")
 //       return false;
 //     }
 //   
 //     if (document.free_flowers.month.value  < nmonth )
 //     {
 //       alert ("\n The Date to Be Delivered (Month) Is Incorrect")
 //       return false;
 //     }
 //   
 //     if (document.free_flowers.day.value < nday )
 //     {
 //       alert ("\n The Date to Be Delivered (Day) Is Incorrect")
 //       return false;
 //     }










	if (document.free_flowers.first_name.value == "")
  {
    alert ("\n The Recipient First Name Is Blank")
    return false;
  }
	
	if (document.free_flowers.last_name.value == "")
  {
    alert ("\n The Recipient Last Name Is Blank")
    return false;
  }
	
  if (document.free_flowers.city.value == "")
  {
    alert ("\n The City Field Is Blank")
    return false;
  }
	
  if (document.free_flowers.state.value == "")
  {
    alert ("\n The State Field Is Blank")
    return false;
  }
	
	if (document.free_flowers.card_message.value == "")
  {
    alert ("\n The Card Message Is Blank")
    return false;
  }
	
  if (document.free_flowers.winner_name.value == "")
  {
    alert ("\n Your Name Is Blank")
    return false;
  }

  return true;
}




function emailCheck (emailStr)
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("\n Your E-Mail Address is Incorrect");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("\n Your E-Mail Address is Incorrect");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("\n Your E-Mail Address is Incorrect");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("\n Your E-Mail Address is Incorrect");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("\n Your E-Mail Address is Incorrect");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("\n Your E-Mail Address is Incorrect");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("\n Your E-Mail Address is Incorrect");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("\n Your E-Mail Address is Incorrect");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}

