function loginSuggest(fld){
	var login_label = document.getElementById('login_label');
	var login_field = document.getElementById('login');
	var passwd_label = document.getElementById('passwd_label');
	var passwd_field = document.getElementById('passwd');
	switch(fld.value){
		case '4':
			login_label.innerHTML = "Client Login";
			login_field.value = "SH2";
			passwd_label.innerHTML = "Client Password";
			passwd_field.value = "";
			break;
		case '3':
			login_label.innerHTML = "Reseller Login";
			login_field.value = "";
			passwd_label.innerHTML = "Reseller Password";
			passwd_field.value = "";
			break;
	}
}
var ddid = "dynamiccontent";
var ddiv = null;
onload = function(){
	newDiv();
	checkAlerts();
};

function checkAlerts(){
	var xmldoc = loadXml("alerts.xml");
	if(xmldoc == null) return;
	var index = xmldoc.getElementsByTagName("index")[0];
	if(index == null) return;
	var color = index.getElementsByTagName("color")[0].childNodes[0].nodeValue;
	var text = index.getElementsByTagName("text")[0].childNodes[0].nodeValue;
	var div = document.getElementById("alerts");
	div.style.color = color;
	div.style.border = "solid 1px "+color;
	div.innerHTML = text;
	var links = div.getElementsByTagName("a");
	for(i=0;i<links.length;i++){
		links[i].style.color = color;
	}
}

function newDiv(){
	if(ddiv == null) ddiv = document.getElementById('dynamic');
	if (ddiv.hasChildNodes()){
		while(ddiv.childNodes.length >= 1){
			ddiv.removeChild(ddiv.firstChild);
		}
	}
	ddiv.appendChild(getRandomElement());
	setTimeout("newDiv()", "3000");
}

function loadXml(path){
	if (window.XMLHttpRequest){
		xhttp=new window.XMLHttpRequest();
	} else {
		xhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xhttp.open("GET",path,false);
	xhttp.send("");
	return xhttp.responseXML;
}

function getRandomElement(){
	var xmldoc = loadXml("dynamic.xml");
	var blocks = xmldoc.getElementsByTagName("block");
	var block = blocks[Math.floor(Math.random()*blocks.length)];
	var div = document.createElement("div");
	div.id = ddid;
	switch(block.getAttribute("type")){
		case "text":
			div.innerHTML = block.getElementsByTagName("text")[0].childNodes[0].nodeValue;
			break;
		case "img":
			var img = document.createElement("img");
			img.src = block.getElementsByTagName("src")[0].childNodes[0].nodeValue;
			img.alt = block.getElementsByTagName("alt")[0].childNodes[0].nodeValue;
			div.appendChild(img);
			break;
	}
	return div;
}