try { if (undefined == xajax.config) xajax.config = {}; } catch (e) { xajax = {}; xajax.config = {}; };
xajax.config.requestURI = "include/a/server.php";
xajax.config.statusMessages = true;
xajax.config.waitCursor = true;
xajax.config.version = "xajax 0.5 Beta 4";
xajax.config.legacy = false;
xajax.config.defaultMode = "asynchronous";
xajax.config.defaultMethod = "POST";
//===============================================================================	
var headID = document.getElementsByTagName("head")[0]; 
var newJs = document.createElement('script');
newJs .type = 'text/javascript';
newJs .src= "include/xajax/xajax_js/xajax_core.js";
headID.appendChild(newJs);
//===============================================================================	

var check_cnt = 0;

function check_xajax_load() 
{
  	var tester = false;
	try 
	{
		if (xajax.isLoaded) tester = true;
	}
	catch (e) {}
	if (tester)
	{
		init();
  	}
	else
	{
		check_cnt++;
		if (check_cnt < 25)  // 5 seconds
		{
			setTimeout("check_xajax_load()", 200)
		}
		else
		{
	  		alert("Javascript component could not be included, please reload and try.");
		}
	}
}

check_xajax_load();

xajax_act = function() { return xajax.request( { xjxfun: 'act' }, { parameters: arguments } ); };
xajax_post = function() { return xajax.request( { xjxfun: 'post' }, { parameters: arguments } ); };

function act(n,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10)
{
	xajax_act(n,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10);
}

function actpost(a,f)
{
	xajax_post(a,xajax.getFormValues(f));
}

var check_debug_cnt = 0;

function check_debug_xajax_load() 
{
	var tester = false;
	try
	{
		if (xajax.debug.isLoaded) tester = true;
	}
	catch (e) {}
	if (tester)
	{
  		act("start");
	}
	else
	{	
		check_debug_cnt++;
		if (check_debug_cnt < 25)  // 5 seconds
		{
			setTimeout("check_debug_xajax_load()", 200)
		}
		else
		{
			alert("debug component could not be included, please reload and try.");
		}
	}
}

function debug()
{
	check_debug_xajax_load();
}


function init()
{
    a =     "<div id='body' style='width:100%; height:100%;'></div>";
    a = a + "<div id='$$mask_close_button' align='right' style='background-color:#eeeeee; visibility:hidden; position:absolute; left:0px; top:0px; width:100%; z-index:900;'><input type='button' value='Cancel' onclick=\"act('[[apa_mask_free]]');\"/></div>";
    a = a + "<div align='center' id='$$popup' style='position:absolute; left:0px; top:22px; width:100%; z-index:899;'></div>";
    document.body.innerHTML = a;
	act("init");
}


function apa_editor_resize()
{
    var editor = document.getElementById('$$apa_editor');   
    var ww = 0, hh = 0;
  
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    ww = window.innerWidth;
    hh = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE 6+ in 'standards compliant mode'
    ww = document.documentElement.clientWidth;
    hh = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE 4 compatible
    ww = document.body.clientWidth;
    hh = document.body.clientHeight;
  }

  ww = ww - 100;
  hh = hh - 60;
  editor.width = ww;
  editor.height = hh;
  
}

function apa_ScreenMask() 
{

  var maskclose = document.getElementById('$$mask_close_button');
  maskclose.style.visibility = 'visible';

  var ww = 0, hh = 0;
  
  
  if( typeof( window.innerWidth ) == 'number' ) 
  {
    //Non-IE
    ww = window.innerWidth;
    hh = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    //IE 6+ in 'standards compliant mode'
    ww = document.documentElement.clientWidth;
    hh = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    //IE 4 compatible
    ww = document.body.clientWidth;
    hh = document.body.clientHeight;
  }
  
  
//  hh = 3000;
//  ww = 3000;
      
         
//    var tgt = document.getElementById(targetId);
    var targetId = "Screen";
    var mskId= targetId + "$$Mask";
    var testMsk = document.getElementById(mskId);
    if (testMsk) testMsk.parentElement.removeChild(testMsk);
    mask = document.createElement("DIV");
    mask.id = mskId;
    var maskStyle = mask.style;
//  var tgtStyle = tgt.style;
    maskStyle.display="block";
    maskStyle.position="absolute";
    maskStyle.zIndex="100";
    maskStyle.filter="alpha(opacity=70)";
    maskStyle.MozOpacity="0.7";
    maskStyle.opacity="0.7";
    maskStyle.backgroundColor="#999999";
//    var pos = afa_FindPos(tgt);
    maskStyle.top="0px";
    maskStyle.left="0px";
    maskStyle.width=ww+"px";
    maskStyle.height=hh+"px";
    
 
mask.innerHTML = "<iframe style='display:none;display:block;position:absolute;top:0;left:0;z-index:-1;filter:mask();width:"+ww+"px;height:"+hh+"px;'></iframe>";
document.body.appendChild(mask);     
}

function apa_RemoveScreenMask() 
{
    var tgtMask = document.getElementById( "Screen$$Mask");
    if (tgtMask) document.body.removeChild(tgtMask);
    var maskclose = document.getElementById('$$mask_close_button');
    maskclose.style.visibility = 'hidden';
    var p = document.getElementById('$$popup');
    p.innerHTML = '';
}
     

