<!--

function move_in(img_name,img_src) {
 document[img_name].src=img_src
}

function move_out(img_name,img_src) {
 document[img_name].src=img_src
}

function opendoc(thedoc) {
  var w=window.open(thedoc,'docwin','width=750,height=500,left=0,top=0,titlebar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,toolbar=no','false');
  var d=w.document;
  w.focus(); 
}

function loadimages() {
//image_u0 = new Image; image_u0.src="graphics/btn0_u.jpg";
//image_uo0 = new Image; image_uo0.src="graphics/btn0_uo.jpg";
//image_d0 = new Image; image_d0.src="graphics/btn0_d.jpg";
//image_do0 = new Image; image_do0.src="graphics/btn0_do.jpg";
//image_u1 = new Image; image_u1.src="graphics/btn1_u.jpg";
//image_uo1 = new Image; image_uo1.src="graphics/btn1_uo.jpg";
//image_d1 = new Image; image_d1.src="graphics/btn1_d.jpg";
//image_do1 = new Image; image_do1.src="graphics/btn1_do.jpg";
}

function writecookie(theForm) {
var formData="theData=;";  
  if (theForm=='info') {
    var d=document.requestdata;
  }
  if (theForm=='grant') {
    var d=document.grantdata;
  }  
  formData=formData+d.Name.value+';'
                   +d.Business.value+';'
                   +d.Address1.value+';'
                   +d.Address2.value+';'
                   +d.Address3.value+';'
                   +d.Address4.value+';'
                   +d.Country.selectedIndex+';'
                   +d.PostCode.value+';'
                   +d.Email.value+';'
                   +d.PhoneArea.value+';'
                   +d.PhoneNum.value+';'
                   +d.Other.value+';'
                   
                   +d.viaPost.checked+';'
                   +d.viaEmail.checked+';'
                   +d.homeUseReq.checked+';'
                   +d.businessUseReq.checked+';'
                   +d.trainingManualReq.checked+';'
                   +d.charterReq.checked+';'
                   +d.caseHistoriesReq.checked+';'
                   +d.howToSetupReq.checked+';'
                   +d.roadSignageReq.checked+';'
                   
                   +d.CDRP.checked+';'
                   +d.Security.checked+';'
                   +d.Individual.checked+';'
                   +d.IamBusiness.checked+';'
                   +d.Council.checked+';'
                   +d.Police.checked+';'
                   +d.Developer.checked+';'
                   +d.HousingAssoc.checked+';'
                   +d.NbhWatch.checked+';'
                   +d.Charity.checked+';'
                   +d.BusWatch.checked+';'
                   +d.Media.checked+';'
                   +d.Comments.value+';'
                   +d.AuthorityName.value+';'
                   +d.NoOfUsers.value+';'
                   +d.Problems.value+';'
  document.cookie=escape(formData);
//alert(formData);
}

function getnext(theBktitems) {
  start=theBktitems.indexOf(';',end);
  end=theBktitems.indexOf(';',start+1);
  if (end==-1) {
    end=theBktitems.length;
  }
}

function readcookie(theForm) {
  var formData=unescape(document.cookie);
  if (theForm=='info') {
    var d=document.requestdata;
  }
  if (theForm=='grant') {
    var d=document.grantdata;
  }
  if (formData.indexOf('theData=')!=-1) {
//alert(formData);
    start=formData.indexOf('theData=');
    end=start;
    getnext(formData);
    d.Name.value=formData.substring(start+1,end);
    getnext(formData);
    d.Business.value=formData.substring(start+1,end);
    getnext(formData);
    d.Address1.value=formData.substring(start+1,end);
    getnext(formData);
    d.Address2.value=formData.substring(start+1,end);
    getnext(formData);
    d.Address3.value=formData.substring(start+1,end);
    getnext(formData);
    d.Address4.value=formData.substring(start+1,end);
    getnext(formData);
    d.Country.selectedIndex=formData.substring(start+1,end);
    getnext(formData);
    d.PostCode.value=formData.substring(start+1,end);
    getnext(formData);
    d.Email.value=formData.substring(start+1,end);
    getnext(formData);
    
    d.PhoneArea.value=formData.substring(start+1,end);
    getnext(formData);
    d.PhoneNum.value=formData.substring(start+1,end);
    getnext(formData);
    d.Other.value=formData.substring(start+1,end);
    getnext(formData);
    
    if (formData.substring(start+1,end)=='true') {d.viaPost.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.viaEmail.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.homeUseReq.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.businessUseReq.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.trainingManualReq.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.charterReq.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.caseHistoriesReq.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.howToSetupReq.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.roadSignageReq.checked=true;}
    getnext(formData);
    
    
    if (formData.substring(start+1,end)=='true') {d.CDRP.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.Security.checked=true;}
    getnext(formData);    
    if (formData.substring(start+1,end)=='true') {d.Individual.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.IamBusiness.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.Council.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.Police.checked=true;}
    getnext(formData);
    
    if (formData.substring(start+1,end)=='true') {d.Developer.checked=true;}
    getnext(formData);
    if (formData.substring(start+1,end)=='true') {d.HousingAssoc.checked=true;}
    getnext(formData);
    
    if (formData.substring(start+1,end)=='true') {d.NbhWatch.checked=true;}
    getnext(formData);
    
    if (formData.substring(start+1,end)=='true') {d.Charity.checked=true;}
    getnext(formData);
    
    if (formData.substring(start+1,end)=='true') {d.BusWatch.checked=true;}
    getnext(formData);
    
    if (formData.substring(start+1,end)=='true') {d.Media.checked=true;}
    getnext(formData);
    
    d.Comments.value=formData.substring(start+1,end);
    getnext(formData);
    
    d.AuthorityName.value=formData.substring(start+1,end);
    getnext(formData);
    
    d.NoOfUsers.value=formData.substring(start+1,end);
    getnext(formData);
    
    d.Problems.value=formData.substring(start+1,end);
    getnext(formData);
  }
}

function checkForm() {
  var d=document.requestdata;
  var isOK=true;
  var errorStr="";
  var emailErrorStr="";
  var postErrorStr="";
    
    if ((!d.viaPost.checked) && (!d.viaEmail.checked)) {
      errorStr="Please specify how you would like the information sent.\n\n";
    }
    
    if ((!d.homeUseReq.checked) && (!d.businessUseReq.checked)) {
      errorStr=errorStr + "Please specify whether you need details on AlertBox for home or business use, or both.\n\n";
    }
    
    if ((!d.Individual.checked) && 
        (!d.IamBusiness.checked) &&
        (!d.CDRP.checked) &&
        (!d.Security.checked) &&
        (!d.Council.checked) &&
        (!d.Police.checked) &&
        (!d.Developer.checked) &&
        (!d.HousingAssoc.checked) &&
        (!d.NbhWatch.checked) &&
        (!d.Charity.checked) &&
        (!d.BusWatch.checked) &&
        (!d.Media.checked) &&
        (d.Other.value=='')) {
      errorStr=errorStr + "Please specify which category of AlertBox user you are in the 'I am' section.\n\n";
    }
  
// ----------Via Email only------------
    
    if ((d.viaEmail.checked) && (!d.viaPost.checked)) {
      var commaDelimiter="";
      if (d.Name.value=='') {
        emailErrorStr="name";
        commaDelimiter=", "; 
      }
      if (d.Email.value=='') {
        emailErrorStr=emailErrorStr + commaDelimiter + "email"; 
      }
      if ((d.PhoneArea.value=='') && (d.PhoneNum.value=='')) {
        emailErrorStr=emailErrorStr + commaDelimiter + "phone number"; 
      }
      
      if (emailErrorStr != '') {
        errorStr=errorStr + "Please specify " + emailErrorStr + ".\n\n";
      }
      
    }
    
// ------------------------------------



// ----------Via Post------------------
    
    if (d.viaPost.checked) {
      var commaDelimiter="";
      if (d.Name.value=='') {
        postErrorStr="name";
        commaDelimiter=", "; 
      }
      if (d.Address1.value=='') {
        postErrorStr=postErrorStr + commaDelimiter + "address"; 
        commaDelimiter=", ";
      }
      if (d.PostCode.value=='') {
        postErrorStr=postErrorStr + commaDelimiter + "post (zip) code"; 
        commaDelimiter=", ";
      }
      if (d.viaEmail.checked) {
        if (d.Email.value=='') { 
          postErrorStr=postErrorStr + commaDelimiter + "email"; 
          commaDelimiter=", ";
        }
      }
      
      if (postErrorStr != '') {
        errorStr=errorStr + "Please specify " + postErrorStr + ".\n\n";
      }
    }

// ------------------------------------
    
    if (errorStr != "") {
      alert(errorStr);
      isOK=false;
    }
  return isOK;
}

function checkGrantsForm() {
  var d=document.grantdata;
  var commaDelimiter="";
  var isOK=true;
  var errorStr="";
  if (d.Name.value=='') {
    errorStr="name";
    commaDelimiter=", "; 
  }
  if (d.Email.value=='') { 
    errorStr=errorStr + commaDelimiter + "email"; 
    commaDelimiter=", ";
  }
  if (errorStr != '') {
    errorStr="Please specify " + errorStr + ".\n\n";
    alert(errorStr);
    isOK=false;
  }
  return isOK;
}

function bookmark(url, description) {
  netscape="Netscape User's hit CTRL+D to add a bookmark to this site."
  if (navigator.appName=='Microsoft Internet Explorer') {
    window.external.AddFavorite(url, description);
  }
  else if (navigator.appName=='Netscape') {
    alert(netscape);
  }
}

function doCharCount() {
  var theStr=document.requestdata.Comments.value
  if (theStr.length>250) {
    document.requestdata.Comments.value=theStr.substring(0,250);
  }
}

function doCharGrantCount() {
  var theStr=document.grantdata.Problems.value
  if (theStr.length>250) {
    document.grantdata.Problems.value=theStr.substring(0,250);
  }
}

function emailFriend() {
   var to = "";  
   var cc = "";  
   var bcc = "";  
   var subject = "Have you seen the AlertBox website";  
   var body = "Thought you might like to see this website. Essentially, AlertBox is an electronic form of neighbourhood watch - for businesses and homes. Their website address is: http://www.alertbox.co.uk";
   var doc = "mailto:" + to + "?subject=" + escape(subject) + "&body=" + escape(body);
   window.location = doc;
}



//-------------

var intervalTimer; // variable to reference the timeout interval setting
var currentImage=-1; // current image to be displayed
var imageList= new Array();

var tinterval=7000; // default time in millseconds for image update

function loadSlideImages() {
image01 = new Image; image01.src="graphics/womanAtWindow-540w3.jpg";
image02 = new Image; image02.src="graphics/slide02.jpg";
image03 = new Image; image03.src="graphics/slide03.jpg";
image04 = new Image; image04.src="graphics/slide04.jpg";
}

function playSlide() {
  if (currentImage < 3)
  {
    currentImage = currentImage + 1;
  }
  else {
    currentImage = 0;
  }
  if (currentImage==0)
    document.slide.src=image01.src;
  if (currentImage==1)
    document.slide.src=image02.src;
  if (currentImage==2)
    document.slide.src=image04.src;
  if (currentImage==3)
    document.slide.src=image03.src;
  intervalTimer = setTimeout("playSlide()",tinterval);
//  alert(currentImage);
}

function checkJoin() {
var f=document.joinform;
  theErrorMessage='';
  commaStr='';
  errorCount=0;
  if (f.FirstName.value=='') {
    theErrorMessage=theErrorMessage+commaStr+'First name';
    commaStr=',';
    errorCount++;
  }
  if (f.LastName.value=='') {
    theErrorMessage=theErrorMessage+commaStr+'Last name';
    commaStr=',';
    errorCount++;
  }
  if (f.TelArea.value=='') {
    theErrorMessage=theErrorMessage+commaStr+'Phone area code';
    commaStr=',';
    errorCount++;
  }
  if (f.Tel.value=='') {
    theErrorMessage=theErrorMessage+commaStr+'Phone number';
    commaStr=',';
    errorCount++;
  }
  if (f.Type.value=='Business') {
    if (f.TradingName.value=='') {
      theErrorMessage=theErrorMessage+commaStr+'Trading name';
      commaStr=',';
      errorCount++;
    }
    if (f.CompanyName.value=='') {
      theErrorMessage=theErrorMessage+commaStr+'Company name';
      commaStr=',';
      errorCount++;
    }
  }
  if (f.PropertyName.value=='') {
    theErrorMessage=theErrorMessage+commaStr+'Property name';
    commaStr=',';
    errorCount++;
  }
  if (f.Street.value=='') {
    theErrorMessage=theErrorMessage+commaStr+'Street';
    commaStr=',';
    errorCount++;
  }
  if (f.City.value=='') {
    theErrorMessage=theErrorMessage+commaStr+'City';
    commaStr=',';
    errorCount++;
  }
  if (f.PostCode.value=='') {
    theErrorMessage=theErrorMessage+commaStr+'PostCode';
    commaStr=',';
    errorCount++;
  }
  
  if (theErrorMessage!='') {
    if (errorCount==1) {
      alert(theErrorMessage+' is a required field');
    }
    if (errorCount>1) {
      alert(theErrorMessage+' are required fields');
    }
    return false;
  }
  else {
    return true;
  }
}

/*
function doSelectForm() {
  var f=document.selectform; 
  if ((!f.Type[0].checked)&&(!f.Type[1].checked)) {
    alert('Please select whether you are a Household or a Business\nby clicking the corresponding radiobutton');
  } 
  else {
    if (f.AreaName.value=='') {
      alert('Please enter the name of your area or community.');
    }
    else {
      f.submit();
    }
  }
}

function doSelectJump() {
  var f=document.selectform; 
  if (f.Type[0].checked) {
    document.location('registerneighbourhood.php?area='+f.AreaName.value);
  }
  if (f.Type[1].checked) {
    document.location('registerbusiness.php?area='+f.AreaName.value);
  }
}

*/

function checkSelect() {
var f=document.selectform;
  if ((!f.Type[0].checked)  && (!f.Type[1].checked)) {
    alert('Please select whether you are a Household or a Business\nby clicking the corresponding radiobutton');
    return false;
  }
  else {
    if (f.AreaName.value=='') {
      alert('Please enter the name of your area or community.');
      return false;
    }
    else {
      return true;
    }
  }
}

function checkOrder() {
var f=document.orderform;
  var nB = parseInt(f.bQuantity.value);
  var nN = parseInt(f.nQuantity.value);
  if (isNaN(nB)) {
    nB = 0;
    f.bQuantity.value = 0;
  }
  if (isNaN(nN)) {
    nN = 0;
    f.nQuantity.value = 0;
  }
  if ((nB == 0) && (nN == 0)) {
    alert('Please specify quantities of each type of communicator required');
    return false;
  }
  else {
    return true;
  }
}


//-->
