/*
 * Ext JS Library 1.1.1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */
 var start=1;
var IsToolShow=0;
Ext.onReady(function(){
    Ext.QuickTips.init();

    // Menus can be prebuilt and passed by reference
    var dateMenu = new Ext.menu.DateMenu({
        handler : function(dp, date){
            Ext.example.msg('Date Selected', 'You chose {0}.', date.format('M j, Y'));
        }
    });

    // Menus can be prebuilt and passed by reference
    var colorMenu = new Ext.menu.ColorMenu({
        handler : function(cm, color){
            Ext.example.msg('Color Selected', 'You chose {0}.', color);
        }
    });
    
    
    
//---------------------------------Tools------------------------------//
        var custom = new Ext.Resizable('tools', {
            wrap:true,
            pinned:false,
            minWidth:50,
            minHeight: 50,
            width: 50,
            Height: 80,
            preserveRatio: false,
            enabled : false,
            //handles: 'all',
            draggable:true,
            dynamic:true
        });
        var customEl = custom.getEl();
        // move to the body to prevent overlap on my blog
        //document.body.insertBefore(customEl.dom, document.body.firstChild);
        
        //customEl.on('dblclick', function(){
            //customEl.hide(true);
        //});

//---------------------------------Tools----End--------------------------//
/*
    var menu = new Ext.menu.Menu({
        id: 'mainMenu',
        items: [
            new Ext.menu.CheckItem({
                text: 'I like Ext',
                checked: true,
                checkHandler: onItemCheck
            }),
            new Ext.menu.CheckItem({
                text: 'Ext for jQuery',
                checked: true,
                checkHandler: onItemCheck
            }),
            new Ext.menu.CheckItem({
                text: 'I donated!',
                checked:false,
                checkHandler: onItemCheck
            }), '-', {
                text: 'Radio Options',
                menu: {        // <-- submenu by nested config object
                    items: [
                        // stick any markup in a menu
                        '<b class="menu-title">Choose a Theme</b>',
                        new Ext.menu.CheckItem({
                            text: 'Aero Glass',
                            checked: true,
                            group: 'theme',
                            checkHandler: onItemCheck
                        }),
                        new Ext.menu.CheckItem({
                            text: 'Vista Black',
                            group: 'theme',
                            checkHandler: onItemCheck
                        }),
                        new Ext.menu.CheckItem({
                            text: 'Gray Theme',
                            group: 'theme',
                            checkHandler: onItemCheck
                        }),
                        new Ext.menu.CheckItem({
                            text: 'Default Theme',
                            group: 'theme',
                            checkHandler: onItemCheck
                        })
                    ]
                }
            },{
                text: 'Choose a Date',
                cls: 'calendar',
                menu: dateMenu // <-- submenu by reference
            },{
                text: 'Choose a Color',
                menu: colorMenu // <-- submenu by reference
            }
        ]
    });
*/
    var tb = new Ext.Toolbar('toolbar');
    tb.add(
    /*
    {
    	
            cls: 'x-btn-text-icon bmenu', // icon and text class
            
            text:'Search By...',
            
            menu:{items: [
                        {text: '<b>Search By House Number</b>', handler: onViewNumber},
                        {text: '<b>Search By Street Name</b>', handler: onViewName}
                ]}
        }, 
        */
           {
            text: 'Tools',
            //handler: onButtonClick,
            tooltip: {text:'Hide or Show Tools Panel', title:'', autoHide:true},
            cls: 'x-btn-text-icon bview',
            handler: onViewTools


        },
         {
            text: 'Search By ...',
            //handler: onButtonClick,
            tooltip: {text:'Hide or Show Search Panel', title:'', autoHide:true},
            cls: 'x-btn-text-icon blist',
            handler: function(){window.parent.ShowSearchBy();}
    
            // Menus can be built/referenced by using nested menu config objects
      
        }, '-',
        {
                    text: 'Entire County',
            handler: onButtonClick,
	    // tooltip: {text:'', title:'', autoHide:true},
            cls: 'x-btn-text-icon ball'	
        	
        	}
        , '-',
        {
                    text: 'Pan View',
            handler: onButtonClick1,
	    //  tooltip: {text:'PAN VIEW (MOVE)', title:'MOVE', autoHide:true},
            cls: 'x-btn-text-icon bpan'	
        	
        	}, '-',
        {
	
        	
        	
        	                    text: 'Zoom In',
            handler: onButtonClick2,
	    // tooltip: {text:'Zoom In (DRAW RECTANGLE AROUND AREA OF INTEREST)', title:'Zoom In', autoHide:true},
            cls: 'x-btn-text-icon bzoomin'	
        	}, '-',
        {
                    text: 'Zoom Out',
            handler: onButtonClick3,
	    // tooltip: {text:'Zoom Out', title:'ZOOM OUT', autoHide:true},
            cls: 'x-btn-text-icon bzoomout'	
        	
        	}, '-',
        {
                    text: 'Go Forward',
            handler: onButtonClick4,
	    // tooltip: {text:'GO BACK (TO PREVIOUS MAP VIEW)', title:'GO BACK ', autoHide:true},
            cls: 'x-btn-text-icon bredo'	
        	
        	}, '-',
        {
                    text: 'Go Back',
            handler: onButtonClick5,
	    // tooltip: {text:'GO FORWARD', title:'GO FORWARD', autoHide:true},
            cls: 'x-btn-text-icon bundo'	
        	
        	}, '-',
        {
                    text: 'Measure',
            handler: onButtonClick6,
	    // tooltip: {text:'MEASURE (CLICK ONCE TO CHOOSE STARTING POINT; DOUBLE CLICK AT END POINT TO SHOW DISTANCE IN FT)', title:'MEASURE', autoHide:true},
            cls: 'x-btn-text-icon bmser'	
        	
        	}, '-',
        {
                    text: 'Identify',
            handler: onButtonClick7,
	    // tooltip: {text:'IDENTIFY (CLICK ON AN AREA OF INTEREST FOR DETAILS ABOUT IT)', title:'IDENTIFY', autoHide:true},
            cls: 'x-btn-text-icon binfor'	
        	
        	}, '-',
        {
                    text: 'Clear',
            handler: onButtonClick8,
	    // tooltip: {text:'CLEAR (REMOVE ALL GRAPHICS FROM MAP VIEW)', title:'CLEAR', autoHide:true},
            cls: 'x-btn-text-icon bclear'	
        	
        	}, '-',
        {
                    text: 'Print',
            handler: onButtonClick9,
            //tooltip: {text:'Print (Print the map)', title:'Print', autoHide:true},
            cls: 'x-btn-text-icon bprint'	
        	
        	}, '-',
        {
                    text: 'Help',
            handler: getScale
        	
        	}
        
        
        
        );

   function getScale()
   {
   top.MyWin.show();
  // a.tab.getComponent()
   }

    // functions to display feedback
    function onViewTools(){
    	if(IsToolShow==1)
    	{
    		
    		customEl.show(true);
    		IsToolShow=0;
    		//document.getElementById("TheTools").innerHTML="<b>hide Tools  </b>";
    		}
    	else
    	  {
    	  	
    	  	customEl.hide(true);
    	  	IsToolShow=1;
    	  	//document.getElementById("TheTools").innerHTML="<b>show Tools  </b>";
    	  	}
        //Ext.example.msg('Button Click','You clicked the "{0}" button.', btn.text);
    }


    function onViewInfor(){
    	
	    window.parent.Example.ShowHideWest();
	    return false;
              }
              
              
                  function onViewNumber(item){
    	 
	    window.parent.Example.ShowHideSearchNumber();

              }
              
                                function onViewName(item){
    	  
	    window.parent.Example.ShowHideSearchName();

              }
              
    function onItemCheck1()
    {
    	if(start==1)
    	{
      w1.ShowLayers("lineON");
      }
    }
        function onItemCheck2()
    {
    	if(start==1)
    	{
      w1.ShowLayers("lineOFF");
      }
    }
        function onItemCheck3()
    {
    	if(start==1)
    	{
      w1.ShowLayers("CLR3ON");
      }
    }
        function onItemCheck4()
    {
    	if(start==1)
    	{
      w1.ShowLayers("CLR3OFF");
      }
    }
        function onItemCheck5()
    {
    	if(start==1)
    	{
      w1.ShowLayers("BW7ON");
      }
    }
        function onItemCheck6()
    {
    	if(start==1)
    	{
      w1.ShowLayers("BW7OFF");
      }
    }
    
    
    function onButtonClick()
    {
    	C_buttondown('T_Ball');
    }
        function onButtonClick1()
    {
    	C_buttondown('T_Bmove');
    }
            function onButtonClick2()
    {
    	C_buttondown('T_Bzoom');
    }
                function onButtonClick3()
    {
    	C_buttondown('T_Bzoomout');
    }
                    function onButtonClick4()
    {
    	C_buttondown('T_Bredo');
    }
                        function onButtonClick5()
    {
    	C_buttondown('T_Bundo');
    }
                           function onButtonClick6()
    {
    	C_buttondown('T_Bmeasure');
    }
                               function onButtonClick7()
    {
    	C_buttondown('T_Bqu');
    }
                                   function onButtonClick8()
    {
    	C_buttondown('T_Bdel');
    }
    
                                       function onButtonClick9()
    {
    	w1.PrintMap()
    }
});

