 $(document).ready(function(){
 	//page stylin
 	$("#sidebarMenu").corner("10px");
 	//$("#loading").hide()
	$("#loading").fadeOut();
	var currentPage = $("#contentWrap h2:first").text()

	$("#sidebarMenu li a").each(function (i) {
        if ($(this).text() == currentPage) {
          $(this).addClass("current");
        } 
      });
 	
 	
 	
 	//creates address book from xml file
 	
	
	$.ajax({
    url: 'humboldt-graphics.xml',
    type: 'GET',
    dataType: 'xml',
    timeout: 1000,
    beforeSend: function() {
    //$("#loading").show()
    },
    error: function(){
        alert('Error loading XML document- Please Refresh');
    },
    success: function(xml){
    	
       $(xml).find('graphic').each(function(){
       		var cardID = $(this).attr("id")
       		var graphicCategory = $(this).attr("category")
       		cardID= "graphic"+cardID
      		var graphicCard = $(document.createElement('ul')).attr("id",cardID)
 			//alert($(this).children().length)
 			for(i=0;i<$(this).children().length;i++) {
 				var cellText =  $(this).children().eq(i).text()
 				//var cellAttr =  $(this).children().eq(i).attr("title")
 				var cellClass = $(this).children()[i].tagName
 				
 				
 				
 				switch (cellClass) {
					case "preview":
 						var theItem = $(document.createElement('li')).html("<img src='"+cellText+"' />").addClass(cellClass).appendTo(graphicCard);
 						break;


					case "link":
 						var theItem = $(document.createElement('li')).html("<a href='"+cellText+"' class='downloadLink' >Download Graphic</a>").addClass(cellClass).appendTo(graphicCard);
 						break;

					default:
  						var theItem = $(document.createElement('li')).html(cellText).addClass(cellClass).appendTo(graphicCard);
				}

 				$(document.createElement('strong')).html(cellClass).prependTo(theItem.not('.preview,.link'))
 				
 				
 			}
 			
 			
 			 $(graphicCard).appendTo("#"+graphicCategory);
 			 
 			 $("#graphics ul:even").addClass("striped");
        
        
    	});
 
    //hides initial sections
    	
		$("#graphics > div").not("#Logos").hide();
		$("#graphicsTabs .Logos a").addClass("current")
		
		
    	$("#graphicsTabs li a").click(function(event){
    		var section = $(this).parent().attr("class")
    		$("#graphics > div").not("#"+section).hide();
    		$("#graphics #"+section).fadeIn("slow");
    		$("#graphicsTabs li a").removeClass("current")
    		$(this).addClass("current")
			
    	 return false;
    	 
    	});
    
    	
    	
    }//end ajax
    

});
});