var weather_icon_dir = "images/weather/";

function createInfoHtml(xml_marker){
	var type = xml_marker.getAttribute("type");
	var name = xml_marker.getAttribute("name");
    var date = xml_marker.getAttribute("date");
    var time = xml_marker.getAttribute("time");
    var location = xml_marker.getAttribute("location");
    var location_submitted = xml_marker.getAttribute("location_submitted");
    var miles_hiked = xml_marker.getAttribute("miles_hiked");
    var name = xml_marker.getAttribute("name");
    
				
    var info_html = '<div class="trackus_info_inner box" style="border-right-style: none;"><ul>';
    if(type == 'journal')
    {
    	info_html = info_html + '<li class="current_info_item"><div class="current_info_item_label">Journal Entry By:</div><div class="current_info_item_value"> ' + name + '</div></li>';
    }
    else
    {
    	info_html = info_html + '<li class="current_info_item"><div class="current_info_item_label">Photo Entry By:</div><div class="current_info_item_value"> ' + name + '</div></li>';
    }
    
    info_html = info_html + '<li class="current_info_item"><div class="current_info_item_label">Date:</div><div class="current_info_item_value"> ' + date + '</div></li>';
    info_html = info_html + '<li class="current_info_item"><div class="current_info_item_label">Location:</div><div class="current_info_item_value"> ' + location + '</div></li>';
    info_html = info_html + '<li class="current_info_item"><div class="current_info_item_label">Miles Hiked:</div><div class="current_info_item_value"> ' + miles_hiked + '</div></li>';
    info_html = info_html + '<li class="current_info_item"><div class="current_info_item_label">Miles to Katahdin:</div><div class="current_info_item_value"> ' + (2174.0-miles_hiked) + '</div></li> </ul></div><div id = "goto_last_entry_link" style="text-align: center; text-decoration: underline; font-size: .80em;"><a href="#" onClick="gotoLastEntry();">Move Map to Last Entry</a></div>';
    return info_html;
}

function createHtml(xml_marker){
var id = xml_marker.getAttribute("id");
	var type = xml_marker.getAttribute("type");
	var title = xml_marker.getAttribute("title");
    var entry_text = xml_marker.getAttribute("entry_text");
    var image = xml_marker.getAttribute("image");
	var weather_image = xml_marker.getAttribute("weather_image");
    
    if(type == 'journal')
    {
    	if(image != null)
		{
			ext = image.substr(image.length-4,image.length);
        	html = '<div class="trackus_thumbnail" style="padding: 0 0 25px 0;"> <a href="' + pic_directory + image + '" rel="lightbox" ><img id="thumbnail" class="box" src="' + pic_directory + 'thumbs/' + image + '"></a> </div>';
        }
	//if(title)
	//{
        html = html + '<div class="title_bar_div"><div class="alignleft left_title track_us_title" style="margin: 0;">';
		if(title) {
		 html = html + title + ':';
		 }
		html = html + '</div><div class="alignright right_title" style="margin: 0;">Journal</div><div style="clear: both;"></div></div>';
	//}
        html = html + '<div class="trackus_excerpt_description">"' + entry_text.substr(0,400) + '..."</div> <div class="trackus_weather_seemore">';
		
	if(weather_image) {
		 html = html + '<div class="trackus_weather alignleft" style="background: #FFFFFF;"><img src="' + weather_icon_dir + weather_image + '"></div>';
	}
	html = html + '<div class="trackus_journal_entry_link alignright"><a href="journal.php?id=' + id + '#' + id + '">See Full Entry</a></div></div>';
    } 
    else
    {
		ext = image.substr(image.length-4,image.length);
    	html = '<div class="trackus_thumbnail" style="padding: 0 0 10px 0;"> <a href="' + pic_directory + image + '" rel="lightbox" ><img id="thumbnail" class="box" src="' + pic_directory + 'thumbs/' + image + '"></a> </div>';
		 html = html + '<div class="title_bar_div"><div class="alignleft left_title" style="margin: 0;">';
		 if(title) {
		 html = html + title + ':';
		 }
		 html = html + '</div><div class="alignright right_title" style="margin: 0;">Photo</div><div style="clear: both;"></div></div>';
        html = html + '<div class="trackus_excerpt_description">' + entry_text + '</div>';
    }
    	
    return html;
}

function Entry(entry_xml) {
	this.type = entry_xml.getAttribute("type");
	this.id = entry_xml.getAttribute("id");
	this.marker_icon_id = entry_xml.getAttribute("marker_icon_id");
	this.zoom = entry_xml.getAttribute("zoom");
	this.info_html = createInfoHtml(entry_xml);
        this.html = createHtml(entry_xml);
	this.point = new GLatLng(parseFloat(entry_xml.getAttribute("lat")), parseFloat(entry_xml.getAttribute("lng")));
} 
	
	
	
	

	

