<!--

/*****************************************************************
JavaScript for SpandauGo / Online
 	- Doc Holiday Data -

created by 	Dr.Holger Maerz 
version: 1.0 
Last Date Changes: 24.04.2008 
edited by: (pls enter name and date)

this class is for testing if listed hosts are online.Itering all listed links
and using prototype.js for AJAX to prove if Host is online. switching images dependent on status 
*  
*******************************************************************/

/////////////////////////////////////////////////////////////////////////////////////
//News CLASS
/////////////////////////////////////////////////////////////////////////////////////
 	
function Online(){
	
	
	
	this.init=function(){
	
		try {
				
				var node = document.getElementById("links");
												
				for(var i=0;i<node.childNodes.length;i++){
					if(node.childNodes[i].nodeType!=1)continue;
					if(node.childNodes[i].tagName.toUpperCase()=="DIV")
						this.getAllLists(node.childNodes[i])
										
				}
				
		}	
	    catch(e){		
				alert("JavaScript Exception: online.init()\r\n\r\n" +e);
		}		
	}
	
	this.getAllLinks=function(node){
				
		try{					
				for(var i=0;i<node.childNodes.length;i++){
						
						if(node.childNodes[i].nodeType!=1)continue;
						
						if(node.childNodes[i].tagName.toUpperCase()=="LI"){			
							
							var urlObj=this.getLink(node.childNodes[i]);
														
							this.isHostOnline(urlObj.a.href, urlObj.img);
							
						}
				}
		}
		 catch(e){		
				alert("JavaScript Exception: Online.getAllLinks()\r\n\r\n" +e);
		}	
				
	}
			
	this.getLink=function(node){
		
		try {	
									
				var link=new Object();
					
				for(var i=0;i<node.childNodes.length;i++){
					
					if(node.childNodes[i].nodeType!=1)continue;
											
					if(node.childNodes[i].tagName.toUpperCase()=="A")
							link.a=node.childNodes[i];
					
					if(node.childNodes[i].tagName.toUpperCase()=="IMG")
						link.img=node.childNodes[i];	
						
				}
					
				return link;
				
				
		}	
	    catch(e){		
				alert("JavaScript Exception: Online.getLink()\r\n\r\n" +e);
		}			
	}
	
	this.getAllLists=function(node){
		
		try {	
				for(var i=0;i<node.childNodes.length;i++){
					if(node.childNodes[i].nodeType!=1)continue;
					if(node.childNodes[i].tagName.toUpperCase()=="UL")
						this.getAllLinks(node.childNodes[i])
					
				}
		}	
	    catch(e){		
				alert("JavaScript Exception: Online.getAllLists()\r\n\r\n" +e);
		}			
	}
	 
	this.isHostOnline=function(url, img){
	
		try {
				
				new Ajax.Request('AJAX/AJAXManager.php',{ 
					
					method: 'post', 
					parameters: {method: "isOnline", param: url} ,
					
					onComplete: function(json) {
											
						var data = eval('(' + json.responseText + ')');
						
						var src="images/offline.gif";
						var txt="offline";
						
						if(data.online) {
							src="images/online.gif";
							txt="online";	
						}
												
						img.src=src;
						img.alt=txt;
										
					}
				});
				

		}	
	    catch(e){		
				alert("JavaScript Exception: Online.isHostOnline()\r\n\r\n" +e);
		}		
	}
	
	
	
}	


//-->
