/*
 * Ext JS Library 2.0
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

    var myData = [
        ['Entire County','Help'],
        ['Zoom In','Help1'],
        ['Zoom Out','Help2'],
        ['Pan View','Help3'],
       // ['Go Back','Help4'],
       // ['Go Forward','Help5'],
        ['Measure','Help6'],
        ['Identify','Help7']
        //['Clear','Help8'],
        //['Print','Help9'],
        //['E_mail','Help10'],
        //['Feed Back','Help11'],
        //['Search By Last Name','Help12'],
        //['Search By Street Name','Help13']
    ];

	var MyWindow = function(){};

        MyWindow.tabs=new Ext.TabPanel({
        	    region: 'center',
                    el: 'help',
                    autoTabs:true,
                    activeTab:0,
                    deferredRender:false,
                   resizeTabs:true, // turn on tab resizing
                   id:'tab1_TabPanel',
        	   minTabWidth: 115,
                   tabWidth:135,
                   enableTabScroll:true,
                   width:1000,
                   height:500,
                   defaults: {autoScroll:true},
                    plugins: new Ext.ux.TabCloseMenu(),
                    border:false
                 });
   /*              
       MyWindow.nav = new Ext.Panel({
            title: 'Help Topic',
            region: 'west',
            split: true,
            width: 200,
            collapsible: true,
            margins:'3 0 3 3',
            cmargins:'3 3 3 3',
            items:new Ext.grid.GridPanel({
            	id:"TopicGrid",
        store: new Ext.data.SimpleStore({
        fields: [
           {name: 'tip'},
           {name: 'tabId'}
        ]
    }),
        columns: [
            {id:"company",header: "Topic", width: 200, sortable: false, dataIndex: 'tip'},
            {header: "ID", width: 200, sortable: false, dataIndex: 'tabId',hidden:true }
        ],
        stripeRows: true,
        autoExpandColumn: 'company',
        height:350,
        width:200,
        border:false
    })
        });
*/
	MyWindow.prototype={
		
		win:new Ext.Window({
			    title:"<br><center>Help and Tips</center><br>",
                layout: 'border',
                width:1050,
                height:550,
                closable:true,
                shadow:true,
                closeAction:'hide',
				draggable:true,
                plain: true,
               // items: [MyWindow.nav, MyWindow.tabs]
			   items:MyWindow.tabs
                /*
                buttons: [{
                    text:'Submit',
                    disabled:true
                },{
                    text: 'Close',
                    handler: function(){
                        var a =new MyWindow();
                        a.hide();
                    }
                }]
                */
            }),
		  show:function(){
		  	
                       this.win.show();
                                 },
		  hide:function(){
		    this.win.hide();
		  		 },
		  addTab:function(TheTitle,TheURL,flag,isClose,WindowId,theId,isScroll,icon){
    	if(flag=="yes")
    	{
        MyWindow.tabs.add({
            title: TheTitle,
            id:theId,
            iconCls: icon,
            html: '<iframe id="'+WindowId+'" name="'+WindowId+'" frameborder="0"  src="'+TheURL+'" height="100%" width="100%" marginheight="0" marginwidth="0" scrolling="'+isScroll+'" > </iframe>',
            closable:isClose
                        }).show();
      }
      else
      	{
      		
            MyWindow.tabs.add({
            title: TheTitle,
            id:theId,
            iconCls: icon,
            html: '<iframe id="'+WindowId+'" name="'+WindowId+'" frameborder="0"  src="'+TheURL+'" height="100%" width="100%" marginheight="0" marginwidth="0" scrolling="'+isScroll+'" > </iframe>',
            closable:isClose
                         });
      		
      		
      		
      	}
                                                                                    } 	
		  	};



var MyWin;
Ext.onReady(function(){
	
	 MyWin=new MyWindow();
	 MyWin.addTab("Content","blount_help/help.html","yes",false,"ZoomHelpWin2","Help","yes","");
	/*
   //MyWin.addTab("Entire County","blount_help/EntireCounty.html","yes",false,"ZoomHelpWin2","Help","yes","entirecounty");
   //MyWin.addTab("Zoom In","blount_help/ZoomIn.html","no",false,"ZoomHelpWin","Help1","yes","zoomin");
   //MyWin.addTab("Zoom Out","blount_help/ZoomOut.html","no",false,"ZoomHelpWin1","Help2","yes","zoomout");
   //MyWin.addTab("Pan View","blount_help/PanView.html","no",false,"ZoomHelpWin3","Help3","yes","panview");
   //MyWin.addTab("Go Back","blount_help/GoBack.html","no",false,"ZoomHelpWin4","Help4","yes","goback");
   //MyWin.addTab("Go Forward","blount_help/GoForward.html","no",false,"ZoomHelpWin5","Help5","yes","goforward");
   //MyWin.addTab("Measure","blount_help/Measure.html","no",false,"ZoomHelpWin6","Help6","yes","measure");
   //MyWin.addTab("Identify","blount_help/Identify.html","no",false,"ZoomHelpWin7","Help7","yes","identify");
   //MyWin.addTab("Clear","blount_help/Clear.html","no",false,"ZoomHelpWin8","Help8","yes","clear");
   //MyWin.addTab("Print","blount_help/Print.html","no",false,"ZoomHelpWin9","Help9","yes","print");
   //MyWin.addTab("E_mail","blount_help/E_mail.html","no",false,"ZoomHelpWin10","Help10","yes","mail");
   //MyWin.addTab("Feed Back","blount_help/FeedBack.html","no",false,"ZoomHelpWin11","Help11","yes","feedback");
   //MyWin.addTab("Last Name","blount_help/LastName.html","no",false,"ZoomHelpWin12","Help12","yes","last");
   //MyWin.addTab("Street Name","blount_help/StreetName.html","no",false,"ZoomHelpWin13","Help13","yes","street");
		  //MyWindow.nav.getComponent("TopicGrid").getStore().loadData(myData);
	  //MyWindow.nav.getComponent("TopicGrid").on( "rowclick", function(){
	  	
	  	//var b = MyWindow.nav.getComponent("TopicGrid").getSelectionModel().getSelected().get("tabId");
	  	//MyWindow.tabs.getComponent(b).show();
	  	
	  	
	  	//});

	var custom = new Ext.Resizable('help_div', {
    wrap:false,
    pinned:false,
    //minWidth:50,
    //minHeight: 50,
    preserveRatio: false,
    dynamic:true,
    //handles: 'all', // shorthand for 'n s e w ne nw se sw'
    draggable:true
});
*/
    Ext.get('mb1').on('click', function(e){
        Ext.MessageBox.confirm('Confirm', 'Are you sure you want to do that?', showResult);
    });

    Ext.get('mb2').on('click', function(e){
        Ext.MessageBox.prompt('Name', 'Please enter your name:', showResultText);
    });

    Ext.get('mb3').on('click', function(e){
        Ext.MessageBox.show({
           title: 'Address',
           msg: 'Please enter your address:',
           width:300,
           buttons: Ext.MessageBox.OKCANCEL,
           multiline: true,
           fn: showResultText,
           animEl: 'mb3'
       });
    });

    Ext.get('mb4').on('click', function(e){
        Ext.MessageBox.show({
           title:'Save Changes?',
           msg: 'You are closing a tab that has unsaved changes. <br />Would you like to save your changes?',
           buttons: Ext.MessageBox.YESNOCANCEL,
           fn: showResult,
           animEl: 'mb4',
           icon: Ext.MessageBox.QUESTION
       });
    });

    Ext.get('mb6').on('click', function(){
        Ext.MessageBox.show({
           title: 'Please wait',
           msg: 'Loading items...',
           progressText: 'Initializing...',
           width:300,
           progress:true,
           closable:false,
           animEl: 'mb6'
       });

       // this hideous block creates the bogus progress
       var f = function(v){
            return function(){
                if(v == 12){
                    Ext.MessageBox.hide();
                    Ext.example.msg('Done', 'Your fake items were loaded!');
                }else{
                    var i = v/11;
                    Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
                }
           };
       };
       for(var i = 1; i < 13; i++){
           setTimeout(f(i), i*500);
       }
    });

    Ext.get('mb7').on('click', function(){
        Ext.MessageBox.show({
           msg: 'loading, please wait...',
           progressText: 'loading...',
           width:300,
           wait:true,
           waitConfig: {interval:200},
           icon:'ext-mb-download', //custom class in msg-box.html
           animEl: 'mb7'
       });

    });

    Ext.get('mb8').on('click', function(){
        Ext.MessageBox.alert('Status', 'Changes saved successfully.', showResult);
    });

    //Add these values dynamically so they aren't hard-coded in the html
    Ext.fly('info').dom.value = Ext.MessageBox.INFO;
    Ext.fly('question').dom.value = Ext.MessageBox.QUESTION;
    Ext.fly('warning').dom.value = Ext.MessageBox.WARNING;
    Ext.fly('error').dom.value = Ext.MessageBox.ERROR;

    Ext.get('mb9').on('click', function(){
        Ext.MessageBox.show({
           title: 'Error',
           msg: 'Please type a Street name at first!',
           buttons: Ext.MessageBox.OK,
           animEl: 'mb9',
           fn: showResult,
           icon: Ext.MessageBox.WARNING
       });
    });

    Ext.get('mb10').on('click', function(){
        Ext.MessageBox.show({
           title: 'Error',
           msg: 'Please type a last name at first!',
           buttons: Ext.MessageBox.OK,
           animEl: 'mb10',
           fn: showResult1,
           icon: Ext.MessageBox.WARNING
       });
    });
    
    Ext.get('mb12').on('click', function(){

    });
    
    
    
        function showResult1(btn){
        Ext.example.msg('Error', 'The last name field is is required', btn);
    };

    function showResult(btn){
        Ext.example.msg('Error', 'The street name field is is required', btn);
    };

    function showResultText(btn, text){
        Ext.example.msg('Error', 'You clicked the {0} button and entered the text "{1}".', btn, text);
    };
});