function copyAddress() 
{ 
document.form1.deliveryfname.value = document.form1.fname.value  
document.form1.deliverylname.value = document.form1.lname.value 
document.form1.deliverystreet.value = document.form1.street.value 
document.form1.deliverycity.value = document.form1.city.value
} 

//Global variable set at start of script
var emptyString = "Please enter a valid "

function validateString(myfield, s) {

 if (myfield.value.length > 0 )
   { return true }
	else {
		myfield.focus()
		alert(emptyString + s)
		return false
	}
}

function greaterthan3(myfield, s) {

 if (myfield.value.length > 3)
   { return true }
	else {
		myfield.focus()
		alert("The " + s + " must be more than 3 characters long")
		return false
	}
}

function greaterthantovalid(myfield, s) {

 if (myfield.value.length > 3)
   { return true }
	else {
		myfield.focus()
		alert("Please enter a valid " + s)
		return false
	}
}

function is_nonEmpty_PhoneNum(theElement, theElementName)
{
  var s
  var l
  
  
  s = theElement.value;
  s = replace(s,' ','')
  if ( (s == "") || (isNaN(Math.abs(s))) || (s.length < 6)  )
  {
    alert( theElementName +  " must be made up of at least ----------- 6 digits.");
    theElement.focus(); 
    return false;
  }
  return true;
}


function validateEmail(s)
{


if ((s == "" || s.value.indexOf('@', 0) == -1) || s.value.indexOf('.') == -1) 

     			{
                         s.focus()
		         alert("Please enter a valid E-mail Address")
		         return false
			}
         else {
      		return true
              }
}


function checkTheSame(s1,s2,comment)
{

if (s1.value == s2.value)

{
     return true
} 

else {
       s1.focus()
       alert(comment)
       return false
      }
}


function isDOB(s,comment) 
  {
	var i = parseInt(s.value)
	
        if ((i >= 1900) && (i <= 2000)) 
        {
         return true
        }
        else
         {
           s.focus()
           alert(comment)
           return false
         }   
}


function is_nonEmpty_CardNum(theElement, theElementName)
{
  var s
  var l
  s = theElement.value;
  if ((s == "") || (isNaN(Math.abs(s))))
  {
    alert(theElementName +  " must be made up of digits only.");
    theElement.focus(); 
    return false;
  }
  return true;
}

function replace(string,text,by) {
// Replaces text with by in string
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
}
