﻿// JScript File

//these functions help with the pop up information overlay div tags that are on the site in various locations
<!--

var IE = false;
var tempX = 0;
var tempY = 0;

//if (navigator.appName == "Microsoft Internet Explorer"){IE = true}
//if(!IE)
//{document.captureEvents(Event.MOUSEMOVE);}

document.onmousemove = update;

function update(e)
{ 
  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)
    { // this doesn't work on IE6!! (works on FF,Moz,Opera7)
      tempX = e.pageX;
      tempY = e.pageY;
      
    }
    else if (e.clientX || e.clientY)
    { // works on IE6,FF,Moz,Opera7
      tempX = e.clientX + document.body.scrollLeft;
      tempY = e.clientY + document.body.scrollTop;
      
    }  
  }
  
  
       
}


function initXMLHttpRequest()
{
	// mozilla, etc.
	if (window.XMLHttpRequest)
	{
		req = new XMLHttpRequest();
	}
	// internet explorer
	else if (window.ActiveXObject)
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
	}

   return(req);
}

function ShowWebImg_MetalibResource(resourceid)
{
   //PURPOSE: Calls the back end server page which processes the request and then pushes it into the page
   //PARAMETERS: datasource = url that contains the means to get the data you want
   //            ProcessType = where you deliver the data after it completes the fetching
   
   // **** ElementID is used for 'zone' when Passing to ProcessMultiResults
   
    //alert(resourceid);
  
    var objXML = initXMLHttpRequest();
    var strData= "";
    var datasource = "pagethumbnail_processor.aspx?refresh=0&height=150&width=200&resourceID=" + resourceid;
    
    objXML.open("GET", datasource)
    objXML.onreadystatechange = function()
    {
        if(objXML.readyState == 4 )
        {
            //alert(objXML.responseText);
            
            strData = objXML.responseText;
            if(strData.length > 2)
            {//alert(strData);
            
                document.getElementById("img" + resourceid).src = strData;
             }   
            
        }
        else
        {
           // document.getElementById('StatusText').innerHTML = "Getting data...";
            //alert(objXML.readyState);
        }
    }
    
    objXML.send(null);

}

function ShowWebImg_WebResource(url, div, height, width)
{
   //PURPOSE: Calls the back end server page which processes the request and then pushes it into the page
   //PARAMETERS: datasource = url that contains the means to get the data you want
   //            ProcessType = where you deliver the data after it completes the fetching
   
   // **** ElementID is used for 'zone' when Passing to ProcessMultiResults
   
   // alert(url);
  
    var objXML = initXMLHttpRequest();
    var strData= "";
    var datasource = "pagethumbnail_processor.aspx?refresh=1&height=" + height + "&width=" + width + "&url=" + url;
    
    objXML.open("GET", datasource)
    objXML.onreadystatechange = function()
    {
        if(objXML.readyState == 4 )
        {
            //alert(objXML.responseText);
            
            strData = objXML.responseText;
            if(strData.length > 2)
            {//alert(strData);
            
                //alert(strData);
            
                document.getElementById("img" + div).src = strData;
             }   
            
        }
        else
        {
           // document.getElementById('StatusText').innerHTML = "Getting data...";
            //alert(objXML.readyState);
        }
    }
    
    objXML.send(null);

}


function ShowInfoOverlay(div)
    {
    
        //alert("hi");
        
         
         if(document.getElementById(div).style.top == "" || document.getElementById(div).style.display == "none")
        {
          
           //alert(tempY);
        //update();
        
            //alert("ClientY: " + e.clientY);
            //alert("PageY: " + e.pageY);

            
            if(tempY < 250)
            {
                tempY = tempY;
            }else
            {
                tempY = tempY - 350;
            }
          
          //alert(tempY);
          
          tempY = tempY + "px";
          
            document.getElementById(div).style.top = tempY;
            document.getElementById(div).style.left = "200px";  
           TurnOnInfoOverlay(div);
        }
    }
    
    function ShowInfoOverlay_WithImage(div, url, height, width)
    {
    
       ShowWebImg_WebResource(url, "img"+div, height, width);
          
       ShowInfoOverlay(div)
       
    }
    
    function ShowInfoOverlay_WithImage(div, url)
    {
    
       ShowWebImg_WebResource(url, "img"+div, '75', '100');
          
       ShowInfoOverlay(div)
       
    }

    
    
    
    var TurnOffDiv;
    
    function CloseOverlay(div)
    {
        document.getElementById(div).style.display = "none";
    }
    
    function HideInfoOverlay(div)
    {
        TurnOffDiv = div;
        setTimeout("ReallyTurnOffDiv();", 3000);
        
    }
    
    function TurnOnInfoOverlay(div)
    {
     document.getElementById(div).style.display = "block";
    }
    
     
    function ReallyTurnOffDiv()
    {
    document.getElementById(TurnOffDiv).style.display = "none";
    }
    

function ShowDBInfo(info)
   {
    if(document.getElementById(info).style.display == "block")
    {
        document.getElementById(info).style.display="none";
        }else
        {
         ShowWebImg_MetalibResource(info); //uses Ajax to get the website info and puts it into the images on the description area;
        
        document.getElementById(info).style.display="block";
        }
   }
   
    function HideDBInfo(info)
   {
    document.getElementById(info).style.display="none";
   }

