
var map;
var layers;
var items = [];
var tabArray = [];

/**
 * 初期化
 */
function init(){
	
	Rico.Corner.round("header",{corners:"all",color:"transparent"} );
	Rico.Corner.round("searchFrame",{corners:"all",bgColor:"#FFFFFF"} );
	Rico.Corner.round("bukkenResultFrame",{corners:"tl,tr",bgColor:"#FFFFFF"} );
	Rico.Corner.round("blogResultFrame",{corners:"tl,tr",bgColor:"#FFFFFF"} );
	Rico.Corner.round("layerFrame",{corners:"tl,tr",bgColor:"#FFFFFF"} );
	Rico.Corner.round("legendFrame",{corners:"tl,tr",bgColor:"#FFFFFF"} );
	Rico.Corner.round("rightMenuAd",{corners:"all",bgColor:"#FFFFFF"} );

	
	map = new GMap2(document.getElementById("map"));
	
    map.setCenter(new GLatLng(35.602959, 138.7), 6);
	map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
	map.enableDoubleClickZoom();
	//map.enableContinuousZoom();

	/*
	GEvent.addListener( map , "click" , function(overlay,  point) {
		$('debug').innerHTML = point.lat() + "," + point.lng() ;
	} );
	*/
    
    changeLayer( $('optionLayer').value );
	
	setTimeout("resize()",10);
}

function initLayers() {
	layers = new Array();
	
	
	var name = "land1974";
	var optionLayers = [];
	optionLayers[0] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[0].myLayers= '1';
	optionLayers[0].myFormat='image/png';
	optionLayers[0].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_shuto_ken&Service=WMS';
	optionLayers[0].getTileUrl=CustomGetTileUrl;
	optionLayers[0].getOpacity = function() {return 0.5;}
	optionLayers[0].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(35.074964853989556,139.1253662109375),
		new GLatLng(36.24427318493909,140.43548583984375 ) );		
	optionLayers[1] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[1].myLayers= '1';
	optionLayers[1].myFormat='image/png';
	optionLayers[1].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_chubu_ken&Service=WMS';
	optionLayers[1].getTileUrl=CustomGetTileUrl;
	optionLayers[1].getOpacity = function() {return 0.5;}
	optionLayers[1].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.72355492704219,136.3897705078125),
		new GLatLng(35.46514408578586,137.3345947265625) );
	optionLayers[2] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[2].myLayers= '1';
	optionLayers[2].myFormat='image/png';
	optionLayers[2].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_kinki_ken&Service=WMS';
	optionLayers[2].getTileUrl=CustomGetTileUrl;
	optionLayers[2].getOpacity = function() {return 0.5;}
	optionLayers[2].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.175453097578526,134.923095703125),
		new GLatLng(35.25907654252574,136.0107421875) );
	for( var i = 0 ; i < optionLayers.length; i++ ) {
		optionLayers[i] = new GTileLayerOverlay( optionLayers[i] );
	}
	layers[name] = optionLayers;
	
	var name = "land1979";
	var optionLayers = [];
	optionLayers[0] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[0].myLayers= '2';
	optionLayers[0].myFormat='image/png';
	optionLayers[0].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_shuto_ken&Service=WMS';
	optionLayers[0].getTileUrl=CustomGetTileUrl;
	optionLayers[0].getOpacity = function() {return 0.5;}
	optionLayers[0].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(35.074964853989556,139.1253662109375),
		new GLatLng(36.24427318493909,140.43548583984375 ) );
	optionLayers[1] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[1].myLayers= '2';
	optionLayers[1].myFormat='image/png';
	optionLayers[1].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_chubu_ken&Service=WMS';
	optionLayers[1].getTileUrl=CustomGetTileUrl;
	optionLayers[1].getOpacity = function() {return 0.5;}
	optionLayers[1].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.72355492704219,136.3897705078125),
		new GLatLng(35.46514408578586,137.3345947265625) );
	optionLayers[2] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[2].myLayers= '2';
	optionLayers[2].myFormat='image/png';
	optionLayers[2].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_kinki_ken&Service=WMS';
	optionLayers[2].getTileUrl=CustomGetTileUrl;
	optionLayers[2].getOpacity = function() {return 0.5;}
	optionLayers[2].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.175453097578526,134.923095703125),
		new GLatLng(35.25907654252574,136.0107421875) );
	for( var i = 0 ; i < optionLayers.length; i++ ) {
		optionLayers[i] = new GTileLayerOverlay( optionLayers[i] );
	}
	layers[name] = optionLayers;
	
	var name = "land1984";
	var optionLayers = [];
	optionLayers[0] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[0].myLayers= '3';
	optionLayers[0].myFormat='image/png';
	optionLayers[0].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_shuto_ken&Service=WMS';
	optionLayers[0].getTileUrl=CustomGetTileUrl;
	optionLayers[0].getOpacity = function() {return 0.5;}
	optionLayers[0].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(35.074964853989556,139.1253662109375),
		new GLatLng(36.24427318493909,140.43548583984375 ) );
	optionLayers[1] =  new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[1].myLayers= '3';
	optionLayers[1].myFormat='image/png';
	optionLayers[1].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_chubu_ken&Service=WMS';
	optionLayers[1].getTileUrl=CustomGetTileUrl;
	optionLayers[1].getOpacity = function() {return 0.5;}
	optionLayers[1].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.72355492704219,136.3897705078125),
		new GLatLng(35.46514408578586,137.3345947265625) );
	optionLayers[2] =  new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[2].myLayers= '3';
	optionLayers[2].myFormat='image/png';
	optionLayers[2].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_kinki_ken&Service=WMS';
	optionLayers[2].getTileUrl=CustomGetTileUrl;
	optionLayers[2].getOpacity = function() {return 0.5;}
	optionLayers[2].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.175453097578526,134.923095703125),
		new GLatLng(35.25907654252574,136.0107421875) );
	for( var i = 0 ; i < optionLayers.length; i++ ) {
		optionLayers[i] = new GTileLayerOverlay( optionLayers[i] );
	}
	layers[name] = optionLayers;
	
	var name = "land1989";
	var optionLayers = [];
	optionLayers[0] =  new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[0].myLayers= '4';
	optionLayers[0].myFormat='image/png';
	optionLayers[0].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_shuto_ken&Service=WMS';
	optionLayers[0].getTileUrl=CustomGetTileUrl;
	optionLayers[0].getOpacity = function() {return 0.5;}
	optionLayers[0].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(35.074964853989556,139.1253662109375),
		new GLatLng(36.24427318493909,140.43548583984375 ) );
	optionLayers[1] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[1].myLayers= '4';
	optionLayers[1].myFormat='image/png';
	optionLayers[1].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_chubu_ken&Service=WMS';
	optionLayers[1].getTileUrl=CustomGetTileUrl;
	optionLayers[1].getOpacity = function() {return 0.5;}
	optionLayers[1].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.72355492704219,136.3897705078125),
		new GLatLng(35.46514408578586,137.3345947265625) );
	optionLayers[2] =  new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[2].myLayers= '4';
	optionLayers[2].myFormat='image/png';
	optionLayers[2].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_kinki_ken&Service=WMS';
	optionLayers[2].getTileUrl=CustomGetTileUrl;
	optionLayers[2].getOpacity = function() {return 0.5;}
	optionLayers[2].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.175453097578526,134.923095703125),
		new GLatLng(35.25907654252574,136.0107421875) );
	for( var i = 0 ; i < optionLayers.length; i++ ) {
		optionLayers[i] = new GTileLayerOverlay( optionLayers[i] );
	}
	layers[name] = optionLayers;
	
	var name = "land1994";
	var optionLayers = [];
	optionLayers[0] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[0].myLayers= '5';
	optionLayers[0].myFormat='image/png';
	optionLayers[0].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_shuto_ken&Service=WMS';
	optionLayers[0].getTileUrl=CustomGetTileUrl;
	optionLayers[0].getOpacity = function() {return 0.5;}
	optionLayers[0].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(35.074964853989556,139.1253662109375),
		new GLatLng(36.24427318493909,140.43548583984375 ) );
	optionLayers[1] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[1].myLayers= '5';
	optionLayers[1].myFormat='image/png';
	optionLayers[1].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_chubu_ken&Service=WMS';
	optionLayers[1].getTileUrl=CustomGetTileUrl;
	optionLayers[1].getOpacity = function() {return 0.5;}
	optionLayers[1].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.72355492704219,136.3897705078125),
		new GLatLng(35.46514408578586,137.3345947265625) );
	optionLayers[2] = new GTileLayer(new GCopyrightCollection(""),1,19) ;
	optionLayers[2].myLayers= '5';
	optionLayers[2].myFormat='image/png';
	optionLayers[2].myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=landuse_kinki_ken&Service=WMS';
	optionLayers[2].getTileUrl=CustomGetTileUrl;
	optionLayers[2].getOpacity = function() {return 0.5;}
	optionLayers[2].myLatLngBounds = new GLatLngBounds( 
		new GLatLng(34.175453097578526,134.923095703125),
		new GLatLng(35.25907654252574,136.0107421875) );
	for( var i = 0 ; i < optionLayers.length; i++ ) {
		optionLayers[i] = new GTileLayerOverlay( optionLayers[i] );
	}
	layers[name] = optionLayers;
	
	
	/*
	var name = "ortho1970";
	var optionLayer= new GTileLayer(new GCopyrightCollection(""),1,17);
	optionLayer.myLayers= 'ORTHOIMG';
	optionLayer.myFormat='image/png';
	optionLayer.myBaseURL='http://orthophoto.mlit.go.jp/wms/default.aspx?';
	optionLayer.getTileUrl=CustomGetTileUrl;
	optionLayer.getOpacity = function() {return 0.8;}
	layers[name] = optionLayer;
	
	

	
	var name = "chika10";
	var optionLayer= new GTileLayer(new GCopyrightCollection(""),1,17);
	optionLayer.myLayers= '21';
	optionLayer.myFormat='image/png';
	optionLayer.myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=kokudo_suchi_chika';
	optionLayer.getTileUrl=CustomGetTileUrl;
	optionLayer.getOpacity = function() {return 1.0;}
	layers[name] = optionLayer;
	
	var name = "chika11";
	var optionLayer= new GTileLayer(new GCopyrightCollection(""),1,17);
	optionLayer.myLayers= '22';
	optionLayer.myFormat='image/png';
	optionLayer.myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=kokudo_suchi_chika';
	optionLayer.getTileUrl=CustomGetTileUrl;
	optionLayer.getOpacity = function() {return 1.0;}
	layers[name] = optionLayer;
	
	var name = "chika12";
	var optionLayer= new GTileLayer(new GCopyrightCollection(""),1,17);
	optionLayer.myLayers= '23';
	optionLayer.myFormat='image/png';
	optionLayer.myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=kokudo_suchi_chika';
	optionLayer.getTileUrl=CustomGetTileUrl;
	optionLayer.getOpacity = function() {return 1.0;}
	layers[name] = optionLayer;

	var name = "chika13";
	var optionLayer= new GTileLayer(new GCopyrightCollection(""),1,17);
	optionLayer.myLayers= '24';
	optionLayer.myFormat='image/png';
	optionLayer.myBaseURL='http://www.geographynetwork.ne.jp/ogc/wms?ServiceName=kokudo_suchi_chika';
	optionLayer.getTileUrl=CustomGetTileUrl;
	optionLayer.getOpacity = function() {return 1.0;}
	layers[name] = optionLayer;
	*/
	 
}

function getOptionLayers(name) {
	if( !layers ) {
		initLayers();
	}
	return layers[name] ;
}




/**
 * レイヤの変更
 */
function changeLayer(value) {
	
	if( this.optionLayers ) {
		for( var i = 0 ; i < this.optionLayers.length ; i++ ) {
			map.removeOverlay( this.optionLayers[i] );
		}
	}
	this.optionLayers = null;
	
	if( value ) {
		this.optionLayers= getOptionLayers(value);
		for( var i = 0 ; i < this.optionLayers.length ; i++ ) {
			map.addOverlay( this.optionLayers[i] );
		}
	}



}

function doAction() {

	alert("スマッチAPIの公開停止に伴い、現在機能をご利用いただけません。");
	return;
	
	$('bukkenResult').innerHTML = "検索中です...";
	var url = "./Smatch/getBukkenInfoEX.php?";
	var pars = "V=2" ;
	
	if( $('SE010').checked )  pars += "&SE[]=010";
	if( $('SE011').checked )  pars += "&SE[]=011";
	if( $('SE020').checked )  pars += "&SE[]=020";
	if( $('SE021').checked )  pars += "&SE[]=021";
	if( $('SE030').checked )  pars += "&SE[]=030";
	
	if( $('M1').checked )  pars += "&M[]=1";
	if( $('M2').checked )  pars += "&M[]=2";
	if( $('M3').checked )  pars += "&M[]=3";
	if( $('M4').checked )  pars += "&M[]=4";
	if( $('M5').checked )  pars += "&M[]=5";
	if( $('M5').checked )  pars += "&M[]=6";
			   
	pars +=  "&QUERY=" + encodeURI($("QUERY").value);
	pars += "&CNT=20";
	pars += "&P=1";
	//pars += "&debug=true";
	
	//alert(pars);
	var myAjax = new Ajax.Request( url, { 
		method: 'get', 
		parameters: pars, 
		onSuccess: responseBukkenInfo,
		onFailure: function() {alert("失敗しました。");} ,
		onException: function(request,exception) {alert(exception); }
		 });
		
	
	$('blogResult').innerHTML ="検索中です...";
	var url = "./Smatch/getKijiInfo.php?";
	var pars = "" ;			   
	pars +=  "&QUERY=" + encodeURI( $("QUERY").value);
	pars += "&CNT=20";
	pars += "&P=1";
	
	var myAjax = new Ajax.Request( url, { 
		method: 'get', 
		parameters: pars, 
		onSuccess: responseKijiInfo,
		onFailure: function() {alert("失敗しました。");} ,
		onException: function(request,exception) {alert(exception); }
		 });
	
}

function responseBukkenInfo(request) {
	var html = "";
	var bounds = new GLatLngBounds();
	map.clearOverlays();
	items = [];
	tabArray = [];
	if( request ) {
		//alert(request.responseText);
		//var result = request.responseText.parseJSON();
		var result =  eval('(' + request.responseText + ')');
		if( result.smatch.resultset.item ) {
			for( var i = 0 ; i < result.smatch.resultset.item.length ; i++ ) {
				var item = result.smatch.resultset.item[i];
				if( !isNaN(parseFloat(item.latitude ) )) {
					if( items.length % 2 == 0 ) {
						html += "<div id='item" + items.length + "' onclick='selectItem(" + items.length + ")' class='bukkenRecord01' >" ;
			        } else {
			        	html += "<div id='item" + items.length + "' onclick='selectItem(" + items.length + ")' class='bukkenRecord02' >" ;
			        }
			        
			        if( !item.stitle || item.stitle == "" ) {
			        	item.stitle = item.title;
			        } 
			        html += "<a href='javascript:selectItem(" + items.length + ")' >" +  item.stitle + "</a></div>";
			            
		            var marker = createBukkenMarker(item);
		            bounds.extend(new GLatLng(item.latitude,item.longitude));
					if( marker ) {
						try {
		            		map.addOverlay(marker);
						} catch ( e ) {

						}
					}
					items.push(item);
				}
				
			}
			
		} else {
			html = "検索結果は存在しません。";
		}
		
	}
	if( !bounds.isEmpty() ) {
		var center = bounds.getCenter();
		var sw = bounds.getSouthWest();
		var ne = bounds.getNorthEast();
		var delta = new GSize( ne.lng() - sw.lng(), ne.lat() - sw.lat());
		//var minZoom = map.spec.getLowestZoomLevel(center, delta, map.viewSize); 
		var minZoom = map.getBoundsZoomLevel(bounds);
		map.setCenter(center, minZoom);
	}
	$('bukkenResult').innerHTML = html;
}


function responseKijiInfo(request) {
	var html = "";
	if( request ) {
		//alert(request.responseText);
		//var result = request.responseText.parseJSON();
		var result =  eval('(' + request.responseText + ')');
		if( result.smatch.resultset.item ) {
			for( var i = 0 ; i < result.smatch.resultset.item.length ; i++ ) {
				var item = result.smatch.resultset.item[i];
				
				if( i % 2 == 0 ) {
					html += "<div id='item" + i + "' onclick='selectItem(" + i + ")' class='bukkenRecord01' >" ;
		        } else {
		        	html += "<div id='item" + i + "' onclick='selectItem(" + i + ")' class='bukkenRecord02' >" ;
		        }
				html += "<a href='" + item.link + "' target='_blank'>" 
						+ item.title + "</a></div>";
			}
		
		} else {
			html = "検索結果は存在しません。";
		}
		
	}
	$('blogResult').innerHTML = html;
}


function createBukkenMarker(item) {

	if( tabArray[item.latitude + "," + item.longitude] ) {
		var tabs = tabArray[item.latitude + "," + item.longitude];
		tabs.push(  new GInfoWindowTab( String( tabs.length + 1 ) , createBukkenHTML( item ) ) );
		item.marker = tabs.marker;
		item.tabIndex = tabs.length - 1;
	} else {
		var point = new GLatLng(item.latitude,item.longitude);
		var marker = new GMarker(point);
		var tabs = [];
		tabs[0] = new GInfoWindowTab( "1" , createBukkenHTML( item ) );
	 	GEvent.addListener(marker, "click", function() {
	   		marker.openInfoWindowTabsHtml(tabs , { "selectedTab" : marker.tabIndex });
	 	});
		tabArray[ item.latitude + "," + item.longitude ] = tabs;
	 	item.marker = marker;
		tabs.marker = marker;
		item.tabindex = 0;
	}
 	return marker;
}


function createBukkenHTML( item ) {
	var html = "";
	html += "<div class='bukkenDetail' style='font-weight:bold;'>" + item.category + "</div>";
	html += "<h2>" ;
	html += "<a target='_blank' href='" + item.link + "' >";
	html += item.stitle 
	html += "</a>";
	html += "</h2>";
	html += "<div class='bukkenDetail'><span style='font-weight:bold;'>住所：</span>" + item.address + "</div>";
	html += "<div class='bukkenDetail'><span style='font-weight:bold;'>価格：</span>" + item.kakaku + "</div>";
	html += "<div class='bukkenDetail'><span style='font-weight:bold;'>間取り：</span>" + item.madori + "</div>";
	html += "<div class='bukkenDetail'><span style='font-weight:bold;'>面積：</span>" + item.menseki + "</div>";
	html += "<div class='bukkenDetail'><span style='font-weight:bold;'>築年：</span>" + item.chikunen + "</div>";
	//html += "<div>" + item.description + "</div>";	

	if( item.kanigazo != null && item.kanigazo != "" ) {
		html += "<a target='_blank' href='" + item.kanigazo + "' >";
		html += "<img width='100' height='100' style='1px #000000 solid;' src='" + item.kanigazo +"' />";
		html += "</a>";
	}
	if( item.madorigazo != null && item.madorigazo != "" ) {
		html += "<a target='_blank' href='" + item.madorigazo + "' >";
		html += "<img width='100' height='100' style='1px #000000 solid;'  src='" + item.madorigazo +"' />";
		html += "</a>";
	}

	html += '<div>';
	//html += '<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=convivialblog-22&o=9&p=13&l=st1&mode=books-jp&search=%E3%83%9E%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%B3&=1&fc1=&lt1=&lc1=&bg1=&f=ifr" marginwidth="0" marginheight="0" width="268" height="60" border="0" frameborder="0" style="border:none;" scrolling="no"></iframe>';
	html += '</div>';
	return html;
}



function selectItem(index) {
	var item = items[index];
	if( item && item.marker ) {
		item.marker.tabIndex = item.tabIndex;
		GEvent.trigger( item.marker , "click");
		
	}

}



function getWindowWidth(){
  if(window.innerWidth) return window.innerWidth; // Mozilla, Opera, NN4
  if(document.documentElement && document.documentElement.clientWidth){ // 以下 IE
   return document.documentElement.clientWidth;
  }
  else if(document.body && document.body.clientWidth){
   return document.body.clientWidth;
  }
  return 0;
}


function getWindowHeight(){
  if(window.innerHeight) return window.innerHeight; // Mozilla, Opera, NN4
  if(document.documentElement && document.documentElement.clientHeight){ // 以下 IE
   return document.documentElement.clientHeight;
  }
  else if(document.body && document.body.clientHeight){
   return document.body.clientHeight;
  }
  return 0;
}


function resize() {
	
	
	var topMargin = 
		parseInt( Element.getDimensions('header').height ) + 
		parseInt( Element.getDimensions('topMenu').height );
	var leftMargin = parseInt( Element.getDimensions('leftMenu').width );
	var rightMargin =  parseInt( Element.getDimensions('rightMenu').width );
	var bottomMargin = parseInt( Element.getDimensions('footer').height );
	//$('map').style.top = topMargin + "px";
	//$('map').style.left = leftMargin + "px";
	$('map').style.width = getWindowWidth() - ( leftMargin + rightMargin) - 13 + "px";
	$('map').style.height = getWindowHeight() - ( topMargin + bottomMargin ) - 20 + "px";
	$('leftMenu').style.height = parseInt( $('map').style.height ) + 4 + "px";
	$('rightMenu').style.height = parseInt( $('map').style.height ) + 4 + "px";
	
	$('bukkenResultFrame').style.height = parseFloat( $('map').style.height ) / 2 + 2  + "px";
	$('blogResultFrame').style.height = $('bukkenResultFrame').style.height;
	$('bukkenResult').style.height = parseInt($('bukkenResultFrame').style.height) - 40 + "px";
	$('blogResult').style.height = $('bukkenResult').style.height;
	
}

function unload() {
	GUnload();
}

window.onload = init;
window.onresize = resize;
window.onunload = unload;