// JavaScript Document


var SlideAction = function(){}

var s= new SlideShow();

load_slides = s.load_slides;
start_slides = s.start_slides;

SlideAction.prototype = {

	processReqChange:function ()
	{
	  if (req.readyState == 4 && req.status == 200 
		  && req.responseXML != null)
	  {
		var items = [];
		var nl = req.responseXML.getElementsByTagName( 'slide' );
		for( var i = 0; i < nl.length; i++ )
		{
		  var nli = nl.item( i );
		  var src = nli.getAttribute( 'src' ).toString();
		  var width = parseInt( nli.getAttribute( 'width' ).toString() );
		  var height = parseInt( nli.getAttribute( 'height' ).toString() );
		  items.push( { src: src, width: width, height: height } );
		}
		load_slides( items );
		start_slides();
	  }
	},
	
	loadXMLDoc:function( url )
	{
	  req = false;
	  if(window.XMLHttpRequest) {
		try {
		  req = new XMLHttpRequest();
		} catch(e) {
		  req = false;
		}
	  }
	  else if(window.ActiveXObject)
	  {
		try {
		  req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
		try {
		  req = new ActiveXObject("Microsoft.XMLHTTP");
		} catch(e) {
		  req = false;
		}
	  }
	  }
	  if(req) {
		req.onreadystatechange = this.processReqChange;
		req.open("GET", url, true);
		req.send("");
	  }
	}
}

window.onload = function(){
	var s = new SlideAction();
	s.loadXMLDoc( "http://"+location.host+"/top/slide.xml" );
}
