function ValPost(button) {
	if (Page_ClientValidate != null) {
		if (!Page_ClientValidate()) return false;
	}
	button.disabled = true;
}
function ClearDropDownList(dropDownList) {
	while (dropDownList.options.length) {
		dropDownList.remove(0);
	}

	AddNewOptionTo(dropDownList, 'Select...', '');
}

function AddNewOptionTo(dropDownList, text, value) {
	var newOption = document.createElement('OPTION');
	newOption.value = value;
	newOption.text = text;
	dropDownList.add(newOption);
}

function SetSelectedValueOfSelectList(selectList, selectedValue) {
	for(i=0; i < selectList.length; i++) {
		if (selectList.options[i].value == selectedValue) {
			selectList.options[i].selected = true;
		}
	}
}


function confirmChange(ruleName,includeInComplianceCheck) {
	if(includeInComplianceCheck!='ignore')
		return confirm("Are you sure you want to include: " + ruleName.toUpperCase() + "\nin the compliance check?");
	else
		return confirm("Are you sure you want to bypass this " + ruleName.toUpperCase() + "\nrule for all future compliance checks?"); 
}


function showDhtmlWin(windowName) {
	var DivRef = document.getElementById(windowName);
	DivRef.style.display = "block";

	var browserWidth = document.body.clientWidth;
    var browserHeight = document.body.clientHeight;

	leftPos = (browserWidth > 600) ? parseInt(browserWidth - 600)/2 : 0;
	topPos = (browserHeight > 400) ? parseInt(browserHeight - 400)/2 : 0;

	document.getElementById(windowName).style.left = leftPos;

	document.getElementById(windowName).style.top = topPos;
	window.scrollTo(0,0);
	
	// Insert IFrame shim underneath DHTML window to hide drop down menus in IE
	var IfrRef = document.getElementById('DivShim');
	if(IfrRef!=null)
	{
	IfrRef.style.width = DivRef.offsetWidth;
    IfrRef.style.height = DivRef.offsetHeight;
    IfrRef.style.top = DivRef.style.top;
    IfrRef.style.left = DivRef.style.left;
    IfrRef.style.zIndex = DivRef.style.zIndex + 1;
    IfrRef.style.display = "block";
    }
    var lyr = document.getElementById('lyrWaitingIcon');
    if(lyr!=null)
    {
		lyr.innerHTML = "<img src=http://portal.shipcompliant.com/web/themes/common/LoadingBar.gif>";
    }
}
 

function closeDhtmlWin(windowName) {
	document.getElementById(windowName).style.display = "none";
	// Hide iFrame shim
	var IfrRef = document.getElementById('DivShim');
	if(IfrRef!=null)
	{
		IfrRef.style.display = "none";	
	}
}



/* NEW ALERT  */
function setNotificationPrefs(checkboxId,notify) {
		document.getElementById(checkboxId + "-email").disabled = !notify;
}

/*  CLOSED REPORTS  */
function regenerateReport() {
	confirm("Data in this Report has changed since it was Submitted.\nReprinting this report will change its status to OPEN.\n\nYou will need to resubmit it and MARK it as SUBMITTED\nto change its status to SUBMITTED.\n\nAre you sure you want to reprint this report?");
}

function downloadReport() {
	document.getElementById('reportOptions').style.visibility = 'visible';
}

	
	
/* IMPORT ORDER - STEP 2 */
function checkAll(checkedStatus) {
	var i = 1;
	while (document.getElementById("ch" + i) != null) {
		document.getElementById("ch" + i).checked = checkedStatus;
		i++;
	}
}
