var mTop, mLeft;

function moveCenter()
{
	var sHeight = window.screen.availHeight;
	var sWidth  = window.screen.availWidth;

	mTop        = ( (sHeight / 2 ) - 275);
	mLeft       = ( (sWidth  / 2 ) - 225);

	self.moveTo( mLeft, mTop );
	self.focus ();
}

function getCenter()
{
	var sHeight = window.screen.availHeight;
	var sWidth  = window.screen.availWidth;

	mTop        = ( (sHeight / 2 ) - 275);
	mLeft       = ( (sWidth  / 2 ) - 225);
}

function bRoll2(itemName,itemState)
{
   if ( itemState == 1 )
      {
      itemName.className = 'msgButtonRoll';
      }
   else
      {
      itemName.className = 'msgButton';
      }
}

function ResendMailNofify(popURL, cid) {
	popURL += '?w=6&p='+cid;
	window.open(popURL, 'tbPop3', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=200');
}
// opens the avatar gallery
function galPop(popURL) {
	popURL +='?w=8';
	window.open(popURL,'tbPop4','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=440');
}
// opens the avatar gallery
function galPop2(popURL,u) {
	popURL +='?u='+u;
	window.open(popURL,'tbPop4','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=440');
}
// openes the avatar upload form
function avPop(popURL) {
	window.open(popURL,'tbPop5','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=450,height=200');
}
// openes the avatar upload form
function avPop2(popURL,u) {
	popURL +='?u='+u;
	window.open(popURL,'tbPop6','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=450,height=200');
}
// marks forum read
function markRead(popURL) {
	window.open(popURL,'tbPop7','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=350,height=150');
}

// shows the attachment upload
function fileUp(popURL)
{
   var strParams;

   getCenter()

   strParams = 'left='+ mLeft + ',top=' + mTop + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=550,height=450';

	window.open ( popURL, 'filePop', strParams );
}

// shows the PM user lookup
function TBUserLookup(popURL) {
	popURL += '?w=4';
	window.open(popURL, 'tbPop2', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=500,height=325');
}

// forum quick jump
function quickJ(aPath) {
	if (aPath!='0')
		window.location.href=aPath;
}

// pm select/deselect all checkboxes...
function doCheckboxes() {
	var nVal=document.forms[0].pmcall.checked;
//	alert(nVal);
	for (var i=0;i<document.forms[0].elements.length;i++) {
		var e = document.forms[0].elements[i];
		if ((e.name == 'pms') && (e.type=='checkbox')) {
			e.checked=nVal;
		}
	}

}

// pm check for delete
function checkDelete(eod) {
	var dCount=0;
	for (var i=0;i<document.forms[0].elements.length;i++) {
		var e = document.forms[0].elements[i];
		if ((e.name == 'pms') && (e.type=='checkbox')) {
			if(e.checked==true) {
				dCount += 1;
			}
		}
	}
	if(dCount==0) {
		alert('You must select the messages you want to delete!');
	} else {
		document.forms[0].eod.value=eod;
		document.forms[0].submit();
	}
}

// pm check for reply
function checkReply() {
	var dCount=0;
	for (var i=0;i<document.forms[0].elements.length;i++) {
		var e = document.forms[0].elements[i];
		if ((e.name == 'pms') && (e.type=='checkbox')) {
			if(e.checked==true) {
				dCount += 1;
			}
		}
	}
	switch(dCount) {
		case 0: {
			alert('You must select the message you want to reply to!');
			break;
		}
		case 1: {
			document.forms[0].eod.value='ri';
			document.forms[0].submit();
			break;
		}
		default: {
			alert('You can select only 1 message for replies!');
			break;
		}
	}

}

// pm check for forward
function checkForward() {
	var dCount=0;
	for (var i=0;i<document.forms[0].elements.length;i++) {
		var e = document.forms[0].elements[i];
		if ((e.name == 'pms') && (e.type=='checkbox')) {
			if(e.checked==true) {
				dCount += 1;
			}
		}
	}
	if(dCount==0) {
		alert('You must select at least one message to forward!');
	} else {
		document.forms[0].eod.value='fw';
		document.forms[0].submit();
	}
}

// pm get filtered member list for sending
function sendFilter(fChar) {
	document.forms[0].ml.value=fChar;
	document.forms[0].cu.value='-1';
	document.forms[0].submit();
}

// pm name list passback
function sendNamesToParent() {
	var nLen=document.forms[0].uDrop2.length;
	if (nLen==0){
		alert('You did not select any names to be added!');
	} else {
		var nStr='';
		var i;
		for (i=0;i<nLen;i++) {
			if (i>0) {
				nStr += ',' + document.forms[0].uDrop2[i].value;
			} else {
				nStr += document.forms[0].uDrop2[i].value;
			}
		}
		window.opener.document.forms[0].uName.value=nStr;
		window.close();
	}
}

// New in v2.4 : processes thread subscriptions
function doSubscribe(popURL) {
	window.open(popURL,'tbPop10','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=350,height=150');
}

// updated in v2.4 : Moved from TBform.js
function TBTagsHelp(popURL) {
	window.open(popURL, 'tbPop', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=600,height=410');
}
