function OnGoClick()
{
	app.Init();
	app.SetElection(Ext.getCmp('electionRadio').getGroupValue());
	app.SetMaptype(Ext.getCmp('maptypePres').getGroupValue());
	app.SetThematic(Ext.getCmp('thematic').getValue() ? 1 : 0);
	
	app.Update();
}

function OnLinkClick(level, region)
{
	app.Init();
	app.SetElection(Ext.getCmp('electionRadio').getGroupValue());
	app.SetMaptype(Ext.getCmp('maptypePres').getGroupValue());
	app.SetThematic(Ext.getCmp('thematic').getValue() ? 1 : 0);
	
	app.SetLevel(level);
	app.SetRegion(region);
	
	app.Update();
}

function OnMapClick(x, y)
{
	app.Init();
	app.SetElection(Ext.getCmp('electionRadio').getGroupValue());
	app.SetMaptype(Ext.getCmp('maptypePres').getGroupValue());
	app.SetThematic(Ext.getCmp('thematic').getValue() ? 1 : 0);
	
	app.UpdateMap(x,y);
}


function Update()
{
	election = Ext.getCmp('electionRadio').getGroupValue();
	maptype = Ext.getCmp('maptypePres').getGroupValue();
	thematic = Ext.getCmp('thematic').getValue() ? 1 : 0;
	if(maptype == 1 && election == 2001)
	{
		Ext.MessageBox.show({
			title: 'Error',
			msg: 'There are no parliamentary results for the 2000 run-off elections.\nPlease select Presidential or another year',
			width:400,
			buttons: Ext.MessageBox.OK//,
			//animEl: paragraph
		});
		return false;
	}
	return true;	
}

var cardNav = function(page){
	var l = Ext.getCmp('card-panel').getLayout();

	btng = Ext.getCmp('btnGraph');
	btnm = Ext.getCmp('btnMap');
	
	if(page == 'map')
	{
		l.setActiveItem(0);
		Ext.getCmp('card-panel').setTitle('Map : ' + title);//		SetView(0);
		btnm.toggle(true);
		btng.toggle(false);
	}
	else
	{
		l.setActiveItem(1);
		Ext.getCmp('card-panel').setTitle('Graph : ' + title);
		btnm.toggle(false);
		btng.toggle(true);
	}
};
/*
var grid; // grid component
var xg = Ext.grid;
	
	
function createGrid()
{
	grid = new xg.GridPanel(
	{
		store: ds, // use the datasource
 		region:'south',
		cm: new xg.ColumnModel(
			[
				{id:'party',header: "Party",  sortable: true, dataIndex: 'party'},
				{id:'name',header: "Candidate Name",  sortable: true, dataIndex: 'name'},
				{id:'votes',header: "Votes",  sortable: true, dataIndex: 'votes',align:'right'}					
			]
		),        
 
		viewConfig: 
		{
			forceFit:true
		},
 
		width:450,
		stripeRows:true,
		//title:'Search results',
		layout:'fit',
		iconCls:'icon-grid',
		renderTo: "stats",
		autoHeight:true
 
	});
}
 	// ----------------
	//	vars
	// ----------------
/*	var ds;	// datasource var
* 
	// ----------------
	//	Create datasource
	// ----------------
function createDS()
{
	ds = new Ext.data.Store({
    	proxy: new Ext.data.HttpProxy({
        	url: 'search.php', // serverside script to post to
        	method: 'POST' // method of posting .. GET or POST .. I've used POST
    	}),

    	// the reader
        reader:  new Ext.data.JsonReader({
			totalProperty: 'total',
			root: 'results', // the object wich old the records
			id: 'party', // the fieldname wich hold the id ... optional
			fields: [{name:'party'},'name',{name:'votes',type:'int'}] // the fields the reader need to render 
		})        	

	});				
}


*/