1: function addLoadEvent(func) {
  2:     var oldonload = window.onload;
  3:     if (typeof window.onload != 'function') {
  4:         window.onload = func;
  5:     }
  6:     else {
  7:         window.onload = function() {
  8:             oldonload();
  9:             func();
 10:         }
 11:     }
 12: }
 13: 
 14: var Request = function(url) {        
 15:         this.ajaxURL = url;
 16:         this.httpRequest= null;
 17:         this.Response;
 18:         
 19:         var self=this; 
 20:         
 21:         this.updating = false;
 22:         this.abort = function() {
 23:             if (self.updating) {
 24:                 self.updating=false;
 25:                 self.httpRequest.abort();
 26:                 self.httpRequest=null;
 27:             }
 28:         };
 29:        
 30:         
 31:         this.GET = function(){ 
 32:         if (self.updating) { return false; }
 33:         if (window.XMLHttpRequest) { // Mozilla, Safari, ...
 34:             this.httpRequest = new XMLHttpRequest();
 35:             if (this.httpRequest.overrideMimeType) {
 36:                 this.httpRequest.overrideMimeType('text/xml');
 37:                 // See note below about this line
 38:             }
 39:         } 
 40:         else if (window.ActiveXObject)
 41:             { // IE
 42:             try {
 43:                 this.httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
 44:                 } 
 45:                 catch (e) {
 46:                            try {
 47:                                 this.httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
 48:                                } 
 49:                              catch (e) {}
 50:                           }
 51:              }//end IE
 52: 
 53:         if (!this.httpRequest) {
 54:             alert('Giving up :( Cannot create an XMLHTTP instance');
 55:             return false;
 56:         }
 57:              
 58:         
 59:        try{  
 60:           
 61:            this.httpRequest.onreadystatechange =  this.ReadyStateChange(this);         
 62:            this.httpRequest.open('GET', this.ajaxURL,true);
 63:            this.httpRequest.send(null); 
 64:            
 65:         }catch(e){
 66:             alert(e);            
 67:         }
 68:          
 69:     };//end GET function
 70:     
 71:     
 72:     this.ReadyStateChange = function(requestObj)
 73:     {
 74:     
 75:             return function(){
 76:                 if(requestObj.httpRequest.readyState==4 || requestObj.httpRequest.readyState=='complete')
 77:                 {
 78:                     if(requestObj.httpRequest.status==200)
 79:                     {
 80:                         requestObj.Response=requestObj.httpRequest.responseXML;
 81:                         updateHeaderimage(requestObj)
 82:                         //return requestObj.Response;
 83:                     }               
 84:                 }
 85:             };//end function    
 86:     };//end ReadyStateChange
 87:     
 88: }//end Request object
 89: var globalImages = [];  
 90: function GetData(){
 91: 
 92:     var request = new Request("images.xml");
 93:     
 94:     request.GET();
 95: }
 96: 
 97: function updateHeaderimage(request){
 98:     var xmldoc = request.Response;
 99:     
100:     var allTracks = xmldoc.getElementsByTagName("track");
101: 
102:     var olEl=document.createElement('ol');          
103:     olEl.setAttribute("id","headerimages");
104:     
105:     var allImages = []; 
106:     //attach events to items in that list
107:     for (var i=0;i<allTracks.length;i++)
108:         {
109:             var image = [];
110:             var trackElm = allTracks[i];                        
111:             var titleElm = trackElm.getElementsByTagName("title").item(0);                      
112:             var titleText = titleElm.firstChild.nodeValue;
113:             image['titleText'] = titleText;
114:             var imageElm = trackElm.getElementsByTagName("image").item(0);                      
115:             var imageSrc = imageElm.firstChild.nodeValue;
116:             
117:             image['imageSrc'] = imageSrc;
118:             var creatorElm = trackElm.getElementsByTagName("creator").item(0);                      
119:             var creatorText = creatorElm.firstChild.nodeValue;  
120:             image['creatorText'] = creatorText;
121:             var liEl=document.createElement('li');
122:             var linkEl=document.createElement('a');
123:             var linkText =document.createTextNode(titleText); 
124:             linkEl.setAttribute("href",imageSrc);
125:             
126:             var imageID = "image"+i;
127:             
128:             linkEl.setAttribute("id","image"+i);
129:             linkEl.appendChild(linkText);
130:             
131:             liEl.appendChild(linkEl);
132:             
133:             olEl.appendChild(liEl);
134:             allImages[imageID] = image;
135:             
136:             linkEl.onclick=resetImage;
137: 
138:         }
139:     globalImages =  allImages;
140:     var curimageDiv = document.getElementById('curimage');
141:     
142:     var image=document.getElementById('rotatingimage'); 
143:     //image.setAttribute('src',imageSrc); 
144:     var imageparent = image.parentNode;
145:     
146:     curimageDiv.insertBefore(olEl, imageparent)
147:     curimageDiv.style.paddingRight = '160px';
148:     //curimageDiv.appendChild(olEl);
149:     
150: }
151: 
152: 
153: 
154: function resetImage()
155: {
156: 
157:     for (var key in globalImages) 
158:     {
159:         if(document.getElementById(key))
160:         {
161:             var link = document.getElementById(key);
162:             link.removeAttribute('class');
163:             link.style.backgroundColor = 'transparent';
164:             //link.setAttribute("class",'');
165:         }
166:     }
167:     var elid = this.getAttribute('id');
168:     
169:     this.setAttribute("class",'selected');
170:     this.style.backgroundColor = '#FFB25D';
171:     
172:     var imageSrc = globalImages[elid]['imageSrc'];
173:     var creatorText = globalImages[elid]['creatorText'];
174:     var titleText = globalImages[elid]['titleText'];
175:     var image=document.getElementById('rotatingimage'); 
176: 
177:     image.setAttribute('src',imageSrc); 
178:     var imageparent = image.parentNode;
179:     
180:     image.setAttribute('alt',titleText + '('+creatorText+')');
181:     image.setAttribute('title',titleText + '('+creatorText+')');
182:     //get the p for the title text
183:     var curimage = document.getElementById('curimage'); 
184:     var altp = curimage.getElementsByTagName("p")[0];   
185:     
186:     var replacementaltp=document.createElement('p');
187:     var altText =document.createTextNode(titleText);
188:     replacementaltp.appendChild(altText);
189:     curimage.replaceChild(replacementaltp,altp );   
190:     return false;
191: }
192: 
193: 
194: 
195: addLoadEvent(GetData);

Parsed by FSHL V0.4.19 in 0.139 sec