// JavaScript Document
Ext.BLANK_IMAGE_URL = 'ext/resources/images/default/s.gif';
	var win;
	var panel1;

function showWindow($id){
	try{
	//alert('showWindow: ' + $id);
	var url = '';
	var w = 800;
	switch($id){
		case 'btn1':
		case 'm_raceinfo':
			url = 'race-info';
			w = 900;
		break;
		case 'btn2':
		case 'm_registration':
			url = 'registration';
			w = 900;
		break;
		case 'btn3':
		case 'm_trailshots':
			url = 'trail-shots';
			w = 900;
		break;
		case 'btn4':
		case 'm_schedule':
			url = 'schedule';
			w = 975;
		break;
		case 'btn5':
		case 'm_transfer':
			url = 'transfer';
			w = 900;
		break;
		case 'btn6':
		case 'm_map':
			url = 'map';
			w = 900;
		break;
		case 'header':
			url = 'http:\/\/www.thewanderboy.net\/about.php';
			w = 900;
		break;

	}
	
	panel1 = new Ext.Panel({
		region:'center',					   
		id: $id + 'panel',					  
		autoScroll: true,
		margins:'0 0 0 0',
		border: false,
		bodyStyle: 'padding: 0px 0px 0px 0px'
	});
	
	win = new Ext.Window({
		//title: 'Conquer Corregidor - The 10-mile Island Run Challenge',						 
          width:w, //831
          height:558,
          closeAction:'hide',
          plain: false,
		shim:false,
		draggable: false,
		resizable: false,
		maximizable:true,
		layout: 'border',
		bodyStyle: 'padding: 0px 0px 0px 0px',
		y:47,
		items : [panel1],
          buttons: [{
			id:'viewinwindow',
          	text: 'View in new tab/window',
               handler: function(){
				if($id != 'header'){
				window.open ("conquer-corregidor" + "/" + url + ".php?v=" + Math.random(),"another_view"); 	
				}else{
				window.open (url + "?v=" + Math.random(),"another_view"); 	
				}
              		
			}},{
          	text: 'Close',
               handler: function(){
               win.hide();
			}
          }]
     });
	

	win.show($id);
	
	if($id != 'header'){
	panel1.load({
	    url: "conquer-corregidor" + "/" + url + ".php?v=" + Math.random(),
	    params: {source: "1"}, // or a URL encoded string
	    nocache: false,
	    text: "Loading...",
	    timeout: 30,
	    scripts: true
	});
		
	}else{
	panel1.load({
	    url: url + "?v=" + Math.random(),
	    params: {source: "1"}, // or a URL encoded string
	    nocache: false,
	    text: "Loading...",
	    timeout: 30,
	    scripts: true
	});
	
	Ext.getCmp('viewinwindow').disabled = true;
	}
	
	
	}catch(e){
		alert(e);		
	}
}
				 
