<!--

//rollovers...
if(document.images)
{
     
		
		homenormal = new Image();
		homenormal.src = "../images/btn_home.jpg";
		homerollover = new Image();
		homerollover.src = "../images/roll_home.jpg";
		
		aboutusnormal = new Image();
		aboutusnormal.src = "../images/btn_aboutus.jpg";
		aboutusrollover = new Image();
	        aboutusrollover.src = "../images/roll_aboutus.jpg";
		
		downloadnormal = new Image();
		downloadnormal.src = "../images/btn_download.jpg";
		downloadrollover = new Image();
		downloadrollover.src = "../images/roll_download.jpg";
		
                registernormal = new Image();
		registernormal.src = "../images/btn_register.jpg";
		registerrollover = new Image();
		registerrollover.src = "../images/roll_register.jpg";
		  		
                contactusnormal = new Image();
		contactusnormal.src = "../images/btn_contactus.jpg";
		contactusrollover = new Image();
		contactusrollover.src = "../images/roll_contactus.jpg";
}

function onoff(imgName, state)
{
        if(document.images)
	{               
		document.images[imgName].src = eval(imgName+state+".src");
        }
}

function Validate()
{
  var temp, i, NDigits, Currency;

  // Check that the Order Amount is not less than 0
  temp = document.OrderForm.amount.value;     // Put into a variable
  temp = temp.substring(1, temp.length);      // Remove the leading $
  temp = parseFloat(temp);                    // Convert to float
  if(temp < 0) {
    alert("Order must be greater than zero");
    return false;
  }
  
  // Check that the Organisation Name has been entered
  temp = document.OrderForm.name.value;
  if(temp.length == 0) {
    alert("Please enter your name");
    document.OrderForm.name.focus();
    return false;
  } else if(temp.length < 3) {
    alert("Please enter at least 3 characters for your name");
    document.OrderForm.name.focus();
    return false;
  }

  // Check that the Email Address has been entered, and has a @ and a .
  temp = document.OrderForm.email.value;
  if(temp.length < 5 || temp.indexOf("@") <= 0 || temp.indexOf(".") <= 0) {
    alert("Please enter a valid email address to which you want your registration code to be sent.");
    document.OrderForm.email.focus();
    return false;
  }
  
  SetCurrencyAndDesc(45.00);
  SetCartID();

  return true;
}

function CheckFloat(value)
{
  var i;
  
  if(value.length == 0) return 0;
  for(i=0; i<value.length; i++) {
    if((value.charAt(i) < "0" || value.charAt(i) > "9") && value.charAt(i) != ".") return 0;
  }
  return value;
}

// Email address should've been validated by now
function SetCurrencyAndDesc(value)
{
  var temp;

  document.OrderForm.currency.value = "USD";
  document.OrderForm.amount.value = value;
  document.OrderForm.desc.value = "Focus Magic US$"+value;
}

function SetCartID()
{
  var CartID, OrganisationName, EmailAddress;

  CartID = "";

  OrganisationName=document.OrderForm.name.value;
  EmailAddress=document.OrderForm.email.value;

  OrganisationName = SearchAndReplace(OrganisationName, ";", " ");
  OrganisationName = SearchAndReplace(OrganisationName, "  ", " ");
  EmailAddress = SearchAndReplace(EmailAddress, ";", "");
  EmailAddress = SearchAndReplace(EmailAddress, " ", "");

  document.OrderForm.email.value = EmailAddress;

  CartID="WPFMORD;";
  if(OrganisationName.length > 0) CartID = CartID + "Org=" + OrganisationName + ";";
  if(EmailAddress.length > 0) CartID = CartID + "Email=" + EmailAddress + ";";
  CartID = CartID + "Notes=Win, OutbackPhotoPromo;";

  document.OrderForm.cartId.value = CartID;
}

function SearchAndReplace(s, one, another)
{
// In a string replace one substring with another
  if (s.length == 0) return "";
  var res = "";
  var i = s.indexOf(one,0);
  var lastpos = 0;
  while (i != -1) {
    res += s.substring(lastpos,i) + another;
    lastpos = i + one.length;
    i = s.indexOf(one,lastpos);
  }
  res += s.substring(lastpos);  // the rest
  return res;
} 
//-->