function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
/* This code is Copyright (c) 1996 Nick Heinle and Athenia Associates, 
 * all rights reserved. In order to receive the right to license this 
 * code for use on your site the original code must be copied from the
 * Web site webreference.com/javascript/. License is granted to user to 
 * reuse this code on their own Web site if and only if this entire copyright
 * notice is included. Code written by Nick Heinle of webreference.com.
 */
var t
delay = 400;
imgNumber = 0;
totalimgNumber = 17;
anim = new Array();

for (i = 0; i < totalimgNumber; i++) {
anim[i] = new Image (239, 390);
anim[i].src = 'images/wave' + (i + 1) + '.JPG';
} 

function Switch() {                
document.waveanim.src = anim[imgNumber].src;
imgNumber++;
        if(imgNumber >= totalimgNumber) imgNumber = 0;
}
                
function animate() {
Switch();
t=setTimeout("animate()", delay);
}

function stop() {                
document.waveanim.src = "images/wave1.JPG";
clearTimeout(t);
imgNumber = 0;
}

function setupPage() {
	
	isFlowers = new ImageScroller("isFlowersFrame", "isFlowersImageRow");
	//**    [begin] Modify these to change your images  **//
	isFlowers.addThumbnail("images/200_elizabethryman1.jpg", "images/full_elizabethryman1.jpg", "Elizabeth Ryman", "Description.");
	isFlowers.addThumbnail("images/200_alisonbest.jpg", "images/full_alisonbest.jpg", "Alison J Best", "Description.");
	isFlowers.addThumbnail("images/200_charlenemorton.jpg", "images/full_charlenemorton.jpg", "Chalene Morton", "Description.");
	isFlowers.addThumbnail("images/200_annereynolds1.jpg", "images/full_annereynolds1.jpg", "Anne Reynolds", "Description.");
	isFlowers.addThumbnail("images/200_austinemery.jpg", "images/full_austinemery.jpg", "Austin Emery", "Description.");
	isFlowers.addThumbnail("images/200_benthrill.jpg", "images/full_benthrill.jpg", "Ben Thrill", "Description.");
	isFlowers.addThumbnail("images/200_gemmaburgess.jpg", "images/full_gemmaburgess.jpg", "Gemma Burgess", "Description.");
	isFlowers.addThumbnail("images/200_georginapotier2.jpg", "images/full_georginapotier2.jpg", "Georgina Potier", " Description.");
	isFlowers.addThumbnail("images/200_georginapotier1.jpg", "images/full_georginapotier1.jpg", "Georgina Potier", "Description.");
	isFlowers.addThumbnail("images/200_hannahbroadway.jpg", "images/full_hannahbroadway.jpg", "Hannah Broadway", "Description.");
	isFlowers.addThumbnail("images/200_harrietjones.jpg", "images/full_harrietjones.jpg", "Harriet Challis-Jones", "Description.");
	isFlowers.addThumbnail("images/200_hollydomino1.jpg", "images/full_hollydomino1.jpg", "Holly Domino", "Description.");
	isFlowers.addThumbnail("images/200_sarahroberts1.jpg", "images/full_sarahroberts1.jpg", "Sarah Roberts", "Description.");
	isFlowers.addThumbnail("images/200_hollydomino3.jpg", "images/full_hollydomino3.jpg", "Holly Domino", "Description.");
	isFlowers.addThumbnail("images/200_janinepartington.jpg", "images/full_janinepartington.jpg", "Janine Partington", "Description.");
	isFlowers.addThumbnail("images/200_jaynepierson.jpg", "images/full_jaynepierson.jpg", "Jayne Pierson", "Description.");
	isFlowers.addThumbnail("images/200_judithalexander.jpg", "images/full_judithalexander.jpg", "Judith Alexander", "Description.");
	isFlowers.addThumbnail("images/200_katieshipley.jpg", "images/full_katieshipley.jpg", "Katie Shipley", "Description.");
	isFlowers.addThumbnail("images/200_laviniagallie.jpg", "images/full_laviniagallie.jpg", "Lavinia Gallie", "Description.");
	isFlowers.addThumbnail("images/200_lesleybenett1.jpg", "images/full_lesleybenett1.jpg", "Lesley Bennett", "Description.");
	isFlowers.addThumbnail("images/200_louisecunningham.jpg", "images/full_louisecunningham.jpg", "Louise Cunningham", "Description.");
	isFlowers.addThumbnail("images/200_louisehicks.jpg", "images/full_louisehicks.jpg", "Louise Hicks", "Description.");
	isFlowers.addThumbnail("images/200_lucindaholmes.jpg", "images/full_lucindaholmes.jpg", "Lucinda Holmes", "Description.");
	isFlowers.addThumbnail("images/200_jamesgreen.jpg", "images/full_jamesgreen.jpg", "James Green", "Description.");
	isFlowers.addThumbnail("images/200_saniacufley.jpg", "images/full_saniacufley.jpg", "Sania Cufley", "escription.");
	isFlowers.addThumbnail("images/200_staceybarrell.jpg", "images/full_staceybarrell.jpg", "Stacey Barrell", "Description.");
	isFlowers.addThumbnail("images/200_suerobson.jpg", "images/full_suerobson.jpg", "Sue Robson", "Description.");
	
	//**    [end]   Modify these to change your images  **//								
	isFlowers.setThumbnailHeight(200);
	isFlowers.setThumbnailWidth(200);
	isFlowers.setThumbnailPadding(2);
	isFlowers.setScrollType(0);
	isFlowers.enableThumbBorder(false);
	isFlowers.setClickOpenType(1);
	isFlowers.setThumbsShown(2);
	isFlowers.setNumOfImageToScroll(1);
	isFlowers.renderScroller();
	
	//Also need to envoke the maxlength function while we're at it.
	setMaxLength();
};

function setMaxLength() {
	var x = document.getElementsByTagName('textarea');
	var counter = document.createElement('div');
	counter.className = 'bodytext';
	for (var i=0;i<x.length;i++) {
		if (x[i].getAttribute('maxlength')) {
			var counterClone = counter.cloneNode(true);
			counterClone.relatedElement = x[i];
			counterClone.innerHTML = 'Max Length <span>0</span>/'+x[i].getAttribute('maxlength');
			x[i].parentNode.insertBefore(counterClone,x[i].nextSibling);
			x[i].relatedElement = counterClone.getElementsByTagName('span')[0];

			x[i].onkeyup = x[i].onchange = checkMaxLength;
			x[i].onkeyup();
		}
	}
}

function openWindow(location){
	window.open(location);
}
	
function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.relatedElement.className = 'toomuch';
	else
		this.relatedElement.className = '';
	this.relatedElement.firstChild.nodeValue = currentLength;
	// not innerHTML
}

function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

function getSelectedCheckbox(buttonGroup) {
   // Go through all the check boxes. return an array of all the ones
   // that are selected (their position numbers). if no boxes were checked,
   // returned array will be empty (length will be zero)
   var retArr = new Array();
   var lastElement = 0;
   if (buttonGroup[0]) { // if the button group is an array (one check box is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            retArr.length = lastElement;
            retArr[lastElement] = i;
            lastElement++;
         }
      }
   } else { // There is only one check box (it's not an array)
      if (buttonGroup.checked) { // if the one check box is checked
         retArr.length = lastElement;
         retArr[lastElement] = 0; // return zero as the only array value
      }
   }
   return retArr;
} // Ends the "getSelectedCheckbox" function

function getSelectedCheckboxValue(buttonGroup) {
   // return an array of values selected in the check box group. if no boxes
   // were checked, returned array will be empty (length will be zero)
   var retArr = new Array(); // set up empty array for the return values
   var selectedItems = getSelectedCheckbox(buttonGroup);
   if (selectedItems.length != 0) { // if there was something selected
      retArr.length = selectedItems.length;
      for (var i=0; i<selectedItems.length; i++) {
         if (buttonGroup[selectedItems[i]]) { // Make sure it's an array
            retArr[i] = buttonGroup[selectedItems[i]].value;
         } else { // It's not an array (there's just one check box and it's selected)
            retArr[i] = buttonGroup.value;// return that value
         }
      }
   }
   return retArr;
} // Ends the "getSelectedCheckBoxValue" function

function countChecked(formControls){
//var formControls = document.details.q7;
var c = 0;
for (var i = 0; i < formControls.length; i++)
if (formControls[i].type.toLowerCase() == 'checkbox' && formControls[i].checked)
c++;
return c;
}

function isValidText(string,allowed) {
    for (var i=0; i< string.length; i++) {
        if (allowed.indexOf(string.charAt(i)) == -1) {
            return false;
        }
    }
    return true;
}

function checkLen(str,maxlen){
	if(str.length>maxlen){
		return false;
	}
}

function validatesurvey() {
if(getSelectedRadio(document.details.q1) == -1) {
	alert('Please select an answer for question 1.');
	return false;
}
//set q1string
document.details.q1string.value = getSelectedRadioValue(document.details.q1);

if (document.details.q2.value == '' || checkLen(document.details.q2.value,'400')==false) {
	alert('Please enter an answer for question 2. You can use up to 400 characters.');
	return false;
}

if (document.details.q3a.value == '' || checkLen(document.details.q3a.value,'400')==false) {
	alert('Please enter an answer for question 3. You can use up to 400 characters.');
	return false;
}

if (document.details.q3b.value == '' || checkLen(document.details.q3b.value,'400')==false) {
	alert('Please enter an answer for question 3. You can use up to 400 characters.');
	return false;
}

if (document.details.q4.value == '') {
	alert('Please enter an answer for question 4. You can use up to 10 characters.');
	return false;
}

if (document.details.q5.value == '' || checkLen(document.details.q5.value,'400')==false) {
	alert('Please enter an answer for question 5. You can use up to 400 characters.');
	return false;
}

if (document.details.q6.value == '' || checkLen(document.details.q6.value,'400')==false) {
	alert('Please enter an answer for question 6. You can use up to 400 characters.');
	return false;
}

if(countChecked(document.details.q7)>3){
	alert('Please select a maximum of 3 designs for quesiton 7.');
	return false;
}
//build string for checked design checkboxes
document.details.q7string.value = getSelectedCheckboxValue(document.details.q7);

if(getSelectedRadio(document.details.q8) == -1) {
	alert('Please select an answer for question 8.');
	return false;
}
//set q8string
document.details.q8string.value = getSelectedRadioValue(document.details.q8);

if(getSelectedRadio(document.details.q9) == -1) {
	alert('Please select an answer for question 9.');
	return false;
}
//set q9string
document.details.q9string.value = getSelectedRadioValue(document.details.q9);

//build string for checked newspaper checkboxes
document.details.q10string.value = getSelectedCheckboxValue(document.details.q10);

if (document.details.q11.value == '' || checkLen(document.details.q11.value,'400')==false) {
	alert('Please enter an answer for question 11. You can use up to 400 characters.');
	return false;
}

if (document.details.q12.value == '' || checkLen(document.details.q12.value,'400')==false) {
	alert('Please enter an answer for question 12. You can use up to 400 characters.');
	return false;
}
// now check the email addresses
email = document.details.email.value
AtPos = email.indexOf("@")
StopPos = email.lastIndexOf(".")
var validemail = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@._-'; // define valid email characters

if (email == "" || isValidText(email,validemail)==false) {
alert('Please enter a valid email address. You can use any letter and number and the following @._-');
return false;
}
if (AtPos == -1 || StopPos == -1) {
alert('Please enter a valid email address');
return false;
}
if (StopPos < AtPos) {
alert('Please enter a valid email address');
return false;
}
if (StopPos - AtPos == 1) {
alert('Please enter a valid email address');
return false;
}
vericode=document.details.vcode.value.toUpperCase()
if (vericode == '' || vericode !='T6KF23') {
	alert('Please enter a valid verification code.');
	return false;
}

//form is correct so proceed
return true;
}


function checkfields(multi) {

   var valid = true;

   if (multi.name.value == ""){
      alert("Name is blank!");
          multi.name.focus();
      valid = false;
   }

   if (multi.email.value == ""){
      alert("E-mail is blank!");
          multi.email.focus();
      valid = false;
   }

var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
var check=/@[\w\-]+\./;
var checkend=/\.[a-zA-Z]{2,3}$/;

   if(((multi.email.value.search(exclude) != 
-1)||(multi.email.value.search(check)) == 
-1)||(multi.email.value.search(checkend) == -1)){
      alert("Incorrect email address!");
      multi.email.focus()
      valid = false;
   }

   return valid;
}

