$(document).ready(function()
{
  $.ajax({
  	 type: "GET",
	 url: 'locations.xml',
	 dataType: ($.browser.msie) ? "text" : "xml",
	 success: function(data){
	  var xml;
	  if (typeof data == "string") {
	   xml = new ActiveXObject("Microsoft.XMLDOM");
	   xml.async = false;
	   xml.loadXML(data);
	  } else {
	   xml = data;
	  }
	 
	  $(xml).find("location").each(function()
	  {
	  	for(var i=0; i<locationArray.length; i++){
	  		
	  		var j=i+1;
		  	if($(this).attr("code") == locationArray[i]){
		  		
		  		$("#locationInfo"+j).append("<div class='blk_font'><strong>" + $(this).find("name").text() + " - (" + $(this).attr("code") + ")</strong></div>" + $(this).find("street").text() + "<br>" + $(this).find("city").text() + ", " + $(this).find("state").text() + " " + $(this).find("zip").text() + "<br>" + $(this).find("phone").text());
				$("#locationInfo"+j).append("<br><br>");
				
		  		$(this).find("day").each(function()
		  		{
					if((($(this).find("open1").text() == '0:00' && $(this).find("meridiem1").text() == '0')||($(this).find("open1").text() == '12:00' && $(this).find("meridiem1").text() == 'AM')) && $(this).find("close1").text() == '12:00' && $(this).find("meridiem2").text() == 'AM') $("#locationInfo"+j).append("<div class='hours'><div class='day'>" + $(this).attr("dow") + "</div><div class='times'>Open 24 hrs</div></div>");
					else{
		  				if($(this).find("open2").text() == '0:00' && $(this).find("meridiem1").text() != '0') $("#locationInfo"+j).append("<div class='hours'><div class='day'>" + $(this).attr("dow") + "</div><div class='times'>" + $(this).find("open1").text() +  $(this).find("meridiem1").text() + "-" + $(this).find("close1").text() +  $(this).find("meridiem2").text() + "</div></div>");
						if($(this).find("meridiem1").text() == '0') $("#locationInfo"+j).append("<div class='hours'><div class='day'>" + $(this).attr("dow") + "</div><div class='times'>Closed</div></div>");
						if(($(this).find("open2").text() != '0:00' && $(this).find("meridiem3").text() != '0') && ($(this).find("close2").text() != '0:00' && $(this).find("meridiem4").text() != '0')) $("#locationInfo"+j).append("<div class='hours'><div class='day'>" + $(this).attr("dow") + "<br><br></div><div class='times'>" + $(this).find("open1").text() + $(this).find("meridiem1").text() + "-" + $(this).find("close1").text() + $(this).find("meridiem2").text() + " and<br>" + $(this).find("open2").text() + $(this).find("meridiem3").text() + "-" + $(this).find("close2").text() + $(this).find("meridiem4").text() + "</div></div>");
					}
		  		});
		  	}
  		}
	  	
	  	});
	  
 	}
	});
	
});
