//*** Copyright 2009 by Burt Petrescue. Used with permission
/*
required
 images: waiting.gif
 js: inc_commonjs.js, inc_border.js
 declares:
  domnshow
  g_so
  g_hs
  g_ur
  g_cr
contactus.asp
*/

preloadlist('vgfx/waiting.gif');

var msgbox_width,titlebgcolor,dobgfade=true,titlecolor_opt;
var msgbox_styles=new Array();//2nd dimension: msgbox_width, titlebgcolor, fadebg, titlecolor_opt
msgbox_styles[0]=[500,'#FFC809',true,null];//default style - modal dialog// #FFC809 //#CCFF00
msgbox_styles[1]=[500,'#FFC809',false,null];//same as above but non-modal
msgbox_styles[2]=[500,'#FFC809',true,'#000'];//used to be #009DDE - for non-alert blue message
msgbox_styles[3]=[650,'#FFC809',true,null];//like the default style but extra-wide
msgbox_loadstyle(0);

var msgbox_buttonlist = Array('Ok','Continue','Cancel','Yes','No','Close');
var msgbox_b_ok=0, msgbox_b_continue=1, msgbox_b_cancel=2, msgbox_b_yes=3, msgbox_b_no=4, msgbox_b_close=5;

//var showhelppane=false;
var thisbid=0;

var mbsid=0;//msgbox_stackid - 1 Based, not 0 Based!!! 0 is reserved for the fader div on some arrays
var mbsmaxstack=5;
var msgbox_bid=new Array(-1,-1,-1,-1,-1,-1);
var msgbox_callback=new Array('','','','','','');
var msgbox_typeid=new Array(0,0,0,0,0,0);
var closeonclick=new Array(true,true,true,true,true,true);
var msgbox_lastx=new Array(0,0,0,0,0,0);
var msgbox_lasty=new Array(0,0,0,0,0,0);
var lastmsgboxwindowtitle=new Array('','','','','','');
var msgbox_currentid=new Array(0,0,0,0,0,0);
var referenceobj=new Array();
//var currentehelpswitchid=new Array(0,0,0,0,0,0);
var mb_obj=new Array(1,1,1,1,1,1);//left off - change arrays to mbfaderdiv,mbdiv
var mb_interval=new Array();
var mb_fadecount=new Array(0,0,0,0,0,0);
var mb_opacityfctr=new Array(.5,1,1,1,1,1);
var mb_fadestep=new Array(20,20,20,20,20,20);
var msgboxisopen=new Array(false,false,false,false,false,false);

/*var switchid_1=1;
var switchid_2=2;
var switchid_3=4;
var switchid_4=8;
var switchid_5=16;
var switchid_6=32;
var switchid_7=64;*/

var pane_updatems=30;
var pane_anchor_point=new Array(0,0);
var pane_fm_addx=10,pane_fm_addy=0;
var pane_max=5;

var pane_div=new Array(null,null,null,null,null,null);
var pane_content=new Array(null,null,null,null,null,null);
var pane_current_positioning=new Array('','','','','','');
var pane_current_anchor_rect=new Array([0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]);//x,y,width,height
var pane_rect=new Array([0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]);//x,y,width,height
var pane_current_anchor_id=new Array('','','','','','');
var pane_status=new Array('closed','closed','closed','closed','closed','closed');
var pane_delaymouseout=new Array(0,0,0,0,0,0);

var doinstantfade=false;

getWindowSize();
getScrollXY();
addloadcommand('msgbox_outputdivs()');
addloadcommand('msgbox_init()');

var currentstyleid=0;
function msgbox_loadstyle(id){
 msgbox_width=msgbox_styles[id][0];
 titlebgcolor=msgbox_styles[id][1];
 dobgfade=msgbox_styles[id][2];
 titlecolor_opt=msgbox_styles[id][3];
 currentstyleid=id;
}
function msgbox_outputdivs(){
 var msgboxhtml='';
 for (var i=1;i<=mbsmaxstack;i++){
  msgboxhtml+='<div id="msgboxdiv'+i+'" name="msgboxdiv'+i+'" style="width:'+msgbox_width+';display:none;position:absolute;"></div>';
 } 
 msgboxhtml='<div id="msgboxfaderdiv" name="msgboxfaderdiv" style="display:none;position:absolute;background:#999999;"></div>'+msgboxhtml;
	msgboxhtml='<div id="showmediv1000" name="showmediv1000" style="display:none;position:absolute;"></div>'+msgboxhtml;
 appendhtml(msgboxhtml);
}
function msgbox_init(){
 mb_obj[0]=getobj('msgboxfaderdiv');
 for (var i=1;i<=mbsmaxstack;i++){
  mb_obj[i]=getobj('msgboxdiv'+i);
 }
}
function getlastknownmbsid(){
 var thismbsid=mbsmaxstack;
 for (var i=mbsmaxstack;i>=1;i--){
  if (msgboxisopen[i]){
   thismbsid=i;
   break;
  }
 }
 return thismbsid;
}
function setavailablembsid(){//sets mbsid to the next available spot
 mbsid=1;
 for (var i=1;i<=mbsmaxstack;i++){
  if (!msgboxisopen[i]){
   mbsid=i;
   break;
  }
 }
}
function msgboxesareopen(){
 for (var i=mbsmaxstack;i>=1;i--){
  if (msgboxisopen[i])
   return true;
 }
 return false;
}

function msgbox_destroy(id){
 hideobj(mb_obj[id]);
 setopacity(mb_obj[id],0);
 clearInterval(mb_interval[id]);
 changetext(mb_obj[id],'');
 if (id>=1){
  msgboxisopen[id]=false;
  mbsid=getlastknownmbsid();
  if (!msgboxesareopen())
   mb_fadeboxout(0);//fade out background now that all msgboxes are invisible
 }
 if (!msgboxesareopen())
  togglecontenttohide(1);
}

function mb_fadeboxin(id,thisfadevalue){
 if (!msgboxisopen[(id==0)?1:id]) return;
 if(bd_w3c){
  clearInterval(mb_interval[id]);
  if (thisfadevalue==null)
   mb_fadecount[id]=0;
  else
   mb_fadecount[id]=thisfadevalue/mb_opacityfctr[id];
  if (dobgfade && !bd_opera){
   if (dofx((id==0)?1:0)){
    setopacity(mb_obj[id],mb_fadecount[id]*mb_opacityfctr[id]);
    showobj(mb_obj[id]);
    mb_interval[id]=setInterval('mb_sub_fadein('+id+')',15);
    getspeeddiff();
   } else {
    setopacity(mb_obj[id],100*mb_opacityfctr[id]);
    showobj(mb_obj[id]);
    if (id>=1)//fade in background now that msgbox is visible
     mb_fadeboxin(0,100);
   }
  } else {
   setopacity(mb_obj[id],100);
   showobj(mb_obj[id]);
  }
 }
}
function mb_fadeboxout(id){
 var thisfadevalue=getopacity(mb_obj[id]);
 if(bd_w3c){
  clearInterval(mb_interval[id]);
  if (doinstantfade || !dofx((id==0)?1:0)){
   msgbox_destroy(id);
  } else {
   if (thisfadevalue==null)
    mb_fadecount[id]=100;
   else
    mb_fadecount[id]=thisfadevalue/mb_opacityfctr[id];
   setopacity(mb_obj[id],mb_fadecount[id]*mb_opacityfctr[id]);
   showobj(mb_obj[id]);
   if (dofx((id==0)?1:0)){
    mb_interval[id]=setInterval('mb_sub_fadeout('+id+')',15);
    getspeeddiff();
   } else {
    msgbox_destroy(id);
   }
  }
 }
}
function mb_sub_fadein(id){
 if (!msgboxisopen[(id==0)?1:id]) return;
 mb_fadecount[id]=mb_fadecount[id]>100-mb_fadestep[id]*.7?100:mb_fadecount[id]+mb_fadestep[id]*.7;
 setopacity(mb_obj[id],mb_fadecount[id]*mb_opacityfctr[id])
 if(mb_fadecount[id]>=99){
  showobj(mb_obj[id]);
  clearInterval(mb_interval[id]);
  handlespeeddiff(2000,(id==0)?1:0);
  if (id>=1){//fade in background now that msgbox is visible
   clearInterval(mb_interval[0]);
   mb_fadeboxin(0,getopacity(mb_obj[0]));
  }
 }
}
function mb_sub_fadeout(id){
 mb_fadecount[id]=mb_fadecount[id]<0-mb_fadestep[id]?0:mb_fadecount[id]-mb_fadestep[id];
 setopacity(mb_obj[id],mb_fadecount[id]*mb_opacityfctr[id]);
 if(mb_fadecount[id]<=0){
  handlespeeddiff(2000,(id==0)?1:0);
  msgbox_destroy(id);
 }
}


function msgbox_clickedbutton(bid,this_mbsid){
 this_mbsid=(this_mbsid==null)?mbsid:this_mbsid;
 thisbid=bid;//defined for callback ease of use
 if (lastfocusedobj){
// alert(lastfocusedobj.id);//left off
  lastfocusedobj.focus();//set focus here just in case the callback sets it elsewhere
 }
 msgbox_bid[this_mbsid]=thisbid;
 safeeval(msgbox_callback[this_mbsid]);
 if (closeonclick[this_mbsid]){
/*  if (document.msgboxform){
   if (document.msgboxform.optout.checked && currentehelpswitchid[this_mbsid]>0){
    sethelpswitch(currentehelpswitchid[this_mbsid]);
   }
  }*/
  msgbox_close(this_mbsid);
//  currentehelpswitchid[this_mbsid]=0;
//  mb_fadeboxout(this_mbsid);
 }
}
function msgbox_close(this_mbsid,thisid){
 if (this_mbsid==null)
  this_mbsid=mbsid;
 if (thisid!=null){
  if (thisid!=msgbox_currentid[this_mbsid])
   return;
 }
// currentehelpswitchid[this_mbsid]=0;
 mb_fadeboxout(this_mbsid);
 if (!msgboxesareopen())
  togglecontenttohide(1);
}
function msgbox_closeall(){
 msgbox_closetype(0);
}
function msgbox_assigntype(typeid){
 msgbox_typeid[mbsid]=typeid;
}
function msgbox_closetype(typeid){
 doinstantfade=true;
 for (var i=0;i<=mbsmaxstack;i++){
  if (msgbox_typeid[i]==typeid){
   msgbox_close(i);
  }
 }
 doinstantfade=false;
}
function msgbox_doresize(){
 getWindowSize();// gets windowWidth and windowHeight
 getScrollXY();
 var minx=scrollOffsetX;
 var maxx=windowWidth+scrollOffsetX;
 var miny=scrollOffsetY;
 var maxy=windowHeight+scrollOffsetY;
 var docwidth=getpagewidth();
 var docheight=getpageheight();
 if (docheight<windowHeight)
  docheight=document.body.height=windowHeight;
 
 moveit(mb_obj[0],0,0);
 mb_obj[0].style.width=docwidth+'px';
 mb_obj[0].style.height=docheight+'px';
 
 
 for (var i=1;i<=mbsid;i++){
  var msgboxdivwidth=getwidth(mb_obj[i]);
  var msgboxdivheight=getheight(mb_obj[i]);
  var x=(maxx-minx)/2+minx-msgboxdivwidth/2;
  var y=(maxy-miny)/2+miny-msgboxdivheight/2;
  if (referenceobj[i]!=null){
   var pos=findpos(referenceobj[i]);
   x=pos[0]+10;
   y=pos[1]+getheight(referenceobj[i]);
  }
  if ((x+msgboxdivwidth)>=maxx)
   x=maxx-msgboxdivwidth-20;
  if ((y+msgboxdivheight)>=maxy)
   y=maxy-msgboxdivheight-20;
  if (x<minx)
   x=minx;
  if (y<miny)
   y=miny;
  if (msgbox_lastx[i]!=x || msgbox_lasty[i]!=y){
   moveit(mb_obj[i],x,y);
   msgbox_lastx[i]=x;
   msgbox_lasty[i]=y;
  }
 } 
 
}
function mbover(what){
 var obj=what.firstChild;
 obj.style.backgroundColor='#EEEEEE';
 obj.style.borderWidth='2 1px 1px 2';
}
function mbout(what){
 var obj=what.firstChild;
 obj.style.backgroundColor='#D4D4DF';
 obj.style.borderWidth='0 3px 3px 0';
}

function msgbox_setcloseonclick(b){
 closeonclick[mbsid]=b;
}

function msgbox_settitle(x){
 var obj=getobj('msgbox_title_txt'+mbsid);
 if (obj==null) return;
 changetext(obj,x);
}








function msgbox_open(rawhtml,windowtitle,buttonset,callingobj,callback,helpswitch){
 var html=striptag(striptag(rawhtml,'script'),'inlinescript'); //first strip the html of some tags
 
 setavailablembsid();//sets mbsid to next available on stack
 mb_obj[mbsid].style.width=msgbox_width+'px';
// currentehelpswitchid[mbsid]=0;
 msgbox_typeid[mbsid]=0;
 windowtitle=(windowtitle==null?domnshow:windowtitle);
/* if (helpswitch!=null){
  if (!gethelpswitch(helpswitch) && helpswitch!=switchid_7){//quick solution for switchid_7
   mb_fadeboxout(mbsid);
   thisbid=msgbox_b_continue;//defined for callback ease of use
   msgbox_bid[mbsid]=thisbid;
   safeeval(callback);
   return;
  }
  currentehelpswitchid[mbsid]=helpswitch;
 }*/
 msgbox_currentid[mbsid]++;
 closeonclick[mbsid]=true;
 window.focus(); 
 var oldopacity=getopacity(mb_obj[mbsid])
 msgboxisopen[mbsid]=true;
 //window.onresize=msgbox_doresize;
 //window.onscroll=msgbox_doresize;
 referenceobj[mbsid]=callingobj;
 msgbox_callback[mbsid]=(callback==null?'':callback);
 msgbox_bid[mbsid]=-1;
 if (!buttonset||buttonset==null) buttonset=1;
 function addbutton(bsrc){
  var bid,btitle;
  if (typeof bsrc=='object'){
   bid=bsrc[0];
   btitle=bsrc[1];
  } else {
   bid=bsrc;
   btitle=msgbox_buttonlist[bid];
  }
  return '<div onclick="msgbox_clickedbutton('+bid+','+mbsid+')" onmouseover="mbover(this)" onmouseout="mbout(this)" class=bouter><div class=binner>'+btitle+'</div></div><div class=bpad>&nbsp;</div>'
 }
 //stopflash();
 togglecontenttohide(0);
 getWindowSize();// gets windowWidth and windowHeight
 getScrollXY();
 var minx=scrollOffsetX;
 var maxx=windowWidth+scrollOffsetX;
 var miny=scrollOffsetY;
 var maxy=windowHeight+scrollOffsetY;
 var docwidth=getpagewidth();
 var docheight=getpageheight();
 if (docheight<windowHeight)
  docheight=document.body.height=windowHeight;
 var buttons=''; 
 
 var buttons='';
// if (currentehelpswitchid[mbsid]!=0 && g_so==1)
//  buttons+='<form method=POST name="msgboxform" id="msgboxform"><input type=checkbox class=checkbox_clean value=1 id="optout" style="margin-top:10px;"> Don\'t show this message again.</form>'
 buttons+='<table id=msgbox_btns><tr><td nowrap><div class=bpad>&nbsp;</div>';
 if(typeof buttonset=='string'){
  //format: 104:Button Name 1;105:Button Name 2
  if (buttonset.length>0){
   var barray=buttonset.split(';');
   for (var i=0;i<=barray.length-1;i++){
    var bobj=barray[i].split(':');
    buttons+=addbutton(bobj);
   }
  }
 } else {
  if (buttonset==1){
   buttons+=addbutton(msgbox_b_ok);
  }
  if (buttonset==2){
   buttons+=addbutton(msgbox_b_continue);
  }
  if (buttonset==3){
   buttons+=addbutton(msgbox_b_continue);
   buttons+=addbutton(msgbox_b_cancel);
  }
  if (buttonset==4){
   buttons+=addbutton(msgbox_b_yes);
   buttons+=addbutton(msgbox_b_no);
  }
  if (buttonset==5){
   buttons+=addbutton(msgbox_b_close);
  }
  if (buttonset==6){
   buttons+=addbutton(msgbox_b_cancel);
  }
 }
 buttons+='<div class=clear></div></td></tr></table><div class=onepx></div>';
 var bgcolor=clr_mix('#FFFFFF',titlebgcolor,.1);
 var htmlinner='<div id=msgbox_title style="background-color:'+titlebgcolor+';border-color:'+clr_mix('#FFFFFF',titlebgcolor,.3)+';">'
  + '<div class=sub'+(mt(titlecolor_opt)?'':' style="color:'+titlecolor_opt+'"')+' id="msgbox_title_txt'+mbsid+'">'
  + windowtitle
  + '</div></div>'
  + '<div id=msgbox_title_pin style="background-color:'+bgcolor+';border-color:'+ clr_mix('#000000',titlebgcolor,.8) +';"></div>'
  + '<div id="msgbox_content" style="background-color:'+bgcolor+';"><div class=sub>'
  + html+' '+buttons
  + '</div></div>';
 htmlinner=generateborder(htmlinner,msgbox_width,titlebgcolor,bgcolor,'#404040');
 changetext(mb_obj[mbsid],htmlinner);
 lastmsgboxwindowtitle[mbsid]=windowtitle;
 
 moveit(mb_obj[0],0,0);
 mb_obj[0].style.width=docwidth+'px';
 mb_obj[0].style.height=docheight+'px';
// setopacity(mb_obj[0],oldopacity);
// showobj(mb_obj[0]);
 setopacity(mb_obj[mbsid],oldopacity);
 showobj(mb_obj[mbsid]);
 var msgboxdivwidth=getwidth(mb_obj[mbsid]);
 var msgboxdivheight=getheight(mb_obj[mbsid]);
 
 var x=(maxx-minx)/2+minx-msgboxdivwidth/2;
 var y=(maxy-miny)/2+miny-msgboxdivheight/2;
 if (referenceobj[mbsid]!=null){
  var pos=findpos(referenceobj[mbsid]);
  x=pos[0]+10;
  y=pos[1]+getheight(referenceobj[mbsid]);
 }
 
 if ((x+msgboxdivwidth)>=maxx)
  x=maxx-msgboxdivwidth-20;
 if ((y+msgboxdivheight)>=maxy)
  y=maxy-msgboxdivheight-20;
 if (x<minx)
  x=minx;
 if (y<miny)
  y=miny;
 moveit(mb_obj[mbsid],x,y);
 msgbox_lastx[mbsid]=x;
 msgbox_lasty[mbsid]=y;
// if(oldopacity==0){
//  hideobj(mb_obj[mbsid]);
// }
 if (getlastknownmbsid()==1) bringfront(mb_obj[0]);
 bringfront(mb_obj[mbsid]);
 bringfront(getobj('showmediv1000'));
 mb_fadeboxin(mbsid,oldopacity);
}









function msgbox_dialog_alert(content,callback,title){
 msgbox_open(encapsulate(content),title,1,null,callback);
}
function msgbox_dialog_alert_b3(content,callback,title){
 msgbox_open(encapsulate(content),title,3,null,callback);
}
function msgbox_dialog_ok(content,title,callingobj,callback,helpswitch){//old:(content,callingobj,title,helpswitch,callback)
 msgbox_open(encapsulate(content),title,1,callingobj,callback,helpswitch);
}
function msgbox_dialog_none(content,title,callingobj,callback,helpswitch){
 msgbox_open(encapsulate(content),title,-1,callingobj,callback,helpswitch);
}

/*function msgbox_dialog_close(callingobj,title,content,helpswitch,callback){
 msgbox_open(callingobj,title,encapsulate(content),5,callback,helpswitch);
}
function msgbox_dialog_continue(callingobj,title,content,helpswitch,callback){
 msgbox_open(callingobj,title,encapsulate(content),2,callback,helpswitch);
}
function msgbox_dialog_cancel(callingobj,title,content,helpswitch,callback){
 msgbox_open(callingobj,title,encapsulate(content),6,callback,helpswitch);
}
function myconfirmjs(content,jspos,jsneg,helpswitch,obj){
 var title=domnshow;
 msgbox_open(obj,title,encapsulate(content),4,'msgboxresponsejshandler(\''+jspos+'\',\''+jsneg+'\')',helpswitch);
 return false;
}
*/
function myconfirmurl(content,url,newwindow){
 var title=domnshow;
	if (newwindow==null) newwindow=false;
 msgbox_open(encapsulate(content),title,4,null,'gourlifpositive(\''+url+'\','+newwindow+')');
 return false;
}
function gourlifpositive(url,newwindow){
 if (positiveresponse()){
	 if (newwindow){
 		popupfree(url);
		} else {
   gourl(url);
		}
	}
}
function positiveresponse(){
 return (thisbid==msgbox_b_yes || thisbid==msgbox_b_continue || thisbid==msgbox_b_ok);
}
function msgboxresponsejshandler(jsifpositive,jsifnegative){
 if(positiveresponse())
  safeeval(jsifpositive);
 else
  safeeval(jsifnegative);
}
function encapsulate(c){
 return '<center><table align=center cellpadding=0 cellspacing=0 style="padding:10 8px;"><tr><td class=textblack align=left>'+c+'</td></tr></table></center>';
}

var waitmbsid=0;//used for "waiting on data" msgbox - on close, make sure we close the right one, not always mbsid
function msgbox_waitfordata(callback){
 var content='<img src=/vgfx/waiting.gif width=37 height=37 align=left hspace=10 vspace=5> Please wait while website data is being transferred. This may take up to twenty seconds to process. If it takes longer than twenty seconds then it might indicate that our servers are too busy. Consider clicking the Cancel button and try again after a brief pause.';
 var laststyleid=currentstyleid;
 msgbox_loadstyle(2);
 msgbox_dialog_cancel(null,'Transferring Website Data... (please wait)',content,0,callback);
 msgbox_loadstyle(laststyleid);
 waitmbsid=mbsid;
}
function msgbox_waitforsave(callback){
 var content='<img src=/vgfx/waiting.gif width=37 height=37 align=left hspace=10 vspace=5> Please wait while your changes are being saved. This may take up to twenty seconds to process. If it takes longer than twenty seconds then it might indicate that our servers are too busy. Consider clicking the Cancel button and try again after a brief pause.';
 var laststyleid=currentstyleid;
 msgbox_loadstyle(2);
 msgbox_dialog_cancel(null,'Saving Changes... (please wait)',content,0,callback);
 msgbox_loadstyle(laststyleid);
 waitmbsid=mbsid;
}
function msgbox_closewait(){
 setTimeout('msgbox_close('+waitmbsid+','+msgbox_currentid[waitmbsid]+')',500);
}
function onloadmsg(msg,helpswitch){
 if (mt(helpswitch)) helpswitch=0;
 addloadcommand('msgbox_dialog_ok("'+prepjs(msg)+'",domnshow,null,null,'+helpswitch+')');
}














//********* PANE Initialize
function pane_outputdivs(){
	var html='';
	for (var pid=0;pid<=pane_max;pid++){
	 html+='<div id="pane_div'+pid+'" style="display:none;position:absolute;" onmouseover="pane_mouseoverdiv('+pid+');"></div>';
	}
 appendhtml(html);
}
function pane_writecontentdiv(pid,innerwidth){
 var bgcolor='#EEEEEE';
 var bordercolor='#027DAA';
 var textclass='';
 var htmlinner='<div id="p_pane_content_wrap'+pid+'"><div id="pane_content_wrap'+pid+'" style="overflow:hidden;width:'+innerwidth+'px;height:0px;"><div id="pane_content'+pid+'" class="'+textclass+'" style="text-align:left;background-color:'+bgcolor+';padding-top:2px;"></div></div></div>';
 htmlinner=generateborder(htmlinner,(innerwidth+6),bgcolor,bgcolor,bordercolor);
 changetext('pane_div'+pid,htmlinner);
	pane_content[pid]=getobj('pane_content'+pid);
}
function pane_init(){
	getWindowSize();
	getScrollXY();
	var innerwidth=320;
	for (var pid=0;pid<=pane_max;pid++){
		pane_div[pid]=getobj('pane_div'+pid);
//		pane_writecontentdiv(pid,innerwidth);
	}
 pane_watch();
}
addloadcommand('pane_outputdivs()');
addloadcommand('pane_init()');


//********* PANE Public
function pane_anchor_mousemove(evobj,obj,positioning,this_pane_width){
 if ((pane_div[pane_max]==null)) return;//init hasn't run yet

	pane_anchor_point=anyonmousemove(evobj);
	
	var newpid=-1;
	var anchor_id=obj.id;
	for (var pid=pane_max;pid>=0;pid--){
		if (pane_status[pid]=='closed'){
		 newpid=pid;
		} else {
			if (pane_current_anchor_id[pid]==anchor_id) return; // already open
		}
	}
	if (newpid==-1) return;
 //make sure the anchor doesn't exist under another open popup
	for (var pid=pane_max;pid>=0;pid--){
		if (pane_status[pid]=='open' || pane_status[pid]=='opening' || pane_status[pid]=='doopen'){
			if (pointinrect(g_cursor_point,pane_rect[pid])){
    return;//cursor is over an open pane. Do not react to anchor behind (IE7)
   }
  }
 }
	pid=newpid;
	pane_status[pid]='doingload';
 pane_current_anchor_id[pid]=anchor_id;
	pane_current_positioning[pid]=positioning;
 var pos=findpos(obj);
	pane_current_anchor_rect[pid]=[pos[0],pos[1],getwidth(obj),getheight(obj)];
// obj.style.backgroundColor='#EEEE00';

 getobj_dropcache('pane_content'+pid);//we are recreating the pane html. need to release cached obj handle.
 if (this_pane_width==null) this_pane_width=pane_current_anchor_rect[pid][2]
	pane_writecontentdiv(pid,this_pane_width);
/********** todo 1592 fix - the following somehow breaks future functionality
	pane_writecontentdiv(pid,pane_current_anchor_rect[pid][2]);
	getobj_dropcache();
***********/
 pane_delaymouseout[pid]++;//keep pane open if mouse is over
	bringsubfront(pane_div[pid]);
	
 pane_loaddivcontent(pid);

}


//********* PANE Internal
function pane_watch(){
	for (var pid=0;pid<=pane_max;pid++){
		if (pane_status[pid]=='open' || pane_status[pid]=='opening' || pane_status[pid]=='doopen'){
			var thisx,thisy;
		 var minx=scrollOffsetX;
		 var maxx=windowWidth+scrollOffsetX;
		 var miny=scrollOffsetY;
		 var maxy=windowHeight+scrollOffsetY;
		 var	pane_width=getwidth(pane_div[pid]);
			var pane_height=getheight(pane_div[pid]);
			switch (pane_current_positioning[pid]){
			 case 'BL'://lock to bottom left
					thisx=pane_current_anchor_rect[pid][0];
					thisy=pane_current_anchor_rect[pid][1]+pane_current_anchor_rect[pid][3];
					//constrain to edges of screen
					if (thisy+pane_height>maxy-scrollbarheight)	thisy=maxy-pane_height-scrollbarheight;
					if (thisx+pane_width>maxx-scrollbarwidth)	thisx=maxx-pane_width-scrollbarwidth;
//window.status=pane_height;
				 moveit(pane_div[pid],thisx,thisy);
					break;
				case 'FM'://follow mouse
				 thisx=pane_anchor_point[0]+10;
				 thisy=pane_anchor_point[1]+10;
				 var relativex=thisx-scrollOffsetX+pane_width;
				 var relativey=thisy-scrollOffsetY+pane_height;
				 if (relativex>windowWidth) thisx-=pane_width+20;//relativex-windowWidth;
				 if (relativey>windowHeight) thisy-=pane_height+20;
				 if (thisx<0) thisx=0;
				 if (thisy<0) thisy=0;
					thisx+=pane_fm_addx;
					thisy+=pane_fm_addy;
				 moveit(pane_div[pid],thisx,thisy);
					break;
			}
		 if (pane_status[pid]=='doopen'){
				setfadefast();
				dofadein('pane_div'+pid,null,95);
				setzipfast();
				dozipopen('pane_content_wrap'+pid,null,'pane_doneopen('+pid+')');
				pane_status[pid]='opening';
				pane_delaymouseout[pid]++;
			}
			//if mouse is out of range then close pane
			pane_rect[pid]=[thisx,thisy,pane_width,pane_height];
			if (!pointinrect(g_cursor_point,pane_rect[pid],5))
			 if (!pointinrect(g_cursor_point,pane_current_anchor_rect[pid],5))
					pane_suggestmouseout(pid);
		}
	}
 setTimeout(pane_watch,pane_updatems);
}
function pane_doneopen(pid){
	pane_status[pid]='open';
}
function pane_mouseoverdiv(pid){//triggered only by pane div on mouse over
 pane_delaymouseout[pid]++;
}
function pane_suggestmouseout(pid){//triggered when mouse is outside the acceptable rects
	if (pane_status[pid]=='open'){
	 var matchvalue=pane_delaymouseout[pid];
	 setTimeout(function (){pane_domouseout(pid,matchvalue)},100);
	}
}
function pane_domouseout(pid,matchvalue){
 if (pane_delaymouseout[pid]==matchvalue){
		if (pane_status[pid]=='open'){
			setfadefast();
			dofadeout('pane_div'+pid);
			dozipclose('pane_content_wrap'+pid,null,'pane_doneclose('+pid+')');
			pane_status[pid]='closing';
		}
 }
}
function pane_doneclose(pid){
	pane_status[pid]='closed';
	pane_current_anchor_id[pid]='';
}

function pane_loaddivcontent(pid){
	var html='';
	var xmlpage='';
	switch (pane_current_anchor_id[pid]){
		case 'panc_topsearches':
			xmlpage='ajx_top_searches.asp';
			break;
		case 'panc_translate':
	//		xmlpage='ajx_langs.asp';
   html='<div style="padding:10px 10px;"><div class="list_inner_popup" id="langlist"><div style="color:#888;padding:0px 8px 0;text-align:left;"><table><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=1" rel="nofollow" onclick="return dovtrans(this,1);" target="_top"><img src="/vgfx/english.gif" alt="English" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=2" rel="nofollow" onclick="return dovtrans(this,2);" target="_top"><img src="/vgfx/spanish.gif" alt="Spanish" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=4" rel="nofollow" onclick="return dovtrans(this,4);" target="_top"><img src="/vgfx/pyccko.gif" alt="Pyccko" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=5" rel="nofollow" onclick="return dovtrans(this,5);" target="_top"><img src="/vgfx/italiano.gif" alt="Italiano" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=6" rel="nofollow" onclick="return dovtrans(this,6);" target="_top"><img src="/vgfx/francais.gif" alt="Francais" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=7" rel="nofollow" onclick="return dovtrans(this,7);" target="_top"><img src="/vgfx/deutsch.gif" alt="Deutsch" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=8" rel="nofollow" onclick="return dovtrans(this,8);" target="_top"><img src="/vgfx/portuguese.gif" alt="portuguese" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=9" rel="nofollow" onclick="return dovtrans(this,9);" target="_top"><img src="/vgfx/japan.gif" alt="Japan" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=10" rel="nofollow" onclick="return dovtrans(this,10);" target="_top"><img src="/vgfx/greek.gif" alt="Greek" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr><tr><td height="14px"><a href="/vt_pbtlink.asp?tid=11" rel="nofollow" onclick="return dovtrans(this,11);" target="_top"><img src="/vgfx/nederland.gif" alt="Nederland" onclick="hideobj(\'popup_lang\');" border="0" /></a></td></tr></table></div></div></div>';
			break;
		case 'test':
		 html='a<br><br>b<br><br>v<br><br>f<br><br>g<br><br>r<br><br>d<br><br>s';
			break;
	}
	if (!mt(xmlpage)){
		loadXMLurl(g_ur+xmlpage+'?r='+Math.random(10000), null, pane_loaddivcontent_sub,pid);
		return;
	}
	moveit(pane_div[pid],0,0);
 changetext('pane_content'+pid,html);
	pane_status[pid]='doopen';
}

function pane_loaddivcontent_sub(response,pid){
//todo - why is this called twice???	alert(response);
	//var resp=ajx_getresponsevars(response);
// if (resp[0]===false) return;
// var data=resp[1];
	moveit(pane_div[pid],0,0);
 changetext('pane_content'+pid,response);
	pane_status[pid]='doopen';
}

