<!--

function messageBox(OBJNAME)
{
	var tmp;

	this.show = messageBox_show;
	this.hide = messageBox_hide;
	this.escape_key = messageBox_escapeKeyPress;
	this.getDiv = messageBox_getDiv;
	this.prepare_str = messageBox_prepareStr;
	this.set_pos = messageBox_setPosition;
	this.prepare_msg = messageBox_prepareMsg;
	this.prepare_bg = messageBox_prepareBackground;
	this.write_div = messageBox_writeDiv;
	this.set_css = messageBox_setCss;

	this.OBJNAME = OBJNAME;
	this.str = "";
	this.msgIdent = "AH5ghDF57OpLM7";
	this.nav = (document.all)? ((navigator.userAgent.indexOf("Opera") != -1)? "op" : "ie") : "ns" ;
	
	this.nav_ver = 0;
	this.posX = 0;
	this.posY = 0;
	this.objID = "";
	this.buttons = 0;

	this.onmousePos = false;

	this.configBox = [220, 120];
	this.btn_className = "formButton";
	this.text_className = "";
	this.style = {
		"padding" : "10",
		"background" : "#eeeeee",
		"border" : "1px solid #000000"
	};

	this.ieFilter = false;

	document.write(this.write_div());
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_writeDiv()
{
	var tmp = "";

	tmp += '<div id="'+this.msgIdent+'" style="position:absolute; left:0; top:0; visibility:hidden; padding:'+this.style.padding+'; ';
	tmp += 'border:'+this.style.border+'; width:'+this.configBox[0]+'; height:'+this.configBox[1]+';z-index:11;"></div>';

	return tmp;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_getDiv()
{
	if(this.nav == "ie")
		this.objID = document.all[this.msgIdent].style;

	if(this.nav == "ns")
		this.objID = document.getElementById(this.msgIdent).style;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_show()
{
	this.getDiv();
	this.set_pos();

	var tmp = messageBox_show.arguments;

	if(this.nav == "ie" || this.nav == "op")
		document.all[this.msgIdent].innerHTML = this.prepare_msg(tmp);

	if(this.nav == "ns")
		document.getElementById(this.msgIdent).innerHTML = this.prepare_msg(tmp);

	this.set_css();

	this.objID.visibility = "visible";

	if(this.nav == "ie" || this.nav == "op")
		eval("document.forms['"+this.msgIdent+"_form'].btn_ok.focus()");
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_setCss()
{
	this.objID.padding = this.style.padding;
	this.objID.border = this.style.border;

	this.objID.background = ""+this.prepare_bg(this.style.background)+"";
	this.objID.width = this.configBox[0];
	this.objID.height = this.configBox[1];

	if(this.ieFilter && this.nav == "ie")
	{
		this.objID.background = "transparent";
		this.objID.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+this.style.background+"', sizingMethod='crop')";
	}
	else
		this.objID.background = ""+this.prepare_bg(this.style.background)+"";
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_prepareBackground(bg)
{
	return (bg.indexOf("#") != -1)? bg : "url('"+bg+"')";
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_prepareMsg(obj)
{
	var tmp = "";
	var tmp_ok = "";
	var tmp_cancel = "";

	this.buttons = 1;

	if(obj.length > 1)
	{
		onclick = this.OBJNAME+".hide();"+((obj[1].indexOf("javascript:") == -1)? 'location.href=\''+obj[1]+'\'' : obj[1].substring(3) ) ;

		tmp_ok = '<input type="button" name="btn_ok" value=" Ok " onkeypress="'+this.OBJNAME+'.escape_key()" class="'+this.btn_className+'" onclick="'+onclick+'">';
		tmp_cancel = '&nbsp;<input type="button" name="btn_cancel" value=" Cancel " class="'+this.btn_className+'" onclick="'+this.OBJNAME+'.hide()">';

		this.buttons = 2;
	}
	else
		tmp_ok = '<input type="button" name="btn_ok" value=" OK " onkeypress="'+this.OBJNAME+'.escape_key()" class="'+this.btn_className+'" onclick="'+this.OBJNAME+'.hide()">';

	tmp = '<form name="'+this.msgIdent+'_form" style="margin:0;">';
	tmp += '<table border="0" align="center" width="'+(this.configBox[0] - (this.style.padding*2))+'" ';
	tmp += 'height="'+(this.configBox[1] - (this.style.padding*2))+'">';
	tmp += '<tr><td align="center" valign="top" class="'+this.text_className+'">'+this.prepare_str(obj[0])+'</td></tr>';
	tmp += '<tr><td height="10" align="center" valign="bottom" class="'+this.text_className+'"></td></tr>';
	tmp += '<tr><td height="1" align="center" valign="bottom" class="'+this.text_className+'">'+tmp_ok+''+tmp_cancel+'</td></tr>';
	tmp += '<tr></table></form>';

	return tmp;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_hide()
{
	this.objID.visibility = "hidden";
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_escapeKeyPress(e)
{
	var key = (this.nav == "ie")? event.keyCode : e.which ;

	if(key == 27)
	{
		if(this.buttons == 2)
			eval(this.msgIdent+"_form.btn_cancel.focus()");
		else
			eval(this.msgIdent+"_form.btn_ok.focus()");

		this.hide();
	}
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_setPosition()
{
	this.posX = 0;
	this.posY = 0;

	if(this.onmousePos && typeof(XmousePosition) != "undefined" && typeof(YmousePosition) != "undefined")
	{
		this.posX = XmousePosition - (this.configBox[0] / 2);
		this.posY = YmousePosition - (this.configBox[1] / 2);
	}
	else
	{
		this.posX = document.body.scrollLeft + (document.body.clientWidth / 2 - this.configBox[0] / 2);
		this.posY = document.body.scrollTop + (document.body.clientHeight / 2 - this.configBox[1] / 2);
	}

	this.objID.left = this.posX;
	this.objID.top = this.posY;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_prepareStr(str)
{
    var rc="";
	var j;
	var ch;

    for (j=0;j<str.length;j++)
    {
        ch=str.charAt(j);

		switch(ch)
		{
    	    case '¹': ch="±"
			break;
			case 'œ': ch="¶"
			break;
			case 'Ÿ': ch="¼"
			break;
			case '¥': ch="¡"
			break;
			case 'Œ': ch="¦"
			break;
			case '': ch="¬"
			break;
		}
        rc=rc+ch;
    }
	return(rc);
}

//-->
