function alertXML(pioXML) {
  var string = (new XMLSerializer()).serializeToString(pioXML);
  alert(string);
  
}
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function getSelectedValue(pioSelect) {
  return pioSelect.options[pioSelect.selectedIndex].value
}
 function num2Day(piiDay){
  var aDays = ["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"]
  return aDays[piiDay]
}

function num2Month(piiMonth){
  var aDays = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  return aDays[piiMonth]
}
function getSpan(pioDoc, picSpan) {
  oSpan = pioDoc.getElementById(picSpan)
  
  if (oSpan)
   return  oSpan.innerHTML
  else
    return ""
}
function getAttrById(picSpan, picAttr) {
  cValue = ""
  oSpan = document.getElementById(picSpan)
  if (oSpan) {
  	if (oSpan.getAttribute(picAttr) != null)
    	cValue=oSpan.getAttribute(picAttr);
  }
  return cValue
}
function setAttrById(picSpan, picAttr, picValue) {
  //alert(picSpan)
  var oSpan = document.getElementById(picSpan)
  //if (picAttr == "class")
  //  alert(picSpan + " " + picValue)
  if (oSpan) {

   	oSpan.setAttribute(picAttr, picValue)
    //if (picAttr == "class")
    // 	alert(oSpan.getAttribute("class"))
  }
  else
    alert("cant find " + picSpan + " not setting " +picAttr + " to " + picValue)
}
function setSpan(picSpan, picString) {
  var oSpan = document.getElementById(picSpan)
  //alert(picSpan)
  if (oSpan) {
    oSpan.innerHTML = picString 
    //alert(picString)
  }
  //else
    //alert("no span " + picSpan)

}
function spanVisible(pioDoc, picString, pilShow) {
  var oSpan = pioDoc.getElementById(picString)
  if (pilShow) {
	$("#" + picString).show();
  } else {	
	$("#" + picString).hide();
    //oSpan.style.visibility = pilShow?"visible":"hidden"
  }
  //else
    //alert("no span " + picString)
    

}
function isDecimal(number){// positive or negative decimal
  if(!number) return false;
  decimalRegExp = /^-?(0|[1-9]{1}\d{0,})(\.(\d{1}\d{0,}))?$/
  return decimalRegExp.test(number);
}
function isInteger(n){
  var num = Number(n);
  if(isNaN(num)){
    return false;
  }
  return true
}

var hDDWin 

 // pop up a window to show all properties and methods of an object, used for debugging
  function showProp(obj,cName) {

    hDDWin = window.open('','','width=650,height=450,scrollbars=yes,resizable=yes')
    if (!hDDWin) return
    if (!cName || cName == "") {
      if (obj.id) cName = obj.id
      else if (obj.name) cName = obj.name
    }
    hDDWin.document.open()
    hDDWin.document.writeln('<html><head>')
    hDDWin.document.writeln('</head><body><u>Start Object Properties - ' + cName + '</u></br></br>')
    for (var i in obj) {
    	try {
        hDDWin.document.write(i + ' = ')
        hDDWin.document.write(obj[i])
        hDDWin.document.writeln('</br>')
      }
      catch(er) {
      	hDDWin.document.writeln(' =* ' + er.description + '</br>')
      }
    }
    hDDWin.document.writeln('</br>End Object Properties')
    hDDWin.document.writeln('</body></html>')
    hDDWin.document.close()
  }

  // pop up a window to show all attributes of an object
  function showAttrs(obj) {
    hDDWin = window.open('','propwin','width=300,height=300,scrollbars=yes,resizable=yes')
    if (!hDDWin) return
    hDDWin.document.open()
    hDDWin.document.writeln('<html><body>START</br>')
    atrs = obj.attributes
    for (ia = 0; ia < atrs.length; ia++) {
      hDDWin.document.writeln(atrs[ia].name + ' = ' + atrs[ia].value + '</br>')
    }
    hDDWin.document.writeln('</br>DONE')
    hDDWin.document.writeln('</body></html>')
    hDDWin.document.close()
  }
