function makeImages(idx,link,ip,od,to,tp){
	this.id = idx;
	this.link = link;
	this.path = ip;
	this.order=od;
	this.timeout=to;
	this.type=tp;
	this.write = writeImages;
}
var imagesArray = new Array();
var onlyOne = true;

function parseXML(xmlDomForImages) {
  var list = selectNodeList(xmlDomForImages, "/images/image");
  onlyOne = false;
  sizeImages = list.length;
  for (var i=0; i<list.length; i++) {
	  imagesArray.push(new makeImages(list[i].getAttribute("id"), list[i].getAttribute("link"),list[i].getAttribute("path"), list[i].getAttribute("order"), list[i].getAttribute("timeout"), list[i].getAttribute("type")).write(i));
  }
}


function writeImages(i){
	var str = '';
	if(this.type == '1'){
		str += '<a href="'+this.link+'"><img src="' + this.path + '" style="border: 0px; width: 1000px; height: 250px"/></a>';
	}else {
		str += '<embed width="1000" height="250" src="' + this.path + '" quality="high" type="application/x-shockwave-flash" wmode="transparent" >';
	}

	str += '<input type="hidden" id="timeOutID_' + i + '" value="' + this.timeout + '" name= "timeOut" />';
	return str;
}


var nIndex = 0;
var timerID = null;

function rotate(){
	if(!onlyOne){
		var len = imagesArray.length;
		if(nIndex >= len)
			nIndex = 0;
		document.getElementById('homeAdvertisement').innerHTML = imagesArray[nIndex];
		var timeOut = "";
		if(document.getElementById("timeOutID_" + nIndex) != null ){
			timeOut = document.getElementById("timeOutID_" + nIndex).value;
		}
		nIndex++;
		if(timeOut != 0){
			timerID = setTimeout('rotate()',timeOut*1000);
		}
	}
}

