$(document).ready(function() {
    // do stuff when DOM is ready
    $('.imgBackingShadow a').click(function(event) {
        event.preventDefault(); //stop the link from going to href
        ajaxImageGet(this);
    });

    $('#imagePopUpCloseBtn a').click(function(event) {
        event.preventDefault(); //stop the link from going to href
        $('#imagePopUpHolder').css('display', 'none');
    });
});

// get image
function ajaxImageGet(e) {

  var pos = $(e).position();
  var posWidth = $(e).parents('div:first').width();
  var posHeight = $(e).parents('div:first').height();
  var popUpWidth = $('#imagePopUpHolder').width();
  var popUpHeight = $('#imagePopUpHolder').height();
  var posMiddleWidth = pos.left + (posWidth / 2) - (popUpWidth / 2);
  var posMiddleHeight = pos.top + (posHeight / 2) - (popUpHeight / 2) -18;//pull it up x;

  //alert("POSITION: \nLeft: " + popUpWidth + "\nTop: " + popUpHeight + "\nWidth: " + posWidth + "\nHeight: " + posHeight);

  $('#imagePopUpHolder').css('left', posMiddleWidth).css('top', posMiddleHeight).css('display', 'block');
  $('#imagePopUp').html("<img src='../FastSigns/CMSPages/GetFile.aspx?nodeguid=" + $(e).attr("name") + "' >");

/*  
  $.ajax({
      type: "POST",
      url: "WebService/AjaxGetImage.asmx/GetImage",
      data: '{"fastSignsProductID":"' + thisImage + '"}',
      contentType: "application/json; charset=utf-8",
      dataType: "json",
      success: function(msg) {
          // Do something interesting here.
          //alert(msg);
      var testImageID = "dd3d3a6e-0cf6-475f-9615-59520d4c91b0";

          $('#imagePopResponse').html("<img src='../FastSigns/CMSPages/GetFile.aspx?nodeguid=" + testImageID + "' >");
      }
  });
  
*/
}
// trim function
function rtrim(str, chars) {
    chars = chars || '\\s';
    return str.replace(new RegExp('[' + chars + ']+$', 'g'), '');
}