

function isItDate(str) {
	var testDate = new Date(Date.parse(str));
	if( !testDate.getYear() ) {
		//alert("Not a date!");
		return false; 
	} else {
		return true;
	}
}

function daysInMonth(mo) {
	a = 0;
	switch (mo) {
		case 1: case 3: case 5: case 7: case 8: case 10: case 12:
			a = 31;
			break;
		case 4: case 6: case 9: case 11:
			a = 30;
			break;
		case 2:
			a = 28;
			break;
	}
	return a;
}

function dateFormat (datestr, mode) {
  var str = "";
  var hour, minute, seconds, milliseconds, weekday, day, month, yy, year, startTime;
  var months = new makeArray('January','February','March',
    'April','May','June','July','August','September',
    'October','November','December');
  var weekdays = new makeArray('Sunday','Monday','Tuesday',
    'Wednesday','Thursday','Friday','Saturday');  
  var adate = new Date(Date.parse(datestr));
  
  if (adate.getYear()) {
	  hour = adate.getHours();
	  minute = adate.getMinutes();
	  seconds = adate.getSeconds();
	  milliseconds = adate.getMilliseconds();
	  weekday  = adate.getDay() + 1;
	  day  = adate.getDate();
	  month = adate.getMonth() + 1;
	  yy = adate.getFullYear();
	  year = (yy < 1000) ? yy + 2000 : yy;	  
	  switch (mode) {
		case "short":      
			str = month + "/" + day + "/" + year;      
			break;
		case "euro":      
			str = day + "/" + month + "/" + year;      
			break;
		case "long":      
			str = months[month] + " " + day + ", " + year;
			//str = weekdays[weekday] + ", " + months[month] + " " + day + ", " + year;      
			break;
		case "full":      
			str = weekdays[weekday] + ", " + months[month] + " " + day + ", " + year  + " " + time;      
			break;
		default:      
			str = month + "/" + day + "/" + year;      
			break;
	  }
  }
  return str;
}

function makeArray() {
     for (i = 0; i<makeArray.arguments.length; i++)
          this[i + 1] = makeArray.arguments[i];
}

function checkNumValid (str, notzero) {
		// return True if either non-numeric or less than or equal to 0
		var isbad=0, oneval;

		oneval = trimNumStr(str);
		if (oneval.length < 1) {
			isbad = 1;
		} else {
			if (isNaN(oneval)) {
				isbad = 1;
			} else {
				if (notzero) {
					if (oneval <= 0)
						isbad = 1;
				} else {
					if (oneval < 0)
						isbad = 1;			
				}
			}		
		}

		return isbad;	
	}
	
	function trimNumStr (str) {
		var newstr;
		//str = "$13,456,222.00";
		// remove all commas and dollar signs from string
		re = /\%|\,|\$+/g;
		newstr = str.replace(re, "");
		//alert (newstr);
		return newstr;
	}	
	
	function setElementColor (obj, setcolor) {
		// set color parameter of given object
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.color = setcolor;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.color = setcolor;	
			}	
		}	
	}
	
	function setElementText (obj, str) {
		// update HTML of element requested
		//alert(obj = "obj = " + obj + ", str = " + str);
		if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).innerHTML = str;
		} else {
			if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).innerHTML = str;	
			}	
		}		
	}	

	function toggleVisibility (obj, force) {
		var stat, setstyl, obj;
		
		if (force >= 0) {
			//if force parameter passed, don't toggle mode, set it to mode passed in
			if (force == 1)
				setstyl = 'visible';
			else
				setstyl = 'hidden';
		} else {
			//toggle mode from whatever it is now, so need to check current status
			stat = null;
			if (document.getElementsByTagName && document.getElementById) {
				//Netscape 6+ model (also works in IE 6)
				if (document.getElementById(obj))
					stat = document.getElementById(obj).style.visibility;
			} else {
				if (document.all) {
					//IE model (at least, versions prior to 6)
					if (document.all(obj))
						stat = document.all(obj).style.visibility;	
				}	
			}		
			//set to opposite of current status
			setstyl = null;
			if (stat == 'visible')
				setstyl = 'hidden';
			else {
				if (stat == 'hidden')
					setstyl = 'visible';
			}		
		}
		
		// switch it to whatever mode decided above
	    if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.visibility = setstyl;
	    } else {
	    	if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.visibility = setstyl;	
			}	
		}
		
		return setstyl;					
	}
	
	function resetObjTop (obj, pix) {

	    if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.top = pix;
	    } else {
	    	if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.top = pix;	
			}	
		}	
	}
	
	function resetObjLeft (obj, pix) {

	    if (document.getElementsByTagName && document.getElementById) {
			//Netscape 6+ model (also works in IE 6)
			document.getElementById(obj).style.left = pix;
	    } else {
	    	if (document.all) {
				//IE model (at least, versions prior to 6)
				document.all(obj).style.left = pix;	
			}	
		}	
	}
	
function RollOnGeneric(imgName) {
	if (document.images){
		imgFileName = "";
		imgOld = document.images[imgName].src;
		dotPos = imgOld.lastIndexOf('.');
		imgExt = imgOld.substring(dotPos+1, dotPos+4); 
		imgFileName = imgOld.substring(0, imgOld.lastIndexOf('_'));
		imgFileName = imgFileName + "_2." + imgExt;
		document.images[imgName].src = imgFileName;
	}
}

function RollOffGeneric(imgName) {
	if (document.images){
		imgFileName = "";
		imgOld = document.images[imgName].src;
		dotPos = imgOld.lastIndexOf('.');
		imgExt = imgOld.substring(dotPos+1, dotPos+4); 
		imgFileName = imgOld.substring(0, imgOld.lastIndexOf('_'));
		imgFileName = imgFileName + "_1." + imgExt;
		document.images[imgName].src = imgFileName;
	}
}	