onerror=handleErr;function handleErr(msg,url,l) {    //Handle the error here:
    //If return false, the browser displays the standard error message in the JavaScript console.
    //If return true, the browser does not display the standard error message.    return false;}


function addFormEvent(func) {
  if (!document.getElementById | !document.getElementsByTagName) return
  var oldonload=window.onload
  if (typeof window.onload != 'function') { window.onload=func }
  else {
    window.onload=function() { oldonload(); func() }
  }
}



// --------------------- borders for text type inputs ------------------------------ //
function attachBorderAndSelect(id){
  var obj0 = document.getElementById(id)
  obj0.onfocus= function() {this.style.border="2px solid #3366FF"; this.select();}
  obj0.onblur = function() {
                  this.style.border="2px inset #ccc"
                  if (this.value=="") {this.value=this.defaultValue}
                  this.value=this.value
                }
}
// ----------------------------------------------------------------------------- //



// -------------------------- borders for radio and checkboxes ------------------------- //
function attachBorderToRadio(id){
  var obj0 = document.getElementById(id)
  obj0.onfocus= function() {this.style.border="2px solid #3366FF"}
  obj0.onblur = function() {this.style.border="2px solid #fff7dd"}
}
// ----------------------------------------------------------------------------- //



// ------------------------------ border for submit buttons --------------------------- //
function attachBorderToButton(id){
  var obj0 = document.getElementById(id)
  obj0.onfocus= function() {this.style.border="2px solid #3366FF"}
  obj0.onblur = function() {this.style.border="2px outset #fff"}
}
// ----------------------------------------------------------------------------- //



// ------------------------------ Change Border Style Function --------------------------- //
function changeBorder(id,style){
	if (!id && style) return;
    document.getElementById(id).style.border=style;
}
// ----------------------------------------------------------------------------- //



// ------------------------------ Change BackGround Color Function --------------------------- //
function changeBackGround(id,col){
	if (!id && col) return;
    document.getElementById(id).style.background=col;
}
// ----------------------------------------------------------------------------- //



// example contact form
function initContact(){

  if (!document.getElementsByTagName) return  

// text type inputs
 attachBorderAndSelect('username');
 attachBorderAndSelect('surname');
 attachBorderAndSelect('address');
 attachBorderAndSelect('city');
 attachBorderAndSelect('state');
 attachBorderAndSelect('zip');
 attachBorderAndSelect('adults');
 attachBorderAndSelect('children');
 attachBorderAndSelect('infants');
 attachBorderAndSelect('telephone');
 attachBorderAndSelect('fax');
 attachBorderAndSelect('email');
 
// textfield
 attachBorderAndSelect('notes');

// radio buttons defined individually
// though it does not appear to work except in IE
// attachBorderToRadio('rad2_1');
// attachBorderToRadio('rad2_2');

// checkbox
// this does not appear to work except in IE
// attachBorderToRadio('privacy_check');

// submit
 attachBorderToButton('button');

}


// Other "onload" events may be added in the same format as this //
addFormEvent(initContact)
