// JavaScript Document
function echeck(str, msg) 
		{
			var at="@"
			var dot="."
			var lat=str.indexOf(at)
			var lstr=str.length
			var ldot=str.indexOf(dot)
			if (str.indexOf(at)==-1)
				{
				   alert(msg)
				   return false
				}

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

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

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

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

			if (str.indexOf(dot,(lat+2))==-1)
				{
					alert(msg)
					return false
				}
		
			if (str.indexOf(" ")!=-1)
				{
					alert(msg)
					return false
				}

		 	return true					
		}

function Validator(theForm)
{

//First Name check
 if (theForm.fname.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.fname.focus();
    return (false);
  }

// ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ . \t\r\n\f
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
  var checkStr = theForm.fname.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please remove Spaces and Special characters from \"First Name\" field.");
    theForm.fname.focus();
    return (false);
  }



//Surnam check
 if (theForm.sname.value == "")
  {
    alert("Please enter a value for the \"Surname\" field.");
    theForm.sname.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ . \t\r\n\f";
  var checkStr = theForm.sname.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, whitespace  .\" characters in the \"Surname\" field.");
    theForm.sname.focus();
    return (false);
  }


//password check
 if (theForm.pwd.value == "")
  {
    alert("Please enter a value for the \"Password\" field.");
    theForm.pwd.focus();
    return (false);
  }

  var checkOK = "abcdefghijklmnopqrstuvwxyz0123456789";
  var checkStr = theForm.pwd.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Your Password should be no more than 6 characters and must be a combination of letters and numbers, with no spaces. Letters should all be in lower case");
    theForm.pwd.focus();
    return (false);
  }



if (theForm.cpwd.value == "")
  {
   alert("Your Confirm Password should be no more than 6 characters and must be a combination of letters and numbers, with no spaces. Letters should all be in lower case");
    theForm.cpwd.focus();
    return (false);
  }

  var checkOK = "abcdefghijklmnopqrstuvwxyz0123456789";
  var checkStr = theForm.cpwd.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Your Confirm Password should be no more than 6 characters and must be a combination of letters and numbers, with no spaces. Letters should all be in lower case");
    theForm.cpwd.focus();
    return (false);
  }


//checking both password
if(theForm.pwd.value!=theForm.cpwd.value)
      {
            alert("Your password entries did not match.");
            theForm.pwd.focus();
            return (false);
      }
    


//home address validation
if (theForm.address.value == "")
  {
    alert("Please enter a value for the \"Address Line 1\" field.");
    theForm.address.focus();
    return (false);
  }

 






//Suburb validation
if (theForm.suburb.value == "")
  {
    alert("Please enter a value for the \"Suburb\" field.");
    theForm.suburb.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ0123456789-$ % & - / . \t\r\n\f";
  var checkStr = theForm.suburb.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, digit, whitespace and \"$ % & - / .\" characters in the \"Suburb\" field.");
    theForm.suburb.focus();
    return (false);
  }


//Postcode or zip validation
if (theForm.zipcode.value == "")
  {
    alert("Please enter a value for the \"Postcode or zip\" field.");
    theForm.zipcode.focus();
    return (false);
  }

  var checkOK = "0123456789";
  var checkStr = theForm.zipcode.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length; i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length; j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit in the \"Postcode or zip\" field.");
    theForm.zipcode.focus();
    return (false);
  }


//State check
 if (theForm.state.value == "")
  {
    alert("Please enter a value for the \"State\" field.");
    theForm.state.focus();
    return (false);
  }

  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzƒŠŒŽšœžŸÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ . \t\r\n\f";
  var checkStr = theForm.state.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only letter, whitespace  .\" characters in the \"State\" field.");
    theForm.state.focus();
    return (false);
  }


//Country check
 if (theForm.country.selectedIndex ==0)
  {
    alert("Please select one of the \"Country\" options.");
    theForm.country.focus();
    return (false);
   }
   
  
   //Email
   if ((theForm.email.value==null)||(theForm.email.value==""))
		{
			alert("Please Enter Email");
			theForm.email.focus();
			//setTimeout("document.theForm.email.focus();",1);
			return false
		}
	
	if (echeck(theForm.email.value, 'You have Entered Invalid E-mail ID')==false)
		{
			//theForm.email.value="";
			theForm.email.focus();
			//setTimeout("document.theForm.email.focus();",1);
			return false
		}
		


//Phone Number validation
if (theForm.pno.value == "")
  {
    alert("Please enter a value for the \"Phone Number\" field.");
    theForm.pno.focus();
    return (false);
  }

  var checkOK = "0123456789";
  var checkStr = theForm.pno.value;
  var allValid = true;
  var validGroups = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Please enter only digit in the \"Phone Number\" field.");
    theForm.pno.focus();
    return (false);
  }




/* Validation for the select box */
if (theForm.finds.selectedIndex ==0)
  {
    alert("Please select one of the \"Find out about us\" options.");
    theForm.finds.focus();
    return (false);
   }
 

return true;
}

function idcheck()
{
        if(document.gift_mmbrshp.emailids.value=='')
		{
		alert("Email ID is Empty.");
		document.gift_mmbrshp.emailids.focus(); 
		return false;
		}
		
		if(document.gift_mmbrshp.passfd.value=='')
		{
		alert("Password Field is Empty.");
		document.gift_mmbrshp.passfd.focus(); 
		return false;
		}

}





