function loadvideo()
  {
  var so = new SWFObject("http://www.cashyourgoldnow.net/videos/CYGN_WEB_WALK_ON.swf", "CYGN", "400", "240", "9", "#ffffff");
  so.addVariable("quality", "high");
    so.addVariable("duration", "1800");
  so.addVariable("bufferlength", "5");
  so.addVariable("fullscreen", "true");
  so.addVariable("screencolor", "#000000");
  so.addVariable("scale", "noscale");
  so.addVariable("file", "http://www.myvertexwatches.co.uk/flash/vertex_video.flv");
  so.addVariable("image", "http://www.myvertexwatches.co.uk/images/thumb_video.jpg");
  so.addParam("wmode", "transparent");
  so.addVariable("allowScriptAccess", "always");
so.addVariable("type", "video");
  so.addVariable("stretching", "uniform");
  so.addVariable("skin", "skinurl");
  so.addVariable("pluginspage", "http://www.macromedia.com/go/getflashplayer");
  so.addVariable("autostart", "true");

  so.write("flashcontent");
  }

function validate_form(thisform)
  {
  with(thisform)
    {
    if(fname.value == "" || lname.value == "" || address.value == "" || city.value == ""
       || state.value == "" || postal_code.value == "" || email.value == "" || phone.value == "")
      {
      alert("Please fill out entire form");
      return false;
      }
    else
      {
      if(!validatePostalCode())
        return false;

      if(!validateEmail())
        return false;
        
      if(!validatePhone())
        return false;
      }

    }
  return true;
  }

function validatePostalCode()
  {
  var number = document.getElementById("postal_code").value;

  //checks for a numer
  var expr = /^(\d+)$/;

  if(!expr.test(number) || (expr.test(number) && (number < 10000 || number > 99999)))
    {
    alert("Please Enter a valid postal code");
    return false;
    }
  return true;
  }


function validateEmail()
  {
  var email = document.getElementById("email").value;

  //checks for a good email format
  var expr = /^([\-\.\w])+\@([\.\w\-])+\.([\w]{2,3})$/;

  if(!expr.test(email))
    {
    alert("Please Enter a valid email");
    return false;
    }
  return true;

  }

function validatePhone()
  {
  var number = document.getElementById("phone").value;

  //checks for a number format
  var expr = /^([\-\d ])+$/;

  if(!expr.test(number))
    {
    alert("Please Enter a valid phone");
    return false;
    }
  return true;

  }
  
function calculateGold()
  {
  var weight = document.getElementById("weight").value;
  var carat =  document.getElementById("carat").value;
  var carat_multiplier="";

  var troy_oz = 31.10; //1 troy ounce = 31.1034 g
  var amount_per_troy_oz = 480.00;
  var amount = (weight/troy_oz) * amount_per_troy_oz;

  if(carat == 22)
    {
    carat_multiplier = .10; //for 22 CARAT substration 10%   for 18KT us 30% subtration of total value
    }
  else if(carat == 18)
    {
    carat_multiplier = .25; //18KT us 30% subtration of total value
    }
  /*else
    {
    alert("Please Select Carat of your gold.");
    }*/

  if(weight!= "" && !isNaN(amount) && carat != "")
    {
    amount = amount.toFixed(2);
    subtract = (amount*carat_multiplier);
    payout = amount-subtract;
    payout = payout.toFixed(2);
    document.getElementById("result").innerHTML = "Your estimated value is: $"+payout;
    }
  else
    {
    document.getElementById("result").innerHTML = "Insufficient information to approximate.<br/> Please check that both weight and Carat type are filled out appropriately.";
    }



  }
