function popupwindow(url)
{
	newwindow=window.open(url,'','height=450,width=620');
	if (window.focus) {newwindow.focus()}
	return false;
}

function getQueryStringFields()
{
	var qs = location.search.substr(1); // to get rid of the "?"
	var fv_pairs = qs.split('&');var fv=new Array();var field=new Array();
	for(var i=0;i<fv_pairs;i++){fv[i]=fv_pairs.split('=');field[fv[i][0]]=fv[i][1];}
	return field;
} 

function parseGet()
{
	$_GET = new Array;
	$argstr = location.search.substring( 1, location.search.length );
	if( $argstr.indexOf( '%26' ) > 0 )
	{
		$args = $argstr.split( '%26' );
	}
	else
	{
		$args = $argstr.split( '&' );
	}

	for( $i = 0; $i < $args.length; $i++ )
	{
		$list = $args[$i].split( '=' );
		$_GET[ $list[0] ] = $list[1];
	}
}

function WithinLoadedBox()
{
	var czoom = map.getZoom();
	if (lzoom != czoom) return false;
	return lbox.containsBounds(map.getBounds());
//	var cbox = map.getBounds();
//	return (cbox.getSouthWest().lat() > lbox.getSouthWest().lat() &&
//		cbox.getNorthEast().lat() < lbox.getNorthEast().lat() &&
//		cbox.getSouthWest().lng() > lbox.getSouthWest().lng() &&
//		cbox.getNorthEast().lng() < lbox.getNorthEast().lng());
}

function ExpandBox(box, scale)
{
	var midLat = (box.getSouthWest().lat() + box.getNorthEast().lat())/2; 
	var midLng = (box.getSouthWest().lng() + box.getNorthEast().lng())/2;
	var sw = new GLatLng(midLat + (box.getSouthWest().lat() - midLat)*scale, midLng + (box.getSouthWest().lng() -  midLng)*scale, true);
	var ne = new GLatLng(midLat + (box.getNorthEast().lat() - midLat)*scale, midLng + (box.getNorthEast().lng() -  midLng)*scale, true);
	var tmp = new GLatLngBounds(sw, ne);
//	GLog.write("in sw: " + box.getSouthWest());
//	GLog.write("in ne: " + box.getNorthEast());
//	GLog.write("in: " + box);
//	GLog.write("mid: " + midLat + "," + midLng);
//	GLog.write("sw: " + sw);
//	GLog.write("ne: " + ne);
//	GLog.write("out sw: " + tmp.getSouthWest());
//	GLog.write("out ne: " + tmp.getNorthEast());
	return tmp;
}

function UpdateProgress(text)
{
	var progress = document.getElementById("progress");
	if (!progress) return;
	if (text == "") {
		progress.style.visibility = "hidden";
	} else {
		progress.style.visibility = "visible";
		var progresstext = document.getElementById("progresstext");
		progresstext.innerHTML = text;
	}
}

function AddDiv(map, divname, anchor, offset)
{
	var div = document.getElementById(divname);
	if (!div) return;
	var pos = new GControlPosition(anchor, offset); 
	pos.apply(div); 
	map.getContainer().appendChild(div); 
}