function chkform(theForm) {
	msg='Correct the following errors:';
	if(theForm.code.value == "") msg+='\r\n  You must enter a Code';
	if(theForm.lastdate.options[theForm.lastdate.selectedIndex].value == '') msg+='\r\n  You must select the Date Tested';
	if(theForm.mkt.options[theForm.mkt.selectedIndex].value == '') msg+='\r\n  You must select a State';
	if(theForm.locationid.options[theForm.locationid.selectedIndex].value == '') msg+='\r\n  You must select a Location';
	//var re5digit=/^\d{5}$/ //regular expression defining a 5 digit number
	//if(theForm.zipcode.value.search(re5digit) == -1) msg+='\r\n  You must enter a valid Zip Code';
	if(!theForm.cdstatus.selectedIndex) msg+='\r\n  You must select a Status';
	if(msg.length > 40) {
		alert(msg);
		return false;
	}
	return true;
}
function usecard(cardid) {
	document.codeupd.carduse.value = cardid;
}
function usecode(codeid) {
	document.codeupd.code.value = codeid;
}

function open_codehistory(code,extra) {
	var win_str = '/code/redbox-code-history.php?code='+code+extra;
	window.open(win_str,'codehistory','width=540,height=500,scrollbars');
}

function setCSSDisplay(elementid,val) {
	document.getElementById(elementid).style.display = val;
}

function showHideClass(check,tableid,classname) {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var dis_show = "block";
	} else {
		var dis_show = "table-row";
	}

	var disp = (check.checked)? dis_show : "none";
  var tbl = document.getElementById(tableid);
	for (var i=0;i<tbl.rows.length;i++) {
    if (tbl.rows[i].className.indexOf(classname)!=-1) tbl.rows[i].style.display=disp;
  }
}

function showHideID(tbodyid,btnid) {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var dis_show = "block";
	} else {
		var dis_show = "table-row-group";
	} 
	var dis = (document.getElementById(tbodyid).style.display == "none") ? dis_show : "none";
  document.getElementById(tbodyid).style.display = dis;
  btnid.src = (dis=="none") ? '/images/icon_plus.png':'/images/icon_minus.png';
}

function showHideTable(tableid,btnid) {
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		var dis_show = "block";
	} else {
		var dis_show = "table";
	} 
	var dis = (document.getElementById(tableid).style.display == "none") ? dis_show : "none";
  document.getElementById(tableid).style.display = dis;
  btnid.src = (dis=="none") ? '/images/icon_plus.png':'/images/icon_minus.png';
}

function setCSS(id,stylename,attr) {
	var element = document.getElementById(id);
	eval("element.style." + stylename + " = attr");
}
