function loadInstantChat(){
	var ICLoader = new RescueInstantChatLoader();
	ICLoader.ICContainer = "ICContainer";
	ICLoader.HostedCSS = "http://axon.pushon.co.uk/wp-content/themes/axon/InstantChat.css";
	ICLoader.PrivateCode = document.getElementById("Code").value;
	ICLoader.Tracking0 = ""; /* optional */
	ICLoader.Language = ""; /* optional */
	ICLoader.HostedErrorHandler = function(ErrorName){} /* optional */
	ICLoader.Start();
}

                                  
function loadInstantChatNew(sessionType){    
  // Show Instant Chat
  document.getElementById("InstantChatDiv").style.display = "";
  // Hide Channel form
  document.getElementById("ChannelForm").style.display = "none";
  // Hide PIN Code form
  //document.getElementById("PinForm").style.display = "none";
  // Hide Language dropdown
  //document.getElementById("LanguageForm").style.display = "none";
  var ICLoader = new RescueInstantChatLoader();
  ICLoader.ICContainer = "InstantChatDiv";
  ICLoader.HostedCSS = "http://www.axon-it.com/wp-content/themes/axon/InstantChat.css";                        
  //ICLoader.HostedLanguagesForChatOnlyMode = "http://www.axon-it.com/wp-content/themes/axon/standardChat.js";           
  //ICLoader.HostedLanguagesForAppletMode = "http://www.axon-it.com/wp-content/themes/axon/appletChat.js";
  // sessionType == 0, we are after REBOOT
  // Channel session
  if (sessionType == 1) ICLoader.EntryID = "860272325";
  // Private Session
  /*if (sessionType == 2) {
    var pin = document.getElementById("inputPinCode").value;
    if ((pin.length != 6) || isNaN(pin))
    {
      handleError("Private code should be a 6-digit number!");
      return;
    }
    else ICLoader.PrivateCode = document.getElementById("inputPinCode").value;
  } */
  
  ICLoader.Name = document.getElementById("inputYourName").value;
  ICLoader.Comment1 = document.getElementById("inputEmailAddress").value;
  ICLoader.Comment2 = document.getElementById("inputPhoneNumber").value;
  ICLoader.Comment3 = document.getElementById("inputCompanyName").value;
  ICLoader.Comment4 = document.getElementById("inputLocation").value;
  ICLoader.Comment5 = document.getElementById("inputComment").value;
  ICLoader.Tracking0 = "InstantChatForm";
  ICLoader.Language =  ""; /* optional */             
  // Error + No Technician available notification handling
  ICLoader.HostedErrorHandler = function(ErrorName)
  {
    switch(ErrorName)
    {
      case "NOTECHAVAILABLE": handleError("<p>Currently no technicians are available. Please check back later.</p>"); break;
      case "NOTECHWORKING": handleError("<p>Sorry, we're closed. No Technicians are available at this time. Please check back later during our hours of operation.</p>"); break;
      case "INVALID_PARAMETERS": handleError("<p>Invalid parameters supplied. Please contact your support provider.</p>"); break;
      case "SESSIONALREADYSTARTED": handleError("<p>A session using this PIN Code has already been started. Please ask your support provider for a new PIN Code.</p>"); break;
      case "UCONNECTIONERROR": handleError("<p>Unknown connection error occured.</p>"); break;
      case "ERRNOSUCHSSESSION": handleError("<p>The support session cannot be started.</p>"); break;
      case "ERRNOSUCHENTRY": handleError("<p>The online support session cannot be started. Please contact your support provider directly.</p>"); break;
      case "ERRCODEDOESNOTEXIST": handleError("<p>PIN Code does not exist. Please contact your support provider.</p>"); break;
      case "ERRCODEEXPIRED": handleError("<p>PIN Code has expired. Please contact your support provider.</p>"); break;
      case "ERRNOTEXPIRED": handleError("<p>Technician or company does not exist. Please contact your support provider.</p>"); break;
      case "ERRMISSINGTECHLICENSE": handleError("<p>The support session cannot be started. The technician is not configured to support this type of device.</p>"); break;
    }
  }
  ICLoader.Start();
}      
                             
function handleError(ErrorDescription){
  // Hide Instant Chat
  document.getElementById("InstantChatDiv").style.display = "none";
  // Show ErrorForm
  var ef = document.getElementById("ErrorForm");
  ef.style.display = "";
  ef.innerHTML = ErrorDescription;
}             

function handleRebootOrRefresh(){
	if ((window.location + "").indexOf("rescuewebsessionid") != -1){document.getElementById("ICContainer").style.display=""; loadInstantChat();} /* optional */
	if (window.location.hash.length == webSessionIdLength + 1){document.getElementById("ICContainer").style.display=""; loadInstantChat();} /* optional */
}

