<!-- hide the JS Code

////////////////////////////////////////////////////////////////////////
// Validation functions called by forms

function validateLoginForm(form)
{
	// Validate the email address. Must have @ followed by .
	// Must not have special characters
	
	
		if (!validateEmail(form.email.value))
		{
			form.email.focus();
			return false;
		}	

	// Validate the password. Must have 6+ characters
	// Must not have special characters
	
		if (!validatePassword(form.password.value))
		{
			form.password.focus();
			return false;
		}	

	
	return true;
}


function validateArtworkReserve(form)
{
	// Validate the email address. Must have @ followed by .
	// Must not have special characters
	
	
		if (!validateEmail(form.email.value))
		{
			form.email.focus();
			return false;
		}	
	
	return true;
}



function validatePasswordForm(form)
{
		
	// Validate the password. Must have 6+ characters
	// Must not have special characters

		if (!validatePassword(form.password.value))
		{
			form.password.focus();
			return false;
		}	

	// Validate the password. Must have 6+ characters
	// Must not have special characters
	
		if (!validatePassword(form.checkPassword.value))
		{
			form.checkPassword.focus();
			return false;
		}	
		
		if (form.password.value != form.checkPassword.value)
		{
			form.password.focus();
			alert ("Confirmation Failed. Please enter a password and then the same password again to confirm.");
			return false;
		}
	
	return true;
}



function validateContactForm(form)
{
	// Validate the email address. Must have @ followed by .
	// Must not have special characters
	
	
		if (!validateEmail(form.email.value))
		{
			form.email.focus();
			return false;
		}	
	
	// Validate the userName. Must not be blank
	
		if (!validateName(form.uName.value))
		{
			form.uName.focus();
			return false;
		}	
		
	// Validate the phone. If provided must have only +() and numbers
		if (!isBlank(form.phoneNum.value))
		{
			if (!validateTelephoneNumber(form.phoneNum.value))
			{
				form.phoneNum.focus();
				return false;
			}	
		}
		
	// Validate the comments -make sure they are not blank
		if (isBlank(form.qc.value))
		{
				alert("Please Include some comments");
				form.qc.focus();
				return false;
		}
		
	return true;
}


function validateCommentsForm(form)
{
	// Validate the email address. Must have @ followed by .
	// Must not have special characters
	
	
		if (!validateEmail(form.email.value))
		{
			form.email.focus();
			return false;
		}	
	
	// Validate the userName. Must not be blank
	
		if (!validateName(form.uName.value))
		{
			form.uName.focus();
			return false;
		}	

	// Validate the comments. Must not be blank
	// Must not have ' " < or >
	
		if (!validateComments(form.comments.value))
		{
			form.comments.focus();
			return false;
		}	

}



function validateUserDetails(form)
{
	// Validate the userName. Must not be blank
	
		if (!validateName(form.chrFullName.value))
		{
			form.chrFullName.focus();
			return false;
		}	

	// Validate the email address. Must have @ followed by .
	// Must not have special characters
	
		if (!validateEmail(form.chrEmail.value))
		{
			form.chrEmail.focus();
			return false;
		}	

		if (!validatePassword(form.chrPassword.value))
		{
			form.chrPassword.focus();
			return false;
		}	


	// Validate the address. Must not be blank
	
		if (!validateStreetName(form.chrAddressLine1.value))
		{
			form.chrAddressLine1.focus();
			return false;
		}	

	// Validate the city. Must not be blank
	
		if (!validateCity(form.chrAddressCity.value))
		{
			form.chrAddressCity.focus();
			return false;
		}	

	// Validate the country. Must not be blank
	
		if (!validateCountry(form.chrAddressCountry.value))
		{
			form.chrAddressCountry.focus();
			return false;
		}	

	// Validate the post code. Must be ZZ1 1ZZ or ZZ99 9ZZ
	
		if (!validatePostcode(form.chrAddressPostCode.value))
		{
			form.chrAddressPostCode.focus();
			return false;
		}	

	// Validate the telephone number
	
		if (!validateTelephoneNumber(form.chrPhoneNumber.value))
		{
			form.chrPhoneNumber.focus();
			return false;
		}	




}


function validateForgottenPassword(form)
{
	// Validate the email address. Must have @ followed by .
	// Must not have special characters
	
		if (!validateEmail(form.email.value))
		{
			form.email.focus();
			return false;
		}	
}



function validateAuctionForm(form)
{
	// Validate the the auction URL
			
		if (!validateURL(form.chrAuctionURL.value))
		{
			form.chrAuctionURL.focus();
			return false;
		}	

	// Validate the date
	
		if (!validateDate(form.dteAuctionEndDate.value))
		{
			form.dteAuctionEndDate.focus();
			return false;
		}	

	// Validate the time
		if (!validateTime(form.tmeAuctionEndTime.value))
		{
			form.tmeAuctionEndTime.focus();
			return false;
		}	

}


function validateAddArtworkForm(form)
{
	// Validate the picture Title
			
		if (!validateTitle(form.chrPictureTitle.value))
		{
			form.chrPictureTitle.focus();
			return false;
		}	
	
	// Validate the picture description
			
		if (!validateDescription(form.chrPictureDescription.value))
		{
			form.chrPictureDescription.focus();
			return false;
		}	

	// Validate the width
			
		if (!validateWidthHeight(form.smlWidthInches.value))
		{
			form.smlWidthInches.focus();
			return false;
		}	

	// Validate the height
			
		if (!validateWidthHeight(form.smlHeightInches.value))
		{
			form.smlHeightInches.focus();
			return false;
		}	
		
	// Validate the for sale price
			
		if (!validateForSalePrice(form.dblForSalePrice.value))
		{
			form.dblForSalePrice.focus();
			return false;
		}	
		
	// Validate the date
			
		if (!validateDate(form.dtePublished.value))
		{
			form.dtePublished.focus();
			return false;
		}	
		
	// Validate the category
			
		if (isBlank(form.intCategoryID.value))
		{
			alert("Please select a category for the artwork");
			form.intCategoryID.focus();
			return false;
		}	


}








/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
// Start of validation functions used by above

function validateName(name)
{
	//Make sure the name is not blank
	
	if (isBlank(name))
	{
		alert ("Please enter your name.");
		return false;
	}
	
	if (testForInvalidCharacters(name))
    { 
  		alert("Please do not use the characters <,> or single or double quotes in the name"); 
  		return false; 
    } 
	return true;
}





function validatePassword(password)
{
   var reg1 = /^[A-Za-z0-9]{6,}$/; 

   if (!reg1.test(password))
	{
		alert ("The password must be 6 or more characters and can only contain a-z A-Z and 0-9");
		return false;
	}

	return true;

}




function validateStreetName(streetName)
{
  //undefined is allowed
  if(isUndefined(streetName))
  {
	  return true;
  }
	// is the street name blank?
	
	if (isBlank(streetName))
	{
		alert ("Please enter the street name.");
		return false;

	}

   if (testForInvalidCharacters(streetName))
    { 
  		alert("Please do not use the characters <,> or single or double quotes in the street name"); 
  		return false; 
    } 

	return true;
}




function validateCity(city)
{
  //undefined is allowed
  if(isUndefined(city))
  {
	  return true;
  }


	// is the town field blank?
	
	if (isBlank(city))
	{
		alert ("Please enter the city.");
		return false;
	}

  if (testForInvalidCharacters(city))
  { 
  		alert("Please do not use the characters <,> or single or double quotes in the city"); 
  		return false; 
  } 
	return true;
}



function validateCountry(country)
{
  //undefined is allowed
  if(isUndefined(country))
  {
	  return true;
  }
  // is the county field blank?
	
	if (isBlank(country))
	{
		alert ("Please enter the country.");
		return false;
	}

   if (testForInvalidCharacters(country))
    { 
  		alert("Please do not use the characters <,> or single or double quotes in the country"); 
  		return false; 
    } 

	return true;
}




function validatePostcode(postcode)
{
  //undefined is allowed
  if(isUndefined(postcode))
  {
	  return true;
  }
  
  // the valid format is ZZ1 1ZZ or ZZ99 9ZZ
  var reg1 = /[A-Za-z]{1,2}[0-9]{1,2}[\ ][0-9][A-Za-z]{2}$/; 

  if (!reg1.test(postcode))
	{
		alert ("Please enter the postcode formatted like Z33 3ZZ or ZZ4 4ZZ or ZZ99 9ZZ.");
		return false;
	}

	return true;
}




function validateForSalePrice(price)
{
  // the valid format is 99999.99
  var reg1 = /^[0-9]{0,4}[\.]{0,1}[0-9]{0,2}$/; 

  if (isBlank(price) || (!reg1.test(price)) || (price > 9999.99))
	{
		alert ("Please enter a price up to 9999.99");
		return false;
	}

	return true;
}


function validateTelephoneNumber(telephone) 
{
  //undefined is allowed
  if(isUndefined(telephone))
  {
	  return true;
  }
	
  // must start with 0 or +44
  if (!(telephone.charAt(0)=="0" || telephone.indexOf("+",0)!=-1)) 
  { 
  		alert("Phone number must start with 0 or +."); 
  		return false; 
  } 
  
  // make sure the number is long enough 
  if (telephone.length <= 6) 
  { 
  		alert("Please include full phone number with area code."); 
  		return false; 
  } 

  var reg1 = /^[0-9\ \+\(\)]{1,}$/; // numbers 0-9, space and plus are valid

  if (!reg1.test(telephone))
  { 
  		alert("Please only use number 0 to 9, ( and ), + and space in the phone number. Example +44 (131) 123 4567"); 
  		return false; 
  } 

  // a plus can only be the first character
  if (telephone.indexOf("+",1)!=-1)
  { 
  		alert("+ can only be the first character of the phone number"); 
  		return false; 
  } 

  return true;
}




function validateComments(comments) 
{
 // make sure the number is long enough 
  if (comments.length <= 2) 
  { 
  		alert("Please add some comments."); 
  		return false; 
  } 

  if (comments.length > 1024) 
  { 
  		alert("Please keep your comments within 1024 characters."); 
  		return false; 
  } 

  if (testForInvalidCharacters(comments))
  { 
  		alert("Please do not use the characters <,> or single or double quotes"); 
  		return false; 
  } 

  return true;
}





function testForInvalidCharacters(strTestString) 
{

  var reg1 = /^.*[\'\"\<\>].*$/; // make sure there are no ' " < or >

  if (reg1.test(strTestString))
  { 
  		return true; 
  } 

  return false;
}


function validateTitle(title) 
{
 // make sure the number is long enough 
  if (title.length <= 2) 
  { 
  		alert("Please add a picture title."); 
  		return false; 
  } 

  if (testForInvalidCharacters(title))
  { 
  		alert("Please do not use the characters <,> or single or double quotes in the title"); 
  		return false; 
  } 

  return true;
}


function validateDescription(description) 
{
  if (testForInvalidCharacters(description))
  { 
  		alert("Please do not use the characters <,> or single or double quotes in the description"); 
  		return false; 
  } 

  return true;
}




function validateWidthHeight(value) 
{
  // the valid format is nnn = 999
  var reg1 = /^[0-9]{1,3}$/; 
	
  if (isBlank(value) || (!reg1.test(value)) || (value <= 0) || (value > 999))
  { 
  		alert("Please enter width and height in inches between 1 and 999"); 
  		return false; 
  } 

  return true;
}



// this function is courtesy of http://www.webreference.com/ and has been adapted as needed for this form
function validateEmail(email) 
{
	// this function has been levereged from the web
	// One regular expression contains not valid strings. The email must NOT match
	// the second regular expression MUST match. I have explained the regular expression strings

  // the first expression looks for invalid items of	e.g.
  // a@b.com@com OR a.b.c@a.com OR a.b@com OR something starting .
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
  
  // the second expression makes sure there are only valid characters, but also
  // allows name@[123.123.123.123] format as well
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid

  if (testForInvalidCharacters(email))
  { 
  		alert("Please do not use the characters <,> or single or double quotes in the email"); 
  		return false; 
  } 

  if (!reg1.test(email) && reg2.test(email)) 
  { 
    return true;
  }
  alert("\"" + email + "\" is an invalid e-mail!"); 
  return false;
}




function validateURL(URL) 
{
 // make sure the number is long enough 
  if (URL.length <= 15) 
  { 
  		alert("Please add a full URL"); 
  		return false; 
  } 
  URL=URL.toLowerCase();
  if ((URL.indexOf("http://") < 0) && (URL.indexOf("https://") < 0))
  { 
  		alert("please make sure the URL starts with http:// or https://"); 
  		return false; 
  } 
  if (testForInvalidCharacters(URL))
  { 
  		alert("Please do not use the characters <,> or single or double quotes"); 
  		return false; 
  } return true;
}




function validateDate(date) 
{
 // make sure the date has an acceptable format 
  var reg2 = /^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}$/; // valid

  if (isBlank(date) || !reg2.test(date)) 
  { 
    alert("Date should be in format dd/mm/yyyy - Please Use Date Picker for easiest date selection"); 
	return false;
  }
  return true;
}


function validateTime(time) 
{
 // make sure the time has an acceptable format 
  var reg2 = /^[0-9]{1,2}\:[0-9]{2}$/; // valid

  if (!reg2.test(time)) 
  { 
    alert("Time should have the format HH:MM e.g. 09:30 or 18:45 (Note - 24 Hr clock)"); 
	return false;
  }
  return true;
}





function isUndefined(testString)
{
	if (testString == "Undefined")			
	{
		return true;
	}	
			
	return false;
}


function isBlank(testString)
{
	// zero length string?
	
	if (testString.length == 0)			
	{
		return true;
	}	
	// do we have nothing but spaces
	
	for (var i=0; i<testString.length; i++)		
	{
		if (testString.charAt(i) != " ")
		{
			return false;
		}
	}
	
	return true;	
}




function updateNotification()
{
	document.getElementById("notificationChanged").style.display="block"
	document.getElementById("notificationSuccess").style.display="none"
	document.getElementById("notificationFailure").style.display="none"
}



-->

