function showFeatured(response){ oImg = document.getElementById('featuredimg'); oName = document.getElementById('featuredname'); oText = document.getElementById('featuredtext'); aItem = response.split("@^@"); oName.removeChild(oName.firstChild); oText.removeChild(oText.firstChild); if(aItem.length>1){ oImg.src = "http://www.roddenberry.com/images/shop/prods/"+aItem[3]; oName.appendChild(document.createTextNode(aItem[1])); oName.setAttribute("href","http://www.roddenberry.com/?action=shop.product&pid="+aItem[0]); oText.appendChild(document.createTextNode(unescape(aItem[2]))); setTimeout("rotateFeatured()",6000); }else{ //oImg.parentNode.removeChild(oImg); oName.appendChild(document.createTextNode("Our Store")); oName.setAttribute("href","http://www.roddenberry.com/?action=shop.welcome"); oText.appendChild(document.createTextNode("We do not have any featured items, but there are still plenty available in our online store.")); setTimeout("rotateFeatured()",100); } } function rotateFeatured(){ xmlHttp = XMLHttpObject(); xmlHttp.open("GET","http://www.roddenberry.com/?action=site.getFeatured&dt="+Math.random(),true); xmlHttp.send(null); xmlHttp.onreadystatechange=function(){ if(xmlHttp.readyState==4){ showFeatured(xmlHttp.responseText); } } }