/** 
	* ! THIS FUNCTION REQUIRES JQUERY!
	*
	* The following function takes images from an xml file, the structure of the XML file should be as follows
	* <?xml version="1.0" encoding="utf-8"?>
	* 	<images>
	*		<image id="test_image">
	*		<filename>images/Addressbook.png</filename>
	*		<alttext>This is a test image</alttext>
	*		<start day="12" month="12" year="2009"></start>
	*		<end day="20" month="12" year="2009"></end>
	*	</image>
	*	
	*	<image id="test_image2">
	*		<filename>images/DVD-Player.png</filename>
	*		<alttext>This is test image 2</alttext>
	*		<start day="21" month="12" year="2009"></start>
	*		<end day="23" month="12" year="2009"></end>
	*	</image>
	* </images>
	*/

function ImagesFromXml(xml_file,css_id,default_image,default_image_alt) {	
			
			/*--get the clients current time--*/
			/*now = new Date(2009,11,25);*/
			now = new Date();
	
			/*--get the xml file--*/
             $.ajax({
                 type: "GET",
                 url: xml_file,
                 dataType: "xml",
                 success: function(xml) {
                     $(xml).find('image').each(function(){
                        
						 var id_text = $(this).attr('id')
						 var class_text = $(this).attr('class')
                         var alt_text = $(this).find('alttext').text()
						 var file_name = $(this).find('filename').text()
						 
						 /**
						 	* get the date fields from the xml
							* start dates
							*/
							
						 var image_sday = $(this).find('start').attr('day')
						 var image_smonth = $(this).find('start').attr('month')
						 var image_syear = $(this).find('start').attr('year')
						 
						 /**
							* end dates
							*/
							
						 var image_eday = $(this).find('end').attr('day')
						 var image_emonth = $(this).find('end').attr('month')
						 var image_eyear = $(this).find('end').attr('year')
						 
						 /** 
						 	* create date objects for both start and end dates
							*/
					
						image_start = new Date(image_syear,image_smonth-1,image_sday);
						image_end = new Date(image_eyear,image_emonth-1,image_eday);
						
						/**
							* compare the two dates and if found to be within range replace #update-target with the current image
							* @return false when complete 
							*/
							
						if(Date.parse(now)>=Date.parse(image_start) && Date.parse(now)<=Date.parse(image_end)) {
							
							/**
								* update the inner html of the element with the id #update-target
								*/
							$('#'+css_id).html('<img src="' + file_name + '" alt="' + alt_text + '" id="' + id_text + '" class="' + class_text + '" />');
							
							return false;
						
						}
                        
                     }); //close each(
					
					/** 
			 			* check if the above added an image if not the apply the default
						*/ 
						if(!default_image) { } else {
							if($('#'+css_id).html()=="") {
								$('#'+css_id).html('<img src="' + default_image + '" alt="' + default_image_alt + '" />');
							}
						}
						
                 }
				 
             }); //close $.ajax(
			 
		}