// the following will remove the survey if passed a false result
var ping = {};

ping = {    
  img:null,    
  imgPreload:null,    
  timer:null,    
  init:function() {        
    var sess = new Date();        
    var nocache = sess.getTime();        
   // var imguri = ping.img+"?time="+nocache;  
    
    var imguri = "http://pch.sondages-surveys.ca/media/theme/img/sig-eng.gif" + "?time=" + nocache;
 
    ping.imgPreload = new Image();  
      
    ping.imgPreload.onload = function() {            
      clearTimeout(ping.timer);            
      ping.timer = null;    
              
      //alert("Domain is available"); 
      // no need to call validateSurvey();      
      };        
      ping.imgPreload.src = imguri;        
      ping.timer = setTimeout("ping.fail_to_ping()",2000);    
    },    
    
    fail_to_ping:function() {      
        
      clearTimeout(ping.timer);        
      ping.timer = null;        
      ping.imgPreload = null;        
      //alert("Ping to domain failed!");
      // call validateSurvey to remove the survey from the rendered webpage  
      validateSurvey('false');    
      }
    };
    
function validateSurvey(result){
  var theBrowser = navigator.appName;
  if (result == 'false') {
      if (theBrowser.match("Explorer")){
      // remove the form
      document.getElementById('survey').removeNode(1);

    }else{
      // this way for Firefox
      var theSurvey=document.getElementById('survey');
      var len=theSurvey.childNodes.length;
      while (theSurvey.hasChildNodes()){
        theSurvey.removeChild(theSurvey.childNodes[0]);
      }
    }
  }
}
