<!--
/*
Description : Form validation...
Date		 : 15/05/2002
Author		 : mandogroup ltd ©
History     : JR - Initial Build
Version     : V1.01 - original release
*/

//check for empty fields...
function EmptyField(aFields) {
var bRet = false;
var i = 0;

	for (i=0;i<=aFields.length;i++) {
		if (aFields[i]=='') {
			bRet = true;
			break;
		}
	}
	return(bRet);
}
// Check if the email address is valid...
function ValidateEmail(strEmail){
	var strAt = strEmail.indexOf('@')
	var strDot = strEmail.lastIndexOf('.') 
	var intLength = strEmail.length - 1 
	if ((strAt < 1) || (strDot <= strAt+1) || (strDot == intLength ))
	{ 
		return(false);
	} 
	else
	{
		return(true);
	}
}
// Check if a price is valid...(AL P - 06/08/2003)
function ValidateMoney(price){
var re = /^\£?[0-9]+(\.[0-9]{1,2})?$/.exec(price);
	if (re == null){
		alert("Price or Discount are not in a valid currency format")
		return (false);
    }else{
		return(true);
	}
}
// Check if the date is valid...(AL P - 06/08/2003)
function ValidateDate(dteDate){
var bValid = false; 
var aMatch = /^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/.exec(dteDate); 

	if(aMatch == null){
		alert(dteDate + " is not in dd/mm/yy or dd/mm/yyyy format."); 
	}else{ 
		var oDate = new Date(aMatch[3], --aMatch[2], aMatch[1]); 
		if (aMatch[3] != oDate.getYear() && aMatch[3] != oDate.getFullYear() || aMatch[2] != oDate.getMonth()){
			alert(dteDate + " has the right format, \n" + "but is not a valid calendar date."); 
		}else{
			bValid = true; 
		} 
	}
	return bValid; 
}
// Select All (Used in asking question)
function selectAll(){
 var e = document.forms['frmAsk'].chkSelectAll;
 var j;
 var box;
 var inttop = document.forms['frmAsk'].totalask.value;

	if (e.checked == true){
		for (j = 0; j <= inttop; j++) {
			box = eval('document.frmAsk.chkAsk'+j);
			box.checked = true;
		}
	}else{
		for (j = 0; j <= inttop; j++){
			box = eval('document.frmAsk.chkAsk'+j);
			box.checked = false;
		}
	}
 }
function frmAsk_onsubmit() {
 var inttop = document.forms['frmAsk'].totalask.value;
 var j;
 var blnIsSelected = false;
 var intCount = 0;
 var bConfirmed;
 var box;

	for (j = 0; j <= inttop; j++){
		box = eval('document.frmAsk.chkAsk'+j);
		if (box.checked == true) {
			blnIsSelected = true;
			intCount++;
		}
	}

/*	if (key!='') {
		AdvancedSearch_OnClick();
		return (false);
	} else {
*/
		if (!blnIsSelected) {
			alert('Please choose at least one contact to receive your question');
			return(false);
		}else{
			if ( (intCount<=10)&&(inttop>=15) ){
				return(confirm("You have selected less than 10 people to receive your question.\nExchange response rate is currently running at 15%.\nSelecting more people will help ensure you get a good response.\nClick OK to send your question to your original selection.\nTo select more people from the list click Cancel."));
			}else if ( intCount==1&&(inttop<15) ) {				
				return(confirm("You have selected only one person to receive your question.\nExchange response rate is currently running at 15%.\nSelecting more people will help ensure you get a good response.\nClick OK to send your question to your original selection.\nTo select more people from the list click Cancel."));
			}else{
				return(true);
			}
		}
/*
	}
*/
}
//-->
