err_msg = '';
err = 0;

function echeck(str) 
{
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)

if (str.indexOf(at)==-1)
 {
   return false;
 }

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
 {
   return false;
 }

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
 {
   return false;
 }

if (str.indexOf(at,(lat+1))!=-1)
 {
   return false;
 }

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
 {
   return false;
 }

if (str.indexOf(dot,(lat+2))==-1)
 {
   return false;
 }

if (str.indexOf(" ")!=-1)
 {
   return false;
 }
return true;
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.-";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}


function validate_form() 
{
if (document.formPromo.promo_name.value =='Client Name...')
 {
   alert("Please Input your Full Name.");
   document.formPromo.promo_name.focus()
   return false;
 }
//for contact number of promo
if (!IsNumeric(document.formPromo.promo_mobile.value))
 {
   alert ("Mobile Number Format : example 0919-1234567");
   document.formPromo.promo_mobile.focus()
   return false;
 }
if (document.formPromo.promo_mobile.value != '')
 {
 	if (document.formPromo.promo_mobile.value.length < 10)
	{
		alert ("Mobile Number too short!");
		document.formPromo.promo_mobile.focus()
		return false;
	}
	else if (document.formPromo.promo_mobile.value.length > 12)
	{
		alert ("Mobile Number too long!");
		document.formPromo.promo_mobile.focus()
		return false;
	}
	else if (document.formPromo.promo_mobile.value.length == 11)
	{
		alert ("Please Include hypen (-) example: 0919-1234567");
		document.formPromo.promo_mobile.focus()
		return false;
	}
 }

//email validation for promo
if (document.formPromo.promo_email.value == 'email_here@example.com...')
 {
   alert ("Please provide a valid email address.");
   document.formPromo.promo_email.focus()
   return false;
 }

else
 {
  if (!echeck(document.formPromo.promo_email.value))
   {
     alert ("Please provide a valid email address.");
     document.formPromo.promo_email.focus()
     return false;
   }
 }
}

//validation for contact page////////////////////////////////////////////////////////////////////////////////
function validate_contact()
{
if (document.formContact.merryname.value =='')
 {
   alert("Please Input your First Name.");
   document.formContact.merryname.focus()
   return false;
 }

// Phone number validation contact page
if (document.formContact.merryphone.value == '' && document.formContact.merryphone.value =='')
 {
   alert ("Please enter one contact number. Either landline or mobile number, Thank you.");
   document.formContact.merryphone.focus()
   return false;
 }
if (!IsNumeric(document.formContact.merryphone.value))
 {
   alert ("Please Enter Numbers ONLY. (0-9) w/o hypen nd spaces");
   document.formContact.merryphone.focus()
   return false;
 }
if (document.formContact.merryphone.value != '')
 {
 	if (document.formContact.merryphone.value.length < 7 || document.formContact.merryphone.value.length > 11)
	 {
		alert ("Invalid telephone numbers!");
		document.formContact.merryphone.focus()
		return false;
	 }
 }
if (!IsNumeric(document.formContact.merrymobile.value))
 {
   alert ("Please Enter Numbers ONLY. (0-9) w/o hypen and spaces");
   document.formContact.merrymobile.focus()
   return false;
 }
if (document.formContact.merrymobile.value != '')
 {
 	if (document.formContact.merrymobile.value.length < 7)
	{
		alert ("Mobile Number too short!");
		document.formContact.merrymobile.focus()
		return false;
	}
	else if (document.formContact.merrymobile.value.length > 11)
	{
		alert ("Mobile Number too long!");
		document.formContact.merrymobile.focus()
		return false;
	}
	else if (document.formContact.merrymobile.value.length == 7)
	{
		alert ("Please Include 3 or 4-digits Provider Numbers");
		document.formContact.merrymobile.focus()
		return false;
	}
 }

//email 1 validation contact page
if (document.formContact.merryemail.value == '')
 {
   alert ("Please provide a valid email address.");
   document.formContact.merryemail.focus()
   return false;
 }

else
 {
  if (!echeck(document.formContact.merryemail.value))
   {
     alert ("Please provide a valid email address.");
     document.formContact.merryemail.focus()
     return false;
   }
 }
if (document.formContact.merryconfirmemail.value == '')
 {
   alert ("Please enter the same email to confirm.");
   document.formContact.merryconfirmemail.focus()
   return false;
 }
 if(document.formContact.merryemail.value != document.formContact.merryconfirmemail.value)
 {
   alert ("Confirmation email is not the same as above email!");
   document.formContact.merryconfirmemail.focus()
   return false;
 }
if (document.formContact.merrycomments.value == '')
 {
   alert ("Please enter your comments.");
   document.formContact.merrycomments.focus()
   return false;
 }
else
{
	if(document.formContact.merrycomments.value.length < 10)
	{
   	 alert ("Comments too short!");
     document.formContact.merrycomments.focus()
     return false;
	}
}
}

//Date function
function createdate()
{
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var date=time.getDate();
var year=time.getYear();
if (year < 2000)    //
year = year + 1900; //
document.write(lmonth + " ");
document.write(date + ", " + year);
}
// JavaScript Document

