//
var DFMT = ''; var ACTMN = '';

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 analOut(s) {
  var WANAL = window.open('','ANALYZE','height=400,width=400')
  WANAL.focus();
  WANAL.document.open();
  WANAL.document.write('<pre>' + s + '</pre>');
  WANAL.document.close();
  this.focus;
}

// Return DOM Handle for specified DOM object ID
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
  }
}

// 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;
}

// Set DOM object visibility:  obj = DOM object handle;  s = visibility option
function setVis(obj,s) {
  switch(DOMS) {
    case 1:  obj.visibility       = s; break;		// layers
    default: obj.style.visibility = s; break;		// IE4+ and NS6+
  }
}

// Set DOM object visibility:  obj = DOM object handle;  s = visibility option
function setBor(obj,bs,bc) {
  switch(DOMS) {
//    case 0:  break;									// no DOM
//    case 1:  obj.borderColor = bc;		obj.borderStyle = bs;		break;	// layers
    default: obj.style.borderColor = bc;	obj.style.borderStyle = bs;	break;	// IE4+ and NS6+
  }
}

function molnk(s,oid) {
  obj = getObj(oid);
  switch(s) {
    case 1:  setBor(obj,'outset','#00f'); break;
    case 2:  setBor(obj,'inset', '#00f'); break;
    default: setBor(obj,'solid', '#fff'); break;
  }
}

// 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 field(s) for required input, When a field is found with missing input,
// alert user, set field pink, and set focus to it.
function chkRqrd(s) {
  if (arguments.length<2) return true
  for ( var i = 1; i < arguments.length; i++ ) {
    fptr = s[arguments[i]];								// Get form field pointer
    if ( fptr.value=='' ) return setErm(fptr,'You must enter your name to continue.')	// Check field for content
  }
  return true;
}

// 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 chkReg(s) {
   if (s.Name.value=='')		return setErm(s['Name'],		'You must enter your name to continue.')
   if (s.Street1.value=='')		return setErm(s['Street1'],		'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 zip code to continue.')
   if (s.Telephone.value=='')		return setErm(s['Telephone'],		'You must enter your phone number to continue.')
   if (s.Email.value=='')		return setErm(s['Email'],		'You must enter your email address to continue.')
   return true;
}

// 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 chkEditorial(s) {
   if (s.Name.value=='')		return setErm(s['Name'],		'You must enter your name to continue.')
   if (s['MM_EMAILTO[]'][1].value=='')	return setErm(s['MM_EMAILTO[]'][1],	'You must enter your email address to continue.')
   s.Email.value = s['MM_EMAILTO[]'][1].value;
   return false;
}

function chkContact(s) {
   if (s.contact.value=='')		return setErm(s['contact'],	'You must enter your name to continue.')
   if (s.phone.value=='')		return setErm(s['phone'],	'You must enter your phone number to continue.')
   if (s.email.value=='')		return setErm(s['email'],	'You must enter your email address to continue.')
   return true;
}

function chkMerge(s) {
  if (s.destbusid.value=='')   return setErm(s['destbusid'],	'You must specify the destination business id before you can complete the record merge.')
  return true;
}

function weather() { document.location = "http://www.weather.com/outlook/recreation/local/" + document.WEAT.zip[document.WEAT.zip.selectedIndex].value }

function postClass() {
  window.open('classified-post.php','classified','height=300,width=450,scrollbars');
  return false;
}

function chkClassified(s) {
  if (s['clcatid'].selectedIndex=="0")	return setErm(s['clcatid'],		'You must select an ad category to continue.')
  if (s.cladtitle.value=='')		return setErm(s['cladtitle'],		'You must enter an ad title to continue.')
  if (s.cladphone.value=='')		return setErm(s['cladphone'],		'You must enter your contact phone number to continue.')
  if (s.cladtext.value=='')		return setErm(s['cladtext'],		'You must enter some ad text to continue.')
}
