
function pagina()
{

//toolbar
        var toolbar = new mapfish.widgets.toolbar.Toolbar({
            map: map, 
            configurable: false
       });
	   
	   //toolbar.render('toolbar');
	   
	   //separadors del toolbar
	   var addSeparator = function() { 
            toolbar.add(new Ext.Toolbar.Spacer());
            toolbar.add(new Ext.Toolbar.Separator());
            toolbar.add(new Ext.Toolbar.Spacer());
        };
                
		// this is a quick fix for http://trac.mapfish.org/trac/mapfish/ticket/126
		toolbar.autoHeight = false;
		toolbar.height = 25;
		
 
 		
            myModel = [{
            text: "Recursos Turístics",
            expanded: true,
            checked: true,
            children: [{
                text: "Punts d'Informació",
                icon: "images/icons/icon_1.png",
                layerName: "Punts info",
                checked: false
            },{
                text: "Cooperatives i Molins d'Oli",
                icon: "images/icons/icon_0.png",
                layerName: "Cooperatives",
                checked: false
            },{
                text: "Zona d'interès arqueològic",
                icon: "images/icons/icon_3.png",
                layerName: "Zona arqueolo",
                checked: false
            },{
                text: "Patrimoni religiós",
                icon: "images/icons/icon_4.png",
                layerName: "Esglesies",
                checked: false
            },{
                text: "Pintura rupestre",
                icon: "images/icons/icon_5.png",
                layerName: "Pintures",
                checked: false
            },{
                text: "Torres i Castells",
                icon: "images/icons/icon_2.png",
                layerName: "Torres i Castells",
                checked: false
            },{
                text: "Museus i Espais Visitables",
                icon: "images/icons/icon_6.png",
                layerName: "Museus",
                checked: false
            },{
                text: "RCP / ARI",
                icon: "images/icons/icon_7.png",
                layerName: "RCP",
                checked: false
            },{
                text: "Hotels i Hostals",
                icon: "images/icons/icon_8.png",
                layerName: "Hotels i hostals",
                checked: false
            },{
                text: "Càmpings",
                icon: "images/icons/icon_9.png",
                layerName: "Campings",
                checked: false
			},{
                text: "Restaurants",
                icon: "images/icons/icon_10.png",
                layerName: "Restaurants",
                checked: false
            },{
                text: "Cases de Colònies",
                icon: "images/icons/icon_11.png",
                layerName: "Colonies",
                checked: false
			},{
                text: "Albergs",
                icon: "images/icons/icon_12.png",
                layerName: "Albergs",
                checked: false
			},{
                text: "Rutes",
                icon: "images/icons/icon_13.png",
                layerName: "Rutes",
                checked: false
			},{
                text: "Refugis FEEC",
                icon: "images/icons/icon_14.png",
                layerName: "Refugis FEEC",
                checked: false
			},{
                text: "Esports d'aventura",
                icon: "images/icons/icon_15.png",
                layerName: "esports aventura",
                checked: false
			},{
                text: "Àrea de descans i lleure",
                icon: "images/icons/icon_16.png",
                layerName: "Picnic",
                checked: false
			},{
                text: "Vistes panoràmiques",
                icon: "images/icons/icon_17.png",
                layerName: "Vistes",
                checked: false
			},{
                text: "Punts d'interès general",
                icon: "images/icons/icon_18.png",
                layerName: "Punts general",
                checked: false
			},{
                text: "Fonts",
                icon: "images/icons/icon_19.png",
                layerName: "Fonts",
                checked: false
			},{
                text: "Parcs i jardins",
                icon: "images/icons/icon_20.png",
                layerName: "Parcs i jardins",
                checked: false
			},{
                text: "Punts d'interés natural",
                icon: "images/icons/icon_22.png",
                layerName: "Punts natural",
                checked: false
			},{
                text: "Monestirs",
                icon: "images/icons/icon_25.png",
                layerName: "Monestirs",
                checked: false
			}]
            
        },{
            text: "Capes de base",
            expanded: true,
            children: [{
                text: "Físic de Google",
                id: 'gphy',
                checked: false,
                layerName: "Google Physical"
                
            },{
                text: "Carrers de Google",
                id: 'gmap',
                checked: true,
                layerName: "Google Streets"
                
            },
			{
                text: "Híbrid de Google",
                id: 'ghyb',
                checked: false,
                layerName: "Google Hybrid"
                
            },
			{
                text: "Imatge aèria Google",
               id: 'gsat',
                checked: false,
                layerName: "Google Satellite"
                
            }]
        }];
			
			

			var viewport = new Ext.Viewport({
            layout:'border',
            items:[
                new Ext.BoxComponent({ // raw
                    region: 'north',
                    el: 'north',
                    height: 80
					
                }),/*{
                    region: 'south',
                    contentEl: 'south',
                    split: true,
                    height: 100,
                    minSize: 100,
                    maxSize: 200,
                    collapsible: true,
                    title: 'Informació del punt clicat',
                    margins: '0 0 0 0'
                },*/{
                    region: 'west',
                    id: 'west-panel',
                    title: '  ',
                    //split: true,
                    width: 250,
                    minSize: 175,
                    maxSize: 400,
                    collapsible: true,
                    margins: '0 0 0 0',
                    layout: 'accordion',
                    layoutConfig:{
                        animate: true
                    },
                    items: [
					{
						//labelWidth: 75, // label settings here cascade unless overridden
						contentEl: 'west',
						frame:true,
						collapsed: true,
						title: 'Cerca per Població',
						html:'<br><form name="form" method="post" action="res_poblacio.php" target="iframe_res"><input name="poblacio" type="text" id="poblacio"><br><br><div align="center"><input type="submit" name="Submit" value="Enviar"></div><br></form><tr><td><iframe name="iframe_res" marginwidth="2" width="165" height="300" scrolling="auto" frameborder="0"></iframe>'
					},{
                        contentEl: 'west',
						frame:true,
						title: 'Capes',
						//collapsed: false,
                        border: false,
                        xtype: 'layertree',
						model: myModel,
                        map: map
                    }]
                },{
                   region: 'center',
                        //title: 'map',
                        layout: 'fit',
                        frame: false,
                        border: true,
                        margins: '0 0 0 0',
                        items: [{
                            xtype: 'mapcomponent',
                            map: map,
                            tbar: toolbar,
                            border: false
                        }]
                }
             ]
        });
			
	  //anem posant els controls de la barra toolbar que ens interessin (amb separadors de tant en tant)
      toolbar.addControl(  new OpenLayers.Control.ZoomToMaxExtent({
         map: map,
         title: 'Zoom a la màxima extensió'
      }), {
         iconCls: 'zoomfull', 
         toggleGroup: 'map'
      }
   );
      
   
      
   toolbar.addControl(
      new OpenLayers.Control.ZoomBox({
         title: 'Zoom - : clica en el mapa o utilitza el botó esquerre del ratolí i dibuixa un rectangle'
      }), {
         iconCls: 'zoomin', 
         toggleGroup: 'map'
      }
   );
   
   toolbar.addControl(
      new OpenLayers.Control.ZoomBox({
         out: true,
         title: 'Zoom + : clica en el mapa o utilitza el botó esquerre del ratolí i dibuixa un rectangle'
      }), {
         iconCls: 'zoomout', 
         toggleGroup: 'map'
      }
   );
      
   toolbar.addControl(
      new OpenLayers.Control.DragPan({
         isDefault: false,
         title: 'Moure mapa: manté apretat el botó esquerre del ratolí i mou el mapa'
      }), {
         iconCls: 'pan', 
         toggleGroup: 'map'
      }
   );
   
   toolbar.addControl(
		 new OpenLayers.Control.DragPan({
         isDefault: true,
         title: 'Clica als elements del mapa per veure´n més informació'
      }), {
         iconCls: 'query', 
         toggleGroup: 'map'
      }
	);
      

	addSeparator();
	 
	  
	toolbar.add({xtype: 'tbtext', text: '<a href="#" onClick="javascript:print_mapa();"><img src="images/print.png" title="Imprimir" border="0"></a>'});
	addSeparator();
	toolbar.add({xtype: 'tbtext', text: '<a href="cerca_recurs2.php" title="Clica aquí per fer una cerca per comarca">Cerca per recurs túristic i comarca</a>'});
	toolbar.activate();

/*
	  
	   var printConfigUrl = 'http://demo.mapfish.org/mapfishsample/1.1/print/info.json';

	  toolbar.addControl(
	  new mapfish.widgets.print.PrintAction({
            map: map,
            configUrl: printConfigUrl,
            overrides: layerOverrides,
            fillSpec: function(printCommand) {
                mapfish.widgets.print.PrintAction.prototype.fillSpec.call(this, printCommand);
 
                //our layout needs two fields... hard code them here
                printCommand.spec.comment = "No comment";
                printCommand.spec.mapTitle = "PrintControl";
            }
        })
	  
	  );*/
    /* el punt, el quadrat i la linia no em funcionen
	addSeparator();
      
   toolbar.addControl(
      new OpenLayers.Control.DrawFeature(vectorLayer, OpenLayers.Handler.Point, {
         title: 'Draw a point on the map'
      }), {
         iconCls: 'drawpoint', 
         toggleGroup: 'map'
      }
   );
      
   toolbar.addControl(
      new OpenLayers.Control.DrawFeature(vectorLayer, OpenLayers.Handler.Path, {
         title: 'Draw a linestring on the map'
      }), {
         iconCls: 'drawline', 
         toggleGroup: 'map'
      }
   );
      
   toolbar.addControl(
      new OpenLayers.Control.DrawFeature(vectorLayer, OpenLayers.Handler.Polygon, {
         title: 'Draw a polygon on the map'
      }), {
         iconCls: 'drawpolygon', 
         toggleGroup: 'map'
      }
   ); */
   
  
};

function print_mapa()
{
	var bName = navigator.appName;
	var bVer = parseFloat(navigator.appVersion);
	var contenido = document.getElementById("map").innerHTML;
	ventana=window.open("print.php","TurisMapes","width=950,resizable");
	ventana.document.open();
	ventana.document.write('<html><head><title>TurisMapes</title></head><body style=\"background-color: #FFFFFF\">');
	ventana.document.write(contenido);
	ventana.document.write('</body></html>');
	ventana.document.close();
	ventana.print();
	ventana.focus();
}