var popupWindowHelp;
var popupWindowSelect;

function confirmSubmit(Message) {
	if(confirm(Message + "\n\nPress 'OK' to continue or 'Cancel' to abort.")) return true; else return false;
}

function confirmMessage(Message, URL) {
	if (confirm(Message + "\n\nPress 'OK' to continue or 'Cancel' to abort.")) window.location.href = URL;
}

function confirmRemove(URL) {
	confirmMessage("Are you sure you want to remove this item?", URL);
}

function displayHelp(lTopicID) {
	var winWidth = 350;
	var winHeight = 450;
	if(popupWindowHelp) popupWindowHelp.close();
	popupWindowHelp = window.open("/app/?common/help/?TopicID=" + lTopicID, "popupWindowHelp", "width=" + winWidth + ", height=" + winHeight + ", resizable=1, scrollbars=1, toolbar=0, location=0, menubar=0, status=1, directories=0, dependent=1");
	if (window.focus) popupWindowHelp.focus();
}

function selectItem(sType, sForm, sField, lFilterAccount) {
	var winWidth = 460;
	var winHeight = 460;
	if (popupWindowSelect) popupWindowSelect.close();
	popupWindowSelect = window.open('/app/?common/select/?Type=' + sType + '&Form=' + sForm + '&Field=' + sField + '&FilterAccountID=' + lFilterAccount, "popupWindowSelect", "width=" + winWidth + ", height=" + winHeight + ", resizable=1, scrollbars=1, toolbar=0, location=0, menubar=0, status=0, directories=0, dependent=1");
	if (window.focus) popupWindowSelect.focus();
}

function setPage(sForm, lTableID, lPage) {
	eval('document.' + sForm + '.hCT' + lTableID + 'P.value = ' + lPage);
	eval('document.' + sForm + '.submit()');
}

function toggleElementVisibility(ElementName, ElementVisibility) { 
	if(ElementVisibility == 1)
		ElementVisibility = '';
	else
		ElementVisibility = 'none';

	if (document.getElementById)
		document.getElementById(ElementName).style.display = ElementVisibility;
	else if (document.all)
		eval('document.all.' + ElementName + '.style.display = ' + ElementVisibility);
}

function toggleMultiElementVisibility(ElementList, ElementVisibility) { 
	var ElementName = ElementList.split(',');
	for(counter = 0; counter < ElementName.length; counter++ ) {
		toggleElementVisibility(ElementName[counter], ElementVisibility);
	}
}

function checkVisibility(ControlName, VisibleValue, ElementName) {
	if (document.frmMain) {
		if (eval('document.frmMain.' + ControlName + '.value') == VisibleValue)
			toggleElementVisibility(ElementName, 1);
		else
			toggleElementVisibility(ElementName, 0);
	}
}

function checkVisibilityRadio(ControlName, VisibleValue, ElementName) {
	if (document.frmMain) {
		for (i = 0; i < document.frmMain[ControlName].length; i++) {
			if (document.frmMain[ControlName][i].checked)
				CurrentValue = document.frmMain[ControlName][i].value;
		}
	
		if (CurrentValue == VisibleValue)
			toggleElementVisibility(ElementName, 1);
		else
			toggleElementVisibility(ElementName, 0);
	}
}

window.status = 'HyperCORE v2.0';