// We define the function first
function ElevationButtonControl() {
}

// To "subclass" the GControl, we set the prototype object to
// an instance of the GControl object
ElevationButtonControl.prototype = new GControl();

// Creates a one DIV for each of the buttons and places them in a divContainer
// DIV which is returned as our control element. We add the control to
// to the map divContainer and return the element for the map class to
// position properly.
ElevationButtonControl.prototype.initialize = function(map) {
       
	    var divButtonBackground = document.createElement("div");
        divButtonBackground.id = "elevation_button_control";

        // ================================
        // Build HTML
        // ================================
		var htmlButtons = "";
		var strElevationLink = strURL + '/view_route?r=' + route_key + '&show_elevation_panel=1&rs=' + escape(document.referer);	

		htmlButtons = "<a href='"+strElevationLink+"' target='_blank'><img src='images/btn_elevation_up.jpg' height='40' width='125' border='0' id='btnElevation' onmouseover=\"this.src='images/btn_elevation_down.jpg';\" onmouseout=\"this.src='images/btn_elevation_up.jpg';\"/></a><br/>";
		
		if (intWindowWidth > 500) {
			htmlButtons = "<div style='text-align:center;'>" + htmlButtons;
				htmlButtons += "<div style='border:1px solid #666''>";
				htmlButtons += "<a href='http://click.linksynergy.com/fs-bin/stat?id=6b1nDRmFSrA&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=http%253A%252F%252Fitunes.apple.com%252FWebObjects%252FMZStore.woa%252Fwa%252FviewSoftware%253Fid%253D306561234%2526mt%253D8%2526partnerId%253D30' target='_blank' title='Download iMapMyRide+ for iPhone'><img src='images/btn_imapmyride_plus.jpg' border='0' /></a>";
				htmlButtons += "<a href='http://click.linksynergy.com/fs-bin/stat?id=6b1nDRmFSrA&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=http%253A%252F%252Fitunes.apple.com%252FWebObjects%252FMZStore.woa%252Fwa%252FviewSoftware%253Fid%253D306468004%2526mt%253D8%2526partnerId%253D30' target='_blank' title='Download iMapMyRun+ for iPhone'><img src='images/btn_imapmyrun_plus.jpg' border='0' /></a>";
				htmlButtons += "<a href='http://click.linksynergy.com/fs-bin/stat?id=6b1nDRmFSrA&offerid=146261&type=3&subid=0&tmpid=1826&RD_PARM1=http%253A%252F%252Fitunes.apple.com%252FWebObjects%252FMZStore.woa%252Fwa%252FviewSoftware%253Fid%253D306554556%2526mt%253D8%2526partnerId%253D30' target='_blank' title='Download iMapMyFitness+ for iPhone'><img src='images/btn_imapmyfit_plus.jpg' border='0' /></a><br/>";
				htmlButtons += "<div style='padding:3p;font-size:9px;text-align:center;color:#FFF;background-color:#000;>VIEW OUR iPHONE APPS</div>";
				htmlButtons += "</div>";
			htmlButtons += "</div>";
		}

        // ================================
        // Append Master Container to Map
        // ================================
		divButtonBackground.innerHTML = htmlButtons;
        map.getContainer().appendChild(divButtonBackground);

        return divButtonBackground;
}

// By default, the control will appear in the top left corner of the
// map with 7 pixels of padding.
ElevationButtonControl.prototype.getDefaultPosition = function() {
        return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(5, 3));
}
