var loops=20;
var interval=4;// seconds between changing example site
var user_click=false;// user has hovered over example or clicked button
function get_random_example(){
  // Feb 2009: display example customer cms website and testimonial on home page
  // element "random_example" must exist somewhere on the page
  if(!loops&&!user_click){
    return;
  }
  if(!document.getElementById||!document.getElementById("random_example")){
    return;
  }
  XMLHttp=null;
  if(window.ActiveXObject){
    XMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }else{
    if(window.XMLHttpRequest){
      XMLHttp=new XMLHttpRequest();
    }else{
      return;
    }
  }
  XMLHttp.open("GET","http://www.123live.co.uk/scripts/gallery-random.asp",true);
  XMLHttp.onreadystatechange=get_random_example_return;
  XMLHttp.send(null);
}

function get_random_example_return(){
  try{
    if(XMLHttp.readyState!=4){
      return;
    }
    var str="";
    var JSON;
    var str_title="Open this website in a new window";
    var height;
    JSON=XMLHttp.responseText.replace(/([^=])(')([^;])/g,"$1\\'$3");
    eval(JSON);
    height=parseInt(0.75*width);
    str=  "<h2>One of our customers' websites ...</h2>"+
          "<div style='font-weight:bold'>"+link_text+"</div>"+
          "<div onmouseover='user_click=true;clearTimeout(t)'>"+
          "<a href='http://www."+domain+"?click_from_123Live_gallery' target='example_website'>"+
          "<img style='border:none;width:"+width+"px;height:"+height+"px' src='"+image_url+"' title='"+str_title+"' alt='example CMS website'>"+ // SCREENSHOT
          "</a>"+
          "<p onclick='get_random_example()' style='cursor:pointer;font-weight:bold;text-align:center;text-decoration:underline;color:#80003F;'><img src='see-another-customers-website.gif' style='height:21px' alt='see another customer\\'s website'></p>"+
          "<h2>... and what they say about us:</h2>"+
          "<p style='font-family:courier new;padding:0 20px;line-height:130%'>"+testimonial+" - <a href='http://www."+domain+"?click_from_123Live_gallery' target='example_website'>www."+domain+"</a></p>"+
          "</div>";
  }catch(e){
    str="";
  }
  loops=user_click?0:loops;
  if(!loops&&!user_click){
    return;
  }
  document.getElementById("random_example").innerHTML=str;
  if(loops){
    t=setTimeout("get_random_example()",interval*1000);
    loops--;
  }
}
