function toggleDiv(divid, divImgid){
  if(document.getElementById(divid).style.display == 'none'){
    document.getElementById(divid).style.display = 'block';
	if (divImgid != '')
	{
		document.getElementById(divImgid).innerHTML = '<img src="images/backtitle-down.gif" border="0">';
	}
  }else{
    document.getElementById(divid).style.display = 'none';
	if (divImgid != '')
	{
		document.getElementById(divImgid).innerHTML = '<img src="images/backtitle-up.gif" border="0">';
	}
  }
}
function deleteItem(sURL, pMSG) {
	if (sURL.indexOf("?") == -1) sURL += "?";
	if (confirm(pMSG)) document.location=sURL + '&rand_num=' + Math.round(1000000000 * Math.random()).toString();
}
function changeCol(o, col) {
	o.style.backgroundColor = col;
}
function isNumeric(num) {
	var st="0123456789";
	for (i=0; i<num.length; i++) {
		if (0 > st.indexOf(num.charAt(i))) return false;
	}
	return true;
}
function isReal(num) {
	st="0123456789.";
	if (num.length == 0) return false
	for (i=0; i<num.length; i++) {
		if (0 > st.indexOf(num.charAt(i))) return false;
	}
	if ((num.indexOf(".") >= 0)&&(num.indexOf(".", num.indexOf(".")+1) !=-1 )) return false;
	if ((num.indexOf(".")+1 == num.length)&&(num.indexOf(".")>=0)) return false
	return true;
}
function isEmail(x) {
	var filter  = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([a-zA-Z]{2,3})|(aero|coop|info|museum|name|mobi))$/;
	if (filter.test(x.toLowerCase())) return true;
	return false;
}
function showHide(sID) {
	d = document.getElementById(sID);
	if (d.style.display == "") d.style.display = "none";
	else d.style.display = "";	
}
function isDate(st, format) {
	var a = new Array()
	if (format == "mm/dd/yyyy") {
		a = st.split("/");
		if (a.length == 3) return isValidDate(a[2], a[0], a[1])
	}
	if (format == "yyyy-mm-dd") {
		a = st.split("-");
		if (a.length == 3) return isValidDate(a[2], a[1], a[0])
	}
	return false
}
function isValidDate(y, m, d) {
	if (!isNumeric(y)||y=="") return false
	if (!isNumeric(m)||m=="") return false
	if (!isNumeric(d)||d=="") return false
	if (m<1||m>12) return false;
	var maxDay = 31;
	if (m == 4 || m == 6 || m == 9 || m == 11) maxDay = 30; else if (m == 2) if (y % 4 > 0) maxDay =28; else if (y % 100 == 0 && y % 400 > 0) maxDay = 28; else maxDay = 29;
	return (d<=maxDay)&&(d>=1)
}
