
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 wd = document.body.offsetWidth;
	var bakdiv = document.getElementById('bakdiv1');
	var bakwd = bakdiv.offsetWidth;
	var margn = (wd - bakwd) < 0 ? 0 : wd - bakwd;
	bakdiv.style.left = (margn / 2) + 'px';
	ib$('copyrgt1').style.left = (margn / 2 + 5) + 'px';

	if (is_ie6)
	{
		document.body.innerHTML = '';
		var notice = ironbox.makeElem('div', document.body);
		ironbox.styleElem(notice, {"font-weight": "bold", "font-size": "13pt", "color": "white", "margin": "50px"});
		var ie6note = "We're sorry, Internet Explorer 6 is not currently supported by the ar15Builder. <br>Please visit us with a newer browser.";
		ie6note += "<br><br><br><br><br>Browser Download Links:";
		ie6note += '<br><br><br><a style="color: white;" href="http://www.mozilla.com/en-US/firefox">Mozilla Firefox</a>';
		ie6note += '<br><br><a style="color: white;" href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer 7</a>';
		ie6note += '<br><br><a style="color: white;" href="http://www.google.com/chrome">Google Chrome</a>';
		ie6note += '<br><br><a style="color: white;" href="http://www.apple.com/safari">Apple Safari</a>';
		
		notice.innerHTML = ie6note;
		//ironbox.fetchJS('http://www.opalsfire.com/gunbuilder/dtop/jdat/badbrowser.js');	//for DEV testing only
	}
	else
	{
		bakdiv.style.visibility = 'visible';
		ib$('copyrgt1').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 = [
	["dtop/js/ironboxR1.js", ib_desktop.onBeforeIbExt],	
	["dtop/js/desktop_customR1.js", null],	
	["raphael", null],	
	["ironboxextR1", "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);}();

