//include in this file any custom code that you want your Ironbox desktop to run 
//but not code that is specific to individual applications

var ib_desktop = {};
//default: tryfreq X trynum is 20 secs
ib_desktop.tryfreq = 20;
ib_desktop.trynum = 1000;
ib_desktop.bodyready = false;

ib_desktop.onStartUp = function()
{
	/******************************************************************************************/
	//at this point both the desktop initial DOM and the Ironbox framework should be available
	//so include in this section any custom code, including Ironbox calls, that need to run
	//immediately at start up, before the desktop_custom.js file arrives

	//....

	var bakdiv1 = ib$('bakdiv1');
	var bakdiv2 = ib$('bakdiv2');
	
	window.onresize = function()
	{	
		var w1 = bakdiv1.offsetWidth;
		var w2 = bakdiv2.offsetWidth;
		if (w1 == w2) return;
		bakdiv2.style.left = (w1 - w2) / 2 + 'px';
	}

	window.onresize();
	bakdiv2.style.visibility = 'visible';

	//end of custom startup code
	/******************************************************************************************/
};

ib_desktop.onCouldNotStart = function()
{
	//give up trying to load desktop page after 20 secs -- (change time and how to respond if desired)
	alert('Error or delay loading website from server. Please refresh browser to try again.');
};

ib_desktop.testDomAvail = function()
{
	//this tests whether mydesktop.htm (or equivalent renamed file) has its DOM ready for access (returns true)
	//the 2nd test is to try to make this happen earlier than the window.onload event - it should work in most cases
	//(note: many types of dom-ready tests are possible, modify this if desired - 
	//but do not modify into a loop or setInterval, ironbox will do that automatically)

	return (ib_desktop.bodyready || Boolean(document && document.getElementById('dt_ref001')));
};



//***************************************
//Do Not Modify Code Below this Line

ib_desktop.onIronbox = function(){
ironbox.doNotUntil(ironbox.loadCustomDt, ib_desktop.testDomAvail, ib_desktop.tryfreq, ib_desktop.trynum, ib_desktop.onCouldNotStart);};
ib_desktop.onBeforeIbExt = function(){ironbox.loadExt(); };
ib_desktop.dt_jsfiles = [
	["http://www.seadune.com/sea/r1003/ironbox_base.js", ib_desktop.onBeforeIbExt],
	["http://www.seadune.com/sea/r1003/desktop_custom_vs.js", null],
	["http://www.seadune.com/sea/r1003/ironboxext.js", null],
	["http://www.seadune.com/sea/raphael.js", null],
	["http://www.seadune.com/sea/jscolor.js", "ib_desktop.onIronbox"]
						
];
ib_desktop.loadIronbox = function(){
var be = function(x,y,z){if(x.addEventListener) x.addEventListener(y,z,false);
else if (x.attachEvent)	x.attachEvent('on' + y, z);};
var s = document.createElement('script'); s.type = 'text/javascript';
if (s.readyState){var c = false; be(s, 'readystatechange', function()
{if (!c && (/loaded|complete/.test(s.readyState)) )
{ib_desktop.dt_jsfiles[0][1](); c = true;}});} else be(s, 'load', ib_desktop.dt_jsfiles[0][1]);
s.src = ib_desktop.dt_jsfiles[0][0]; document.getElementsByTagName('head')[0].appendChild(s);}();


