/***************************************************************************************///alert panel, like alert, disable all the element
function alertPanel(id){
this.backDiv=document.createElement('DIV');
//function called when click ok/cancel
this.funcOk=false;
this.funcCancel=false;
//resize
this.sw=1;
this.sh=1;
this.w=0;
this.h=0;
this.fw=300;
this.fh=200;
this.ft=100;
this.opened=false;
this.openedh=false;//opened by hangUp, can't close when press esc
this.backDiv.style.cssText='filter:alpha(opacity=4);'+
'-moz-opacity:0.04;'+
'opacity:0.04;'+
'background-color:#000000;';
document.body.appendChild(this.backDiv);
this.backDiv.style.display='none';
this.backDiv.style.position='absolute';
this.backDiv.style.zIndex=999;
this.backDiv.style.left='0px';
this.backDiv.style.top='0px';
if(_reportPanel){
this.w=parseInt(_reportPanel.parentDiv.offsetLeft+_reportPanel.parentDiv.offsetWidth)+(document.all?10:0);
this.h=parseInt(_reportPanel.parentDiv.offsetTop+_reportPanel.parentDiv.offsetHeight);
}else{
this.w=parseInt(window.screen.width);
this.h=parseInt(window.screen.height);
}
this.backDiv.style.width=this.w+'px';
this.backDiv.style.height=this.h+'px';
this.foreDiv=document.createElement('DIV');
document.body.appendChild(this.foreDiv);
this.foreDiv.style.display='none';
this.foreDiv.style.position='absolute';
this.foreDiv.style.zIndex=999;
this.foreDiv.style.background='buttonface';
this.foreDiv.style.border="2px outset #000000";
this.foreDiv.style.overflowX="auto";
this.messageDiv=document.createElement('DIV');
this.messageDiv.style.paddingTop='10px';
this.messageDiv.style.overflowX="auto";
this.messageDiv.style.overflowY="auto";
this.buttonDiv=document.createElement('DIV');
this.buttonDiv.style.textAlign='center';
this.foreDiv.appendChild(this.messageDiv);
this.foreDiv.appendChild(this.buttonDiv);
this.buttonOk=document.createElement('INPUT');
this.buttonOk.type='BUTTON';
this.buttonOk.onclick=onClickAlertPanelOk;
this.buttonOk.value='OK';
this.buttonOk.style.marginTop='-6px';
this.buttonCancel=document.createElement('INPUT');
this.buttonCancel.type='BUTTON';
this.buttonCancel.onclick=onClickAlertPanelCancel;
this.buttonCancel.value='CANCEL';
this.buttonCancel.style.marginTop='-6px';
this.sline=document.createElement('HR');
this.buttonDiv.appendChild(this.sline);
this.buttonDiv.appendChild(this.buttonOk);
this.buttonDiv.appendChild(this.buttonCancel);
this.buttonCancel.style.display='none';
this.showButtonCancel=function(){
this.buttonCancel.style.display='inline';
}
this.hideButtonCancel=function(){
this.buttonCancel.style.display='none';
}
this.disableButtonOk=function(){
this.buttonOk.disabled=true;
}
this.activeButtonOk=function(){
this.buttonOk.disabled=false;
}
this.onKeyDownEsc=function(){
if(!this.openedh){
this.onClickCancel();
}
}
this.setFuncOk=function(func){
this.funcOk=func;
}
this.setFuncCancel=function(func){
this.funcCancel=func;
}
this.onClickOk=function(){
if(this.funcOk){
if(typeof(funcOk)=='function'){
this.funcOk();
}else{
eval(this.funcOk);
}
}
this.close();
}
this.onClickCancel=function(){
if(this.funcCancel){
if(typeof(funcCancel)=='function'){
this.funcCancel();
}else{
eval(this.funcCancel);
}
}
this.close();
}
this.hideButtonDiv=function(){
this.buttonDiv.style.display='none';
this.resetSize();
}
this.showButtonDiv=function(){
this.buttonDiv.style.display='block';
this.resetSize();
}
//resize
this.setS=function(ssw,ssh){
this.sw=ssw?ssw:1;
this.sh=ssh?ssh:1;
}
this.resetSize=function(){
var rsw=this.sw?this.sw:1;
var rsh=this.sh?this.sh:1;
var fw=this.fw*rsw;
var fh=this.fh*rsh;
this.foreDiv.style.left=(this.w/2-fw/2)+'px';
this.foreDiv.style.top=(this.h/2-fh/2-this.ft)+'px';
this.foreDiv.style.width=fw+'px';
this.foreDiv.style.height=fh+'px';
this.messageDiv.style.width=fw+'px';
this.messageDiv.style.height=(fh-(this.buttonDiv.style.display=='none'?20:45))+'px';
}
this.resizeWidth=function(){
//this.messageDiv.style.width=(parseInt(this.messageDiv.scrollWidth)+1)+'px';
//this.foreDiv.style.width=(parseInt(this.foreDiv.scrollWidth)+1)+'px';
}
this.open=function(){
this.resetSize();
this.backDiv.style.display='block';
this.foreDiv.style.display='block';
if(this.buttonOk.disabled==false && this.buttonDiv.style.display!='none')this.buttonOk.focus();
disableSelectS();
this.resizeWidth();
this.setFuncOk(false);
this.setFuncCancel(false);
}
this.close=function(){
this.backDiv.style.display='none';
this.foreDiv.style.display='none';
//some times, message is a div element. can not clear here for confirm used setTimeout
//this.setMessage('');
activeSelectS();
this.opened=false;
this.openedh=false;
this.setS(1,1);
this.showButtonDiv();
}
this.isHtmlString=function(s){
var reg=/[<>]/;
return reg.test(s);
}
this.tranString=function(s){
return this.isHtmlString(s)?s:('<span style="background:yellow;">'+s+'</span>');
}
this.setMessage=function(s){
this.messageDiv.innerHTML=this.tranString(s);
}
this.appendMessage=function(s){
this.messageDiv.innerHTML+='<br/>'+this.tranString(s);
}
//simple alert
this.alertMessage=function(s){
this.activeButtonOk();
this.hideButtonCancel();
if(this.opened){
this.appendMessage(s);
this.resizeWidth();
return true;
}else{
this.setMessage(s);
this.opened=true;
this.open();
}
}
//hang up a message wait for server addScript to close it
this.hangUpMessage=function(s){
this.opened=false;
this.hideButtonCancel();
this.disableButtonOk();
if(this.openedh){
this.appendMessage(s);
this.resizeWidth();
return true;
}else{
this.setMessage(s);
this.openedh=true;
this.open();
}
}
}
function onClickAlertPanelOk(){
if(_alertPanel)with(_alertPanel){
onClickOk();
}
}
function onClickAlertPanelCancel(){
if(_alertPanel)with(_alertPanel){
onClickCancel();
}
}
function setAlertS(sasw,sash){
if(_alertPanel)with(_alertPanel){
setS(sasw,sash);
}
}
function myAlert(s){
if(_alertPanel)with(_alertPanel){
alertMessage(s);
}
}
function hangMsg(s){
msgBox2(s);
if(_alertPanel)with(_alertPanel){
setS(1,0.3);
hideButtonDiv();
hangUpMessage(s);
}
}
function hangClose(){
if(_alertPanel)with(_alertPanel){
close();
}
}
//Because fok will be translated to string, all the variable can not be local, must be global.
//or get from global function
function myConfirm(msg,fok,fcancel){
//not very well. myconfirm use the same alertPanel with myalert
//so we need setTimout to wait
var jsok='f='+fok+';'
+'f2=function(){'
+' if(!_alertPanel.opened&&!_alertPanel.openedh){'
+' f();'
+' }else{'
+' setTimeout("f2()",100);'
+' }'
+'};'
+'f2();';
var jscancel='f='+fcancel+';'
+'f2=function(){'
+' if(!_alertPanel.opened&&!_alertPanel.openedh)'
+' f();'
+' else'
+' setTimeout("f2()",100);'
+'};'
+'f2();';
//debug2(jsok);
//debug2(jscancel);
if(_alertPanel)with(_alertPanel){
activeButtonOk();
showButtonCancel();
opened=true;
open();
setFuncOk(jsok);
setFuncCancel(jscancel);
setMessage(msg);
}
}
//for ie's bug: select 's z-index
function disableSelectS(){
var ss=document.getElementsByTagName('SELECT');
var i,ssl=ss.length;
for(i=0;i<ssl;i++){
ss[i].disabled=true;
}
}
function activeSelectS(){
var ss=document.getElementsByTagName('SELECT');
var i,ssl=ss.length;
for(i=0;i<ssl;i++){
ss[i].disabled=false;
}
}