﻿// JScript File

function getScrollLocation()
{
  var scrollX, scrollY;
  
  if (document.all)
  {
     if (!document.documentElement.scrollLeft)
        scrollX = document.body.scrollLeft;
     else
        scrollX = document.documentElement.scrollLeft;
           
     if (!document.documentElement.scrollTop)
        scrollY = document.body.scrollTop;
     else
        scrollY = document.documentElement.scrollTop;
  }   
  else
  {
     scrollX = window.pageXOffset;
     scrollY = window.pageYOffset;
  }

  document.getElementById("ctl00_xCoord").value = scrollX;
  document.getElementById("ctl00_yCoord").value = scrollY;
}

function setScrollLocation()
{
  var x = document.getElementById("ctl00_xCoord").value;
  var y = document.getElementById("ctl00_yCoord").value;
  window.scrollTo(x, y);
}


function scrollto(x, y) {
    window.scrollTo(x, y);
    document.getElementById("ctl00_xCoord").value = x;
    document.getElementById("ctl00_yCoord").value = y;
}



window.onload = setScrollLocation;
window.onscroll = getScrollLocation;
window.onkeypress = getScrollLocation;
window.onclick = getScrollLocation;


function toggleInfoBox(id) {
    var box = document.getElementById(id);

    if(box.style.display == "inline") {
        box.style.display = "none";
    }
    else {
        box.style.display = "inline";
    }
}

function getTextBox(sender) {
    return document.getElementById(sender.id.substr(0,sender.id.lastIndexOf("_")) + "_textComment");
}

function confirmPublicEvent(sender, action) {
    return confirm(
        "Är du säker på att du vill utföra följande handling/skicka följande meddelande till kunden?\n\n" +
        action + "\n\n" +
        getTextBox(sender).value);
}