/* Common Javascript operations for Worminator.
 * By Janak J Parekh <janak at cs dot columbia dot edu>
 */
function popUp(url) {
	window.open(url,"MyPopup",'height=700,width=700,scrollbars');
}
		
function processSelection(type) {
	var whichRadio = 'ip'; // Default paranoia
	if(type == 'watchlist' && document._watchlistSelectorForm._watchlistSelector.selectedIndex > 0) {
		var checkboxes = document._watchlistSelectorForm._watchlistReportOn;
		for(i=0; i < checkboxes.length; i++) {
			if(checkboxes[i].checked) {
				whichRadio = checkboxes[i].value;
			}
		}
				
		window.location.href = 'watchlist.jsp?' + document._watchlistSelectorForm._watchlistSelector.value +
		  '&reportOn=' + whichRadio + '&all=' + document._watchlistSelectorForm._watchlistAll.checked;
					  
	} else if(type == 'warnlist' && document._warnlistSelectorForm._warnlistSelector.selectedIndex > 0) {
		var checkboxes = document._warnlistSelectorForm._warnlistReportOn;
		for(i=0; i < checkboxes.length; i++) {
			if(checkboxes[i].checked) {
				whichRadio = checkboxes[i].value;
			}
		}

		window.location.href = 'warnlist.jsp?' + document._warnlistSelectorForm._warnlistSelector.value +
			'&reportOn=' + whichRadio + '&all=' + document._warnlistSelectorForm._warnlistAll.checked;				
	}
}

/* Generate an email... we use this as an antispam measure. */
function genEmail(name, emailprefix, emailsuffix) {
	document.write(name + " (<a href='mailto:" + emailprefix + "@" + emailsuffix + "'>" + emailprefix + "@" + emailsuffix + "</a>)");
}

/* See if a string is empty in JavaScript, including whitespaces. */
function isEmpty(mytext) {
	//match any white space including space, tab, form-feed, etc.
	if ((mytext==null) || (mytext.length==0) || ((mytext.search(/^\s{1,}$/g)) > -1)) {
		return true;
	}
	else {
		return false;
	}
}
