function methodize(func, scope)
{
    return (function() { func.call(scope); });
}

if(document.layers) 
{ 
	document.captureEvents(Event.MOUSEMOVE);
	document.onmousemove = captureMousePosition;
} 
else if(document.all) 
	document.onmousemove = captureMousePosition;
else if(document.getElementById)  
	document.onmousemove = captureMousePosition;

var xMousePos = 0; 
var yMousePos = 0; 

function captureMousePosition(e) 
{
	if(document.layers) 
	{
		xMousePos = e.pageX;
      yMousePos = e.pageY;
   } 
   else if(document.all) 
   {
		xMousePos = window.event.x+document.body.scrollLeft;
      yMousePos = window.event.y+document.body.scrollTop;
   } 
   else if(document.getElementById) 
   {
		xMousePos = e.pageX;
      yMousePos = e.pageY;
   }
}
function msgWin(id, title, msg, xPos, yPos, vWidth, vHeight)
{
	this.id = id;
	this.title = title;
	var HeightAdjustorBar = 30;
	var adjHeightBar = parseInt(vHeight) + parseInt(HeightAdjustorBar);
	this.msg = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" WIDTH="'+vWidth+'" HEIGHT="'+adjHeightBar+'" id="Extreme"><PARAM NAME=movie VALUE="http://site.123securityproducts.com/video/flv/oneExp.swf?file='+msg+'&vWidth='+vWidth+'&vHeight='+adjHeightBar+'"><PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED src="http://site.123securityproducts.com/video/flv/oneExp.swf?file='+msg+'&vWidth='+vWidth+ '&vHeight='+adjHeightBar+'" quality=high bgcolor=#FFFFFF WIDTH="'+vWidth+'" HEIGHT="'+adjHeightBar+'"  NAME="Extreme" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
	this.parent = '';
	this.left = xPos;
	this.top = yPos;
	this.vHeight = vHeight;
	this.vWidth = vWidth;
	
	var WidthAdjustor = 0;
	var adjWidth = parseInt(vWidth) + parseInt(WidthAdjustor);
	this.adjWidth = adjWidth;
	
	var HeightAdjustor = 51;
	var adjHeight = parseInt(vHeight) + parseInt(HeightAdjustor);
	this.adjHeight = adjHeight;
	
	this.buttonText = 'X';
	
	
	this.moving = 0;
	this.offsetLeft = 0;
	
	this.create();
}

msgWin.prototype.create = function()
{
	var w = document.createElement('div');
	w.id = this.id;
	w.style.width = this.adjWidth;
	w.style.height = this.adjHeight;
	w.style.border = '1px solid #000';
	w.style.background = '#FFF';
	w.style.position = 'absolute';

	if(!this.left)
	{
		w.style.left = '50%';
		w.style.top = '50%';
		w.style.marginLeft = '-150px';
		w.style.marginTop = '-50px';
	}
	else
	{
		w.style.left = this.left+'px';
		w.style.top = this.top+'px';
	}

	var t = document.createElement('div');
	t.id = this.id+'_title';
	t.style.borderBottom = '1px dashed #000';
	t.style.textAlign = 'center';
	t.style.fontWeight = 'bold';
	t.style.fontSize = '16px';
	t.innerHTML = this.title;
	t.style.background = '#628db4';
	t.onmouseover = function() {this.style.cursor = 'move';};
	t.onmousedown = methodize(this.startMove, this);
	t.onmouseup = methodize(this.stopMoving, this);
	
	w.appendChild(t);
	
		var tmp = document.createElement('div');

	tmp.style.textAlign = 'center';
	tmp.style.padding = '0px 0 0px 0';
	tmp.style.background = '#fff';
	
	var b = document.createElement('input');
	b.type = 'button';
	b.value = this.buttonText;
	b.style.position = 'absolute';
	b.style.top = '0%';
	b.style.right = '0%';
	b.style.fontSize = '10px';
	b.onmouseover = function() {this.style.cursor = 'pointer';};
	b.onclick = function() {this.parentNode.parentNode.style.display = 'none';};
	
	tmp.appendChild(b);
	w.appendChild(tmp);
	
	var c = document.createElement('div');
	c.id = this.id+'_content';
	c.style.minHeight = '75px';
	c.style.fontSize = '13px';
	c.style.padding = '0px';
	c.style.background = '000';
	c.innerHTML = this.msg;
	
	w.appendChild(c);
	
	if(this.parent) {
		document.getElementById(this.parent).appendChild(w); }
	else {
		document.body.appendChild(w); 
	return; }
};

msgWin.prototype.hide = function()
{
	document.getElementById(this.id).style.display = 'none';
	
	return;
};

msgWin.prototype.show = function()
{
	document.getElementById(this.id).style.display = 'inline';
};

msgWin.prototype.startMove = function()
{
	this.moving = 1;
	
	document.getElementById(this.id).parentNode.onmousemove = methodize(this.stopMove, this);
	document.getElementById(this.id).parentNode.onmouseup = methodize(this.stopMove, this);
	
	var el = document.getElementById(this.id);
	
	el.style.zIndex = 2;

		var l = parseInt(el.style.left);	
	
	this.offsetLeft = xMousePos - l;
}

msgWin.prototype.stopMove = function()
{
	if(!this.moving)
		return;
	
	var el = document.getElementById(this.id);
	
	el.style.margin = '0';
	el.style.padding = '0';
	el.style.left = (xMousePos - this.offsetLeft)+"px";
	el.style.top  = (yMousePos - 10)+"px";
}

msgWin.prototype.stopMoving = function()
{
	this.moving = 0;
	
	document.getElementById(this.id).style.zIndex = 1;
	
	return;
}

