
// alternate window resizing funciton
function resizeWindowX() {
	var table = document.getElementById("ContentTable");
	var dX = table.scrollWidth - document.body.clientWidth;
	var dY = table.scrollHeight - document.body.clientHeight;
	window.resizeBy(dX, dY);

	var moveToX = window.screen.width / 10;
	var moveToY = window.screen.height / 10;
	window.moveTo(moveToX, moveToY);    

	var maxWidth = (window.screen.width - moveToX) - 50;
	var maxHeight = (window.screen.height - moveToY) - 50;

	if (document.body.clientWidth > maxWidth) {
		window.resizeBy((maxWidth - document.body.clientWidth), 0);
		moveToX = 0;
	}
	if (document.body.clientHeight > maxHeight-50) {
		window.resizeBy(0, (maxHeight - document.body.clientHeight));
		moveToY = 0;
	}
	if (moveToX == 0 || moveToY == 0) {
		window.moveTo(moveToX, moveToY);
	}
}
    
// utility function called by getCookie( )
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}

// primary function to retrieve cookie by name
function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return "";
}

// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain) {
	if (getCookie(name)) {
	    document.cookie = name + "=" +
	        ((path) ? "; path=" + path : "") +
	        ((domain) ? "; domain=" + domain : "") +
	        "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
