// JavaScript Document
function hidePopup()
{
	var obj=document.getElementById("AJAXPopup");
	var imgIDObj=document.getElementById("imgID");
	obj.style.display="none";	
	imgIDObj.src="http://www.sagecreekwholesale.com/images/designImages/clearImage-400x440.jpg";
}

function showPopup(imgPath)
{
//alert(imgNum);
if(navigator.appName == "Microsoft Internet Explorer")
{
	clicktest();
	 
}

var imgIDObj=document.getElementById("imgID");
imgIDObj.src=imgPath;

var obj=document.getElementById("AJAXPopup");
obj.style.display="block";
}

function loadingEvents(SumIMG)
{
	if(navigator.appName != "Microsoft Internet Explorer")
			{
		 		for(var i=1;i<SumIMG+1;i++)
				{
					init("IMG" + i);
				}
			}
} 
/*******************************************************
*****INIT THE MOUSE EVENT FOR FIREFOX*******************/

function init(imgNum)

{

//this element is declared in the page itself.I put the subscribe form on the page in between a div element that called:"subscribe1","subscribe2","subscribe3"
//alert(imgNum);
var fobj = document.getElementById(imgNum);

fobj.onmouseup = clicktest; // update(event) implied on NS, update(null) implied on IE

if (fobj.captureEvents) fobj.captureEvents(Event.MOUSEUP);

 

} 

/**************USE THE MOUSE EVENT FOR THE  POPUP****************
*****************************************************************/

function clicktest(e)

{

      var posx,posy; 

      if (!e) e = window.event; // works on IE, but not NS (we rely on NS passing us the event)

  if (e)

  {

      if (e.pageX || e.pageY)

      {

            //alert("page");

            posx = e.pageX;

            posy = e.pageY;

      }

      else if (e.clientX || e.clientY)

      {

           // alert("client");

            posx = e.clientX;

            posy = e.clientY;

            if (navigator.appName == "Microsoft Internet Explorer")

            {//alert("body");

                  posx += document.body.scrollLeft;

                  //alert(posx );

                  posy += document.body.scrollTop;

                  //alert(posy );

            }

      }

  } 
 var scrY = screen.availHeight;
 var scrX = screen.availWidth;

 		if(posy>scrY){
			posy=scrY - document.getElementById("AJAXPopup").style.height - 50; 
			}
		if (posx>scrX){
			posx = scrx - document.getElementById("AJAXPopup").style.width - 200;
		}

      document.getElementById("AJAXPopup").style.top=posy - 100 + "px";

      document.getElementById("AJAXPopup").style.left=posx - 150 + "px"; 

      //return false;

} 