/*Event.observe(window,'load',function {
	Event.observe('','click',clickPlayer);
});
*/
function clickAbstain2(frmTeam) {
	i = 0;
	intCount = 0;
	while(elemCB = frmTeam.elements[i++]) {
		if(elemCB.type == 'checkbox' && elemCB.checked == true) {
			intCount++;
		}
	}
	
	i = 0;
	while(elemCB = frmTeam.elements[i++]) {
		if(elemCB.type == 'checkbox' && intCount == 0) {
			elemCB.disabled = false;
		} else if(elemCB.type == 'checkbox' && intCount == 1 && 
			elemCB.checked == false) {
				elemCB.disabled = true;
		} else if(elemCB.type == 'checkbox' && intCount > 1 &&
			elemCB.value != -2) {
				elemCB.checked = false;
				elemCB.disabled = true;
		} else if (elemCB.type == 'checkbox' && intCount > 1 &&
			elemCB.value == -2) {
				elemCB.checked = true;
				elemCB.disabled = false;
		}
	}
}

function clickPlayer(frmTeam) {
	var intCount = 0;
	i = 0;
	while(elemCB = frmTeam.elements[i++]) {
		if(elemCB.type == 'checkbox' && elemCB.checked == true) {
			intCount++;
		}
	}
	
	if(intCount == 2) {
		i = 0;
		while(elemCB = frmTeam.elements[i++]) {
			if(elemCB.type == 'checkbox' && elemCB.checked != true) {
				// 	if it is selected, leave it how it is
				// 	otherwise disable it
				elemCB.disabled = true;
			}
		}
	}
	else if(intCount < 2) {
		i = 0;
		while(elemCB = frmTeam.elements[i++]) {
			elemCB.disabled = false;
		}
	}
}

function submitDD() {
    document.dd.submit();
}

function changeAction() {
    document.frmAction.submit();
}

function formSubmit () {
    document.dd.submit();
}

function changeTeam() {
    document.frmDestTeam.submit();
}

function confirmBids() {
    var agree=confirm("Are you sure you wish to make these bids?");
    if (agree)
            return true ;
    else
            return false ;
}

function countLeft(field,max) {
	if(field.value.length > max) {
		field.value = field.value.substring(0,max);
	} else {
		count = max - field.value.length;
	}
	document.getElementById('charsLeft').innerHTML = "You have <strong>" + count + "</strong> characters left.";
}

function autorefresh() {
	var timeoutPeriod = 1000*30;
	setTimeout("window.location.reload();",timeoutPeriod);
}

