
<!--

	function JSLIsPhone(pctl, pmsg)
	{
		pattern = /^[0-9]{1}([0-9]|[ ])*$/; 
		if (pctl.value.length < 9 ||pattern.test(pctl.value)==false){doAlert(pmsg); pctl.focus();pctl.select(); return false;}
		return true;
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// DATE VALIDATION ///////
//////////////////////////

	function JSLValidDD(pctl, pmsg)
	// the day number and the error message value are passed in
	{
		// check that the day number is a valid one
		if (pctl.value < 1 || pctl.value > 31)
		{
			doAlert(pmsg); pctl.focus(); pctl.select(); return false;
		}
		return true;
	}
	function JSLValidMM(pctl, pmsg)
	// the month number and the error message value are passed in
	{
		// check that the month number is a valid one
		if (pctl.value < 1 || pctl.value > 12)
		{
			doAlert(pmsg); pctl.focus(); pctl.select(); return false;
		}
		return true;
	}
	function JSLValidDate(dd,mm,yy,datetype)
	// the form field names (for day, month, year) and the date type value (eg "date of birth", "start date") are passed in
	{
		var intDay = dd.value;
		var intMonth = mm.value;
		var intYear = yy.value;

		// check that the day number is valid for those months which only have 30 days
		// NB we don't have to check those months which have 31 days as this has been done by JSLValidDD (above)
  	if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30))
		{
				doAlert("Please enter a valid " + datetype + " day number for the month (1 - 30)"); dd.select(); dd.focus(); return false;
		}

		// if the entered month is February, check that the day number is valid, depending on whether it's a leap year or not
		if (intMonth == 2)
		{
			if (LeapYear(intYear) == true)
			{
				if (intDay > 29)
					{
						doAlert("Leap year - please enter a valid " + datetype + " day number (1 - 29)"); dd.select(); dd.focus(); return false;
					}
			}
			else
			{
				if (intDay > 28)
				{
					doAlert("Please enter a valid " + datetype + " day number (1 - 28)"); dd.select(); dd.focus(); return false;
				}
			}
		}
		return true;
	}
	function LeapYear(intYear)
	{
		// establish whether the entered year is a leap year - use '%' (modulus, division remainder)
		if (intYear % 100 == 0)
		{
			if (intYear % 400 == 0)
			{
				return true;
			}
		}
		else
		{
			if ((intYear % 4) == 0)
			{
				return true;
			}
		}
		return false;
	}
		
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// OPEN POPUP WINDOW ///////
////////////////////////////////////

	/*
		function openpopup(){
		var popurl="./popup-pastresults.cfm"
		winpops=window.open(popurl,"","width=400,height=400,")
		}
	*/
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CHECK FOR EMPTY FORM FIELD ///////
/////////////////////////////////////
	
	function JSLNotNull(pctl, pmsg)
	{
		if (pctl.value == "")
		{
			doAlert(pmsg); pctl.focus(); pctl.select(); return false;
		}
		return true;
	}	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CHECK FOR TEXT ONLY ///////
/////////////////////////////////////
	
	function JSLIsTextOnly(pctl, pmsg)
	{
		pattern = /^([ ]|[a-zA-Z])+[a-zA-Z]+([ ]|[a-zA-Z])*$/;
		if (pattern.test(pctl.value)==false){doAlert(pmsg); pctl.focus(); pctl.select(); return false;}
		return true;
	}
	
	function JSLIsTextOnlyWithHyphens(pctl, pmsg)
	{
		pattern = /^([ ]|[a-zA-Z-])+[a-zA-Z-]+([ ]|[a-zA-Z-])*$/;
		if (pattern.test(pctl.value)==false){doAlert(pmsg); pctl.focus(); pctl.select(); return false;}
		return true;
	}		

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CHECK FOR VALID E-MAIL FORM FIELD ///////
/////////////////////////////////////

	function JSLCheckIsEmail(p_fld, pmsg) {
					 var atPos = p_fld.value.indexOf("@");
					 if (atPos < 1 || atPos == (p_fld.value.length - 1))
						 { doAlert(pmsg); p_fld.focus(); return false; }
					 atPos = p_fld.value.indexOf(" ");
					 if (atPos > -1)
						 { doAlert(pmsg); p_fld.focus(); return false; }
					 atPos = p_fld.value.indexOf(".");
					 if (atPos < 1 || atPos == (p_fld.value.length - 1))
						 { doAlert(pmsg); p_fld.focus(); return false; }
					 if(p_fld.value.indexOf(':') > 0){
						 doAlert(pmsg); p_fld.focus(); return false;
					 }
				 return true;
	}
	
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CHECK THAT VALUE HAS BEEN CHOSEN FORM SELECT LIST ///////
////////////////////////////////////////////////////////////

	function JSLSelected(pctl, pmsg){
	   if (pctl.value == "none") { doAlert(pmsg); pctl.focus(); return false; }
	   return true;
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CHECK THAT VALUE IS A TRUE INTEGER ///////
/////////////////////////////////////////////

	function JSLIsInteger(pctl, pmsg)
	{
		pattern = /^[0-9]*$/;
		if (pattern.test(pctl.value)==false){doAlert(pmsg); pctl.focus(); pctl.select(); return false;}
		return true;
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AUTO-SUBMIT FORM SELECT LISTS ///////
////////////////////////////////////////

	function submitCompany(id){
		document.frmSelectCompany.submit();
	}
	
	function submitAddress(id){
		document.frmSelectAddress.submit();
	}
	
	function submitContact(id){
		document.frmSelectContact.submit();
	}
	
	function submitProject(id){
		document.frmSelectProject.submit();
	}

	function submitTask(id){
		document.frmSelectTask.submit();
	}	

	function submitTaskStatus(id){
		document.frmSelectTaskStatus.submit();
	}	

	function submitCalllog(id){
		document.frmSelectCalllog.submit();
	}	

	function submitCompanyDomain(id){
		document.frmSelectDomain.submit();
	}	

	function submitWebstatSite(id){
		document.frmSelectWebstatSite.submit();
	}	

	function submitWebstatSection(id){
		document.frmSelectWebstatSection.submit();
	}	

	function submitWebstatSubSection(id){
		document.frmSelectWebstatSubSection.submit();
	}	

	function submitWebstatPage(id){
		document.frmSelectWebstatPage.submit();
	}	
	
	function submitLinks(id){
		document.showLinks.submit();
	}	
	
	function submitLanguage(id){
		document.frmlanguagePicker.submit();
	}	
	
	function selectDocument(id){
		document.fSelectDocument.submit();
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// IMAGE ROLLOVER SCRIPTS ///////
////////////////////////////////////////

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImagesTeam() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImagesTeam.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestoreTeam() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObjTeam(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImageTeam() { //v3.0
  var i,j=0,x,a=MM_swapImageTeam.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//-------------------------------------- TRIM STRING FUNCTIONS ---------------------------------------------
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

function doAlert(msg){
	alert(msg);
	//$('alertbox').innerHTML = msg;
	//new Effect.Appear('alertbox');
	//new Effect.ScrollTo('alertbox');
}


/**
 * DHTML date validation script for dd/mm/yyyy. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		doAlert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		doAlert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		doAlert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		doAlert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		doAlert("Please enter a valid date")
		return false
	}
return true
}

function formChecknewsreg(){
	 $('email').value = $F('email').replace(/\ /gi,'');
	 if (!JSLNotNull(document.newsregform.breederFirstname, "Please enter the firstname.")) { 
	 	new Effect.Highlight('firstname');
		return false;
	}
	 if (!JSLIsTextOnly(document.newsregform.breederFirstname, "Please enter text only in the firstname.")) { 
	 	new Effect.Highlight('firstname');
		return false 
	}
	 if (!JSLNotNull(document.newsregform.breederSurname, "Please enter the surname.")) { 
	 	new Effect.Highlight('surname');
	 	return false;
	}
	 if (!JSLIsTextOnly(document.newsregform.breederSurname, "Please enter text only in the surname.")) { 
	 	new Effect.Highlight('surname');
		return false; 
	}
	 if (!JSLNotNull(document.newsregform.breederTel, "Please enter the a contact number.")) { 
	 	new Effect.Highlight('contactnumber');
		return false; 
	}
	 if (!JSLIsPhone(document.newsregform.breederTel, "Please enter a numeric figure - i.e. 01234123123.")) { 
	 	new Effect.Highlight('contactnumber');
		return false;
	}
	 if (!JSLNotNull(document.newsregform.breederEmail, "Please enter your e-mail address.")) { 
	 	new Effect.Highlight('email');
		return false; 
	}
	 if (!JSLCheckIsEmail(document.newsregform.breederEmail, "Please enter a correctly formatted e-mail address.")) { 
	 	new Effect.Highlight('email');
		return false; 
	}
	 
	 var isChecked = false;
	 var checkedIndex = '';
	
	 $$('.cNewsregEmailType').each( function(el,index){
			if(el.checked==true) {
				isChecked = true;
				checkedIndex = index;
			}
		 }                                                                                                
	 );
	 if (isChecked == false){
		 alert("Please select an email option"); 
		 $$('.cNewsregEmailType')[0].focus();  
		 new Effect.Highlight($$('.cNewsregEmailType')[0]);
		 return false;
	 }
	 isChecked = false;
	 checkedIndex = '';
	 $$('.cNewsregBreederType').each( function(el,index){
			if(el.checked==true) {
				isChecked = true;
				checkedIndex = index;
			}
		 }                                                                                                
	 );
	 if (isChecked == false){
		 alert("Please indicate if you breed Puppies, Kittens or both."); 
		 $$('.cNewsregBreederType')[0].focus();  
		 new Effect.Highlight($$('.cNewsregBreederType')[0]);
		 return false;
	 }
	 return true;
}



function scrolltop() {
	new Effect.ScrollTo($$('.right')[0]); 	
}


function JSLCheckLength(pctl, pmsg, maxchar){
		   if (pctl.value.length >= maxchar) { alert(pmsg); pctl.focus(); return false; }
		   return true;
}



//-->



