window.onload = init;

function init() {
	prepareLinks("body-wrap-interior","body-wrap","/includes/getDigitalINS.cfm");
}

function prepareLinks(containerId,canvasId,file) {
  if (!document.getElementById) return false;
  if (!document.getElementById(containerId)) return false;
  if (!document.getElementById(canvasId)) return false;
  var links = document.getElementById(containerId).getElementsByTagName("a");
   
  for (var i=0; i<links.length; i++) {
	  if(links[i].id =="script") {
    links[i].canvasId = canvasId;
    links[i].file = file;
    links[i].onclick = function() {
      var data = this.getAttribute("href").split("?")[1];
      return (!sendData(data,this.file,this.canvasId));
	}
    }
  }
}


function sendData(data,file,canvasId) {
  var request = getHTTPObject();
  if (request) {
    request.onreadystatechange = function() {
      parseResponse(request,canvasId);
    };
    request.open( "POST", file, true );
    request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    request.send(data);
    return true;
  } else {
    return false;
  }
}

function parseResponse(request,canvasId) {
  if (request.readyState == 4) {
    if (request.status == 200) {
      document.getElementById(canvasId).innerHTML = request.responseText;
      init();
    }
  }
}

function getHTTPObject() {
	
try
{
var xhr = new XMLHttpRequest();
	
	return xhr;
	
	
}
catch (error)
{
try
{
	
 xhr = new ActiveXObject("Microsoft.XMLHTTP");

return xhr;
}
catch (error)
{
return false;
}
}
}




function getWidth(image)
{
    // get a reference to the img element in the popup
    // set the source of that element
    image.src = imagesrc;

    // get the dimensions of the image
    var width = image.width;
   //var height = image.height;

    // and resize the window
    return width;
}

function getHeight(image)
{
    // get a reference to the img element in the popup
    // set the source of that element
    image.src = imagesrc;

    // get the dimensions of the image
    //var width = image.width;
    var height = image.height;

    // and resize the window
    return height;
}
 