// func to populate tables
function getTable(identify){
	$.ajax({
		type: "GET",
		url: "prod_info/"+identify+".xml",
		dataType: "xml",
		success: function(xml) {
			// to handle rowspan entries - create a temp value for the first row
			var titleRow = "";
			var firstRow = "";
			var firstRow_dd = "";
			var firstRow_sd = "";
			var show_dd = true;
			var show_sd = true;
			var show_24 = false;
			var secondRow = "";
			var tableHtml = "";
			// populate the table
			$(xml).find('record').each(function(){
				// get text
				tableHtml = $(this).find('contents').text();
			});
			
			// end the table HTML
			//$("#"+identify+"_loading").hide();
			$("#"+identify+"_show").empty().append(tableHtml);
			$("tr:nth-child(even)").addClass("odd");
			// add mouseover events
			
			$("tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});
			$("#"+identify+"_show").show();
		
			// move to it's anchor
			//$.scrollTo("#"+identify,800);
			$("#"+identify+"_show a").click(function(){
				$.scrollTo(this.hash, 800);
				return false;
			});
		}
	});
}

//
function tidyString(theString){
	theString = theString.replace('&', '&amp;');
	theString = theString.replace('£', '&pound;');
	return theString;
}

//
// when ready start it
$(document).ready(function() {
	$(".titlebar").click(function() {
		if ($("#"+this.id+"_show").is(":visible")){
			$("#"+this.id+"_show").toggle();
		} else {
			getTable(this.id);
		}
		$("#"+this.id+" img").toggle();
	});
});
