function goHelp(cid) {
	doPopup('helpwindow','/archangel/woa/mgHelp.php?CategoryID=' + cid + '#c' + cid,
		600,500,'yes','yes','yes',1);
}
function fixIERightSide() {
	return;
}
function setCookie(name, value) {
	if (value != null && value != "")
	document.cookie=name + "=" + value; // + "; expires=" + expiry.toGMTString();
}
	// to display close buttons when they're not in the main frame...
function setCloseButton() {
	if (parent.frames.frameMain) return;
	var x = self.document.getElementById('btnClose');
	if (x) {
		x.style.display = 'inline';
		var z = x.offsetHeight;
		++z;
		x.style.height = z + 'px';
	}
	return;
}
var bindingsHeight      = 400;
var bindingsWidth       = 500;
function gobindings(type,object) {
	var h = screen.height/2-(bindingsHeight/2);
	var w = screen.width/2-(bindingsWidth/2);
	var pos = "top=" + h + ",left=" + w;
	var x = new Date();
	var s = x.getTime();
	var url;
	if (type != '0')
		url = "/archangel/woa/mgBindings.php?type=" + type + "&object_id=" + object;
	else
		url = "/archangel/woa/mgBindings.php?linked=" + object;
	doPopup('Bindings',url,bindingsWidth,bindingsHeight,'yes','yes','no',1);
}
function UPLDWindow(wt) {
	var url = "/archangel/woa/mgFileBox.php?camefrom=" + wt;
	doPopup('FileWindow',url,650,450,'yes','yes','yes',1);
}
function HELPWindow(type) {
	var url = "/archangel/woa/popup.php?showhelp=" + type;
	doPopup('HelpWindow',url,500,400,'yes','yes','yes',1);
}
function goFilebox(cfrom) {
	doPopup('FileBox','/archangel/woa/mgFileBox.php?camefrom=' + cfrom,600,500,'yes','yes','yes',1);
}
function doPopup (sName,sUrl,nW,nH,sResize,sScrollbars,sStatus,bUnique) {
	if (bUnique == 2) {
		var wmain = self;
		if (wmain.name != 'WOAMain') {
			wmain = parent;
			if (typeof(wmain) == 'object' && typeof(wmain.name) != 'undefined' && wmain.name != 'WOAMain') {
				wmain = parent.opener;
				if (typeof(wmain) == 'object' && typeof(wmain.name) != 'undefined' && wmain.name != 'WOAMain') {
					wmain = '';
				} else if (!/msie/i.test(navigator.userAgent) && typeof(wmain.name) != 'undefined' && wmain.name != 'WOAMain') wmain = '';
			}
		}
	}
	var itop = screen.height/2-(nH/2);
	var ileft = screen.width/2-(nW/2)-10;
	var pos = "top=" + itop + ",left=" + ileft;
	var unq = '';
	if (bUnique == 1) {
		var x = new Date();
		unq = x.getTime();
	}
	if (bUnique==2 && typeof(wmain) == 'object' && typeof(wmain.popupWindows) != 'undefined' && typeof(wmain.popupWindows[sName]) == 'object' && !wmain.popupWindows[sName].closed) {
		wmain.popupWindows[sName].focus();
	} else {
		var hWnd = window.open(sUrl, sName + unq,pos+",width=" + nW + ",height=" + nH +
		",location=1,resizable=" + sResize + ",scrollbars=" + sScrollbars + ",status=" + sStatus);
		if ((document.window != null) && (!hWnd.opener)) hWnd.opener = document.window;
	}
	if (bUnique==2 && typeof(wmain) == 'object' && typeof(wmain.popupWindows) != 'undefined') {
		wmain.popupWindows[sName] = hWnd;
	}
}
function linkto_right(url) {
	var x = document.getElementById('rightsidediv');
	var dl = document.getElementById('mDivLoading');
self.scrollTo(0,0);
	if(dl) dl.style.display='block';
	if(!x) return;
	var xmlhttp=getXMLObj();
	if(!xmlhttp) return;
	xmlhttp.open('GET',url,true);
	xmlhttp.onreadystatechange=function(){
		if(xmlhttp.readyState==4){
			if(x.childNodes[0]&&typeof(x.childNodes[0])!='undefined')
				while(x.childNodes[0]&&typeof(x.childNodes[0])!='undefined')
					x.removeChild(x.childNodes[0]);
			if(dl) dl.style.display='none';
			x.innerHTML=xmlhttp.responseText;
			if ((/\/x.php/.test(url)||/^x.php/.test(url)) && typeof(emInit)!='undefined') setTimeout('emInit()',100);
			else if (/options.php/.test(url) && typeof(optShowTab)!='undefined') optShowTab(0);
		}
	}
	xmlhttp.send(null);
}
function linkto_weblink(url) {
	open(url,'_blank');
}
function linkto_gen(paramstring) {
	open (paramstring, "_self");
}
function add_address(str,typ) {
	var doit = 1;
	if (typ == 'b') doit = confirm("Confirm BlackList: Click OK to blacklist this sender, or Cancel to cancel.");
	else
	if (typ == 'w') doit = confirm("Confirm WhiteList: Click OK to whitelist this sender, or Cancel to cancel.");
	else
		doit = confirm("Confirm Add Contact: Click OK to add this sender as a contact, or Cancel to cancel.");
	if (!doit) return doit;
	var url = "addaddr.php?addr=" + str + "&type=" + typ;
	open (url,'mgwoamonitor');
	return doit;
}
function bind_new(formname) {
	var x = new Date();
	var s = x.getTime();
	var url;
	url = "mgBindings.php?type=99&object_id=0&formname=" + formname;
	doPopup('Bindings',url,530,400,'yes','yes','no',0);
}
function linkto_compose(paramstring) {
	doPopup('mgComposeEmail','/archangel/woa/compose.php?' + paramstring,750,550,'yes','yes','yes',1);
}
var lastRowChecked = null;
var mgShiftDown = false;
var mgCtrlDown = false;
function kModifiers(e) {
	e || (e = window.event); mgShiftDown = e.shiftKey; mgCtrlDown = e.ctrlKey;
}
function mgUpdRow(rowID,chkd,chkshift) {
	if (!rowID) return;
	var x = document.getElementById(rowID);
//if ('$_SESSION[user]' == 'bscoder') alert(x.type);
	if (!x) return;
	var retstr = '';
	var tmpi = x.getElementsByTagName('input');
	if (tmpi[0] && /radio/i.test(tmpi[0].type)) return;
	var chrs = rowID.replace(/[0-9]+/,'');		// alpha portion of rowID
	var crow = parseInt(rowID.replace(/[a-zA-Z]+/,''));	// numeric portion of rowID
	if (chkshift && lastRowChecked && mgShiftDown) {
		var lrow = parseInt(lastRowChecked.replace(/[a-zA-Z]+/,''));
		var estart;
		var eend;
		if (crow != lrow) {
			if (crow < lrow) { estart = crow; eend = lrow; }
			else { estart = lrow; eend = crow; }
			if (eend - estart > 1) {
				for (a=estart; a<=eend; a++) {
					var tmptr = document.getElementById(chrs + a);
					var tmpi = tmptr.getElementsByTagName('input');
					if (tmpi.length) {
						var tmpchkbx = tmpi[0];
						tmpchkbx.checked = chkd;
						mgUpdRow(chrs + a, chkd, 0);
					}
	  			}
			}
  		}
	}
	if (x && x.className != 'selRow') {
		if (chkd) {
			if (crow % 2)
				x.style.backgroundColor='#f5efb5';
			else
				x.style.backgroundColor='#fffbc1';
			x.style.color = 'navy';
		} else {
			x.style.color = '#000';
			if (crow % 2)
				x.style.backgroundColor='#eee';
			else
				x.style.backgroundColor='#fff';
		}
	}
	if (chkshift) lastRowChecked = rowID;
}
function IE_images() {
	if (!/MSIE/.test(navigator.userAgent)) return;
	var x = document.getElementsByTagName('img');
	for (var a=0; a<x.length; a++) {
		if (x[a].parentNode.tagName == 'A') {
			x[a].onmouseover = function() { this.className='mgHILITE'; }
			x[a].onmouseout = function() { this.className='mgLOLITE'; }
		}
	}
}

