

	// Function that switches out a standard drop down menu,
	// and replaces it with one that can be styled fully
	
	// modified for use with EOS system -modules within the platform
	// have a parent form element by default so this has been modified
	// to target a div instead.  JK 22nd April '10
	 
		function createDropDown(elForm) {
			$(elForm).each(function() {
				// Grab the necessary elements
				var dropDownForm = $(this);
				var dropDownSubmit = dropDownForm.find("input[type='submit']");
				var elSelect = dropDownForm.find("select:first")
				var elOptions = elSelect.find("option");
				
				// Hide drop down button
				dropDownSubmit.each(function() { $(this).css("display", "none");});
				
				// Build up new drop down
				var dropDownHTML = '<div class="drop-down">';
				
				// Grab all the drop down options to make the drop down links
				elOptions.each(function(intIndex) {
					if (intIndex == 0) {
						dropDownHTML += '<div class="selected"><a href="' + $(this).val() + '">' + $(this).text() + '</a></div>';
						dropDownHTML += '<div class="shadow"><ul>';
					} else {
						dropDownHTML += '<li><a href="' + $(this).val() + '">' + $(this).text() + '</a></li>';
					}
					
					
	
					if ((elOptions.length - 1) == intIndex) {
						dropDownHTML += '</ul></div></div>';
					}
				});
	
				
				// Replace drop down options with drop down links
				elSelect.replaceWith(dropDownHTML);
	
				// Store drop down information
				var dropDownList = dropDownForm.find("ul");
				var dropDownSelected = dropDownForm.find("div.selected");
				
				// Slide up and down functionality
				dropDownSelected.click(function() {
					$(this).toggleClass("open");
					dropDownList.slideToggle("fast");
	
				});
				
				// If the forms submit button is pressed then go to the first link of the javascrip drop down
				dropDownSubmit.click(function() {
					window.location.href = dropDownList.find("a:first").attr("href");
					return false;
				});
	
				// TODO: This needs to be changed to the final location of the JSON content on the LOCOG servers 
				$.getJSON("http://www.cogapp.com/temp/locog/json/links-list.js?callback=?");
	
			});
		}
	
		// Function that outputs the drop down links from the JSON content
		function linkData(data) {
			$.each(data.links.link, function(){
				$("div.drop-down ul").append('<li><a href="' + $(this).attr("url") + '">' + $(this).attr("name") + '</a></li>');
			});
		}
	//End cross-domain drop down
