var CurUrl;
var MapLocAdvSearch = false;

function DoResize ( ) {
	var x,y;
	var themapdiv;
	var logoDiv;
	
	if (self.innerHeight) { // all except Explorer
		x = self.innerWidth - 120;
		y = self.innerHeight - 10;
		//x = self.innerWidth - 120;
		//y = self.innerHeight - 70;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		x = document.documentElement.clientWidth - 100;
		y = document.documentElement.clientHeight - 10;
	} else if (document.body) { // other Explorers
		x = document.body.clientWidth - 20;
		y = document.body.clientHeight;
	}
	
	themapdiv = document.getElementById('map');
	themapdiv.style.width=x+'px';
	themapdiv.style.height=y+'px';
	
	if ( map != null ) {
		map.checkResize();
	}
}

function setCookie(c_name,value,expiredays) {
	var exdate = new Date()
	exdate.setDate(exdate.getDate() + expiredays)
	document.cookie = c_name + "=" + escape(value) + ((expiredays==null) ? "" : "; expires="+exdate.toGMTString())
}

function getCookie(c_name) {
	if (document.cookie.length > 0) {
		c_start=document.cookie.indexOf(c_name + "=")
		
		if (c_start!=-1) {
			c_start=c_start + c_name.length+1
			c_end=document.cookie.indexOf(";",c_start)
			if (c_end==-1) c_end=document.cookie.length
			return unescape(document.cookie.substring(c_start,c_end))
		}
	}
	return ""
}

function SetRedMarker(lat, lon) {
	var point = new GLatLng(lat, lon);
		
	var greenIcon = new GIcon(G_DEFAULT_ICON);
	greenIcon.image = "http://www.ineedawrecker.com/images/green-dot.png";
	greenIcon.iconSize = new GSize(32, 32);
	
	var marker = new GMarker(point, {icon:greenIcon});
	
	map.clearOverlays();
	map.addOverlay(marker);
	
	marker.openInfoWindowHtml('Here is your last location');
	
	map.setCenter(point);
}

function AddMarker(lat, lon, html, blue) {
	
	var point = new GLatLng(lat, lon);
	
	if (blue !== undefined) {
		var blueIcon = new GIcon(G_DEFAULT_ICON);
		blueIcon.image = "http://www.ineedawrecker.com/images/blue-dot.png";
		blueIcon.iconSize = new GSize(32, 32);
		var marker = new GMarker(point, {icon:blueIcon});
	} else {
		glat = lat;
		glon = lon;
		
		var marker = new GMarker(point);
	}	
	
	map.addOverlay(marker);
	marker.openInfoWindowHtml(html);
	map.setCenter(point);
}

function loadSearchDiv(url) {
	$('#SearchResultsDiv').html('<center><img src="images/loading.gif" alt="Loading" style="vertical-align: middle;"> Loading...</center>');
	
	$.get(url, function(data) {
			$('#SearchResultsDiv').html(data);
		});
	
	CurUrl = url;
}

function SearchDetailsToggle(id) {
	jQuery("#SearchDetailsTr"+id).toggle();
	
	if ($("#SearchDetailsTr"+id).is(":visible")) {
		$("#SearchToggleButton"+id).attr("src", "images/toggle_minus.gif");
	} else {
		$("#SearchToggleButton"+id).attr("src", "images/toggle_plus.gif");
	}
}
