var SW_dispatcher=false;
function GetObj(id){return document.getElementById(id);}
function SW_LocalInit(){
	var topp=false,p=window,s="",fnd=false;
	while (p!=topp) { topp=p; p=p.parent; if (topp.SW_Init!=undefined) {fnd=true; break;}}
	if (fnd) {SW_dispatcher=topp;} else {
		document.write("<script src='"+sysPubURL+"/windows_ie.js'></script>");}
		document.onkeypress=SW_onKeyPress;
}
SW_LocalInit();

function SW_onKeyPress(e){
	if (document.all) e=event;
	if (e.keyCode==27){
		if (!SW_dispatcher.popupClosed){SW_dispatcher.SW_ClosePopup();return;}
		ModalResult("cancel");
	}
}
function ModalResult(mr){SW_dispatcher.SW_ModalResult(mr);}
function GetCallerWindowPath(){
	var cw=window; pw=false, s="";
	while ((cw!=pw)&&(cw)){if (window.top==cw){if (s) s="."+s;s="window.top"+s;}else{if(s){s="."+s;}s=cw.name+s;}pw=cw;cw=cw.parent;}
	return s;
}
function OpenModal(params) {
	var w=false,h=false,callback=undefined,url=undefined,wnd;
	if (typeof(params)=='string'){url=params; params=undefined;}else{
		if (params.url!=undefined) url=params.url;
		if (params.w!=undefined) {w=params.w; h=params.h;}
		if (params.callback!=undefined) callback=params.callback;
	}
	s=GetCallerWindowPath();
	return SW_dispatcher.SW_OpenModalWindow(url,w,h,params,callback,s);
}

function GetAbsXY(elem) {
	this.x=OffsetX(elem);this.y=OffsetY(elem);
	while (elem.offsetParent!=null){
		elem=elem.offsetParent;this.x+=OffsetX(elem);this.y+=OffsetY(elem);
		if (elem.tagName=='BODY') break;
	} return this;
}

function OffsetX (elem) {return elem.offsetLeft;}
function OffsetY (elem) {return elem.offsetTop;}
function dump(e){var s="";for (var i in e){if ((i=='outerText')||(i=='innerHTML')||(i=='innerText')||(i=='outerHTML')) continue;s+="["+i+":"+e[i]+"]   ";}return s;}
function OpenPopupUnder(el,inner,rightAlign){
	SW_dispatcher.popupCallerWindow=window;
	SW_dispatcher.SW_OpenPopupUnder(el,inner,rightAlign);
}
function OpenPopupAt(x,y,inner,rightAlign) {
	SW_dispatcher.popupCallerWindow=window;
	SW_dispatcher.SW_OpenPopup(x,y,inner,rightAlign);
}
function OpenPopupMenu(el,items,useButton) {
	SW_dispatcher.popupCallerWindow=window;
	SW_dispatcher.SW_OpenPopupMenu(el,items,useButton);
}
function setErrorHandler(callback) {SW_dispatcher.SW_errorCallback=callback; }
function raiseError(error,details) {if (SW_dispatcher.SW_errorCallback) {try{SW_dispatcher.SW_errorCallback(error,details);} catch(e){}}}
function SetWindowSize(w,h){SW_dispatcher.SW_SetWindowSize(w,h)};
function SetWindowTitle(s){SW_dispatcher.SW_SetWindowTitle(s)};