if 	(document.getElementById)	var DOMS = 3	// Supports Web Standard (getElementById)
else if	(document.all)		 	var DOMS = 2	// Supports MS document.all
else if	(document.layers)	 	var DOMS = 1	// Supports NS layers
else				 	var DOMS = 0;	// No DOM gateway support

function getObj(oid) {
  switch(DOMS) {					// Check for various browsers
    case 1: return(document[oid]);			// Supports Layers (NS4)
    case 2: return(document.all[oid]);			// Supports document.all (ie4)
    case 3: return( ((document.getElementById(oid))?document.getElementById(oid):'') );	// Supports getElementById
  }
}

// Position DOM object:  obj = DOM object handle;  x = left coord;  y = top coord.
function setPos(obj,x,y) {
  switch(DOMS) {
    case 1:  obj.moveTo(x,y);			    break;	// NS 4
    default: obj.style.left = x; obj.style.top = y; break;	// IE4+,NS6+
  }
}

// Return true if node a contains node b.
function contains(a, b) { if (b==null) return;
  while (b.parentNode) {
	b = b.parentNode;
	if (b.id == a) return true;
  }
  return false;
}

function setVis(event,nid,oid,s) {
  if ( (!s) && (contains(nid,((window.event)?window.event.toElement:event.relatedTarget))) ) return;
  document.getElementById(oid).style.visibility = ((s)?'visible':'hidden');
}

function molnk(s,oid,c) {
  obj = document.getElementById(oid);
  switch(c) {
    case '1': {
      switch(s) {
        case 1:  obj.style.borderColor = '#000 #000 #000 #000'; break;
        case 2:  obj.style.borderColor = '#000 #000 #000 #000'; break;
        default: obj.style.borderColor = '#000 #000 #000 #000'; break;
      }
      break;
    }      

    default: {
      switch(s) {
        case 1:  obj.style.borderColor = '#000 #000 #000 #000'; break;
        case 2:  obj.style.borderColor = '#000 #000 #000 #000'; break;
        default: obj.style.borderColor = '#000 #000 #000 #000'; break;
      }
      break;
    }      
  }
}

// Set DOM object text clor:  obj = DOM object handle;  s = color
function setColor(obj,s) {
  switch(DOMS) {
    case 1:  obj.color       = s; break;		// layers
    default: obj.style.color = s; break;		// IE4+ and NS6+
  }
}

// Set DOM object text clor:  obj = DOM object handle;  s = color
function swZ(obj1,obj2) {
  switch(DOMS) {
    case 1:  { obj1.zindex       = 6; obj2.zindex       = 5; break; }	// layers
    default: { obj1.style.zindex = 6; obj2.style.zindex = 5; break; }	// IE4+ and NS6+
  }
}

function imgRot(s,pt) {
  document.images[s].src = ROT1[pt].src;
  ++pt;  if ( !s[pt] ) { pt = 1 };
  setTimeout('imgRot("' + s + '",' + pt+ ')',3000);
}

// Set DOM object visibility:  obj = DOM object handle;  s = visibility option
function setBor(obj,bs,bc) {
  switch(DOMS) {
    case 0:  break;									// no DOM, do nothing
    case 1:  break;									// layers, do nothing
    default: obj.style.borderColor = bc;	obj.style.borderStyle = bs;	break;	// IE4+ and NS6+
  }
}

var winHome = '';
function showHome(s) { 
  if (winHome!="") winHome.close();
  winHome = window.open(s,'HOMEVIEW','height=389,width=514');
}

// Reset input field color when changed
function fldReset() { this.style.backgroundColor=''; this.style.borderColor='#bbbbbb'; }

// display error message, color error field, set 
function setErm(f,m) {
  alert(m);
  f.onchange = fldReset;
  f.style.backgroundColor="#ff9";
  f.style.borderColor="#f00"; 
  f.focus();
  return false;
}

// Check mailto form field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkContact(s) {
   if (s.firstname.value=='')		return setErm(s['firstname'],		'You must enter your first name to continue.')
// if (s.lastname.value=='')		return setErm(s['lastname'],		'You must enter your last name to continue.')
// if (s.street.value=='')		return setErm(s['street'],		'You must enter your street address to continue.')
// if (s.city.value=='')		return setErm(s['city'],		'You must enter your city to continue.')
// if (s.state.value=='')		return setErm(s['state'],		'You must enter your state to continue.')
// if (s.zipcode.value=='')		return setErm(s['zipcode'],		'You must enter your zipcode to continue.')
// if (s.dayphone.value=='')		return setErm(s['dayphone'],		'You must enter your day time phone number to continue.')
   if (s.email.value=='')		return setErm(s['email'],		'You must enter your email address to continue.')
   if ((s.email.value.indexOf('@')==-1) || (s.email.value.indexOf('.')==-1))
   				return setErm(s['email'],	'Your E-mail address appears to be invalid. Please check!');
   return true;
}

function distCheck(s) {
  var sz = s['MM_EMAILTO[]'].length;
  if (sz==undefined) {
    if (s['MM_EMAILTO[]'].checked==true) {
      open_Broadcast();
      return true;
    }
  }
  else for (var i=0; i<sz; i++) if (s['MM_EMAILTO[]'][i].checked==true) { open_Broadcast(); return true; }
  alert("You must select at least 1 email recipent to continue.");
  return false;
}

function verifyDelete(s) { return(confirm("Are you sure you want to delete " + s + "?")); }

function open_Broadcast() {
  window.open('','broadcast','height=500,width=500,scrollbars');
  return false;
}

function adminContact(contactid) {
  window.open('admin_contact.php?contactid='+contactid,'contact','height=580,width=780,scrollbars');
  return false;
}

function adminElevation(eid) {
  window.open('admin_elevation.php?eid='+eid,'elevation','height=520,width=580,scrollbars');
  return false;
}

function adminModel(mid) {
  window.open('admin_model.php?mid='+mid,'model','height=520,width=600,scrollbars,resizable');
  return false;
}

function adminHome(hid) {
  window.open('admin_home.php?hid='+hid,'home','height=520,width=600,scrollbars,resizable');
  return false;
}


function adminLot(lotid) {
  window.open('admin_lot.php?lotid='+lotid,'lot','height=530,width=600,scrollbars,resizable');
  return false;
}

function adminFloorplan(mid,fpid) {
  window.open('admin_floorplan.php?mid='+mid+'&fpid='+fpid,'home','height=350,width=560,scrollbars,resizable');
  return false;
}

function adminRoof(rfid) {
  window.open('admin_roof.php?rfid='+rfid,'roof','height=220,width=580,scrollbars,resizable');
  return false;
}

function bigmap(ifn) {
  window.open('bigmap.php?ifn='+ifn,'bigmap','height=530,width=640,scrollbars');
  return false;
}
function editLink(lcatid,lid)	{ window.open('admin_edit_link.php?lcatid='+lcatid+'&lid='+lid,'link','height=550,width=500,scrollbars,resizable'); return false; }
function editLinkCat(lcatid)	{ window.open('admin_edit_lcat.php?lcatid='+lcatid,'lcat','height=500,width=500,scrollbars,resizable'); return false; }
function editLinkmode()	{ window.open('admin_edit_linkmode.php','lmode','height=200,width=300,scrollbars,resizable'); return false; }
