var MsgBox_Style = {Critical:16, Information:64, Exclamation:49, Question:36};
var MsgBox_Button = {OK:1, Cancel:2, Abort:3, Retry:4, Ignore:5, Yes:6, No:7};
var MsgBox_Container;

function MsgBox_UpdateAttributes(strID, msgboxstyle, msgboxtitle, msgboxtext, commandname){
	var oContainer = document.getElementById(strID);
	
	if (oContainer != null){
	  oContainer.setAttribute('msgboxstyle', msgboxstyle);
	  oContainer.setAttribute('msgboxtitle', msgboxtitle);
	  oContainer.setAttribute('msgboxtext', msgboxtext);
	  oContainer.setAttribute('commandanme', commandname);
	}
}

function MsgBox_ShowDialog(containerID){
	
	MsgBox_Container = document.getElementById(containerID);
	
	if (MsgBox_Container != null){
		var res = false;
		if (navigator.appName.indexOf('Microsoft')>-1)
			res = MessageBox(MsgBox_Container.msgboxtext, MsgBox_Container.msgboxstyle, MsgBox_Container.msgboxtitle);
		else
			res = confirm(MsgBox_Container.attributes['msgboxtext'].value, MsgBox_Container.attributes['msgboxstyle'].value, MsgBox_Container.attributes['msgboxtitle'].value);

    return res;
	}
	return false;
}

function MsgBox_ShowClientOnlyDialog(containerID){
  var res = MsgBox_ShowDialog(containerID);
  if (res == MsgBox_Button.Yes || res == true) return true;
  return false;
}

function MsgBox_ShowPostbackDialog(containerID){
    var res = MsgBox_ShowDialog(containerID);

    if ((res != MsgBox_Button.No) && (res !== MsgBox_Button.OK) && (res != false)) {
     
      var commandname = MsgBox_Container.getAttribute('commandanme');
      if (commandname == null) commandname = '';
    
      var pbr = MsgBox_Container.attributes['postbackeventreference'].value;
		  pbr = pbr.substring(0, pbr.length-4);
		  pbr += ", '" + commandname+'|'+res + "')";
			eval(pbr);
      return true;
    }
    
    return false;
}

function MsgBox_ShowCallbackDialog(msgboxID, containerID){
  var res = MsgBox_ShowDialog(containerID);

  if (res == MsgBox_Button.Yes || res == true) {
    var commandname = MsgBox_Container.getAttribute('commandanme');
    if (commandname == null) commandname = '';
    MsgBox_CallServer(msgboxID, commandname+'|'+res);
    return true;
  }
  
  return false;
}
// =================================================================================================================
function MsgBoxShow(strID){
	//var oContainer = document.all[strID];
	var oContainer = document.getElementById(strID);
	
	if (oContainer != null){
	
		// Style
		var Critical = 16;
		var Information = 64;
		var Exclamation = 49;
		var Question = 36;
	    
		// Buttons
		var OK = 1;
		var Cancel = 2;
		var Abort = 3;
		var Retry = 4;
		var Ignore = 5;
		var Yes = 6;
		var No = 7;

		var res;
		if (navigator.appName.indexOf('Microsoft')>-1)
			res = MessageBox(oContainer.msgboxtext, oContainer.msgboxstyle, oContainer.msgboxtitle);
		else
			res = confirm(oContainer.attributes['msgboxtext'].value, oContainer.attributes['msgboxstyle'].value, oContainer.attributes['msgboxtitle'].value);
		//var res = MessageBox(oContainer.msgboxtext, oContainer.msgboxstyle, oContainer.msgboxtitle);
		//alert(oContainer.attributes['msgboxstyle'].value);
		
		

		//var pbr = oContainer.postbackeventreference;
		var pbr = oContainer.attributes['postbackeventreference'].value;
		pbr = pbr.substring(0, pbr.length-4);
		pbr += ", " + res + ")";
		
		eval(pbr);
		
/*		switch(oContainer.msgboxstyle*1){
			case Exclamation :
				if(res == OK) eval(oContainer.postbackeventreference);
				break;
			case Question :
				if(res == Yes) eval(oContainer.postbackeventreference);
				break;
			default :
				eval(oContainer.postbackeventreference);
		}*/
	}
}
// =================================================================================================================