// JavaScript Document

//General Overlay Collection
var permanent;

permanent = new OverlayCollection('permanent', 25);
//Settings
permanent.useLabels = true;
permanent.labelType= 'Numeric';

//Clear Placemarks
permanent.clearPlacemarkListings = function(){
}

//Show Placemarks
permanent.showPlacemarkListings = function(){
	this.clearPlacemarkListings();
	if(this.length > 0){
		var placemarks = this.getPage(this.currPage);
		for (var i = 0; i < placemarks.length; i++){
			this.addToList(placemarks[i]);
		}
	}
	this.showPaging();
}


//Show Placemarks
permanent.markPlacemarkListings = function(){
	if(this.length > 0){
		var placemarks = this.getPage(this.currPage);
		for (var i = 0; i < placemarks.length; i++){
			var spot = $('placemark_' + placemarks[i].prikey);
			spot.innerHTML = parsePlacemarkData(' | <a href="javascript:goToPlacemark(placemark:prikey)">view on map</a>&nbsp;<img src="placemark:iconimage" width=\"24\" height=\"19\"  style="position: absolute; margin-top: -5px">',placemarks[i]);
		}
	}
}

//Clear Placemarks
permanent.unmarkPlacemarkListings = function(){
	if(this.length > 0){
		var placemarks = this.getPage(this.currPage);
		for (var i = 0; i < placemarks.length; i++){
			var spot = $('placemark_' + placemarks[i].prikey);
			spot.innerHTML = '';
		}
	}
}

permanent.addToList = function(placemark){
}

permanent.getInfoHTML = function(placemark){
	var addr = new Address();
	try{
		addr.loadFromObject(placemark);
	}
	catch(ex){
	}
	var str = new String();
	str = '<div class=\"infoWindowTitle\">placemark:name</div>';
	str += '<div class=\"infoWindowAddress\">' + addr.toHTMLString() + '</div>';
//	str += '<span onclick=\"svp();" class=\"fakelink\">Streetview</span>';
	str += '<ul class=\"infoWindowOptions\">';
	str += placemark.weburl.length > 0 ? '<li><a href=\"' + this.root +'/includes/redirects/webcount.cfm?listingID=placemark:prikey\" target=\"_blank\">Visit website</a></li>' : '';	
	str += '<li><a href=\"./index.cfm?action=display&listingid=placemark:prikey&hit=1">More Info</a></li>';
	str += '<li><a href=\"javascript:getDirections(placemark:prikey)">Directions</a></li>';
//	str += '<li><a href=\"javascript:directions.directionsFrom(placemark:prikey)\">Directions From Here</a></li>';
	str += '</ul">';
	if(placemark.distance){
			str += '<div class=\"infoWindowSection\">Distance: ' + placemark.distance.toFixed(1) + ' miles</div>';
	}

	return parsePlacemarkData(str,placemark);
}

permanent.updateBubble = function(args){
}
