var cms_qmp = new Object;
var init_object = new Object;
var mousex;
var mousey;
var startx = null;
var starty = null;
var start_left;
var current_clip_length;
var current_clip_start;
var current_clip_end;
var current_clip_url;
var current_clip_title;
var current_clip_desc;
var current_clip_img;


function load_clip(){
  if(document.getElementById('qsp_source_url')){
    ksl_url = document.getElementById('qsp_source_url').value;	
  }
  if(document.getElementById('start_time')){
    start_time = document.getElementById('start_time').value;
  }
  if(document.getElementById('end_time')){
    end_time = document.getElementById('end_time').value;
  }
}
function move_loader(){
  var req;
  try { req = new XMLHttpRequest(); } catch (e) {};
  try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {};
  try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {};
  if(!req){
    return null;
  }
  document.write("<sc" + "ript language='text/javascript' src='http://qmedia.xlontech.net/100170/sdk/latest/movenetworks.js' import='qvt'>" + "< " + "/sc" + "ript>");	
  req.open("GET", "/javascript/movenetworks.php", false);
  req.send(null);
  if(req.status == 200){
    eval(req.responseText);
    init_player();
  }
  return;
}

function init_player(){
  load_clip();
  var height = parseInt(document.getElementById("QSPHolder").offsetHeight);
  var width = parseInt(document.getElementById("QSPHolder").offsetWidth);
  MN.QMPInstall.MSG_NOTWIN = MN.QMPInstall.MSG_NOTIE = "Welcome to the beta version of the NEW ksl.com streaming video player. Currently, the player is only available on Internet Explorer 5.5 or later on the Windows Platform. The player will be available for other browsers very soon.<BR /> ksl.com video is still offered in the Real Video format. <a href='?nid=245'>Click here to visit our \"Watch\"  page.</a>";
  MN.QVT.CreatePlayer("QSPHolder", OnPlayerLoaded, width, height);
}

function OnPlayerLoaded(player){
  cms_qmp = player;
  if(cms_qmp){
    var height = parseInt(document.getElementById("QSPHolder").offsetHeight);
    var width = parseInt(document.getElementById("QSPHolder").offsetWidth);
    
    MN.Event.Observe(cms_qmp, 'PlayStateChanged', OnPlayStateChanged);
    cms_qmp.UserAspectRatio(width/height);
    var scrubby = document.getElementById('scrubby');
    starting_left = parseInt(scrubby.currentStyle["left"]);
    cms_qmp.SetAutoPlayNext(false);
  }
}

function load_current_sec(id){
	var element = document.getElementById(id);
	if(cms_qmp != null){
	  element.value = cms_qmp.CurrentPosition();
	}
}

function jump_to_date(){
	var element = document.getElementById('jump_date');
	var msec = Date.parse(element.value);
}

//The following function was stolen from somewhere on the internet.
function getMouseXY(e) // works on IE6,FF,Moz,Opera7 
{ 
  if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)
  { 
    if (e.pageX || e.pageY)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      mousex = e.pageX;
      mousey = e.pageY;
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      mousex = e.clientX + document.body.scrollLeft;
      mousey = e.clientY + document.body.scrollTop;
    }  
  }
}

function toggle_play_pause(){
  var img = document.getElementById('playpauseimg');
  try{
    if(cms_qmp.CurrentPlayState() != 3){
      return 0;
    }
    if(!cms_qmp.Paused()){
      if(document.URL.indexOf('stage.bonnint.net') == -1){
	img.src = '/resources/move/graphics/movePlay.gif';
      }
      else {
	img.src = '/icons/play_16.gif';
      }
    }
    else {
      if(document.URL.indexOf('stage.bonnint.net') == -1){
	img.src = '/resources/move/graphics/movePause2.gif';
      }
      else {
	img.src = '/icons/pause_16.gif';
      }
    }
    cms_qmp.Paused(!cms_qmp.Paused());
    return 1;
  }
  catch(e){
    return -1;
  }
}
var times = 0;
function OnPlayStateChanged(oldS, newS){
  if(newS == 3){
    updating_progress = 1;
    update_scrub(1);
    update_time_window(1);
  }
  if(playing_ad == 1){
    
    if(newS == 5){
      updating_progress = 0;
      playing_ad = 0;
      cms_qmp.Stop();
      highlight(current_clip_title, current_clip_img, current_clip_desc);
      rotate_ads(0);
      play();
      return;
    }
    
  }
  else if(newS == 5 || newS == 4){
    var img = document.getElementById('playpauseimg');
    if(document.URL.indexOf('stage.bonnint.net') == -1){
      img.src = '/resources/move/graphics/movePlay.gif';
    }
    else {
      img.src = '/icons/play_16.gif';
    }
    updating_progress = 0;
    
  }
  else if(newS == 3){
    var img = document.getElementById('playpauseimg');
    if(document.URL.indexOf('stage.bonnint.net') == -1){
      img.src = '/resources/move/graphics/movePause2.gif';
    }
    else {
      img.src = '/icons/pause_16.gif';
    }

  }
  
}


function TransitionToClip(oldS, newS){
  if((newS == 5 || newS == 4) && oldS == 3){
    playing_ad = 0;
    cms_qmp.Stop();
    play();
  }
}

function play(){
  if(playing_ad == 1){
    alert_window("Returning...");
    return;
  }
  if(toggle_play_pause() != 0){
    return;
  }
  
  load_clip();
  if(ksl_url != ''){
    //    alert_window('Buffering...');
    if(end_time != ''){
      if(start_time == ''){
	cms_qmp.Play(ksl_url, 0, end_time);
      }
      else{
	cms_qmp.Play(ksl_url, start_time, end_time);
      }
    }
    else {
      if(start_time != ''){
	cms_qmp.Play(ksl_url, start_time);
      }
      else {
	var retval = cms_qmp.Play(ksl_url);
      }
   
    }

  }
}

function insert_live_url(id){
  var element = document.getElementById(id);
  var live_url = "http://qmplive.xlontech.net/ksltv/stream/";	
  var now = new Date();
  var year = now.getFullYear();
  year += "";
  year = year.substr(2,4);
  var day = now.getDate();
  day += "";
  if(day.length < 2){
    day = '0' + day;
  }
  var month = now.getMonth();
  month++;
  month += "";
  if(month.length < 2){
    month = '0' + month;
  }
  var todays_url = live_url + year + month + day + ".qvt";
  //var todays_url = live_url + 'output.qmx';
  element.value = todays_url;

  play();
}
function do_scrub(e){
  var scrub_bar = document.getElementById('scrub_bar');
  var qsp_holder = document.getElementById('QSPHolder');
  var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
		'Sep', 'Oct', 'Nov', 'Dec'];
  getMouseXY(e);
  if(startx == null){
    startx = mousex;
  }
  if(starty == null){
    starty = mousey;
  }
  if(start_left == null){
    start_left = scrub_element.style.left;
    if(start_left == ""){
      start_left = 0;
    }
    else {
      start_left = parseInt(start_left);
    }
  }
  var new_left = (mousex - startx);
  new_left = new_left + start_left;
  if(new_left < starting_left){
    new_left = starting_left;
  }
  if(new_left > parseInt(scrub_bar.offsetWidth) + starting_left){
    new_left = parseInt(scrub_bar.offsetWidth) + starting_left;
  }
  
  var percentage = ((new_left - starting_left) / scrub_bar.offsetWidth);
  
  if(cms_qmp.Live() && end_time == ""){
    var current_date = new Date;
    current_date.setTime(cms_qmp.StartTimestamp()*1000 + cms_qmp.Duration()*1000);
    var playing_date = new Date;
    playing_date.setTime(cms_qmp.StartTimestamp()*1000 + cms_qmp.CurrentPosition()*1000);

    
    if(playing_date.getHours() == current_date.getHours()){
      var current_milliseconds = current_date.getMilliseconds();
      current_milliseconds += current_date.getSeconds() * 1000;
      current_milliseconds += current_date.getMinutes() * 60 * 1000;
      var total = current_milliseconds / (60 * 60 * 1000);
      var farthest_left = total * parseInt(scrub_bar.offsetWidth);
      if(new_left > farthest_left){
	new_left = farthest_left;
      }
    }
    var new_date = playing_date;
    var percentage = ((new_left - starting_left) / scrub_bar.offsetWidth);
    var new_minutes = (percentage * 3600) / 60;
    var new_seconds = (percentage * 3600) % 60;
    new_date.setMinutes(new_minutes);
    new_date.setSeconds(new_seconds);
    var month = months[new_date.getMonth()];	
    var seconds = new_date.getSeconds() + "";
    var minutes = new_date.getMinutes() + "";
    var hours = new_date.getHours() + "";
    if(seconds.length == 1){
      seconds = "0" + seconds;
    }
    if(minutes.length == 1){
      minutes = "0" + minutes;
    }
    if(hours.length == 1){
      hours = "0" + hours;
    }
    
    
    time_string = month + " " + new_date.getDate() + " " + hours + ":" + 
      minutes + ":" + seconds;
    alert_window(time_string);
  }
  
  scrub_element.style.left = new_left + "px";

  return false;
}
var scrub_timeout = 50;
//var current_pos;
var current_date;
var time_window_timeout = 500;
function update_time_window(first){
  if(updating_progress == 0){
    return;
  }
  if(cms_qmp.CurrentPlayState() == 3 || first == 2){
    var time_string;
    var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug',
		 'Sep', 'Oct', 'Nov', 'Dec'];
    if(cms_qmp.Live() || (start_time != "" && end_time != "")){
      current_date = new Date;
      current_date.setTime(cms_qmp.StartTimestamp() * 1000 + cms_qmp.CurrentPosition() * 1000);
      var month = months[current_date.getMonth()];	
      var seconds = current_date.getSeconds() + "";
      var minutes = current_date.getMinutes() + "";
      var hours = current_date.getHours() + "";
      if(seconds.length == 1){
	seconds = "0" + seconds;
      }
      if(minutes.length == 1){
	minutes = "0" + minutes;
      }
      if(hours.length == 1){
	hours = "0" + hours;
      }
      
      
      time_string = month + " " + current_date.getDate() + " " + hours + ":" + 
	minutes + ":" + seconds;
      
    }
    else {
      var current_pos = cms_qmp.CurrentPosition();
      var duration = cms_qmp.Duration();
      var current_minutes = current_pos / 60;
      var current_secs = Math.floor(current_pos % 60) + "";
      if(current_minutes < 1){
	current_minutes = "0";
      }
      if(current_secs.length == 1){
	current_secs = "0" + current_secs;
      }
      var total_minutes = duration / 60;
      var total_secs = Math.floor(duration % 60) + "";
      if(total_minutes < 1){
	total_minutes = "0";
      }
      if(total_secs.length == 1){
	total_secds = "0" + total_secs;
      }
      time_string = current_minutes + ":" + current_secs +
	" / " + total_minutes + ":" + total_secs;
    }
    alert_window(time_string);
  }
}
var updating_progress;
var last_update = 0;
var starting_left = 0;
function update_scrub(first){
  if(updating_progress == 0){
    return;
  }
  var current_date = new Date;

  if(cms_qmp.CurrentPlayState() == 3){
    var scrub_bar = document.getElementById('scrub_bar');
    var scrubby = document.getElementById('scrubby');
    var current_pos = cms_qmp.CurrentPosition();
    var current_clip_length;
    
    if(start_time != "" && end_time != ""){
      current_clip_length = parseFloat(end_time) - parseFloat(start_time);
      start_time = parseFloat(start_time);
      end_time = parseFloat(end_time);
    }
    else if(!cms_qmp.Live() && cms_qmp.Duration() > 0){
      start_time = 0;
      end_time = cms_qmp.Duration();
      current_clip_length = cms_qmp.Duration();
    }
    if(scrub_element == null){
      if((current_pos >= end_time) && (end_time != 0)){
	scrubby.style.left = parseInt(scrub_bar.offsetWidth) + starting_left + 'px';
	return;
      }
      else {
	if(cms_qmp.Live() && end_time == ""){
	  current_date.setTime(cms_qmp.StartTimestamp()*1000 + cms_qmp.CurrentPosition()*1000);
	  var current_milliseconds = current_date.getMilliseconds();
	  current_milliseconds += current_date.getSeconds() * 1000;
	  current_milliseconds += current_date.getMinutes() * 60 * 1000;
	  
	  var total = current_milliseconds / (60 * 60 * 1000);
	  var new_left = total * parseInt(scrub_bar.offsetWidth);
	  scrubby.style.left = starting_left + new_left + 'px';
	}
	else if(current_clip_length > 0){
	  var current_duration = current_pos - start_time;
	  var total = current_duration / current_clip_length;
	  var new_left = total * parseInt(scrub_bar.offsetWidth);
	  scrubby.style.left = starting_left + new_left + 'px';
	}
      }
    }
  }
  
  var real_current_date = new Date();
  if((real_current_date.getTime() - last_update) > 1000){
    
    update_time_window(0);
    last_update = real_current_date.getTime();
  }
  window.setTimeout("update_scrub(0)", scrub_timeout);
}

var once = 0;
function alert_once(alert_string){
  if(once == 0){
    alert(alert_string);
    once++;
  }
}

function update_video(){
  var scrub_bar = document.getElementById('scrub_bar');
  var scrubby = document.getElementById('scrubby');
  var percentage = (parseInt(scrubby.style.left) - starting_left) / parseInt(scrub_bar.offsetWidth);
  var current_clip_length;
  load_clip();
  current_clip_end = end_time;
  
  if(start_time != "" && end_time != ""){
    current_clip_length = parseFloat(end_time) - parseFloat(start_time);
    start_time = parseFloat(start_time);
    end_time = parseFloat(end_time);
  }
  else if(!cms_qmp.Live() && cms_qmp.Duration() > 0){
    start_time = 0;
    end_time = cms_qmp.Duration();
    current_clip_length = cms_qmp.Duration();
    current_clip_end = cms_qmp.Duration();
  }
  else {
    current_clip_length = -1;
  }
  
  if(current_clip_length != -1){
    var current_sec = parseFloat(start_time) + parseFloat(current_clip_length * percentage);
  }
  else if(!cms_qmp.Live() && cms_qmp.Duration() > 0){
    var current_sec = cms_qmp.Duration() * percentage;
  }
  else if(cms_qmp.Live() && end_time == ""){
    var current_date = new Date;
    var current_position = cms_qmp.CurrentPosition();
    current_date.setTime(cms_qmp.StartTimestamp()*1000 + current_position*1000);
    var current_milliseconds = current_date.getMilliseconds();
    current_milliseconds += current_date.getSeconds() * 1000;
    current_milliseconds += current_date.getMinutes() * 60 * 1000;
    var millisec_in_hour = percentage * 3600 * 1000; //percentage times number of milliseconds in an hour.
    var current_sec = ((current_position*1000) - current_milliseconds + millisec_in_hour)/ 1000;
  }
  else {
    current_sec = cms_qmp.CurrentPosition();
  }
  alert_window("---");

  /*if(current_clip_end != ""){
    cms_qmp.Play(url, current_sec, current_clip_end);
  }
  else {
    cms_qmp.Play(url, current_sec);
    }*/

  if(cms_qmp.Live()){
    cms_qmp.CurrentPosition(current_sec);
  }
  else if(current_sec < current_clip_end){
    cms_qmp.CurrentPosition(current_sec);
  }
  else {
    cms_qmp.CurrentPosition(current_clip_end - .0005);
  }
  updating_progress = 1;
  update_time_window(2);
}

function alert_window(text){
  var time_window = document.getElementById("qsp_time_window");
  if(time_window.innerText != text){
    time_window.innerText = text;
  }
}

function stop_scrub(){
  document.onmousemove = null;
  document.onmousedown = null;
  document.onmousedrag = null;
  document.onmouseup = null;
  update_video();
  scrub_element = null;
}

var scrub_element;

function false_function() {
  return false;
}

function start_scrub(){
  startx = null;
  starty = null;
  start_left = null;
  scrub_element = document.getElementById('scrubby');
  document.onmousemove = do_scrub;
  document.onmousedown = false_function;
  document.onmousedrag = false_function;
  document.onmouseup = stop_scrub;
}
var fast_forward_counter = -100;
var fast_forward_click = 100;
var fast_forward_pos;
function fastforward(){
  if(cms_qmp.CurrentPlayState() == 3){
    document.onmousedown = false_function;
    document.onmousedrag = false_function;
    document.onmouseup = stop_fast_forward;
    fast_forward_counter = 0;
    fast_forward_pos = cms_qmp.CurrentPosition();
    do_fast_forward();
  }
}

function do_fast_forward(){
  var increment = 2;
  load_clip();
  if(fast_forward_counter >= 0){
    current_clip_end = end_time;
        
    
    
    if(end_time == ""){
      real_end = cms_qmp.Duration();
    }
    else {
      real_end = parseFloat(end_time);
    }

    if(fast_forward_pos + increment < real_end){
      fast_forward_pos += increment;
      cms_qmp.Play(ksl_url, fast_forward_pos);
    }
    else { 
      stop_fastforward();
      return;
    }
    window.setTimeout("do_fast_forward()", fast_forward_click);
  }
}

function stop_fast_forward(){
  document.onmouseup = null;
  document.onmousedown = null;
  document.onmousedrag = null;
  document.onmouseup = null;
  fast_forward_counter = -100;
}

function error_log(error){
  document.getElementById('errors').innerHTML += error;
}

function back(){
  
  if(playing_ad == 1){
    return;
  }
  load_clip();
  if(cms_qmp.CurrentPlayState() == 3){
    current_clip_start = start_time;
    currnet_clip_end = end_time;
        
    var current_pos = cms_qmp.CurrentPosition();
    var new_pos = current_pos - 3600; //Subtract an hour if we're live 
    //when they hit back.
    if(start_time != ""){
      if(new_pos < parseFloat(start_time)){
	new_pos = parseFloat(start_time);
      }
    }
    if(new_pos < 0){
      new_pos = 0;
    }
    alert_window('---');
    /*if(end_time != ""){
      cms_qmp.Play(url, new_pos, parseFloat(end_time));
    }
    else {
      cms_qmp.Play(url, new_pos);
    }*/
    cms_qmp.CurrentPosition(new_pos);
  }
}

function next(){
  if(playing_ad == 1){
    return;
  }
  load_clip();
  if(cms_qmp.CurrentPlayState() == 3){
    current_clip_start = start_time;
    current_clip_end = end_time;
        
    var current_pos = cms_qmp.CurrentPosition();
    var new_pos = current_pos + 3600; 
    //when they hit back.
    if(end_time != ""){
      if(new_pos > parseFloat(end_time)){
	new_pos = parseFloat(end_time) - 5;
      }
    }
    if(new_pos > cms_qmp.Duration()){
      new_pos = cms_qmp.Duration() - 1;
    }

    alert_window('---');
    /*if(end_time != ""){
      cms_qmp.Play(url, new_pos, end_time);
    }
    else {
      cms_qmp.Play(url, new_pos);
    }*/
    cms_qmp.CurrentPosition(new_pos);
  }
}

function highlight(title, img, desc){
  var text = "<img src='" + img + "' /><br />";
  text += "<span class='highlight_title'>" + title + "</span><br />";
  text += desc + "<br />";
  var highlight_box = document.getElementById('current_clip_highlight');
  if(highlight_box){
    highlight_box.innerHTML = text;
  }
}

var played_clips = 0;
var override_ads = 0;
function load_and_play_clip(new_url, new_start_time, new_stop_time, title, img, desc){
  ksl_url = new_url;
  start_time = new_start_time;
  end_time = new_stop_time;
  current_clip_title = title;
  current_clip_img = img;
  current_clip_desc = desc;
  if(playing_ad == 1){
    return;
  }
  cms_qmp.Stop();
  if(((played_clips % 3) == 0) && override_ads != 1){
	play_ad();
    }
    else {	
    highlight(current_clip_title, current_clip_img, current_clip_desc);
    play();	
  }	


  played_clips++;
}


var played_ads = [];
var start_clip = 0;
var start_ad = 0;


function rotate_clips(direction){
  if(direction > 0){
    if(start_clip + 1 > (quantum_clips.length - 1)){
      start_clip = quantum_clips.length - 1; //
    }
    else {
      start_clip += 1;
    }
  }
  else if (direction < 0) {
    if(start_clip - 1 < 0){
      start_clip = 0;
    }
    else {
      start_clip -= 1;
    }
  }
  else {
    start_clip = 0;
  }
  var container = document.getElementById('clips_container');
  var newHTML = "";
  for(var i = start_clip; i < start_clip + num_clips_at_a_time; i++){
    if(i < quantum_clips.length){
      var item = quantum_clips[i];
      var item_text = "<div class=\"quantum_clip_container\"><a href=\"#\" onclick=\"load_and_play_clip('" + item.quantumclipurl + "', '" + item.quantumclipstart + "', '" + item.quantumclipend + "', '" + item.title.replace(/'/, "\\'") + "', '" + item.image + "', '" + item.text.replace(/'/,"\\'") + "'); return false;\" class=\"quantum_clip\"><img src=\"" + item.image + "?filter=hl5\" /><br />" + item.title + "</a></div>";
      newHTML += item_text;
    }
  }
  container.innerHTML = newHTML;
}

function rotate_ads(direction){
  if(played_ads.length == 0){
    return;
  }
  if(direction > 0){
    if(start_ad + 1 >= (played_ads.length - 1)){
      start_ad = played_ads.length - 1;
    }
    else {
      start_ad += 1;
    }
  }
  else if (direction < 0) {
    if(start_ad - 1 < 0){
      start_ad = 0;
    }
    else {
      start_ad -= 1;
    }
  }
  else {
    start_ad = played_ads.length - 1;
  }

  var container = document.getElementById('ads_container');
  var newHTML = "";
  for(var i = start_ad; i > start_ad - num_ads_at_a_time && i >= 0; i--){
    var item = played_ads[i];
    if(item.img != "" || item.text != ""){
            if(item.img != ""){
	newHTML += item.img;
      }
      else {
	newHTML += "<a href ='" + item.link + "'>"+ item.text + "</a>";
      }
    }
    
  }
  container.innerHTML = newHTML;
}
http://stocker.bonnint.net/ksl/zionsdirect2.jpg?timestamp=1146178752?copy_id=171

function highlight_ad(ad){
  if(ad.img != "" || ad.text != ""){
    var highlight_box = document.getElementById('current_clip_highlight');
    if(highlight_box != null){
if(ad.img != ""){
      highlight_box.innerHTML = ad.img;
    }
    else {
      highlight_box.innerHTML = "<a href ='" + ad.link + "'>"+ ad.text + "</a>";
    }
 
}

   played_ads.push(ad);
  }

}

var playing_ad;
function play_ad(){
  var ad_url = "/ajax/move_remote_ad_pull.php?length=" + rotation_length;
  var req;
  playing_ad = 1;
  alert_window("---");
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } 
  else if (window.ActiveXObject) {
    // Internet Explorer
    req = new ActiveXObject("Microsoft.XMLHTTP");
    if(!req){
      return true;
    }
  }
  else {
    return true;
  }
  req.open("GET", ad_url, false);
  req.send(null);
  if(req.status == 200){
    eval("var ad = " + req.responseText + ";");
    highlight_ad(ad);
  //  alert("Hi! my dear friend" + url);
    cms_qmp.Play(ad.videourl);
//    alert("After! my dear friend" + url);
  }
  else {
    playing_ad = 0;
    play();
  }
}
var progress_count = 0;
function _QSPNextState(state){
var holder = document.getElementById('QSPHolder');
alert_window("State: " + state + progress_count++);
  switch(state){
  case "qspErrorNotIE":
    holder.innerHTML = "We're sorry, the Quantum Player currently only works on Internet Explorer.  Other platforms will soon be supported.";
    break;
  case "qspErrorNotWindows":
    holder.innerHTML = "We're sorry, the Quantum Player currently only works on Windows.  Other platforms will soon be supported.";
    break;
  case "qspErrorNoWMP9": 
    holder.innerHTML = "You don't have Windows Media Player 9 Installed. Please install and try again.";
    break;
  case "qspActiveXPrompt": 
    holder.innerHTML = "Please wait for the Quantum Media Player to load. When loading is complete, you'll see a security certificate. Please click \"Yes\" or \"Install\" to accept the certificate, which will allow the Quantum Media Player to install";
    break;
  case "qspErrorActiveXUnsafe": 
    holder.innerHTML = "One of Internet Explorer's advanced security settings conflicts with the Quantum Media Player. If you have made a change to the default security settings in Internet Explorer, you may not be prompted to install.  To reset your default security settings, click on the \"Tools\" menu at the top of Internet Explorer.  From the menu that displays select \"Internet Options...\"  Then select the \"Security\" tab from the window that pops up.  On this tab, click the \"Default Level\" button at the bottom.  Then if necessary move the slider above the button to \"medium.\"  Click the \"OK\" button at the bottom of the pop-up window and then refresh this page.";
    break;
  case "qspErrorActiveXBlocked":
    holder.innerHTML = "<p><strong>Important notice to Windows XP users:</strong>" + 
      " Have you installed Service Pack 2 for Windows XP? If so, you will need to look for a yellow information bar, at the top of this page, showing a message about the Quantum Media Player. You will need to click on that information bar and choose \"Install ActiveX Control...\" to continue.</p>" +
      "<p>If you continue to have problems, or if you are not running Windows XP with Service Pack 2, try these troubleshooting steps:</p>" +
      "<ul><li><strong>Have you changed the security settings in Internet Explorer?</strong><br>"+
      "One of Internet Explorer's advanced security settings conflicts with installing the Quantum Media Player. If you have made a change to the default security settings in Internet Explorer, you will not be prompted to install.  To reset your default security settings, click on the \"Tools\" menu at the top of Internet Explorer.  From the menu that displays select \"Internet Options...\"  Then select the \"Security\" tab from the window that pops up.  On this tab, click the \"Default Level\" button at the bottom.  Then if necessary move the slider above the button to \"medium.\"  Click the \"OK\" button at the bottom of the pop-up window and then refresh this page.";
    break;
  case "qspErrorTimeOut":
    holder.innerHTML = "<p>Even on slower Internet connections, it should take less than one minute to download the Quantum Media Player. This may indicate a problem with your Internet connection.</p>";
    break;
  case "qspUpgradeProgress":
    holder.innerHTML = "";
    break;
  case "qspInstallDone": 
    holder.innerHTML = "The Quantum Player is installed. Please close all of your open Internet Explorer windows and then restart Internet Explorer.";
    break;
  default:
    holder.innerHTML = 'There was an unknown problem with the Quantum Player. Please try again later. state:' + state;
    
  }
 
}

