  // fsform.js
  // Revision History
  // --------------------------------------------------
  // See end of file.

  domainName1 = 'www/fengshuiform.com';
  domainName2 = 'fengshuiform.websitesource.net';

  function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
  }

  function bakecookieID() {
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate()+7);
    var curTime = new Date();
    curTime = curTime.getTime();
      document.cookie = "fsfID=fsf"+curTime.toString()+
        ";expires="+expireDate.toGMTString()+";path=/";
    return "fsf"+curTime.toString();
  }

  function getcookieID() {
    var i;
    if (document.cookie ==  "") {  //no visitorID
      document.home_form.visitorIDField.value = bakecookieID();
    } else {
      var cookieArray = document.cookie.split("; ")
      for (i=0; i<cookieArray.length; i++) {
        if (cookieArray[i].split("=")[0] == "fsfID") {
          document.home_form.visitorIDField.value = cookieArray[i].split("=")[1];
	  return;
	}
      }
    }
  }
  
  function deletecookieID() {
    var expireDate = new Date();
    expireDate.setDate(expireDate.getDate()-1);
    var thisCookie = document.cookie.split("; ");
    for (i=0; i<thisCookie.length; i++) {
        cookieName = thisCookie[i].split("=")[0];
        document.cookie = cookieName+"=;expires="+expireDate.toGMTString();
    }
  }
  
  function submitMyForm(optNo) {
//    if (document.domain == domainName) { getcookieID(); }
    document.home_form.opt.value = optNo;
    if (optNo == 6) { bakecookieID(); }
    document.home_form.submit();
  }
  
  //verify form element
  var msg = "";
  var empty_fields = "";

  function verifyElement(e) {
    if (e.value == "") { empty_fields += '\n\n    ' + e.name;	}
  }
  
  function verifyEmail(e) {
    if (e.value.search(/^\w[\-\.\w]*\@\w[\-\.\w]*\.[a-zA-Z]{2,3}$/) != 0) { 
      empty_fields += '\n\n    Accepted Email Format: Mailbox@DomainName\n    Only alphanumeric, underline, hyphen and period characters are allowed.'; }
  }

  function verifyCC(e) {
    if (e.value.search(/^[456]\d{3}([\-\s]?\d{4}){3}/) != 0) { 
      empty_fields += "\n\n    Credit Card: We accept Visa, MC and Discover"; }
  }

  function verifyExpireDate(e1, e2) {
    if ((e1.value.search(/^\d{1,2}/) != 0) && (e2.value.search(/^\d{1,2}/) != 0)) {
      empty_fields += "\n    " + e1.name + "\n    " + e2.name; }
  }

  function verifyCCVer(e) {
    if (e.value.search(/^\d{3}/) != 0) { 
      empty_fields += "\n    Enter 3-digit verification number"; }
  }

  //verify form
  function verifyForm() {
    verifyElement(document.home_form.Bill_Name);
    verifyElement(document.home_form.Bill_Address1);
    verifyElement(document.home_form.Bill_City);
    verifyElement(document.home_form.Bill_State);
    verifyElement(document.home_form.Bill_ZipCode);
    verifyElement(document.home_form.Bill_Country);
    verifyElement(document.home_form.Bill_Phone);
    if (document.home_form.Same_As_Bill.value == "No") {
      verifyElement(document.home_form.Ship_Name);
      verifyElement(document.home_form.Ship_Address1);
      verifyElement(document.home_form.Ship_City);
      verifyElement(document.home_form.Ship_State);
      verifyElement(document.home_form.Ship_ZipCode);
      verifyElement(document.home_form.Ship_Country);
      verifyElement(document.home_form.Ship_Phone);
    }
    verifyEmail(document.home_form.Email);
    verifyElement(document.home_form.Name_on_Card);
    verifyCC(document.home_form.CreditCard);
    verifyExpireDate(document.home_form.Expire1, document.home_form.Expire2);
    verifyCCVer(document.home_form.CCVerify);
 	
    msg = 'There is a problem with one or more fields. ';
    msg += 'Please fill in or correct the following fields: ';
	
    if (empty_fields) {
      msg += empty_fields + "\n";
      alert(msg);
    }
  }

  //complete order, thank you
  function completeOrder() {
    msg = "";
    empty_fields = "";
    verifyForm();
    if (empty_fields) { return; }
    deletecookieID();
    submitMyForm(6);
  }

  ////////////////////////////////////////////////////////////
  // Chinese Zodiac
  ////////////////////////////////////////////////////////////

  var zSigns = ["Ox", "Tiger", "Rabbit", "Dragon", "Snake", "Horse", "Ram", "Monkey",
	"Rooster", "Dog", "Pig", "Rat"];	//12 signs
  var zSignDesc = ['Ox - You work hard and are patient, methodical and self sacrificing.  But you can also be stubborn and rigid.  You have a strength that inspires confidence.',
	'Tiger - You are courageous and active, self assured and a good leader.  But you can also be rash and rebellious.  You are protective and have many admirers.',
	'Rabbit - You are clever and ambitious, social and tactful.  But you can also be easily distracted and thin-skinned.  Fortunately you are lucky and very sensitive to the needs of others.',
	'Dragon - You are powerful, full of vitality, intuitive and artistic.  But you can also be impetuous and become irritated easily.  You are the most lucky of the twelve signs.',
	'Snake - You are charming and wise, philosophical and calm in a crisis.  But you can also be fickle and selfish.  You have success in most everything you try.',
	'Horse - You are cheerful and popular, hard working and sharp.  But you can also be tactless and impatient.  You can acquire great wealth.',
	'Ram (Goat) - You are intelligent and artistic, altruistic with a good business mind.  But you can also be morose and irresponsible with money.  You are good natured and easy going.',
	'Monkey - You are lively and likable, witty and inventive.  But you can also be mettlesome and opportunistic.  You are very skilled in business matters.',
	'Rooster (Cock) - You are resourceful and talented, courageous and amusing.  But you also can be cocky and brazen.  You are the most popular of the twelve signs.',
	'Dog - You are faithful and loyal, magnanimous with a great sense of justice.  But you can also be jumpy and defensive.  You can become very prosperous.',
	'Pig (Boar) - You are sensitive and caring, cultured and lucky.  But you can also be lazy and insecure.  You are very intelligent.',
	'Rat - You are organized and responsible, honest and wise.  But you also can be indecisive and petty.  You have a talent with money and very versatile.'];	//12 sign descriptions
  var zElements = ["Metal", "Metal", "Water", "Water", "Wood", "Wood", "Fire", "Fire",
	"Earth", "Earth"];		//10 elements
  var zElementPic = ["images/element_metal.jpg", "images/element_metal.jpg",
    "images/element_water.jpg", "images/element_water.jpg", "images/element_wood.jpg",
	"images/element_wood.jpg", "images/element_fire.jpg", "images/element_fire.jpg",
	"images/element_earth.jpg", "images/element_earth.jpg"]; //10 elements
  var zElementDesc = ['Metal symbolizes wealth and business acumen. It is represented by the round coin shape, things made of metal and the color white.',
	'Metal symbolizes wealth and business acumen. It is represented by the round coin shape, things made of metal and the color white.',
	'Water symbolizes movement and communication. It is represented by irregular and undulating shapes, things made of glass and the color blue.',
	'Water symbolizes movement and communication. It is represented by irregular and undulating shapes, things made of glass and the color blue.',
	'Wood symbolizes growth and creativity. It is represented by tall thin shapes like a tree trunk, things made of wood and the color green.',
	'Wood symbolizes growth and creativity. It is represented by tall thin shapes like a tree trunk, things made of wood and the color green.',
	'Fire symbolizes intelligence and energy. It is represented by triangular shapes, things made of plastic and the color red.',
	'Fire symbolizes intelligence and energy. It is represented by triangular shapes, things made of plastic and the color red.',
	'Earth symbolizes endurance and stability. It is represented by table-like shapes, things made of clay and stone, and the color yellow.',
	'Earth symbolizes endurance and stability. It is represented by table-like shapes, things made of clay and stone, and the color yellow.'];  	//10 element descriptions
  var zNewYears = [new Date(1901, 1, 19), new Date(1902, 1, 8), new Date(1903, 0, 29),
	new Date(1904, 1, 16), new Date(1905, 1,  4), new Date(1906, 0, 25),
	new Date(1907, 1, 13), new Date(1908, 1,  2), new Date(1909, 0, 22),
	new Date(1910, 1, 10), new Date(1911, 0, 30), new Date(1912, 1, 18),
	new Date(1913, 1,  6), new Date(1914, 0, 26), new Date(1915, 1, 14),
	new Date(1916, 1,  3), new Date(1917, 0, 23), new Date(1918, 1, 11),
	new Date(1919, 1,  1), new Date(1920, 1, 20), new Date(1921, 1,  8),
	new Date(1922, 0, 28), new Date(1923, 1, 16), new Date(1924, 1,  5),
	new Date(1925, 0, 25), new Date(1926, 1, 13), new Date(1927, 1,  2),
	new Date(1928, 0, 23), new Date(1929, 1, 10), new Date(1930, 0, 30),
	new Date(1931, 1, 17), new Date(1932, 1,  6), new Date(1933, 0, 26),
	new Date(1934, 1, 14), new Date(1935, 1,  4), new Date(1936, 0, 24),
	new Date(1937, 1, 11), new Date(1938, 0, 31), new Date(1939, 1, 19),
	new Date(1940, 1,  8), new Date(1941, 0, 27), new Date(1942, 1, 15),
	new Date(1943, 1,  5), new Date(1944, 0, 25), new Date(1945, 1, 13),
	new Date(1946, 1,  2), new Date(1947, 0, 22), new Date(1948, 1, 10),
	new Date(1949, 0, 29), new Date(1950, 1, 17), new Date(1951, 1,  6),
	new Date(1952, 0, 27), new Date(1953, 1, 14), new Date(1954, 1,  3),
	new Date(1955, 0, 24), new Date(1956, 1, 12), new Date(1957, 0, 31),
	new Date(1958, 1, 18), new Date(1959, 1,  8), new Date(1960, 0, 28),
	new Date(1961, 1, 15), new Date(1962, 1,  5), new Date(1963, 0, 25),
	new Date(1964, 1, 13), new Date(1965, 1,  2), new Date(1966, 0, 21),
	new Date(1967, 1,  9), new Date(1968, 0, 30), new Date(1969, 1, 17),
	new Date(1970, 1,  6), new Date(1971, 0, 27), new Date(1972, 1, 15),
	new Date(1973, 1,  3), new Date(1974, 0, 23), new Date(1975, 1, 11),
	new Date(1976, 0, 31), new Date(1977, 1, 18), new Date(1978, 1,  7),
	new Date(1979, 0, 28), new Date(1980, 1, 16), new Date(1981, 1,  5),
	new Date(1982, 0, 25), new Date(1983, 1, 13), new Date(1984, 1,  2),
	new Date(1985, 1, 20), new Date(1986, 1,  9), new Date(1987, 0, 29),
	new Date(1988, 1, 17), new Date(1989, 1,  6), new Date(1990, 0, 27),
	new Date(1991, 1, 15), new Date(1992, 1,  4), new Date(1993, 0, 23),
	new Date(1994, 1, 10), new Date(1995, 0, 31), new Date(1996, 1, 19),
	new Date(1997, 1,  7), new Date(1998, 0, 28), new Date(1999, 1, 16),
	new Date(2000, 1,  5), new Date(2001, 0, 24), new Date(2002, 1, 12),
	new Date(2003, 1,  1), new Date(2004, 0, 22), new Date(2005, 1,  9),
	new Date(2006, 0, 29), new Date(2007, 1, 18), new Date(2008, 1,  7),
	new Date(2009, 0, 26), new Date(2010, 1, 14)];

  function getZodiacSign() {
    if (document.home_form.bmonth.value == '') return false;
    if (document.home_form.bday.value == '') return false;
    if (document.home_form.byear.value == '') return false;
	var bMonth = document.home_form.bmonth.value.valueOf();
	var bDay = document.home_form.bday.value.valueOf();
	var bYear = document.home_form.byear.value.valueOf();
	var bday = new Date(bYear, bMonth, bDay);
	for (var i=0; zNewYears[i]<=bday; i++) { ; }
	var zElementPtr = (zNewYears[--i].getFullYear() - 1900) % 10;
    document.home_form.elementDesc.value = zElementDesc[zElementPtr];
	document.home_form.elementPic.src = zElementPic[zElementPtr];
    document.home_form.element.value = zElements[zElementPtr];
	var zSignPtr = (zNewYears[i].getFullYear() - 1901) % 12;
    document.home_form.signDesc.value = zSignDesc[zSignPtr];
    document.home_form.sign.value = zSigns[zSignPtr];
	return false;
  }

  ////////////////////////////////////////////////////////////
  // Fortune Cookie
  ////////////////////////////////////////////////////////////

  var fFortunes = [
      'Smiling Monk: Positive thinking yields positive results',
      'Rabbit escapes the eagle: The past is the past, today is a new day',
      'Fortune favors the brave, take a chance',
      'A small seed in good soil: A small action today will bring big results tomorrow',
      'Love is available for all, ask and you shall receive',
      'Fortune Cookie says you are very lucky',
      'Dragon flying to heaven: Luck is with you',
      'Fresh wind in sails: You are at the turning point, things will now improve greatly',
      'Don’t be impatient, what you have asked for is coming',
      'Flowering plum tree: It is a good time to start a business or project',
      'You will have success in a job or school situation',
      'Don’t step on the Tiger’s tail, walk softly around superiors',
      'The situation looks promising, take an action to secure positive results',
      'You can proceed with confidence, you are on the right track',
      'Unexpected assistance is coming',
      'What you are thinking is manifesting, have only positive thoughts',
      'We attract what we feel we deserve; this includes love and money',
      'Thunder in the Summer: time for a change',
      'It is now time for thought, the time for action will come later',
      'Time to relax, plan your next vacation',
      'Best to sleep on it',
      'Ask a friend; their advice will be invaluable',
      'Know your good qualities; you are thoughtful, sensitive and kind',
      'There’s a Tiger in the garden, time to be on guard',
      'The willow bows in the wind; time to go with the flow',
      'Be wary of impulsive action; sometimes it is best to wait',
      'Tree losing leaves: all things change, best to let the change happen',
      'Doing a kindness for another will bring you a great gift',
      'When you know your destination you can’t help but get there',
      'A new beginning is at hand',
      'Time to plant some seeds for the future',
      'Your luck is increasing, time to take a chance',
      'Time to find a mentor; a wise person to help you with the next steps',
      'If there is a storm take cover, when the storm lifts then move forward',
      'Your intuition is strong now, follow your own advice',
      'Whatever you wish will come true; what are you wishing for?',
      'Whatever you think about the most will manifest',
      'Carp swim upstream to find their goal; hard work pays off now',
      'Prosperity is coming from the actions you take today',
      'Good luck is all around you; time to claim it as your own',
      'Not choosing is still a choice, make a conscious choice now',
      'Love follows the person who brings happiness to others',
      'Beautiful lily in a field of grass, you are a beautiful spirit, time to shine',
      'Sun at sunrise: time to start afresh and leave the darkness behind',
      'Red sky at sunset: things will be better in the morning',
      'Your aptitude for business is strong right now, use it',
      'You are magnetic; others are very attracted to you',
      'Rebels hide in the hills; guard what is important to you',
      'Always pay yourself first, including compliments',
      'Listening will be useful now, others will reveal secrets',
      'Happiness is near; what will make you the happiest? ',
      'Plan a joyful feast, call some friends, have a party, enjoy life',
      'A tempting proposal is coming, but think it through carefully',
      'To be successful now you must delegate',
      'Success is coming quickly, time to make room for it',
      'Resolute action will improve the situation',
      'Tiger in a trap, how much to you want to be free?',
      'Let go of the old and embrace the new',
      'All things change; change is the only constant',
      'Your efforts bring rewards to you and your friends',
      'Your future is full of promise; picture your desire',
      'Steep mountain ahead, take careful steps',
      'Traveler on a journey, enjoy the journey as much as the destination',
      'Luck comes while you are on the road, time to get out of the house',
      'Your luck is rising like the sun, you can count on your luck',
      'You will spend much but it will pay off handsomely',
      'Pack of hounds; if you do only what others do you get the results that they get',
      'Thunder rumbles in the distance, but thunder doesn’t always bring rain, things will be alright. ',
      'Heaven meets earth; relationship luck is very high now',
      'Harvest time; go out and collect what is yours',
      'The fruit is ripe; time to gather in the bounty',
      'Two dragon fight for a single jewel; be wary of arguments that have no solution',
      'Success is at hand, but there is competition, time for action',
      'A door is closing but a wonderful surprise will come from it',
      'Time to do something you have always wanted to do',
      'The cold ice is melting; you will start to prosper again',
      'The long winter of lack is ending, success is coming',
      'The hen is nesting; results come from cooperation',
      'Bad apple in the bin; don’t let one negative spoil a hundred positives',
      'You are wandering, time to choose a path',
      'Coins scatter from a torn purse; focus your talents on your goal',
      'Ship sails on a sea of glass; things will go very smoothly',
      'Gentle breeze on the lake; you will feel new energy soon',
      'Still waters hide fish; proceed quietly and patiently to gain success',
      'Gust of wind blows up dust; when you can’t see ahead it is time to rest',
      'Plum tree covered in snow; don’t reveal plans too early',
      'Deer with heads high; time to listen and not speak',
      'Dragon lying low in the water; time to rest and meditate',
      'Reconsider the change you are planning',
      'Ship laden with gold; plan your moves step by step',
      'Dragon grasping jewel; think big, you are a magnet of success',
      'The North Star; focus on that which is most important to you',
      'Monk on the mountain top; you are an eternal spirit having a human experience',
      'Yin and yang; peace comes from balancing what you give and what you receive',
      'The closed gate: sometimes a way is blocked to protect us',
      'The shiny bauble; not all that glitters is gold, if it sounds too good to be true it probably is',
      'Monk in meditation; listen to yourself, you know the answer',
      'Mountain hidden by clouds; you may not feel strong at the moment but you truly are',
      'The placid lake; find the peace in your life ',
      'the more prosperity you attract the easier your life will become',
      'Work does not equal money; success comes when you plan for it',
      'the wedding garment is made of a thousand stitches; small actions lead to your goal',
      'two cocks in the hen yard; let others scramble while you receive real success',
      'Young plants still delicate; give some time for your actions to manifest',
      'the summit is in sight; have a short rest but then get back on your path',
      'Turtle moves forward; you have everything you need for this journey',
      'mountain on fire; time to let go and allow new things to come to you',
      'bonfire; time to celebrate and have a good time',
      'campfire burns in the night; time to enjoy the company of others',
      'sailing on a lake; time to be with family and friends',
      'sun is high in the heavens; your luck is very high right now',
      'a forest, bright and green; your talents are numerous and your success will be great.'
      ];

  function fortuneCookie() {
    var fortuneCount = 112;
    var curTime = new Date();
    curTime = curTime.getTime();
    document.home_form.fortune.value = fFortunes[curTime % fortuneCount];
  }





  // Revision History
  // --------------------------------------------------
  // Revsion 1.00
  // 1. Add email syntax verification.
  // Revsion 1.01
  // 1. Add Fortune Cookie feature.
  // Revsion 1.02
  // 1. Added CC verification check.
  // Revsion 1.03
  // 1. Changed verify Bill_Address and Ship_Address to Bill_Address1 and Ship_Address1.

