/*
gmap_v3_size.js, V 1.03, altm, 07.11.2011
Author: ATLSoft, Bernd Altmeier
Author URI: http://www.atlsoft.de
Google Maps V3 init multimap support
released under GNU General Public License
*/
	function SizeControl(controlDiv, map) {
		// Setup custom reszize control
		var controlUI = document.createElement('div');
		controlUI.title = msg_00;
		var urlfull = 'background: url(' + pluri + 'img/full.png) no-repeat;';
		var urlmin = 'background: url(' + pluri + 'img/flat.png) no-repeat;';
		jQuery(controlUI).attr("class", "gmv3_mapbtn");
		jQuery(controlUI).attr("style",urlfull);
		controlDiv.appendChild(controlUI);

		// things to remember
		var center;		
		var isFullsize = false; 
		var trans = false;
		var divmap = "div#" + map.getDiv().id
		var oldval = jQuery(divmap).attr("style");
		var oldbody = jQuery("body").attr("style");
		var oldw = jQuery(divmap).width(); 
		var oldh = jQuery(divmap).height(); 
		var p = jQuery(divmap).position(); 
		var scrolpos;		
		// Setup click event listeners: simply resize
		google.maps.event.addDomListener(controlUI, 'click', function() {
			center = map.getCenter();
			xc = Math.round(jQuery(window).width()/2);
			yc = Math.round(jQuery(window).height()/2);
			if (isFullsize){
				jQuery("div#wpadminbar").attr("style", "visibility:visible;");
				jQuery(divmap).animate({
					top: Math.round(p.top) + 'px',
					left: Math.round(p.left) + 'px',
					width: oldw + 'px',  
					height: oldh + 'px'
					}, 
					1000, 
					function() {
						jQuery("body").attr("style", oldbody);
						jQuery("body").css("overflow", "auto");
						jQuery("html").css("overflow", "auto"); //ie7 fix
						jQuery(divmap).attr("style", oldval);
						jQuery(scrollToEle).scrollTop(scrolpos);
						google.maps.event.trigger(map, 'resize');
					}
				);				
				isFullsize = false; 
				jQuery(controlUI).attr("style",urlfull);
			} else {
				scrolpos = jQuery(scrollToEle).scrollTop();
				jQuery("div#wpadminbar").attr("style", "visibility:hidden;");
				jQuery("body").css("overflow", "hidden");
				jQuery(scrollToEle).scrollTop(0);
				jQuery("html").css("overflow", "hidden"); //ie7 fix
				jQuery(divmap).attr("style", "background-color:#DDDDDD; position:absolute; top:"+yc+"px; left:"+xc+"px; margin:0px; padding:0px; overflow:hidden; z-index:"+fszIndex+";");
				jQuery(divmap).animate({
					top:'0px',
					left:'0px',
					width:'100%',  
					height: '100%' 
					}, 
					1000, 
					function() {
						google.maps.event.trigger(map, 'resize');
					}
				);				
				isFullsize = true; 
				jQuery(controlUI).attr("style",urlmin);
			}
			trans = true;
			// Setup resize listener
			google.maps.event.addDomListener(map, 'resize', function() {
				if (trans){
					if(map["bbox"].isEmpty())
						map.panTo(center);
					else
						map.fitBounds(map["bbox"]);
				} 
				trans = false;
			});
		});
	}	

