//
//	provider.js
//		Various scripts for provider pages.
//

// Definitions

// Globals

	
// Terms checkbox during registration.
function validateterms(elementID)
{
	if (!document.getElementById(elementID).checked)
	{
		alert("Please Accept the Privacy Policy and Terms & Conditions.");
		return false;
	}
}

// Provider profile image zoom
function PrvImgShow(imageUrl)
{
  var div = document.getElementById("ProviderImageZoom");
  var img = document.getElementById("imgProviderZoom");
  if (div && img)    // Just in case.
  {
    img.src = imageUrl;
    div.style.visibility = "visible";
  }
}

function PrvImgHide()
{
  var div = document.getElementById("ProviderImageZoom");
  var img = document.getElementById("imgProviderZoom");
  if (div && img)    // Just in case.
  {
    // to prevent flashing the old image when showing the new
    img.src = "/images/CFL/clr.gif";
    div.style.visibility = "hidden";
  }
}

// Request results image zoom
// Pass thumbnail image reference.
function ReqImgShow(obj, baseID, imageUrl)
{
  var offsetL = 70;       // Off the right of the thumbnail.
  var offsetT = 20;       // Just down a little to look good.
  var maxHeight = 500;    // Max image height, as a default.

  var div = document.getElementById("CustReqResultsImageZoom");
  var img = document.getElementById("imgProviderZoom");
  var base = document.getElementById(baseID);

  if (div && img && base)    // Just in case.
  {
    img.src = imageUrl;

    // Reading is relative to page.
    var coors = findPos(obj);
    //alert("coors = " + coors[0] + ", " + coors[1]);
    var divL = coors[0] + offsetL;
    var divT = coors[1] + offsetT;
    
    // Check bottom screen edge.
    // If we have image height, use it (generally, if it has been cached).
    // If we don't, it's still the 1 pixel clr.gif, so use the max.
    // In IE, we never get the height. Would need to preload.
    var screenBot = truebody().scrollTop + truebody().clientHeight;
    var imgHeight = (img.height >= 10) ? img.height : maxHeight;   // Just to pick a bigger number than 1.
    if ((divT + imgHeight) > screenBot)
    {
      divT = screenBot - imgHeight;
    }

    // Set is relative to base object (next positioned parent up).
    var baseCoors = findPos(base);
    //alert("baseCoors = " + baseCoors[0] + ", " + baseCoors[1]);
    divL -= baseCoors[0];
    divT -= baseCoors[1];

    div.style.left = divL + 'px';
    div.style.top = divT + 'px';
    div.style.visibility = "visible";
  }
}

function ReqImgHide()
{
  var div = document.getElementById("CustReqResultsImageZoom");
  var img = document.getElementById("imgProviderZoom");
  if (div && img)    // Just in case.
  {
    // to prevent flashing the old image when showing the new
    img.src = "/images/CFL/clr.gif";
    div.style.visibility = "hidden";
  }
}

