//Function to load all the images into the page
function loadImages() {

	//Load the variables
	var contentTable = document.getElementById("mainTable");
	var tableRows = contentTable.rows;
	var italicTag;
	var spanTag;
	var boldTag;
	var boldText = "";
	
	//Loop through the table rows getting each second cell
	for (var i=1; i<tableRows.length; i++) {
	
		//Get the bold tag within the cell
		italicTag = tableRows[i].cells[1].getElementsByTagName("i")[0];
		
		//Check if there it has found the italic tag (mozilla bug)
		if (typeof italicType == "undefined") {
		
			//Get all the span tags
			spanTags = tableRows[i].cells[1].getElementsByTagName("span");
			
			//Loop through all the span tags
			for (var j=0; j<spanTags.length; j++) {
			
				//Check if the style element is set with the italic option
				if (spanTags[j].style.fontStyle.toLowerCase() == "italic") {
				
					//This is the correct element
					italicTag = spanTags[j];
				}
			}
		}
		
		//boldTag = tableRows[i].cells[1].getElementsByTagName("b")[0];
		italicText = italicTag.innerHTML; //Text;
		
		//Run this text through a regular expression to remove spaces
		italicText = italicText.toLowerCase();
		itliacText = italicText.replace(/^\s */, "");
		italicText = italicText.replace(/\s *$/, "");
		
		//Check and replace the text into the appropiate image
		switch (italicText.toLowerCase()) {
		
			case "p&amp;o":
			case "p &amp; o":
			case "p&o":
			case "p & o":
				imageSrc = "images/P&amp;O.jpg";
				imageText = "P&amp;O Cruises";
				break;
			
			case "princess":
				imageSrc = "images/Princess.jpg";
				imageText = "Princess Cruises";
				break;
			
			case "rccl":
			case "royal caribbean":
				imageSrc = "images/royal.jpg";
				imageText = "Royal Caribbean Cruises";
				break;
			
			case "celebrity":
			case "celebrity cruises":
				imageSrc = "images/celebrity.jpg";
				imageText = "Celebrity Cruises";
				break;
			
			case "fred":
			case "fred olsen":
				imageSrc = "images/fred.jpg";
				imageText = "Fred Olsen Cruise Lines";
				break;
			
			case "cunard":
				imageSrc = "images/Cunard.jpg";
				imageText = "Cunard";
				break;
			
			case "ncl":
				imageSrc = "images/ncl.jpg";
				imageText = "Norwegian Cruise Line";
				break;
			
			case "costa":
				imageSrc = "images/costa.jpg";
				imageText = "Costa Cruises";
				break;
			
			case "radisson":
			case "regent":
				imageSrc = "images/radisson.jpg";
				imageText = "Regent Seven Sea Cruises";
				break;
			
			case "hollandamerica":
			case "holland america":
				imageSrc = "images/holland.jpg";
				imageText = "Holland America Cruises";
				break;
			
			case "orient":
				imageSrc = "images/orient.jpg";
				imageText = "Orient Lines";
				break;
			
			case "crystal":
				imageSrc = "images/crystal.jpg";
				imageText = "Crystal Cruises";
				break;
			
			case "silverseas":
				imageSrc = "images/silversea.jpg";
				imageText = "Silverseas";
				break;
			
			case "msc":
				imageSrc = "images/msc.jpg";
				imageText = "MSC Cruises";
				break;
			
			case "ocean":
				imageSrc = "images/ocean.jpg";
				imageText = "Ocean Village Cruises";
				break;
			
			case "voyage":
			case "voyages":
			case "voyages of discovery":
				imageSrc = "images/discovery.jpg";
				imageText = "Voyages Of Discovery";
				break;
			
			case "island":
			case "island cruises":
				imageSrc = "images/island.jpg";
				imageText = "Island Cruises";
				break;
			
			default:
				imageSrc = "";
				imageText = italicText;
				break;
		}
		
		//Start the new HTML variable
		newHTML = "";
		
		//Check if the image src isn't blank
		if (imageSrc != "") {
			newHTML += "<img src=\"" + imageSrc + "\" width=\"100\" height=\"36\" border=\"0\" />"
		}
		
		//Check if image src and the image text isn't blank
		if ((imageSrc != "") && (imageText != "")) {
			newHTML += "<br />";
		}
		
		//Check if the image text isn't blank
		if (imageText != "") {
			newHTML += "<b>" + imageText + "</b>";
		}
		
		//Erase the text in the italic tag
		italicTag.innerHTML = "";
		
		//Add the new html to the table cells HTML
		tableRows[i].cells[1].innerHTML = newHTML + tableRows[i].cells[1].innerHTML;
		tableRows[i].cells[1].align = "center";
	}
	
	//Adjust the stylesheet
	var updatedStylesheet = "";
	updatedStylesheet += "<style type=\"text/css\">\n";
	updatedStylesheet += "<!--\n";
	updatedStylesheet += "body,td,th {\n";
	updatedStylesheet += "/*color: #FFFFFF;*/\n";
	updatedStylesheet += "}\n";
	updatedStylesheet += "-->\n";
	updatedStylesheet += "</style>";
	document.writeln(updatedStylesheet);
}

