/**
 * @author 3Devil
 */
var _application = '<a href="#HomePage" onClick="return app.goHome()" class="home"></a> &nbsp;&nbsp;:: OUTDOOR KITCHENATOR';
var _applicationtitle = 'Cunningham Living\'s OUTDOOR KITCHENATOR';
var __totalprice = 'Total Price';
var __instructions = '<p><b>Welcome to ' + _applicationtitle + '</b></p>'
		 +'<ul>'
		 +'<li>You can hide/show navigation panels any time by pressing "H" or "h" from the keyboard'
		 +' or clicking the pin icon on the application title bar.</li>'
		 +'<li>You can hide/show hardware positions any time by pressing the button under "Island Options" panel and/or'
		 +'by pressing "P" or "p" from the keyboard.</li>'
		 +'<li>You can show this help any time by pressing "F2" from the keyboard or clicking the question mark icon'
		 +'on the application title bar.</li>'
		 +'<li>You can navigate trough active hardware zones by pressing "Alt" and the number of corresponding zone,'
		 +' i.e. "Alt + 1". "Alt + 0" is for 10th zone if there is such.</li>'
		 +'</ul>';
var __disclaimer = 'This section of the Outdoor Kitchenator is used to design BBQ Grill Hardware Packages. '
		+'The actual Islands or "cabinet" are <b><u>not included</u></b>. The Islands are our most popular designs and are used for '
		+'<b><u>visualization purposes only</u></b>. '
		+'The Islands are available only as custom quotes from our experienced sales staff. '
		+'If you have an interest in one of our islands and you live within 30 miles of our retail locations in Spring and The Woodlands, TX, '
		+'we will be happy to work with you. Just click here <a href="mailto:CustomerService@Cunninghamgas.com">CustomerService@Cunninghamgas.com</a> to contact us';
var __priceColor = "#800000";
var __reposition;
var app;

Ext.example = function(){
    var msgCt;

    function createBox(t, s){
        return ['<div class="msg">',
                '<div class="x-box-tl"><div class="x-box-tr"><div class="x-box-tc"></div></div></div>',
                '<div class="x-box-ml"><div class="x-box-mr"><div class="x-box-mc"><h3>', t, '</h3>', s, '</div></div></div>',
                '<div class="x-box-bl"><div class="x-box-br"><div class="x-box-bc"></div></div></div>',
                '</div>'].join('');
    }
    return {
        msg : function(title, format, pause){
			pause = pause || 2;
            if(!msgCt){
                msgCt = Ext.DomHelper.insertFirst(document.body, {id:'msg-div'}, true);
            }
            msgCt.alignTo(document, 't-t');
            var s = String.format.apply(String, Array.prototype.slice.call(arguments, 1));
            var m = Ext.DomHelper.append(msgCt, {html:createBox(title, s)}, true);
            m.slideIn('t').pause(pause).ghost("b", {remove:true});
        },

        init : function(){
            var t = Ext.get('exttheme');
            if(!t){ // run locally?
                return;
            }
//            var theme = Cookies.get('exttheme') || 'aero';
            if(theme){
                t.dom.value = theme;
                Ext.getBody().addClass('x-'+theme);
            }
            t.on('change', function(){
                Cookies.set('exttheme', t.getValue());
                setTimeout(function(){
                    window.location.reload();
                }, 250);
            });

            var lb = Ext.get('lib-bar');
            if(lb){
                lb.show();
            }
        }
    };
}();

Ext.onReady(Ext.example.init, Ext.example);

Ext.onReady(function(){
//	Ext.WindowMgr.zseed = 50000;
	Ext.QuickTips.init();
//	vp = new Ext.Viewport();
//	vp.on('resize', function (){
//		vsize = vp.getBox();
//		try {
//			app.center();
//			app.realign();
//		}
//		catch (e) {}
//		try {
//			app.LandingPage.center();
//		} catch(e) {}
//	});

	window.onresize = function() {
		clearTimeout(__reposition);
		__reposition = setTimeout('app.doCenter();', 1000);
	};
	
	app = new VDC.Application({
		url:'/cdt_islands.php' + (__islandLoad ? ('?setupuid=' + __islandLoad) : ''),
		purl:'/cdt_products.php'
	});
	
	app.render();

	clearTimeout(__reposition);
//	__reposition = setTimeout('app.doCenter();', 1500);
});