var timer = 0;

window.onload=function(){
    loadingVideo();
}

function play(selectobject) {
    
    var video = selectobject.options[selectobject.selectedIndex].value;
    
    if(video != "0") {
        loadingVideo();
        
       
        
        document.getElementById("videocontainer").innerHTML = '<embed src="/newsite/video/flvplayer.swf" width="320" height="400" allowfullscreen="true" allowscriptaccess="always" flashvars="&displayheight=400&file='+ video +'.flv&controlbar=over&autostart=true&repeat=none&wmode=transparent&overstretch=true&backcolor=000000&frontcolor=CCCCCC&skin=video/stylish_slim.swf" wmode="transparent" id="vidplayer" />';
    }
}

function loadingVideo() {
    document.getElementById("videoclick").innerHTML = "Loading video..."
    document.getElementById("videoclick").style.zIndex = "500";
    clearTimeout(timer);
    timer = setTimeout("loadedVideo()", 5000);
}

function loadedVideo() {
    document.getElementById("videoclick").style.zIndex = "1";
    clearTimeout(timer);
    timer = setTimeout("loadedVideoText()", 60000);
}

function loadedVideoText() {
    timer = document.getElementById("videoclick").innerHTML = "Click to play again";
    clearTimeout(timer);
}

function load(url,target) {
    document.getElementById(target).innerHTML = '';
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = function() {ahahDone(target);};
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = function() {ahahDone(target);};
            req.open("GET", url, true);
            req.send();
        }
    }
}

function ahahDone(target) {
   // only if req is "loaded"
   if (req.readyState == 4) {
       // only if "OK"
       if (req.status == 200 || req.status == 304) {
           results = req.responseText;
           document.getElementById(target).innerHTML = results;
       } else {
           document.getElementById(target).innerHTML="Sorry, we couldn't load the video - please try again";       }
   }
}