function categorychooser(selObj){ //v1.0
	if (selObj.options[selObj.selectedIndex].value == 0)
		location.href = "./";
	else
		location.href = "./?cat=" + selObj.options[selObj.selectedIndex].value;
}

function CountLeft(field, count, max) { //v1.0
	if (field.value.length > max)
		field.value = field.value.substring(0, max);
	else
		count.value = max - field.value.length;
}

function commentdel(cID,nID) {
  if ( confirm("Are you sure?") )
		location.href = "ad_commentdel.php?cid=" + cID + "&nid=" + nID;
}

function pollcmtdel(cID,nID) {
  if ( confirm("Are you sure?") )
		location.href = "ad_pollcmtdel.php?cid=" + cID + "&nid=" + nID;
}

function userdel(ID) {
  if ( confirm("Are you sure?") )
		location.href = "ad_deluser.php?id=" + ID;
}

function display(id) {
	if (document.layers) {
		document.layers[id].display = (document.layers[id].display != 'block') ? 'block' : 'none';
	} else if (document.all) {
		document.all[id].style.display = (document.all[id].style.display != 'block') ? 'block'	: 'none';
	} else if (document.getElementById) {
		document.getElementById(id).style.display = (document.getElementById(id).style.display != 'block') ? 'block' : 'none';
	}
}

function launchwin(winurl,winname,winfeatures) {
	newwin = window.open(winurl,winname,winfeatures);
	if(parseInt(navigator.appVersion) >= 4) { }
}

function validate_required(field,alerttxt){
	with (field) {
		if ( value==null || value=="" || value==0 )
			{ alert(alerttxt); return false }
		else { return true }
	}
}

function validate_newssub(thisform) {
	with (thisform) {
		if (validate_required(subject,"Precisa de escolher um título!")==false)
			{ subject.focus(); return false }
		else if (validate_required(category,"Precisa de escolher uma categoria!")==false)
			{ category.focus(); return false }
	}
}

function validate_nick(elem, helperMsg){
	if(elem.value.length < 3){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function buttonTagClicked(field){
	var fieldsarray=field.split("~");
	document.getElementById(fieldsarray[0]).value=1;
}

function display(id) {
	if (document.layers) {
		document.layers[id].display = (document.layers[id].display != 'block') ? 'block' : 'none';
	} else if (document.all) {
		document.all[id].style.display = (document.all[id].style.display != 'block') ? 'block'	: 'none';
	} else if (document.getElementById) {
		document.getElementById(id).style.display = (document.getElementById(id).style.display != 'block') ? 'block' : 'none';
	}
}
