

//functions to check all and clear all items
function ysnCheck(actionflag, form){
	flag = 0;
	if (form.itemID) {
		if (form.itemID.length > 1) {
			for(i = 0; i < form.itemID.length; ++i){
				if (form.itemID[i].checked) {
					flag += 1;
					break;
				}
			}
		} else if (form.itemID.checked){
			flag += 1;
		}
    }
    
	if (flag == 0) {
		alert("Please check one or more Item Listings.");
		return (false);
    }
    
    setActionFlag(actionflag,form);
    return true;
}


function setActionFlag(actionflag,form){
	form.actionflag.value = actionflag;
 	return true;
}


function CheckAll(flagval,form){
	flag = "true";

	if (flagval == "0") {
  		flag = 0;
	}

	if (form.itemID) {
  		if (form.itemID.length > 1) {
	 		for(i = 0; i < form.itemID.length; ++i){
				form.itemID[i].checked = flag;
	 		}
  		} else {
     		form.itemID.checked = flag;
  		}
	}  
  	return false;
}

function CheckItem(flagval,form){
	
	form.checkID1.checked = 0;
	form.checkID2.checked = 0;
	
    
	if (flagval == "1") {
  		form.checkID1.checked = "true";	
	}else if (flagval == "0") {
  		form.checkID2.checked = "true";	
	}
}

//checks all DataItem CheckBoxes with the given name with the given value
function CheckAllCheckBoxes(aspCheckBoxID, checkVal, formNum) {

    //generated control name starts with a colon
	re = new RegExp(aspCheckBoxID)  
    for(i = 0; i < document.forms[formNum].elements.length; i++) {

        elm = document.forms[formNum].elements[i]

        if (elm.type == 'checkbox') {

            if (re.test(elm.name)) {

                elm.checked = checkVal

            }
        }
    }
}
