


function popUpChat(subject,pr,ct,url) { // old pop up - do not use!
  var leftPos = (screen.width / 2) - 325
  var topPos = (screen.height / 2) - 265
  if (url) {
    urlPath = url
  } else {
    urlPath = "submit"
  }
  chatWindow = window.open("http://www.telecom.co.nz/help/webchat/" + urlPath + "?subject=" + subject + "&p_prods=" + pr + "&p_cats=" + ct, "chatWindow", "status=1,toolbar=0,menubar=0,location=0,resizable=1,height=530px,width=640px,left=" + leftPos + ",top=" + topPos)
}

function popUpChatWindow(title,subject,pr,ct,omniture) { // pop up the chat request window
  var leftPos = (screen.width / 2) - 325
  var topPos = (screen.height / 2) - 265
  chatWindow = window.open("/help/webchat/form?title=" + title + "&subject=" + subject + "&p_prods=" + pr + "&p_cats=" + ct + "&omniture=" + omniture, "chatWindow", "status=0,toolbar=0,menubar=0,location=0,resizable=1,height=530px,width=640px,left=" + leftPos + ",top=" + topPos)
}

function gradschatpopup(poptype) { // Graduates Programme pop-up
  var leftPos = (screen.width / 2) - 325
  var topPos = (screen.height / 2) - 265
  var url = ""
  if (poptype == 1) {
    url = "/content/0,6845,206424-204587,00.html" // HR Grad, chat off
  } else {
    url = "/content/0,6845,206450-204587,00.html" // HR Grad, chat on
  }
  chatWindow = window.open(url, "chatWindow", "status=0,toolbar=0,menubar=0,location=0,resizable=1,height=670px,width=660px,left=" + leftPos + ",top=" + topPos)
}


function submitChatRequest(obj) { // form validation and submit
  var emailFilter = /^.+@.+$/
  var emailIn = document.frm_chat_data.c_email.value
  if (document.frm_chat_data.c_fname.value == "") {
    document.getElementById("webchat_notification").innerHTML = "Please fill in your first name."
    document.frm_chat_data.c_fname.focus()
  } else if (document.frm_chat_data.c_lname.value == "") {
    document.getElementById("webchat_notification").innerHTML = "Please fill in your last name."
    document.frm_chat_data.c_lname.focus()
  } else if (!(emailFilter.test(emailIn))) {
    document.getElementById("webchat_notification").innerHTML = "Please enter a valid email address."
    document.frm_chat_data.c_email.focus()
//  } else if (document.frm_chat_data.c_comment.value == "") {
//    document.getElementById("webchat_notification").innerHTML = "Please enter your question."
//    document.frm_chat_data.c_comment.focus()
//  } else if (document.frm_chat_data.c_comment.value.length >= 500) {
//    document.getElementById("webchat_notification").innerHTML = "Your question is too long."
//    document.frm_chat_data.c_comment.focus()
  } else {
  } else {
    var s = s_gi('telecomnz-prd')
    s.linkTrackVars = "events"
    s.linkTrackEvents = "event12"
    s.events = "event12"
    s.prop1 = "Submit"
    s.tl(obj, "o", "Start Chat")
    document.frm_chat_data.chat_submit.disabled = true
    document.frm_chat_data.action = "http://bcvipap01.rightnowtech.com:80/Chat/live_tc.jsp?p_db_name=telecom&p_intf_id=1"
    document.frm_chat_data.submit()
  }
}

function setupTimings(id) {
  var spans = document.getElementById(id).getElementsByTagName("span")
  for (var i = 0; i < spans.length; i++) {
    var span = spans[i]
    if (span.className == "timings") {
      var link = document.createElement("a")
      link.href = "#"
      link.innerHTML = "chat times"
      link.onclick = function() {
        this.style.display = "none"
        span.style.display = "inline"
        return false
      }
      span.parentNode.insertBefore(link, span)
      span.style.display = "none"
    }
  }
}



