// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

// Gallery Functions
function displayphoto(photoID){
	document.getElementById("photosrc").src='Images/DBImages/Photos/' + photoID + '.JPG';	
}

//defaultStep=5
var step=2
var scrolltimer = 0;
function scrollDivLeft(id){
	document.getElementById(id).scrollLeft+=step
	scrolltimer = setTimeout("scrollDivLeft('"+id+"')",10)
}

function scrollDivRight(id){
	document.getElementById(id).scrollLeft-=step
	scrolltimer = setTimeout("scrollDivRight('"+id+"')",10)
}

function stopscroll(){
	clearTimeout(scrolltimer);
}

// Form Validation
function checkclientlogin(){
	var ftxt = '';
	
	if (document.clientlogin.Username.value==''){
		ftxt += '\n- Please enter your Username.';
	}
	
	if (document.clientlogin.Password.value==''){
		ftxt += '\n- Please enter your Password.';
	}
	
	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

function checkorderphoto(){
	var ftxt = '';
	
	if (document.orderphoto.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.orderphoto.Address.value==''){
		ftxt += '\n- Please enter your Address.';
	}
	
	if (document.orderphoto.Postcode.value==''){
		ftxt += '\n- Please enter your Postcode.';
	}
	
	if (document.orderphoto.Telephone.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (isValidEmail(document.orderphoto.EmailAddress.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}
	
	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {		
		return true;
	}
}

function updatephotobasket(){
	document.orderphoto.submit();
}	