﻿function initialize() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"),
            { size: new GSize(640,320) } );
        map.removeMapType(G_HYBRID_MAP);
        map.setCenter(new GLatLng(31.316101, 121.464844), 6);
        map.addControl(new GLargeMapControl());
 
        var mapControl = new GMapTypeControl();
        map.addControl(mapControl);
        
      }
    }
    var divObj = GetObj("map");
    var control = GetObj("control");
    if (window.attachEvent) control.attachEvent('onclick',loading);
    if (window.addEventListener) control.addEventListener('click',loading,false);
    divObj.style.left = control.style.left;
    divObj.style.top = control.style.top;
    var RefreyshInterval = 1;
    var t1;
    var flag = true;
    function GetObj(objName){
			if(document.getElementById){
				return eval('document.getElementById("' + objName + '")');
			}else if(document.layers){
				return eval("document.layers['" + objName +"']");
			}else{
				return eval('document.all.' + objName);
			}
		}
    function loading() {
      clearInterval(t1);
      if(flag){
      	divObj.style.display = 'block';
      	control.innerHTML = 'Close';
	    t1 = setInterval( 'zoomOut()', 10 );
	  }else{
	  	control.innerHTML = 'Map+'
	  	t1 = setInterval( 'zoomIn()', 10 );
	  }
	    
      }
      function zoomOut(){
      	if (parseInt(divObj.style.width) < 640){
      	divObj.style.width = (parseInt(divObj.style.width)+10)+'px';
      	 divObj.style.height = (parseInt(divObj.style.height)+5)+'px';
      }else{
      	flag = false;
      	clearInterval(t1);
      	initialize();
      }
    }
    function zoomIn(){
      	if(parseInt(divObj.style.width)< 300){
      		divObj.innerHTML = '';
      		GUnload();
      	}
      	if (parseInt(divObj.style.width)> 0){
      	divObj.style.width = (parseInt(divObj.style.width)-10)+'px';
      	 divObj.style.height = (parseInt(divObj.style.height)-5)+'px';
      }else{
      	flag = true;
      	clearInterval(t1);
      	divObj.style.display = 'none';
      	}
    }