/*	Google Maps API HtmlControl v1.1.2
	based on code posted on Google Maps API discussion group
	last updated/modified by Martin Pearman 20th August 2008
	
	http://googlemapsapi.martinpearman.co.uk/htmlcontrol
	
	This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

	You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

function MyMenuControl(options){
	
	
	this.isVisible=true;
	this.isPrintable=false;	
	this.isSelectable=false;
	if(options){
		this.isVisible=(options.visible===false)?false:true;
		this.isPrintable=(options.printable===true)?true:false;
		this.isSelectable=(options.selectable===true)?true:false;
	}
};

MyMenuControl.prototype=new GControl();

MyMenuControl.prototype.initialize=function(map){

	this.div=document.createElement('div');
	this.div.style.width = "50px";
	this.div.setAttribute("class", "SuperMenuControlHolder"); 	
	this.div.style.marginRight= "30px";						
	this.div.style.border = "1px solid #CCCCCC"	;
	
	var divControls = document.createElement('div');	
	this.div.style.width = "50px";	
	divControls.setAttribute("class", "menuControlHolder"); 
	this.div.appendChild(divControls);			
	
	
	var div = document.createElement('div');	
	div.setAttribute("class", "menuControlHeader"); 	
	div.innerHTML = "Tools";
	div.style.width = "50px";
	div.style.paddingTop = "5px";	
	div.style.paddingBottom = "5px";		
	div.style.background= "#FFFFFF";		
	div.style.borderBottom = "5px solid #CCCCCC"	;	
	divControls.appendChild(div);				
	
	/*start Gary additions for marker control menu*/
			
		var td = document.createElement('div');	
		td.setAttribute("class", "menuControlSubHolders"); 
	

		var addNewMarkerButtom = document.createElement('img');		
		addNewMarkerButtom.id = "addNewMarkerButton";
		addNewMarkerButtom.src= site_img+'Bmu.png';	
		addNewMarkerButtom.title =	"Add a placemark";
		GEvent.addDomListener(addNewMarkerButtom, 'click', function() {
																	
			if(typeof fb_profile.id != "undefined"){
				MyMenuControlSwitch("addNewMarkerButtom");
			}
			else{
				fb_logmein();
			}
		});			

		
		td.appendChild(addNewMarkerButtom);		
		td.style.width = "50px";		
		td.style.background= "#C4D4F3";		
		td.style.paddingTop = "10px";			
		td.style.paddingBottom = "10px";			
		
		
		divControls.appendChild(td);			
	/*end Gary additions for marker control menu*/	
	
	/*start Gary additions for image gallery control menu*/
	
		var td = document.createElement('div');	
		td.setAttribute("class", "menuControlSubHolders"); 		
	
		var addNewMarkerButtom = document.createElement('img');		
		addNewMarkerButtom.id = "seeGallery";				
		addNewMarkerButtom.src=site_img+'Gmu.png';	
		addNewMarkerButtom.title =	"Image Gallery View";
		GEvent.addDomListener(addNewMarkerButtom, 'click', function() {
			MyMenuControlSwitch("seeGallery");
		});						
		
		td.appendChild(addNewMarkerButtom);		
		td.style.width = "50px";	
		td.style.background= "#C4D4F3";		
		td.style.paddingTop = "5px";					
		td.style.paddingBottom = "10px";
		
		divControls.appendChild(td);	
	/*end Gary additions for image gallery control menu*/			

	/*start Gary additions for image gallery control menu*/
	
		var td = document.createElement('div');	
		td.style.width = "50px";	
		td.style.borderTop = "5px solid #CCCCCC"	;			
		td.style.background= "#FFFFFF";		
		td.style.height = "3px";					

		
		divControls.appendChild(td);	
	/*end Gary additions for image gallery control menu*/		

	
	
	this.setVisible(this.isVisible);
	map.getContainer().appendChild(this.div);
	return this.div;
};

MyMenuControl.prototype.getDefaultPosition=function(){
	return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(10,7));
};

MyMenuControl.prototype.selectable=function(){
	return this.isSelectable;
};

MyMenuControl.prototype.printable=function(){
	return this.isPrintable;
};

MyMenuControl.prototype.setVisible=function(bool){
	this.div.style.display=bool ? '':'none';
	this.isVisible=bool;
};

MyMenuControl.prototype.visible=function(){
	return this.isVisible;
};




function MyMenuControlSwitch(button){
	switch(button){
		case 'addNewMarkerButtom' :	
			if(is_shown){
				leftPanel = 'listings_holder';
				addNewMarkerButtomSleep();
				//seeTagCloudButtonSleep();
				//activateStreetViewButtonSleep();
				//seeGallerySleep();
			}
			else{
				leftPanel = 'insert_location_div';
				seeTagCloudButtonSleep();		
				seeGallerySleep();					
				addNewMarkerButtomActive();				
			}
			break;
		case 'seeGallery' :
					addNewMarkerButtomSleep();
					seeTagCloudButtonSleep();
					seeGalleryActive();		
				break;					
	}
}

function addNewMarkerButtomActive(){
	document.getElementById("addNewMarkerButton").src= site_img+'Bmd.png';	
	showInsertLocation();
	is_shown = true;
}

function addNewMarkerButtomSleep(){
	document.getElementById("addNewMarkerButton").src= site_img+'Bmu.png';	
	StopAddAddress();
	is_shown = false;	
}



function seeGalleryActive(){
	document.getElementById("seeGallery").src= site_img+'Gmd.png';		
	window.open(ROOT_URL+'/class.cooliris.php','cooliris','fullscreen=yes, scrollbars=auto');	
}

function seeGallerySleep(){
	document.getElementById("seeGallery").src= site_img+'Gmu.png';		
}


