function runThisFirst(dbpath, sid) {
	var pdscookie = getACookie('StonCorPDS1');
	var internalStonCookie = getACookie('internalSCorEmp');
	
	if(internalStonCookie != 'blank') {
		window.open('/eurpdslogins.nsf/InternalRedir?OpenAgent&userid=' + pdscookie  + '&db=' + dbpath + '&docid=' + sid, '', 'width=700,height=400,resizable,scrollbars,left=20,top=30');
	} else if(pdscookie  == 'blank') {
		window.open('/eurpdslogins.nsf/LoginForm?OpenForm&dbpath=' + dbpath + '&id=' + sid, '', 'width=700,height=400,resizable,scrollbars,left=20,top=30');
	} else {
		window.open('/eurpdslogins.nsf/SendLogEmail?OpenAgent&userid=' + pdscookie  + '&db=' + dbpath + '&docid=' + sid, '', 'width=700,height=400,resizable,scrollbars,left=20,top=30');
	}
}
function getACookie(cookieName) {
	if (document.cookie.length > 0) {
		if (document.cookie.indexOf(cookieName) != -1) {
			var sStartCookie = document.cookie.indexOf('=', document.cookie.indexOf(cookieName));
			var sEndCookie = document.cookie.indexOf(';', sStartCookie);
			if (sEndCookie == -1) {
				sEndCookie = document.cookie.length
			}
			var PlaceToGo = document.cookie.substring(sStartCookie + 1, sEndCookie);
			return unescape(PlaceToGo);
		} else { 
			return 'blank';
		}
	} else {
		return 'blank';
	}
}
function returnDatabasePath() {
	var sCurrentLoc = document.location.toString().toLowerCase();
	var nsfPos = sCurrentLoc.indexOf('.nsf');
	var dbPath = sCurrentLoc.substr(0, nsfPos + 5);
	return dbPath;
}
