﻿function openReport (src) {
	window.open (src, '_blank','menubar=yes,resizable=yes,status=yes,toolbar=no,scrollbars=yes');
	return;
}

function openDialog (src) {
    window.open (src, '_blank', 'menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=yes');
    return;
}

function openDialogSized (src, width, height) {
    window.open (src, '_blank', 'width=' + width + ',height=' + height + ',menubar=no,resizable=yes,status=no,toolbar=no,scrollbars=no');
    return;
}

function openHelp (src) {
	window.open (src, '_blank', 'menubar=yes,resizable=yes,status=yes,toolbar=yes,scrollbars=yes,fullscreen=yes,location=yes');
	return;
}

// relWidth should be a percentage or a pixel offset (ex. -10 or '100%')
// TABLEs must have table-layout:fixed or this will result in infinite recursion!
// Note: If the arguments were (obj, relWidth), this would silently fail to execute,
// and I have no idea why - the object MUST be the last argument.
function autoWidth(relWidth, obj) {
//relWidth = (obj.style.width) ? obj.style.width : relWidth;
var cc = obj.className.split(" ");
for (c in cc) {
	if (cc[c] > 0) relWidth = cc[c]+"%";
}
var defaultCellPadding = 2;
var cellPadding = 2;
/*if (obj.parentNode.tagName == "TD") {
var parentTable =
obj.parentNode.parentNode.parentNode.parentNode;
cellPadding = (parentTable.cellPadding) ?
parentTable.cellPadding : defaultCellPadding;
}*/
var objDiff = (obj.offsetWidth - obj.style.pixelWidth) +
(cellPadding * 2);
var maxWidth = obj.parentNode.clientWidth - objDiff;
if (typeof(relWidth) == "string" && relWidth.slice(-1) == "%") {
var pctValue = relWidth.slice(0, -1) * .01;
newWidth = parseInt(maxWidth * pctValue, 10) + "px";
} else {
newWidth = (maxWidth + parseInt(relWidth, 10)) + "px";
}
return newWidth;
}



function set_readonly(obj) {
	obj.disabled = true;
	var elems = document.getElementsByName(obj.name);
	if (elems.length > 1) return "value";
	var el = document.createElement("<input type='hidden' name='"+obj.name+"' value='"+obj.value+"'>");

	var theForm = document.forms['aspnetForm'];
	if (!theForm) theForm = document.aspnetForm;
	theForm.insertBefore(el);
	return "value";
}
