if (typeof(OPAGENDA) == 'undefined') {
    OPAGENDA = {};
}

if (typeof(OPAGENDA.MapData) == 'undefined') {
	//create defaults if none are set
    OPAGENDA.MapData = {
		"mapdiv":"map",
		"paneldiv":"maptypetext",
		"centerlat":40.72514478577348,
		"centerlng":-73.96751403808594,
		"zoom":13,
		"defaultyear":1985,
		"defaultmaptype":"pov"  //options: pov || demo
	};
}

if (typeof(OPAGENDA.MapTypes) == 'undefined') {
    OPAGENDA.MapTypes = [];
}

if (typeof(OPAGENDA.Hospitals) == 'undefined') {
    OPAGENDA.Hospitals = [];
}

if (typeof(OPAGENDA.MapIcons) == 'undefined') {
    OPAGENDA.MapIcons = {};
}

if (typeof(OPAGENDA.MapIcons.BaseIcon) == 'undefined') {
	OPAGENDA.MapIcons.BaseIcon = new GIcon();
	OPAGENDA.MapIcons.BaseIcon.shadow = "../images/open_shadow.png";
	OPAGENDA.MapIcons.BaseIcon.iconSize = new GSize(18, 45);
	OPAGENDA.MapIcons.BaseIcon.shadowSize = new GSize(36, 45);
	OPAGENDA.MapIcons.BaseIcon.iconAnchor = new GPoint(3, 45);
	OPAGENDA.MapIcons.BaseIcon.infoWindowAnchor = new GPoint(9, 2);
	OPAGENDA.MapIcons.BaseIcon.infoShadowAnchor = new GPoint(9, 38);
}
if (typeof(OPAGENDA.MapIcons.OpenIcon) == 'undefined') {
	OPAGENDA.MapIcons.OpenIcon = new GIcon(OPAGENDA.MapIcons.BaseIcon);
	OPAGENDA.MapIcons.OpenIcon.image = "../images/open.png";
}
if (typeof(OPAGENDA.MapIcons.ClosedIcon) == 'undefined') {
	OPAGENDA.MapIcons.ClosedIcon = new GIcon(OPAGENDA.MapIcons.BaseIcon);
	OPAGENDA.MapIcons.ClosedIcon.image = "../images/closed.png";
}
if (typeof(OPAGENDA.MapIcons.ChangingIcon) == 'undefined') {
	OPAGENDA.MapIcons.ChangingIcon = new GIcon(OPAGENDA.MapIcons.BaseIcon);
	OPAGENDA.MapIcons.ChangingIcon.image = "../images/changing.png";
}

OPAGENDA.Load = function(){ 
	OPAGENDA.MAP = new OPAGENDA.Map(OPAGENDA.MapData, OPAGENDA.MapTypes, OPAGENDA.Hospitals, OPAGENDA.HospitalDataHeaders);
}


OPAGENDA.Map = function(mapsettings, maptypes, waypoints, dataheaders){	
	//set some constants
	this.waypoints = waypoints;
	this.dataheaders = dataheaders;
	this.markers = {"1985":{}, "1995":{}, "2005":{}};  //this would be nicer if it was learned from something else
	this.mapdiv = document.getElementById(mapsettings.mapdiv);
	this.paneldiv = document.getElementById(mapsettings.paneldiv);
	this.center = new GLatLng(mapsettings.centerlat, mapsettings.centerlng);
	this.zoom = mapsettings.zoom;
	this.activeyear = mapsettings.defaultyear;
	this.activemaptype = mapsettings.defaultmaptype;
	this.maptypes = {}; //holds refs to custom maptypes

	//these references make things go a hell of a lot faster
	//these are the 6 panel top images
	this.bannerimgs = {
		"pov1985":$('bannerpov1985'),
		"pov1995":$('bannerpov1995'),
		"pov2005":$('bannerpov2005'),
		"demo1985":$('bannerdemo1985'),
		"demo1995":$('bannerdemo1995'),
		"demo2005":$('bannerdemo2005')
	};
	//these are the 6 divs with maptype descriptions
	this.descdivs = {
		"pov1985":$('pov1985'),
		"pov1995":$('pov1995'),
		"pov2005":$('pov2005'),
		"demo1985":$('demo1985'),
		"demo1995":$('demo1995'),
		"demo2005":$('demo2005')
	};
	//these are the 6 custom radio buttons
	this.btnimgs = {
		"pov1985":$('pov1985btn'),
		"pov1995":$('pov1995btn'),
		"pov2005":$('pov2005btn'),
		"demo1985":$('demo1985btn'),
		"demo1995":$('demo1995btn'),
		"demo2005":$('demo2005btn')
	};

	//make a map
	this.map = new GMap2(this.mapdiv);
	this.map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(5, 50)));
	var bannercontrol = this.MakeMapBanner();
	this.map.addControl(bannercontrol);
	this.povledg = this.MakeLedg('pov');
	this.demoledg = this.MakeLedg('demo');
	switch(this.activemaptype){
		case 'pov':
			this.map.addControl(this.povledg);
			break;
		case 'demo':
			this.map.addControl(this.demoledg);
			break;
	}
	var mtcount = maptypes.length;
	for (var n = 0; n < mtcount; n++){ this.AddMapType( maptypes[n] ); };

	//resize stuff
	OPAGENDA.Utl.regOffsetObjs([$('top'),$('header'),$('footer')]);
	OPAGENDA.Utl.regOffsetBonus(68);
	OPAGENDA.Utl.regMinSize(500);
	OPAGENDA.Utl.regMap(this.map);
	OPAGENDA.Utl.regMapDiv(this.mapdiv);
	OPAGENDA.Utl.regPanelDiv(this.paneldiv);
	OPAGENDA.Utl.sizeMapDiv();
	OPAGENDA.Utl.setResizeListener();

	this.map.setCenter(this.center, this.zoom);
	this.ToggleMapTypeDesc((this.activemaptype + this.activeyear));
	this.ChangeMapType(this.activemaptype);
	this.ProcessMarkers();
	this.AddOverlayListener();
}


OPAGENDA.Map.prototype = {
	"MakeMapBanner":function(){
		ref = this.map;

		var control = function(){}

		control.prototype = new GControl();

		control.prototype.initialize = function(){
			var container = DIV(null, IMG({"src":"images/map_banner_lf.gif"}));
			ref.getContainer().appendChild(container);
			return container;
		}

		control.prototype.getDefaultPosition = function() {
		  return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(-2, -1));
		}

		mycontrol = new control();
		return mycontrol;
	},
	"MakeLedg":function(type){
		ref = this.map;

		var control = function(){}

		control.prototype = new GControl();

		control.prototype.initialize = function(){
			var container = DIV(null, IMG({"src":("images/" + type + "_leg.gif")}));
			ref.getContainer().appendChild(container);
			return container;
		}

		control.prototype.getDefaultPosition = function() {
		  return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(6, 16));
		}

		mycontrol = new control();
		return mycontrol;
	},
	"AddMapType":function(mtdata){
		// create copyright
		var copyright = new GCopyright(3,
                              new GLatLngBounds( new GLatLng(mtdata.bounds[0], mtdata.bounds[1]), new GLatLng(mtdata.bounds[2], mtdata.bounds[3]) ),
                              mtdata.minzoom,
                              mtdata.copyright);

		//add to copyright collection
		var copyrightCollection = new GCopyrightCollection();
		copyrightCollection.addCopyright(copyright);

		// create GTileLayer
		CustomGetTileUrl=function(a, b){
			var c = 17 - b;
			if (b < 12){
				return "http://mt.google.com/mt?n=404&v=ap.5&x="+a.x+"&y="+a.y+"&zoom="+c;
			}else{
				return mtdata.tilesurl + a.x + "_" + a.y + "_" + c + ".png";
			}
		}

		var tilelayers = [];
		tilelayers.push( G_NORMAL_MAP.getTileLayers()[0] );
		tilelayers.push( new GTileLayer( copyrightCollection, mtdata.minzoom, mtdata.maxzoom ) );

		tilelayers[1].getTileUrl = CustomGetTileUrl;

		if (mtdata.ispng) { 
			tilelayers[1].isPng = function(){return true;};
 		}else{
			tilelayers[1].getOpacity = function() {return mtdata.opacity;};
		}

		var custommap = new GMapType(tilelayers, G_NORMAL_MAP.getProjection(), mtdata.name, {minResolution:mtdata.minzoom, maxResolution:mtdata.maxzoom, errorMessage:mtdata.errormsg});

		//add it to the map
		this.map.addMapType(custommap);

		//add a reference to it
		this.maptypes[mtdata.name] = custommap;
	},
	"ProcessMarkers": function(){
		//for each waypoints set process each point
		var count = this.waypoints.length;
		for (var n=0; n < count; n++){
			//sort the set of points on their status
			//this.waypoints[n].data.sort(keyComparator("status"));

			var waypointscount = this.waypoints[n].data.length;

			for (var i=0; i < waypointscount; i++){
				var waypointdata = this.waypoints[n].data[i];
				//this id ref is problematic if we ever want to use more than one set of data
				var id = i;
				this.waypoints[n].data[i].id = id;  //create a cross reference in our waypoint array just in case
				//process all this crap for all three years
				//would be nicer if the years was learned not hard coded
				var m1985 = this.markers["1985"][id] = {};
				var m1995 = this.markers["1995"][id] = {};
				var m2005 = this.markers["2005"][id] = {};

				m1985.data = waypointdata;
				m1985.data.tabtext = this.waypoints[n].tabtext;
				m1985.region = this.waypoints[n].region;
				m1985.marker = this.MakeMarker(waypointdata, 1985);
				if (m1985.marker != null){
					m1985.marker.my_id = id;
					m1985.marker.my_year = 1985;
				}
				m1995.data = waypointdata;
				m1995.data.tabtext = this.waypoints[n].tabtext;
				m1995.region = this.waypoints[n].region;
				m1995.marker = this.MakeMarker(waypointdata, 1995);
				if (m1995.marker != null){
					m1995.marker.my_id = id;
					m1995.marker.my_year = 1995;
				}
				m2005.data = waypointdata;
				m2005.data.tabtext = this.waypoints[n].tabtext;
				m2005.region = this.waypoints[n].region;
				m2005.marker = this.MakeMarker(waypointdata, 2005);
				if (m2005.marker != null){
					m2005.marker.my_id = id;
					m2005.marker.my_year = 2005;
				}
			}
		}
		//add all markers for a given year
		this.AddMarkersInYear(this.activeyear);
		//create side panel of all markers from this.markers
		//this.UpdateSidePanel( this.markers );
	},
	"MakeMarker":function(mdata, year){
		var tipclass;
		var icon;
		var grfx;
		var statusindex;
		switch (year)
		{
			case 1985:
				statusindex = 0;
				break;
			case 1995:
				statusindex = 1;
				break;
			case 2005:
				statusindex = 2;
				break;
		}
		switch (mdata.status[statusindex])
		{
			case 0:
				tipclass = 'tip-base tip-open';
				icon = OPAGENDA.MapIcons.OpenIcon;
				grfx = "../images/open_grfx.gif"
				break;
			case 1:
				tipclass = 'tip-base tip-closed';
				icon = OPAGENDA.MapIcons.ClosedIcon;
				grfx = "../images/closed_grfx.gif"
				break;
			case 2:
				tipclass = 'tip-base tip-downsized';
				icon = OPAGENDA.MapIcons.ChangingIcon;
				grfx = "../images/downsized_grfx.gif"
				break;
			case 3:
				tipclass = 'tip-base tip-restructuring';
				icon = OPAGENDA.MapIcons.ChangingIcon;
				grfx = "../images/restructuring_grfx.gif"
				break;
			case 4:
				tipclass = 'tip-base tip-marked';
				icon = OPAGENDA.MapIcons.ChangingIcon;
				grfx = "../images/marked_grfx.gif"
				break;
			default:
				tipclass = 'tip-base tip-open';
				icon = OPAGENDA.MapIcons.ChangingIcon;
				grfx = "../images/open_grfx.gif"
		}
		if (mdata.point[0] != null && mdata.point[1] != null){
			var point = new GLatLng( parseFloat(mdata.point[0]), parseFloat(mdata.point[1]) );
			var tip = "<div class='"+tipclass+"'><img src='"+grfx+"' style='float:right'/><div class='tip-text-block'><div class='info-title-mini'>"+mdata.name+"</div><div class='info-address'>"+mdata.address[0]+"<br/>"+mdata.address[1] + " NY, " + mdata.address[2]+"</div></div></div>";
			var offset = new GSize(20,-20);
			var opts = {"offset":offset};
	//		var marker = new GMarker( point, icon); //<-- Google's Marker, for testing only
			var marker = new GxMarker( point, icon, tip, opts);
		}else{
			var marker = null;
		}
		return marker;
	},
	"MakeDataCell":function(cdata){
		cdata = (cdata != null)?cdata:"--.--";
//		return SPAN(null, SPAN({'class':'red'},cdata));
		return SPAN({'class':'red'},cdata);
	},
	"MakePercDataCell":function(cdata){
		cdata = (cdata != null)?cdata:"--.--";
		return SPAN(null, SPAN({'class':'red'},cdata), SPAN(null, "%"));
	},
	"MakeStatusText":function(n){
		var text = "";
		switch (n)
		{
			case 0:
				text = "Open";
				break;
			case 1:
				text = "Closed";
				break;
			case 2:
				text = "Downsized";
				break;
			case 3:
				text = "Restructuring";
				break;
			case 4:
				text = "Slated For Closure";
				break;
			default:
				text = "NA";
				break;
		}
		//return text;
		return this.MakeDataCell(text);
	},
	"MakeInfoText":function(array){
		var pelms = []; 
		for (var n=0; n<array.length; n++){
			pelms.push( P(null, array[n]) );
		}
		return pelms;
	},
	"MergeData":function(array){
		var allnull = true;
		var sum = 0;
		for (var n=0; n<array.length; n++){
			if (array[n] != null)
			{
				sum += array[n];
				allnull = false;
			}
		}
		if (allnull)
		{
			return null;
		}else{
			return (Math.round(sum * 100) / 100);
		}
	},
	"MakeMarkerTabs":function(mdata){
		var tab0 = MochiKit.DOM.DIV( {'class':'opmap-marker'},
									DIV({'class':'info-title'}, mdata.name),
									DIV({'class':'info-address'}, 
										SPAN(null, mdata.address[0]),
										BR(),
										SPAN(null, mdata.address[1] + " NY, " + mdata.address[2])
									),
									DIV({'class':'info-body'},
										TABLE({'class':'info-table'}, 
											TBODY(null,
												TR(null,
													TD({'class':'rowlabel'}, "1985"),
													TD({'class':'left'}, this.MakeStatusText(mdata.status[0]))
												),
												TR(null,
													TD({'class':'rowlabel'}, "1995"),
													TD({'class':'left'}, this.MakeStatusText(mdata.status[1]))
												),
												TR(null,
													TD({'class':'rowlabel'}, "2005"),
													TD({'class':'left'}, this.MakeStatusText(mdata.status[2]))
												)
											)
										)
									),
									DIV({'class':'info-body'}, this.MakeInfoText(mdata.tabtext[0]))			
								);

		var tab1 = MochiKit.DOM.DIV( {'class':'opmap-marker'},
									DIV({'class':'info-title'}, mdata.name),
									DIV({'class':'info-body'},
										TABLE({'class':'info-table'}, 
											THEAD(null, 
												TR(null, 
													TD(null, ""),
													TD(null, "1985"),
													TD(null, "1995"),
													TD(null, "2005")
												)
											),
											TBODY(null, 
												TR(null, 
													TD({'class':'rowlabel'}, this.dataheaders.censusdata[4]), 
													TD(null, this.MakePercDataCell(mdata.censusdata['1985'][4])),
													TD(null, this.MakePercDataCell(mdata.censusdata['1995'][4])),
													TD(null, this.MakePercDataCell(mdata.censusdata['2005'][4]))
												),
												TR(null, 
													TD({'class':'rowlabel'}, this.dataheaders.censusdata[5]), 
													TD(null, this.MakePercDataCell(mdata.censusdata['1985'][5])),
													TD(null, this.MakePercDataCell(mdata.censusdata['1995'][5])),
													TD(null, this.MakePercDataCell(mdata.censusdata['2005'][5]))
												),
												TR(null, 
													TD({'class':'rowlabel'}, this.dataheaders.censusdata[6]), 
													TD(null, this.MakePercDataCell(mdata.censusdata['1985'][6])),
													TD(null, this.MakePercDataCell(mdata.censusdata['1995'][6])),
													TD(null, this.MakePercDataCell(mdata.censusdata['2005'][6]))
												),
												TR(null, 
													TD({'class':'rowlabel'}, this.dataheaders.censusdata[7]), 
													TD(null, this.MakePercDataCell(mdata.censusdata['1985'][7])),
													TD(null, this.MakePercDataCell(mdata.censusdata['1995'][7])),
													TD(null, this.MakePercDataCell(mdata.censusdata['2005'][7]))
												),
												TR(null, 
													TD({'class':'rowlabel'}, this.dataheaders.censusdata[8]), 
													TD(null, this.MakePercDataCell(mdata.censusdata['1985'][8])),
													TD(null, this.MakePercDataCell(mdata.censusdata['1995'][8])),
													TD(null, this.MakePercDataCell(mdata.censusdata['2005'][8]))
												),
												TR(null, 
													TD({'class':'rowlabel'}, this.dataheaders.censusdata[9] + "/" + this.dataheaders.censusdata[10]), 
													TD(null, this.MakePercDataCell( this.MergeData([mdata.censusdata['1985'][9], mdata.censusdata['1985'][10]]) )),
													TD(null, this.MakePercDataCell( this.MergeData([mdata.censusdata['1995'][9], mdata.censusdata['1995'][10]]) )),
													TD(null, this.MakePercDataCell( this.MergeData([mdata.censusdata['2005'][9], mdata.censusdata['2005'][10]]) ))
												)
											)
										)
									),
									DIV({'class':'info-body'}, this.MakeInfoText(mdata.tabtext[2]))			
								);

		var tab2 = MochiKit.DOM.DIV( {'class':'opmap-marker'},
									DIV({'class':'info-title'}, mdata.name),
									DIV({'class':'info-body'},
										TABLE({'class':'info-table'}, 
											THEAD(null, 
												TR(null, 
													TD(null, ""),
													TD(null, "1985"),
													TD(null, "1995"),
													TD(null, "2005")
												)
											),
											TBODY(null, 
											TR(null, 
												TD({'class':'rowlabel'}, this.dataheaders.censusdata[0]), 
												TD(null, this.MakePercDataCell(mdata.censusdata['1985'][0])),
												TD(null, this.MakePercDataCell(mdata.censusdata['1995'][0])),
												TD(null, this.MakePercDataCell(mdata.censusdata['2005'][0]))
											),
											TR(null, 
												TD({'class':'rowlabel'}, this.dataheaders.censusdata[1]), 
												TD(null, this.MakePercDataCell(mdata.censusdata['1985'][1])),
												TD(null, this.MakePercDataCell(mdata.censusdata['1995'][1])),
												TD(null, this.MakePercDataCell(mdata.censusdata['2005'][1]))
											),
											TR(null, 
												TD({'class':'rowlabel'}, this.dataheaders.censusdata[2]), 
												TD(null, this.MakePercDataCell(mdata.censusdata['1985'][2])),
												TD(null, this.MakePercDataCell(mdata.censusdata['1995'][2])),
												TD(null, this.MakePercDataCell(mdata.censusdata['2005'][2]))
											),
											TR(null, 
												TD({'class':'rowlabel'}, this.dataheaders.censusdata[3]), 
												TD(null, this.MakePercDataCell(mdata.censusdata['1985'][3])),
												TD(null, this.MakePercDataCell(mdata.censusdata['1995'][3])),
												TD(null, this.MakePercDataCell(mdata.censusdata['2005'][3]))
											)
										))
									),
									DIV({'class':'info-body'}, this.MakeInfoText(mdata.tabtext[2]))
								);

		var tab3 = MochiKit.DOM.DIV( {'class':'opmap-marker'},
									DIV({'class':'info-title'}, mdata.name),
									DIV({'class':'info-body'},
										TABLE({'class':'info-table'}, TBODY(null, 
											TR(null, 
												TD({'class':'rowlabel'}, this.dataheaders.score[0]),
												TD(null, this.MakeDataCell(mdata.score[0]))
											),
											TR(null, 
												TD({'class':'rowlabel'}, this.dataheaders.score[1]),
												TD(null, this.MakeDataCell(mdata.score[1]))
											),
											TR(null, 
												TD({'class':'rowlabel'}, this.dataheaders.score[2]),
												TD(null, this.MakeDataCell(mdata.score[2]))
											)
										))
									),
									DIV({'class':'info-body'}, this.MakeInfoText(mdata.tabtext[3]))
								);

		return [new GInfoWindowTab("Status", tab0), new GInfoWindowTab("Ethnicity", tab1), new GInfoWindowTab("Payer", tab2), new GInfoWindowTab("Quality", tab3)];
	},
	"AddMarkersInYear":function(year){
		//get array by year
		var markers = this.markers[year];
		//loop over array and add markers to map
		for (n in markers){
			if (markers[n].marker != undefined && markers[n].marker != null){
				this.map.addOverlay(markers[n].marker);
			}
		}
	},
	"ReplaceMarkers":function(oldyear, newyear){
		//get array by year
		var oldmarkers = this.markers[oldyear];
		var newmarkers = this.markers[newyear];
		//loop over array and add markers to map
		for (n in oldmarkers){
			if (oldmarkers[n].marker != undefined && oldmarkers[n].marker != null){
				this.map.removeOverlay(oldmarkers[n].marker);
			}
			if (newmarkers[n].marker != undefined && newmarkers[n].marker != null){
				this.map.addOverlay(newmarkers[n].marker);
			}
		}
	},
	"AddOverlayListener": function(){
		GEvent.addListener(this.map, "click", function(marker) {
			if (marker && marker.my_id != undefined){ 
				if ( (marker.my_tabs == undefined || marker.my_tabs == null) ){
					/* Oh, this is not so pretty
					 * better to find way to bind to OPAGENDA.MAP as this
					 */		
					var OM = OPAGENDA.MAP;
					var year = marker.my_year;
					var id = marker.my_id;
					var tabs = OM.MakeMarkerTabs(OM.markers[year][id].data);
					marker.my_tabs = tabs;
				}
				marker.openInfoWindowTabsHtml(marker.my_tabs);
			}
		});
	},
/*
	"UpdateSidePanel": function(markers){
		var rows = map(function(row) {
			return  [ A({"href":"javascript: OPAGENDA.MAP.markers["+row.id+"].marker.openInfoWindow(OPAGENDA.MAP.markers["+row.id+"].marker.my_html);"}, row.name), 
					  row.quality,
					  row.status];
		}, markers);

		row_display = function (row) {
			return TR(null, 
					TD({"class":"data-name"}, row[0]),
					TD({"class":"data-quality"}, row[1]),
					TD({"class":"data-status"}, row[2])
				 	);
		}
	
		var newTable = TABLE({"class":"panel-data"},
			THEAD(null, TR(null, 
				TD({"class":"data-name"},"name"),
				TD({"class":"data-quality"},"quality"),
				TD({"class":"data-status"},"status")
				)),
			TBODY(null, map(row_display, rows))
		);

		this.paneldiv.appendChild(newTable);
	},
*/
	"ChangeYear": function(year, maptype){
		var ref = this;
		var curyear = this.activeyear;

		//update constants
		this.activeyear = year;

		ref.ToggleMapTypeDesc((maptype + year));
		//this order is important
		ref.ToggleMapTypeLedg(maptype);
		ref.ChangeMapType(maptype);

		//not sure if this is doing anything for us
		slightDelay = function (){
			//add markers for given year
			if (year != curyear){
				ref.ReplaceMarkers(curyear, year);
			}
		}

		var t = setTimeout("slightDelay()",600);
	},
	"ChangeMapType": function(maptype){
		var newmaptype;
		if (maptype == 'pov' || maptype == 'demo'){
			newmaptype = this.maptypes[(maptype + (this.activeyear - 5))];
			this.activemaptype = maptype;
		}else{
			newmaptype = maptype;
			this.activemaptype = maptype;
		}
		//changebackground
		this.map.setMapType( newmaptype );
		//change background key image
	},
	"ToggleMapTypeLedg": function(type){
		if (type != this.activemaptype){
			var add = (type == 'pov')?this.povledg:this.demoledg;
			var remove = (type == 'pov')?this.demoledg:this.povledg;
			this.map.removeControl(remove);
			this.map.addControl(add);
		}
	},
	"ToggleMapTypeDesc": function(id){
		for (n in this.descdivs){
			this.bannerimgs[n].style.display = "none";
			this.descdivs[n].style.display = "none";
			this.btnimgs[n].src = "../images/radiobtn_option.gif";
		}
		this.bannerimgs[id].style.display = "block";
		this.descdivs[id].style.display = "block";
		this.btnimgs[id].src = "../images/radiobtn_select.gif";
	}
}
