preload();

//*****************************************************
//* Preload site images
//*****************************************************
function preload() {
  topi = new Image();
  topi.src = 'images/top.jpg';

  bott = new Image();
  bott.src = 'images/bott.jpg';

  lefti = new Image();
  lefti.src = 'images/left.jpg';

  righti = new Image();
  righti.src = 'images/right.jpg';

  aboutOff = new Image();
  aboutOff.src = 'images/aboutoff.jpg';
  aboutOn = new Image();
  aboutOn.src = 'images/abouton.jpg';

  homeOff = new Image();
  homeOff.src = 'images/homeoff.jpg';
  homeOn = new Image();
  homeOn.src = 'images/homeon.jpg';

  rangeOff = new Image();
  rangeOff.src = 'images/rangeoff.jpg';
  rangeOn = new Image();
  rangeOn.src = 'images/rangeon.jpg';

  contactOn = new Image();
  contactOn.src = 'images/contacton.jpg';
  contactOff = new Image();
  contactOff.src = 'images/contactoff.jpg';

}

//*****************************************************
//* Trap Javascript Errors.
//*****************************************************
function stopError() {
  return true;
}

window.onerror = stopError;

//*****************************************************
// Popup fullsize image of thumbnail
//*****************************************************

function showFull(pic) {
    
    settings=
    "toolbar=no,location=no,directories=no,"+
    "status=no,menubar=no,scrollbars=no,"+
    "resizable=yes,width=470,height=375,left=100,top=100";  

    NewWindow=window.open('','',settings);
    NewWindow.document.open();
    NewWindow.document.write('<html><head></head><body color="#000000" bgcolor="#2064AA">');
    NewWindow.document.write('<div>');
    NewWindow.document.write('<img src="'+pic+'" alt="Click the picture to close the window" border="0" onclick="self.close()";>');
    NewWindow.document.write('</div>');
    NewWindow.document.write('<div align="center"><br>');
    NewWindow.document.write('<font face="arial" color="#000000">');
    NewWindow.document.write('Click the photo to close the window');
    NewWindow.document.write('</font></div>');
    NewWindow.document.write('</body></html>');
    NewWindow.document.close();
}
function showFull2(pic) {
    
    settings=
    "toolbar=no,location=no,directories=no,"+
    "status=no,menubar=no,scrollbars=no,"+
    "resizable=yes,width=600,height=520,left=100,top=100";  

    NewWindow=window.open('','',settings);
    NewWindow.document.open();
    NewWindow.document.write('<html><head></head><body color="#000000" bgcolor="#ffffff">');
    NewWindow.document.write('<div align = "center">');
    NewWindow.document.write('<img src="'+pic+'" alt="Click the picture to close the window" border="0" onclick="self.close()";>');
    NewWindow.document.write('</div>');
    NewWindow.document.write('<div align="center"><br>');
    NewWindow.document.write('<font face="arial" color="#000000">');
    NewWindow.document.write('Click the photo to close the window');
    NewWindow.document.write('</font></div>');
    NewWindow.document.write('</body></html>');
    NewWindow.document.close();
}
function showFull3(pic) {
    
    settings=
    "toolbar=no,location=no,directories=no,"+
    "status=no,menubar=no,scrollbars=no,"+
    "resizable=yes,width=520,height=580,left=100,top=100";  

    NewWindow=window.open('','',settings);
    NewWindow.document.open();
    NewWindow.document.write('<html><head></head><body color="#000000" bgcolor="#ffffff">');
    NewWindow.document.write('<div align = "center">');
    NewWindow.document.write('<img src="'+pic+'" alt="Click the picture to close the window" border="0" onclick="self.close()";>');
    NewWindow.document.write('</div>');
    NewWindow.document.write('<div align="center"><br>');
    NewWindow.document.write('<font face="arial" color="#000000">');
    NewWindow.document.write('Click the photo to close the window');
    NewWindow.document.write('</font></div>');
    NewWindow.document.write('</body></html>');
    NewWindow.document.close();
}
function showFull4(pic) {
    
    settings=
    "toolbar=no,location=no,directories=no,"+
    "status=no,menubar=no,scrollbars=no,"+
    "resizable=yes,width=550,height=580,left=100,top=100";  

    NewWindow=window.open('','',settings);
    NewWindow.document.open();
    NewWindow.document.write('<html><head></head><body color="#000000" bgcolor="#ffffff">');
    NewWindow.document.write('<div align = "center">');
    NewWindow.document.write('<img src="'+pic+'" alt="Click the picture to close the window" border="0" onclick="self.close()";>');
    NewWindow.document.write('</div>');
    NewWindow.document.write('<div align="center"><br>');
    NewWindow.document.write('<font face="arial" color="#000000">');
    NewWindow.document.write('Click the photo to close the window');
    NewWindow.document.write('</font></div>');
    NewWindow.document.write('</body></html>');
    NewWindow.document.close();
}

//*****************************************************
// Popup window function
//*****************************************************

function popup(url, name, width, height, scrl, left, top) {
    
    settings=
    "toolbar=no,location=no,directories=no,"+
    "status=no,menubar=no,scrollbars="+scrl+","+
    "resizable=yes,width="+width+",height="+height+",left="+left+",top="+top;   

    NewWindow=window.open(url,name,settings);
}



//*****************************************************
// Show window status message
//*****************************************************
function showStatus(text)
    {
    window.setTimeout("window.status='" + text + "'", 0);
    }

  

//*****************************************************
// Validate form function
//*****************************************************

function checkphone(string) {
    var Chars = "0123456789- ";
    for (var i = 0; i < string.length; i++) {
        if (Chars.indexOf(string.charAt(i)) == -1)
          return false;
        }
        return true;
}


function checkform(form) {
    var errlit ='The information you have entered is incorrect :-\n\n';         
    var errmsg ='';
        
                    
    if (form.name.value.length == 0) {
       errmsg += 'You must enter your name.\n';
       }                            
                       
           
    if ((form.phone.value.length == 0) &&
        (form.email.value.length == 0)) {
         errmsg += 'You must enter either your telephone number,email address, or both.\n';
        }
    else { 
        if ((form.phone.value.length != 0) && 
           (!checkphone(form.phone.value))) {
           errmsg += 'You must enter a numeric telephone number.\n';
       }    
            
        if ((form.email.value.length != 0) &&
        (form.email.value.indexOf("@") < 1)) {
       errmsg += 'You must enter a valid email address.';
       }                            
    }
        
        
    if (errmsg.length > 0) {
        errlit += errmsg;
            alert (errlit);
            return false;
        }
    else {
        return true;
        }
}
