<!--

function messageBox(OBJNAME)
{
	var tmp;

	this.show = messageBox_show;
	this.hide = messageBox_hide;
	this.escape_key = messageBox_escapeKeyPress;
	this.getDiv = messageBox_getDiv;
	this.alpha = messageBox_setAlpha;
	this.prepare_str = messageBox_prepareStr;
	this.set_pos = messageBox_setPosition;
	this.prepare_msg = messageBox_prepareMsg;
	this.write_div = messageBox_writeDiv;

	this.OBJNAME = OBJNAME;
	this.str = "";
	this.msgIdent = "AH5ghDF57OpLM7";
	this.nav = (document.all)? "ie" : ((document.layers)? "ns4" : "ns" ) ;
	this.nav_ver = 0;
	this.posX = 0;
	this.posY = 0;
	this.objID = "";

	//this.onmousePos ={"x" : "XmousePosition", "y" : "YmousePosition"};
	this.onmousePos = false;
	
	this.configBox = [220, 100];
	this.btn_className = "inputt";
	this.msg_className = "tabelaopis";
	this.style = {
		"padding" : "10",
		"background" : "#e6ece6",
		"border" : "1 solid #acb8ac"
	};
		
	this.IE_filter = 'filter:progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=0.1);';

	if(this.nav == "ie")
	{
		tmp = ''+navigator.appVersion.match(/MSIE [0-9\.]+/i);
		this.nav_ver = parseFloat(tmp.substring(5,8));
	}

	document.write(this.write_div());
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

function messageBox_writeDiv()
{
	var tmp = "";
	var bg = (this.style.background.indexOf("#") != -1)? "background-color:"+this.style.background+";" : "background-image:url('"+this.style.background+"');" ;

	tmp = '<div id="'+this.msgIdent+'" style="position:absolute; left:0; top:0; visibility:hidden; padding:'+this.style.padding+'; '+bg+' ';
	tmp += 'border:'+this.style.border+'; width:'+this.configBox[0]+'; height:'+this.configBox[1]+';'+this.IE_filter+'"></div>';

	return tmp;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

function messageBox_getDiv()
{
	if(this.nav == "ie")
		this.objID = document.all[this.msgIdent].style;

	if(this.nav == "ns4")
		this.objID = document.layers[this.msgIdent];

	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")
		document.all[this.msgIdent].innerHTML = this.prepare_msg(tmp);

	if(this.nav == "ns")
		document.getElementById(this.msgIdent).innerHTML = this.prepare_msg(tmp);

	if(this.nav == "ns4")
	{
		document.layers[this.msgIdent].document.open();
		document.layers[this.msgIdent].document.write(this.prepare_msg(tmp));
		document.layers[this.msgIdent].document.close();
	}

	this.objID.visibility = "visible";

	if(this.nav == "ie")
		eval("document.forms['"+this.msgIdent+"_form'].btn_ok.focus()");
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

function messageBox_prepareMsg(obj)
{
	var tmp = "";
	var tmp_ok = "";
	var tmp_cancel = "";
	
	if(obj.length > 1)
	{
		onclick = (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()">';
	}
	else
		tmp_ok = '<input type="button" name="btn_ok" value=" OK " class="'+this.btn_className+'" onclick="'+this.OBJNAME+'.hide()">';	

	tmp = '<table border="0" width="'+(this.configBox[0] - (this.style.padding*2))+'" height="'+(this.configBox[1] - (this.style.padding*2))+'">';
	tmp += '<tr><td align="center" valign="top" class="'+this.msg_className+'">'+this.prepare_str(obj[0])+'</td></tr>';
	tmp += '<tr><td><form name="'+this.msgIdent+'_form"></td></tr>';
	tmp += '<tr><td align="center" valign="bottom" class="'+this.msg_className+'">'+tmp_ok+''+tmp_cancel+'</td></tr>';
	tmp += '<tr><td></form></td></tr></table>';

	return tmp;
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

function messageBox_hide()
{
	if(this.nav == "ie" && this.nav_ver >= 5.5)
		this.alpha(this.OBJNAME);
	else
		this.objID.visibility = "hidden";
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_setAlpha(o)
{
	document.all[this.msgIdent].filters[0].Apply();
	document.all[this.msgIdent].style.visibility="hidden";
	document.all[this.msgIdent].filters[0].Play();
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_escapeKeyPress(e)
{
	var key = (document.layers == "ns4")? e.which : event.keyCode ;

	if(key == 27)
	{
		eval(this.msgIdent+"_form.btn_cancel.focus()");
		this.hide();
	}
}

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function messageBox_setPosition()
{
	this.posX = 0;
	this.posY = 0;

	if(this.onmousePos)
	{
		this.posX = eval(this.onmousePos.x) - (this.configBox[0] / 2);
		this.posY = eval(this.onmousePos.y) - (this.configBox[1] / 2);
	}
	else
	{
		if(this.nav == "ie" || this.nav == "ns")
		{
			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);
		}
	
		if(this.nav == "ns4")
		{
			this.posX = document.body.scrollLeft + (document.body.innerWidth / 2 - this.configBox[0] / 2);
			this.posY = document.body.scrollTop + (document.body.innerHeight / 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);
}

//-->

