/*  Currently included in:
newuser
privacy
changepassword
login
*/

var newwin;

/* openWindow( file, width, height )
* The function will open a new window with the specified width and height measurements.  In the new window,
* the specified file will be loaded in the new window.  In addition, the variable SMLOCALE will be appended
* to the end of the address in order to present the window in the proper language. */
function openWindow( file, width, height )
{
try {
    if (!newwin) {
        newwin = window.open( file, "name","menubar=no,resizable=no,toolbar=no,scrollbars=yes,width=" + width + ",height=" + height );
    }
    else {
        if (width != newwin.outerwidth || height != newwin.outerheight) {
            newwin.resizeTo(width, height);
        }
        newwin.location = file;
    }
    }
    catch (e) {
	newwin = window.open( file,
	"name","menubar=no,resizable=no,toolbar=no,scrollbars=yes,width=" +
	width + ",height=" + height );
	}
	newwin.focus();
}

function getCookie(name)
{
	var cookies = document.cookie;
	var start = cookies.indexOf(name + '=');
	if (start == -1) return null;
	var len = start + name.length + 1;
	var end = cookies.indexOf(';',len);
	if (end == -1) end = cookies.length;
	return unescape(cookies.substring(len,end));
}


function isCookieEnabled()
{
	if (document.all) {
		if (!navigator.cookieEnabled) {
			document.cookiesForm.submit();
		}
	}
	else {
		setCookie('temp','temp');
		var temp = getCookie('temp');
		if (!temp) {
			document.cookiesForm.submit();
		}
	}
}

function setCookie(name, value, expires, path, domain, secure)
{
	value = escape(value);
	expires = (expires) ? ';expires=' + expires.toGMTString() :'';
	path    = (path)    ? ';path='    + path                  :'';
	domain  = (domain)  ? ';domain='  + domain                :'';
	secure  = (secure)  ? ';secure'                           :'';
	document.cookie =
	name + '=' + value + expires + path + domain + secure;
}

function deleteCookie(name, path, domain)
{
	var expires = ';expires=Thu, 01-Jan-70 00:00:01 GMT';
	(path)    ? ';path='    + path                  : '';
	(domain)  ? ';domain='  + domain                : '';

	if (getCookie(name))
	document.cookie = name + '=' + expires + path + domain;
}
