function isValidText(object, text){
  var str = trim(object.value);
  if (str.length > 0){
    return true;
  }
  else{
    window.alert("Please enter your " + text);
    object.focus();
    return false;
  }
}

function isValidNumber(object, text){
  if (isValidText(object, text)){
    var str = trim(object.value);
    var re = new RegExp(/^[0-9]+$/);
    if (re.test(str)){
      return true;
    }
    else{
      window.alert(text + "\nPlease enter a valid number");
      object.focus();
      return false;
    }
  }
  return false;
}


function isValidEmail(object, text) {
  if (isValidText(object, text)){
    if (object.value.indexOf('@', 0) > -1) {
      return true;
    }
    window.alert(text + "\nEmail address is invalid");
    object.focus();
  }
  return false;
}


function trim(strText) { 
  // this will get rid of leading spaces 
  while (strText.substring(0,1) == ' ') 
      strText = strText.substring(1, strText.length); 
  // this will get rid of trailing spaces 
  while (strText.substring(strText.length-1,strText.length) == ' ') 
      strText = strText.substring(0, strText.length-1); 
  return strText; 
} 

function Random() {
images = new Array(8);
images[0] = "<img src='/images/imagehome.jpg' alt='Oriel'>";
images[1] = "<img src='/images/imagehome3.jpg' alt='Oriel'>";
images[2] = "<img src='/images/imagehome4.jpg' alt='Oriel'>";
images[3] = "<img src='/images/imagehome5.jpg' alt='Oriel'>";
images[4] = "<img src='/images/imagehome6.jpg' alt='Oriel'>";
images[5] = "<img src='/images/imagehome7.jpg' alt='Oriel'>";
images[6] = "<img src='/images/imagehome8.jpg' alt='Oriel'>";
images[7] = "<img src='/images/imagehome9.jpg' alt='Oriel'>";
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
} 