var bx_ajax = null;
var bx_ajaxCallback = null;
function bx_initAjax(){
if (bx_ajax){ return true; }
if (window.XMLHttpRequest){
bx_ajax = new XMLHttpRequest();
return true;
}else if (window.ActiveXObject){
bx_ajax = new ActiveXObject("Microsoft.XMLHTTP");
return true;
}
return false;
}
function bx_ajaxRequest( url, method, callback, rnd ){
if (!bx_initAjax()){ return false; }
if (rnd){ url += "&rnd="+Math.random(); }
bx_ajaxCallback = callback;
bx_ajax.open(method,url,true);
bx_ajax.onreadystatechange=bx_ajaxResponse;
bx_ajax.send(null);
return true;
}
function bx_ajaxResponse(){
if ((bx_ajax.readyState==4) || (bx_ajax.readyState=="complete")){
if (bx_ajaxCallback){ bx_ajaxCallback(); }
}
}
function bx_getElementSafe( id ){
if (document.getElementById){
if (document.getElementById(id)) {
return document.getElementById(id);
}
if (document.getElementsByName) {
var elms = document.getElementsByName(id);
if (elms.length>0){
return elms.item(0);
}
}
return document.getElementById(id);
}else if (document.all){
return document.all[id];
}else if (document.layers){
return document.layers[id];
}else{
return false;
}
}
function bx_submit(){
var fm = bx_getElementSafe('bxform');
if (fm){
fm.submit();
}
}
function bx_dologin(){
var c = '';
var ci = bx_getElementSafe('in_bxcompany'); if (ci){ c = ci.value; }
var u = bx_getElementSafe('in_bxusername').value;
var p = bx_getElementSafe('in_bxpassword').value;
bx_taskbarChange('/index.php?prms=boxed,ajax,dologin,'+c+','+u+','+p);
}
function bx_doLogout(){
bx_taskbarChange('/index.php?prms=boxed,ajax,dologout');
}
function bx_closeTaskbar(){
bx_taskbarChange('/index.php?prms=boxed,ajax,close');
}
function bx_hideTaskbar(){
bx_taskbarChange('/index.php?prms=boxed,ajax,hide');
}
function bx_showTaskbar(){
bx_taskbarChange('/index.php?prms=boxed,ajax,show');
}
function bx_taskbarChange(url){
bx_ajaxRequest(url,"GET",bx_taskbarSet,true);
}
function bx_taskbarSet(){
if (bx_ajax.responseText=='[reload]'){
bx_refreshPage();
}else{
var tb = bx_getElementSafe('bx_taskbar');
if (tb){
tb.innerHTML = bx_ajax.responseText;
}
}
}
function bx_fixIE(){
theObjects = document.getElementsByTagName("object");
for (var i = 0; i < theObjects.length; i++) {
theObjects[i].outerHTML = theObjects[i].outerHTML;
}
}
function bx_popEditor(module,editor,w,h,prms){
if (prms.length>0){
if (prms.charAt(0)!=','){ prms = ','+prms; }
}
bx_popWindowFixed('/index.php?prms='+module+','+editor+prms, 'editor', w, h);
}
function bx_popWindow(url, name, width, height){
newWin = window.open(url, name, 'height='+height+',width='+width+',fullscreen=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=auto,resizable=no');
if (newWin.opener == null){ newWin.opener = self; }
newWin.focus();
return newWin;
}
function bx_popWindowFixed(url, name, width, height){
newWin = window.open(url, name, 'height='+height+',width='+width+',fullscreen=no,location=no,menubar=no,status=no,toolbar=no,scrollbars=no,resizable=no');
if (newWin.opener == null){ newWin.opener = self; }
newWin.focus();
return newWin;
}
function bx_refreshPage(){
window.location.reload();
}
var bx_popImageImg;
var bx_popImageTO;
function bx_popImage( src, ttl ){
// Close image if already open
bx_unpopImage();
// Find place to anchor new div
var fm = bx_getElementSafe('bxform');
// Insert div into page
if (fm){
var newdiv = document.createElement('div');
newdiv.setAttribute('id','bximdv');
newdiv.setAttribute('style','border:0px; margin:0px; position:absolute; top:0; left:0;');
newdiv.innerHTML = '';
fm.appendChild(newdiv);
var x = 10;
var y = 10;
if (window.innerWidth){
x = Math.round(window.innerWidth/2)-50;
y = Math.round(window.innerHeight/2)-50;
}else if (document.body.offsetWidth){
x = Math.round(document.body.offsetWidth/2)-50;
y = Math.round(document.body.offsetHeight/2)-50;
}
newdiv.style.position = 'absolute';
newdiv.style.top = y;
newdiv.style.left = x;
bx_popImageImg = new Image();
bx_popImageImg.src=src;
if (bx_popImageImg.complete){
bx_popImageOnLoad();
}else{
bx_popImageImg.onload = bx_popImageOnLoad;
bx_popImageTO = setTimeout ( 'bx_popImageTO=-1; bx_popImageOnLoad();', 10000 );
}
}
}
function bx_unpopImage(){
var fm = bx_getElementSafe('bxform');
var dv = bx_getElementSafe('bximdv');
// Insert div into page
if (fm && dv){
fm.removeChild(dv);
bx_popImageImg.onload = null;
}
}
function bx_popImageOnLoad(){
if (bx_popImageTO>=0){
clearTimeout(bx_popImageTO);
}
var dv = bx_getElementSafe('bximdv');
var im = bx_getElementSafe('bxim');
if (dv && im){
var ttl = im.getAttribute('alt');
dv.innerHTML = '';
var x=10;
var y=10;
if (window.innerWidth){
x = Math.round(window.innerWidth/2)-Math.round(bx_popImageImg.width/2);
y = Math.round(window.innerHeight/2)-Math.round(bx_popImageImg.height/2);
}else if (document.body.offsetWidth){
x = Math.round(document.body.offsetWidth/2)-Math.round(bx_popImageImg.width/2);
y = Math.round(document.body.offsetHeight/2)-Math.round(bx_popImageImg.height/2);
}
dv.style.top = y;
dv.style.left = x;
}
}