var IE5=(document.getElementById && document.all)? true : false;
var W3C=(document.getElementById)? true: false;
var currIDb=null, currIDs=null, xoff=0, yoff=0; zctr=0; totz=0;

function trackmouse(evt){
if((currIDb!=null) && (currIDs!=null)){
var x=(IE5)? event.clientX+document.body.scrollLeft : evt.pageX;
var y=(IE5)? event.clientY+document.body.scrollTop : evt.pageY;
currIDb.style.left=x+xoff+'px';
currIDs.style.left=x+xoff+0+'px';
currIDb.style.top=y+yoff+'px';
currIDs.style.top=y+yoff+0+'px';
return false;
}}

function stopdrag(){
currIDb=null;
currIDs=null;
NS6bugfix();
}

function grab_id(evt){
xoff=parseInt(this.IDb.style.left)-((IE5)? event.clientX+document.body.scrollLeft : evt.pageX);
yoff=parseInt(this.IDb.style.top)-((IE5)? event.clientY+document.body.scrollTop : evt.pageY);
currIDb=this.IDb;
currIDs=this.IDs;
}

function NS6bugfix(){
if(!IE5){
self.resizeBy(0,1);
self.resizeBy(0,-1);
}}

function incrzindex(){
zctr=zctr+2;
this.subb.style.zIndex=zctr;
this.subs.style.zIndex=zctr-1;
}

function createPopup(id, title, width, height, x , y , isdraggable, boxcolor, barcolor, shadowcolor, text, textcolor, textptsize, textfamily, domain ){
if(W3C){
zctr+=2;
totz=zctr;
if (IE5) {
	documentWidth  =document.body.offsetWidth+document.body.scrollLeft-20-width;
	documentHeight =document.body.offsetHeight+document.body.scrollTop-height;
} else if (!IE5) {
	documentWidth=window.innerWidth+window.pageXOffset-20-width;
	documentHeight=window.innerHeight+window.pageYOffset-height;
} else if (W3C) {
	documentWidth=self.innerWidth+window.pageXOffset-20-width;
	documentHeight=self.innerHeight+window.pageYOffset-height;
} 
if (x<0)
	x+=documentWidth;
if (y<0)
	y+=documentHeight;
var titi='';
titi+='<a href="http://mail.'+domain+'/"><img alt="Check Email" border=0 src="http://i.anythingemail.com/images/tinymailbox.gif"></a> ';
titi+='<a href="http://mail.'+domain+'/admin/"><img alt="Command Center" border=0 src="http://i.anythingemail.com/images/tinywrench.gif"></a>';
var txt='';
txt+='<div id="'+id+'_s" style="position:absolute; left:'+(x+0)+'px; top:'+(y+0)+'px; width:'+width+'px; height:'+height+'px; background-color:'+shadowcolor+'; filter:alpha(opacity=50); visibility:visible"> </div>';
txt+='<div id="'+id+'_b" style="border:outset '+barcolor+' 2px; position:absolute; left:'+x+'px; top:'+y+'px; width:'+width+'px; overflow:hidden; height:'+height+'px; background-color:'+boxcolor+'; visibility:visible">';
txt+='<div style="width:'+width+'px; height:16px; background-color:'+barcolor+'; padding:0px; border:1px"><table cellpadding="0" cellspacing="0" border="0" width="'+(IE5? width-4 : width)+'"><tr><td width="'+(width-20)+'"><div id="'+id+'_h" style="width:'+(width-20)+'px; height:14px; font: bold 12px sans-serif; color:'+textcolor+'"> '+titi+title+'</div></td><td align="right"><a onmousedown="closeBox( document.getElementById(\''+id+'_s\'), document.getElementById(\''+id+'_b\'),50); return false"><img src="http://i.anythingemail.com/images/close.gif" border="0" height="14" width="14"></a></td></tr></table></div>';
txt+='<div id="'+id+'_ov" width:'+width+'px; style="margin:2px; color:'+textcolor+'; font:'+textptsize+'pt '+textfamily+';">'+text+'</div></div>';
document.write(txt);
this.IDh=document.getElementById(id+'_h');
this.IDh.IDb=document.getElementById(id+'_b');
this.IDh.IDs=document.getElementById(id+'_s');
this.IDh.IDb.subs=this.IDh.IDs;
this.IDh.IDb.subb=this.IDh.IDb;
this.IDh.IDb.IDov=document.getElementById(id+'_ov');
if(IE5){
this.IDh.IDb.IDov.style.width=width-6;
this.IDh.IDb.IDov.style.height=height-22;
this.IDh.IDb.IDov.style.scrollbarBaseColor=boxcolor;
this.IDh.IDb.IDov.style.overflow="auto";
}else{
this.IDh.IDs.style.MozOpacity=.5;
}
this.IDh.IDb.onmousedown=incrzindex;
if(isdraggable){
this.IDh.onmousedown=grab_id;
this.IDh.onmouseup=stopdrag;
}}}

if(W3C)document.onmousemove=trackmouse;
if(!IE5 && W3C)window.onload=NS6bugfix;

var opacity=100, didS, didB, doS;

function fadeOut() {
	opacity = opacity - 10;
	didB.style.filter='alpha(opacity='+opacity+')';
	var so = opacity/300*doS;
	didS.style.filter='alpha(opacity='+so+')';

	if (opacity>0) {
		setTimeout("fadeOut()", 10);
	} else {
		opacity=100;
	}
}

function closeBox(idS, idB, oS)
{
	if (!IE5) {
		idS.style.display='none';
		idB.style.display='none';
		return false;
	}
	didS = idS;
	didB = idB;
	if (oS)
		doS = oS;
	else 
		doS = 0;
	fadeOut();
	
	return false
}
