// JavaScript Document



 function load_xml(msg)
{   //this function will load xml even used in IE or any other browser
    if ( typeof msg == 'string') {
                   data = new ActiveXObject( 'Microsoft.XMLDOM');
           data.async = false;
           data.loadXML( msg);
        } else {
          data = msg;
        }
        return data;
}


$(document).ready(function() {
        $.ajax({
            type: "GET",
            url: "main_entry/swf/xml_images/banner_list.xml",
            dataType: ($.browser.msie) ? "text/xml" : "xml",
			error:function(){
				$('<p></p>')
	            .html('The banner has failed to load')
	            .appendTo('.slideshow');
				},
            success: function(xml) {
                 /* call the function here and pass the xml document to it */
			   timerDispMilli = '0';
               var xml2=load_xml(xml);
			   
			    $(xml2).find('images').each(function(){
					timerDisp = $(this).attr('delayTime');
					timerDisp.toString();
					timerDispMilli = (timerDisp + '000');
					
				});
			   
			   $(xml2).find('image').each(function(){
                  var imageSrc = $(this).text();
				  var theLink = $(this).attr('urlLink')
				  var theTarget = $(this).attr('linkTargetWindow')
				 // $("#output").append(": " + imageSrc + " " + theLink + " " + theTarget);

                  $('<div><div class="ajaxBannerFrame2"></div><div class="ajaxBannerImage"><img src="' + imageSrc + '"  border="0" width="625" height="222"/></div>' + '<div class="ajaxBannerLink"><a href="' + theLink + '" target="' + theTarget + '">&nbsp;</a></div></div>')
                     .appendTo('.slideshow');
                   });
				   slideshowActivate();
                
            }
        });
    });


function slideshowActivate(){
	
	$('.slideshow').before('<div id="altBannerNav2">').cycle({
        fx:     'fade',
        speed:  300,
        timeout: timerDispMilli,
        pager:  '#altBannerNav2'
    });

};
