
//initial concept

Ext.onReady(function(){
    
    
    Ext.namespace('Earth');
    // NOTE: This is an example showing simple state management. During development,
    // it is generally best to disable state management as dynamically-generated ids
    // can change across page loads, leading to unpredictable results.  The developer
    // should ensure that stable state ids are set for stateful components in real apps.
    //Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

    // create some portlet tools using built in Ext tool ids
    var tools = [{
        id:'close',
        handler: function(e, target, panel){
            panel.hide();
        }
    }];
    
    
    /*Function Window*/
    if(!Earth.functionWindow){
        Earth.functionWindow = new Ext.Window({
                id          : 'functionWindow',
                layout      : 'fit',
                width       : 400,
                autoHeight  : true,
                modal       : true,
                title: 'earth.booking',
                baseCls: 'function-window',
                constrain   : true,
                draggable   : false,
                hideParent  : true,
                initHidden  : true,
                closeAction : 'hide',
                resizable   : false,
                plain       : true,
                items: [
                {
					baseCls:'caramel-panel',
					autoHeight:true,
					bodyStyle: 'padding:0px;',
					frame:true,
					id: 'b6m6',
					items: [new Ext.FormPanel({
                        baseCls: 'caramel-panel',
                        defaultType: 'textfield',
                        labelAlign: 'left',
                        id:'functionsForm',
                        items: [{
                                //hideLabel:true,
                                fieldLabel: 'first.name',
                                id: 'functionFormFirstName',
                                allowBlank:false,
                                anchor: '0'
                            },{
                                //hideLabel:true,
                                fieldLabel: 'last.name',
                                id: 'functionFormLastName',
                                allowBlank:false,
                                anchor: '0'
                            },{
                                //hideLabel:true,
                                fieldLabel: 'company',
                                id: 'functionFormCompany',
                                anchor: '0'
                            },{
                                //hideLabel:true,
                                fieldLabel: 'contact.number',
                                id: 'functionFormPhoneNumber',
                                allowBlank:false,
                                anchor: '0'
                            },{
                                //hideLabel:true,
                                fieldLabel: 'email.address',
                                id: 'functionFormEmail',
                                allowBlank: false,
                                vtype:'email',
                                anchor: '0'
                            },new Ext.form.ComboBox({
                                //hideLabel:true,
                                fieldLabel: 'function.type',
                                store: ['Wedding','Corporate','Social','Birthday'],
                                anchor: '0',
                                id: 'functionFormType'
                            }),{
                                //hideLabel:true,
                                fieldLabel: 'number.of.guests',
                                id: 'functionFormNoGuests',
                                anchor: '0'
                            },new Ext.form.DateField({
                                //hideLabel:true,
                                fieldLabel: 'function.date',
                                anchor: '0',
                                id: 'functionFormDate',
                                format: 'd/m/Y'
                                
                            }),new Ext.form.TimeField({
                                //hideLabel:true,
                                fieldLabel: 'function.time',
                                anchor: '0',
                                id: 'functionFormTime',
                                increment: 30
                                
                            }),{
                                //hideLabel:true,
                                fieldLabel: 'function.duration',
                                id: 'functionFormDuration',
                                anchor: '0'
                            },new Ext.form.TextArea({
                                //hideLabel:true,
                                fieldLabel: 'comments',
                                anchor: '-3',
                                id: 'functionFormQuestions',
                                height:70
                            })
                            
                        ]
                    })
					
					]
            }],
                
                buttons: [{
                        text: 'Clear',
                        handler: function(btn,e){
                        Ext.getCmp('functionFormFirstName').reset();
                        Ext.getCmp('functionFormLastName').reset();
                        Ext.getCmp('functionFormCompany').reset();
                        Ext.getCmp('functionFormPhoneNumber').reset();
                        Ext.getCmp('functionFormEmail').reset();
                        Ext.getCmp('functionFormType').reset();
                        Ext.getCmp('functionFormNoGuests').reset();
                        Ext.getCmp('functionFormDate').reset();
                        Ext.getCmp('functionFormTime').reset();
                        Ext.getCmp('functionFormDuration').reset();
                        Ext.getCmp('functionFormQuestions').reset();
                        
                        }
                        },{
                            text: 'Send',
                            handler: function(btn,e){
					        var personname = 'support';
					        var company = 'earthnightclub';
					        var ext = '.com.au';
							var personname2 = 'ian';
					        var firstname = Ext.getCmp('functionFormFirstName').getValue(); 
					        var lastname = Ext.getCmp('functionFormLastName').getValue();
					        var personcompany = Ext.getCmp('functionFormCompany').getValue();
					        var phonenumber = Ext.getCmp('functionFormPhoneNumber').getValue();
					        var email = Ext.getCmp('functionFormEmail').getValue();
					        var type = Ext.getCmp('functionFormType').getValue();
					        var noguests = Ext.getCmp('functionFormNoGuests').getValue();
					        var date = Ext.getCmp('functionFormDate').getValue();
					        var dt = new Date(date);
					        var time = Ext.getCmp('functionFormTime').getValue();
					        var duration = Ext.getCmp('functionFormDuration').getValue();
					        var questions = Ext.getCmp('functionFormQuestions').getValue();
					        
                            self.location="mailto:"+ personname + "@" + company + ext + ";" + personname2 + "@" + company + ext +"?subject=" + type + " - " + firstname + " " + lastname + "&body=Name: " + firstname + " " + lastname + "%0A%0DCompany: " + personcompany + "%0A%0DPhone Number: " + phonenumber + "%0A%0DReply Email: " + email + "%0A%0DType: " + type + "%0A%0DNumber of Guests: " + noguests + "%0A%0DDate: " + dt.format('d/m/Y') + "%0A%0DTime: " + time + "%0A%0DDuration: " + duration + "%0A%0DQuestions or Comments: " + questions;
                            
                            Ext.getCmp('functionFormFirstName').reset();
                            Ext.getCmp('functionFormLastName').reset();
                            Ext.getCmp('functionFormCompany').reset();
                            Ext.getCmp('functionFormPhoneNumber').reset();
                            Ext.getCmp('functionFormEmail').reset();
                            Ext.getCmp('functionFormType').reset();
                            Ext.getCmp('functionFormNoGuests').reset();
                            Ext.getCmp('functionFormDate').reset();
                            Ext.getCmp('functionFormTime').reset();
                            Ext.getCmp('functionFormDuration').reset();
                            Ext.getCmp('functionFormQuestions').reset();
                            
                            Earth.functionWindow.hide();
                            
                            }
                        }]
                })};
    
    /*Poster Window 1*/    
    if(!Earth.posterWindow1){
            Earth.posterWindow1 = new Ext.Window({
                id          : 'posterBig1',
                title       : 'earth.event',
                baseCls     : 'poster-window',
                layout      : 'fit',
                autoWidth	: true,
                y: 140,
                autoHeight  : true,
                modal       : true,
                constrain   : true,
                draggable   : false,
                hideParent  : true,
                initHidden  : true,
                closeAction :'hide',
                resizable   : false,
                buttons: [{
                    text     : 'Close',
                    handler  : function(){
                        Earth.posterWindow1.hide();
                    }
                }]
            })};
    
    /*Poster Window 2*/    
    if(!Earth.posterWindow2){
            Earth.posterWindow2 = new Ext.Window({
                id          : 'posterBig2',
                title       : 'earth.event',
                baseCls     : 'poster-window',
                layout      : 'fit',
                y: 140,
                autoWidth   : true,
                autoHeight  : true,
                modal       : true,
                constrain   : true,
                draggable   : false,
                hideParent  : true,
                initHidden  : true,
                closeAction :'hide',
                resizable   : false,
                buttons: [{
                    text     : 'Close',
                    handler  : function(){
                        Earth.posterWindow2.hide();
                    }
                }]
            })}; 
            
    /*Poster Window 3*/    
    if(!Earth.posterWindow3){
            Earth.posterWindow3 = new Ext.Window({
                id          : 'posterBig3',
                title       : 'earth.event',
                baseCls     : 'poster-window',
                layout      : 'fit',
                y: 140,
                autowidth   : true,
                autoHeight  : true,
                constrain   : true,
                draggable   : false,
                hideParent  : true,
                initHidden  : true,
                modal       : true,
                closeAction :'hide',
                resizable   : false,
                //html        : Ext.Earth.posterBig3,
                buttons: [{
                    text     : 'Close',
                    handler  : function(){
                        Earth.posterWindow3.hide();
                    }
                }]
            })};  
    
    /*Gallery Window*/
    if(!Earth.galleryWindow){
            Earth.galleryWindow = new Ext.Window({
                baseCls: 'gallery-window',
                resizable: false,
                id: 'galleryWindow',
                title:  'earth.gallery',
                modal: true,
                height: 300,
                width: 715,
                y: 140,
                constrain   : true,
                draggable   : false,
                hideParent  : true,
                initHidden  : true,
                plain       : true,
                closeAction :'hide',
                layout      : 'fit',
                html: Ext.Earth.galleryMaterial,
                
                buttons: [{
                    text     : 'Close',
                    handler  : function(){
                        Earth.galleryWindow.hide();
                       }
                }]
            })};        
    
    /*sign up newsletter window*/
    if(!Earth.signupWindow){
            Earth.signupWindow = new Ext.Window({
                id: 'signupWindow',
                title: 'earth.news',
                baseCls: 'signup-window',
                width: 300,
                autoHeight: true,
                draggable: false,
                resizable: false,
                modal:true,
                closeAction :'hide',
                items: [
                    new Ext.FormPanel({
                        baseCls: 'newsletter',
                        layout:'column',
                        id:'newsLetterForm',
                        width:300,
                        margins:'0 0 0 0',
                        cmargins:'0 5 5 5',
                        layout:'column',
                        items:[{
                            columnWidth:.7,
                            labelAlign: 'top',
                            baseCls:'x-plain',
                            bodyStyle:'padding:5px 0 5px 5px',
                            layout:'form',
                            items:[{
                                xtype:'textfield',
                                hideLabel:true,
                                id: 'newsLetterWindowEmail',
                                vtype:'email',
                                anchor: '0',
                                emptyText: 'Email Address'
                            }]},
                        {
                        columnWidth:.3,
                        baseCls:'x-plain',
                        bodyStyle:'padding:5px 0 5px 5px',
                            items:[new Ext.Button({
                                   text:'Sign Up',
                                   handler: function(btn,e){
					               var personname = 'carapring';
					               var company = 'earth';
					               var ext = '.com.au';
					               var email = Ext.getCmp('newsLetterWindowEmail').getValue(); 
                                   self.location="mailto:"+ personname + "@" + company + ext +"?subject=Newsletter Signup - "+ email + "&body=Email: " + email;
                            }})]
                        }]
                    })
                    ]
                }
            )};  
                 
            
    /*location map window*/    
    if(!Earth.locationMapWindow){
            Earth.locationMapWindow = new Ext.Window({
                id: 'locationMapWindow',
                layout: 'fit',
                title: '27 Hindley St, Adelaide, SA, 5000, Australia',
                baseCls: 'map-window',
                width:800,
                resizable: false,
                draggable: false,
                height:400,
                modal:true,
                closeAction :'hide',
                items: {
                    xtype: 'gmappanel',
                    region: 'center',
                    zoomLevel: 14,
                    gmapType: 'map',
                    mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
                    mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
                    setCenter: {
                        geoCodeAddr: '27 Hindley Street, Adelaide, SA, 5000, Australia',
                        marker: {title: 'earth.nightclub'}
                    }
                }
            })};               
    
    Earth.Application = new Ext.Viewport({
        layout:'anchor',
        items:[{
                id:'container-panel',
                baseCls: 'container-panel',
                autoWidth:true,
                border:false,
                collapsible: false,
                items:[{               
                    id:'earth-panel',
                    baseCls: 'earth-panel',
                    frame: true,
                    split:false,
				    width:777,
				    border:false,
                    collapsible: false,
                    margins:'0 0 0 0',
                    cmargins:'0 0 5 5',
                    layout:'column',
                    items:[{
                        columnWidth:1,
                        items:[{
                        html: Ext.Earth.earthpanel,					
                        autoScroll:false,
                        border:false,
                        iconCls:'nav',
					    bodyStyle:'background:none;'
                    },{
                        columnWidth:1, 
                        items:[{
                            //title: 'earth.dresscode',
                            html: Ext.Earth.dresscode,
						    baseCls:'dresscode'
                        }]
                    }
                    ]
                    }]
                },{
                    region:'south',
                    id:'south-panel',
                    frame: true,
                    split:false,
				    width:777,
				    border:false,
				    baseCls:'south-panel',
                    collapsible: false,
                    margins:'0 0 0 0',
                    cmargins:'0 5 5 5',
                    layout:'column',
                    items:[{
                        columnWidth:1,
                        //title: "earth.calendar",
                        baseCls:'events',  
                        items:[{
						    html: Ext.Earth.events,
						    autoScroll:false,
                            border:false,
                            iconCls:'nav',
					        bodyStyle:'background:none;'
    						
                        }]
                    },{
                        columnWidth:1,
                        items:[{
                            title: 'earth.highlights',
                            baseCls:'upcoming',
						    layout:'column',
                            items:[{
                                id: 'upcomingposter1',
                                columnWidth:0.33,
                                autoHeight:true,
                                baseCls: 'poster'
                                
                                                        },
                            {
                                id: 'upcomingposter2',
                                columnWidth:0.34,
                                autoHeight:true,
                                baseCls: 'poster'
                            },
                            {
                                id: 'upcomingposter3',
                                columnWidth:0.33,
                                autoHeight:true,
                                baseCls: 'poster'
                            }
                            ]
                            
                        }]
                    },{
                        columnWidth:1, 
                        baseCls:'booking',
                        items:[{
                            baseCls:'booking-content',
                            html: Ext.Earth.booking
                        }]
                    }
				    ,{
                        columnWidth:1, 
                        items:[{
                            title: 'earth.residents',
                            html: Ext.Earth.residents,
						    baseCls:'residents'
                        }]
                    }
				    ,{
                        columnWidth:1, 
                        items:[{
                            //title: 'earth',
                            html: Ext.Earth.contactus,
						    baseCls:'contactus'
                        }]
                    }
                    ]
               

            }] //closes border layout
         }] //close container-panel
    });
});


