//***********************************************************//
//This function changes the images on mouseover and on mouseout
//The images are named as below ("over" is added before the extension)
//normal image = "image.gif" --- image replaced = "imageover.gif"
//***********************************************************//
function changeImage(img, action){
	if(action == "over"){
		var str = img.src.substring(0, img.src.length - 4)
		var ext = img.src.substring(img.src.length-4, img.src.length)
		img.src = str + "over" + ext
	}else if(action == "normal"){
		var str = img.src.substring(0, img.src.length - 8)
		var ext = img.src.substring(img.src.length-8, img.src.length)
		ext = ext.substring(4, 8)
		img.src = str + ext
	}
}
//***********************************************************//
//This function verifies the register form
//***********************************************************//
function verifyRegister(frm){
	if(frm.txtUsername.value == "" || frm.txtPassword.value == "" || frm.txtName.value == "" || frm.txtAddr.value == "" || frm.txtEmail.value == ""){
		alert("Please enter details in the required fields.        ")
		return false
	}
	if(frm.txtUsername.value.length < 4 || frm.txtPassword.value.length < 4){
		alert("Username and password must be at least 4 characters long.       ")
		return false
	}
	if(checkString(frm.txtUsername.value)){
		alert("The username contains a non useable character.       ")
		return false
	}
	if(checkString(frm.txtPassword.value)){
		alert("The password contains a non useable character.       ")
		return false
	}
	return true
}
//***********************************************************//
//This function checks a string for specified special characters
//***********************************************************//
function checkString(str){
	var arr = new Array("!", "£", "@", "$", "%", "^", "&", "*", "(", ")", "-", "+", "`", "'", '"', ",", ".", "/", ";", "#", "[", "]", "\\", "=", "{", "}", ":", "@", "~", "?", ">", "<", "|", "¬")
	var check = false
	for(var i=0; i<str.length; i++){
		for(var j=0; j<arr.length; j++){
			if(str.charAt(i) == arr[j]){
				check = true
				break
			}
		}
		if(check == true)
			break
	}
	return check
}
//***********************************************************//
//This function resets all from fields with empty strings
//***********************************************************//
function resetForm(frm){
	for(var i=0; i<frm.elements.length; i++){
		frm.elements[i].value = ""
	}
}
//***********************************************************//
//
//***********************************************************//
function verifyCheckout1(frm){
	if(frm.chkSaveDetails.checked == true){
		if(frm.txtUsername.value == "" || frm.txtPassword.value == ""){
			alert("Please enter a username and password.")
			return false
		}
		if(frm.txtUsername.value.length < 4 || frm.txtPassword.value.length < 4){
			alert("Username and password must be at least 4 characters.")
			return false
		}
	}
	if(frm.txtName.value == "" || frm.txtAddr.value == "" || frm.txtEmail.value == ""){
		alert("Please fill in all required fields.")
		return false
	}
	return true
}
//***********************************************************//
//this function is used to animate the contents on the my account/order summary page
//***********************************************************//
function ordSumAnimate(trId, basketId){
	var objTr, objBasket
	if(document.all){
		objTr = document.all[trId]
		objBasket  =document.all[basketId]
	}else{
		objTr = document.getElementById(trId)
		objBasket  =document.getElementById(basketId)
	}
	if(objBasket.style.display == "none"){
		objBasket.style.display = ""
		objTr.style.backgroundColor = "#D7E6E9"
		objTr.style.height = "30"
	}else{
		objBasket.style.display = "none"
		objTr.style.backgroundColor = "white"
		objTr.style.height = ""
	}
}