var productID = "1";

function Licence_Agreement(theForm){

	if(theForm.Agree[0].checked==false && theForm.Agree[1].checked==false ) {
		alert("Please confirm your acceptance\n     of the licence agreement.");
		return false;
	} else {
		if (theForm.Agree[0].checked==true) {
			getProductID();
			window.location.href = 'download2.htm?pid=' + productID;
		} else { window.location.href = 'index.htm'; }
	}
	return false;
}


function getProductID() {
	var strQry
     passedName = location.search
     lengthOfPassedName=passedName.length
     if (lengthOfPassedName > 0) { // Query string supplied
        strQry = passedName.substring(1,lengthOfPassedName);
        spot=strQry.lastIndexOf("=");
        if (strQry.length != spot) { // get value
      		productID=strQry.substr(spot+1,strQry.length);
      	}
     }         
     return;
}

function Download_Registration_Validator()
{

  if (theForm.Name.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Name.value.length > 30)
  {
    alert("Please enter at most 30 characters in the \"Name\" field.");
    theForm.Name.focus();
    return (false);
  }

  if (theForm.Position.value == "")
  {
    alert("Please enter a value for the \"Position\" field.");
    theForm.Position.focus();
    return (false);
  }

  if (theForm.Organisation.value == "")
  {
    alert("Please enter a value for the \"Organisation\" field.");
    theForm.Organisation.focus();
    return (false);
  }

  if (theForm.Email.value == "")
  {
    alert("Please enter a value for the \"Email\" field.");
    theForm.Email.focus();
    return (false);
  }

  if (theForm.Email.value!="") {
	if (theForm.Email.value.indexOf("@")==-1 || theForm.Email.value.indexOf(".")==-1 || theForm.Email.value.indexOf(" ")!=-1 || theForm.Email.value.length<6) 
	{
		alert("Please enter a valid email address.");
		theForm.Email.focus();
		return (false);
	}
	}
	
  if (theForm.Phone.value == "")
  {
    alert("Please enter a value for the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }

  var checkOK = "0123456789- \t\r\n\f";
  var checkStr = theForm.Phone.value;
  var allValid = 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 and whitespace characters in the \"Phone\" field.");
    theForm.Phone.focus();
    return (false);
  }
  
  getProductID();
  
  theForm.pid.value = productID;

  return (true);
}


