﻿// JScript File

    
    
    function PinHover3D(x, y, title, details)
    { 
        if(document.getElementById('PinControl') != null)
        {
        pinHoverOut();
        }
        getPinDetails(details);
        targetPin = document.getElementById(pinIDPlotted);
        AddMyControl(targetPin);
    }
    
     function AddMyControl(targetPin)
         {
            map.DeletePushpin(targetPin.id);
            var el = document.createElement("img"); 
            el.id = "PinControl";
            pixel=map.LatLongToPixel(new VELatLong(pinLat,pinLon));
            if(pinImgSource.indexOf('nearby') != -1)
		    el.src = 'http://images.longandfoster.com/Images/Map-Icons/single-nearby-16-on.gif';
		    else if(pinImgSource.indexOf('OH-16') != -1)
		    el.src = 'http://images.longandfoster.com/Images/Map-Icons/OH-16-on.gif';
		    else if(pinImgSource.indexOf('OH-visited-16') != -1)
		    el.src = 'http://images.longandfoster.com/Images/Map-Icons/OH-visited-16-on.gif';
		    else
		    el.src = 'http://images.longandfoster.com/Images/Map-Icons/single-family-16-on.gif';
		    
		    pinImgPlotted = el.src
		    var x=pixel.x - 9;
		    var y;
		    if(el.src.indexOf('OH') != -1)
		    y=pixel.y - 35;
		    else
		    y=pixel.y - 15;
            el.style.top = y+'px'; 
            el.style.left = x+'px';
		    el.onmouseout = pinHoverOut;
            el.onclick = getContentForPushpin;
            map.AddControl(el);
            addIFrame(el);
         }

         function addIFrame(el)
         {
            var shim = document.createElement("iframe");
            shim.id = "myShim";
            shim.frameBorder = "0";
            shim.src = "BlankHTML.htm";
            shim.style.position = "absolute";
            shim.allowtransparency = "true";
            shim.style.zIndex = 1;
            shim.style.top  = el.offsetTop+'px';
            shim.style.left = el.offsetLeft+'px';
            shim.width  = el.offsetWidth - 3+'px';
            shim.height = el.offsetHeight - 3+'px';
            //shim.onmouseout = alert('hi again');
            el.shimElement = shim;
            el.parentNode.insertBefore(shim, el);
            
         }
         function pinHoverOut()
         {
            var pinID = pinIDPlotted;              
             var pinImg;
            if(pinImgPlotted.indexOf('nearby') != -1)
		    pinImg = 'http://images.longandfoster.com/Images/Map-Icons/single-nearby-16.gif';
		    else if(pinImgPlotted.indexOf('OH-16') != -1)
		    pinImg = 'http://images.longandfoster.com/Images/Map-Icons/OH-16.gif';
		    else if(pinImgPlotted.indexOf('OH-visited-16') != -1)
		    pinImg = 'http://images.longandfoster.com/Images/Map-Icons/OH-visited-16.gif';
		    else
		    pinImg = 'http://images.longandfoster.com/Images/Map-Icons/single-family-16.gif';
            
            var pin = new VEPushpin
            (               
            pinID,                
            new VELatLong(pinLat,pinLon),                
            pinImg,                
             '',                
             pinDetails3D          
            ); 
            VEPushpin.ShowDetailOnMouseOver = false;
            VEPushpin.OnMouseOverCallback = PinHover;
            map.AddPushpin(pin);
            RemoveMyControl();
         }
         
         function pinHoverOutVisited()
         {
            var pinID = pinIDPlotted;              
             var pinImg;
            if(pinImgPlotted.indexOf('nearby') != -1)
		    pinImg = 'http://images.longandfoster.com/Images/Map-Icons/single-nearby-16.gif';
		    else if(pinImgPlotted.indexOf('OH-16') != -1)
		    pinImg = 'http://images.longandfoster.com/Images/Map-Icons/OH-16.gif';
		    else if(pinImgPlotted.indexOf('OH-visited-16') != -1)
		    pinImg = 'http://images.longandfoster.com/Images/Map-Icons/OH-visited-16.gif';
		    else
		    pinImg = 'http://images.longandfoster.com/Images/Map-Icons/single-family-16.gif';
            
            // changing the viewed pin img detail
            var lastCommaIndex = pinDetails3D.lastIndexOf(','); 
            partDetails = pinDetails3D.substring(0, lastCommaIndex);
            pinDetails3D = partDetails +','+pinImg;
           
            // replotting the pin to the map
            var pin = new VEPushpin
            (               
            pinID,                
            new VELatLong(pinLat,pinLon),                
            pinImg,                
             '',                
             pinDetails3D          
            ); 
            VEPushpin.ShowDetailOnMouseOver = false;
            VEPushpin.OnMouseOverCallback = PinHover;
            map.AddPushpin(pin);
            RemoveMyControl();
         }
         
         function RemoveMyControl()
         {
            while(document.getElementById("PinControl") != null || document.getElementById("myShim") != null)
            {
            var mycontrol = document.getElementById("PinControl");
            if (mycontrol!=null) mycontrol.parentNode.removeChild(mycontrol);
            mycontrol = null;
            
            var myShim = document.getElementById("myShim");
            if (myShim!=null) myShim.parentNode.removeChild(myShim);
            myShim = null;
            }
         }
         // for simple popup
         function addPopupFrame3D(mapPopup)
         {
            var shim = document.createElement("iframe");
            shim.id = "myShimPopup";
            shim.frameBorder = "0";
            shim.src = "BlankHTML.htm";
            shim.style.position = "absolute";
            shim.allowtransparency = "true";
            shim.style.zIndex = 1;
            shim.style.top  = mapPopup.el.style.top;
            shim.style.left = mapPopup.el.style.left;
            shim.width  = mapPopup.el.offsetWidth -3;
            shim.height = mapPopup.el.offsetHeight - 12;
            mapPopup.el.shimElement = shim;
            mapPopup.el.parentNode.insertBefore(shim, mapPopup.el);
         }
       
       // for animated popup
         function addPopupFrame3DAnimation(mapPopup,posX,posY,height,width)
         {
            var shim = document.createElement("iframe");
            shim.id = "myShimPopup";
            shim.frameBorder = "0";
            shim.src = "BlankHTML.htm";
            shim.style.position = "absolute";
            shim.allowtransparency = "true";
            shim.style.zIndex = mapPopup.style.zIndex -1;
            shim.style.top  = mapPopup.offsetTop + 'px';
            shim.style.left = mapPopup.offsetLeft + 1 + 'px';
            //shim.style.top  = mapPopup.style.top - 1 +'px';
            //shim.style.left = mapPopup.style.left - 1 +'px';
            shim.width  = width+ 10 +'px';
            shim.height = height+ 25 +'px';
            mapPopup.shimElement = shim;
            mapPopup.parentNode.insertBefore(shim, mapPopup);
         }
         function RemoveMyPopupFrame3D()
         {
            var myShim = document.getElementById("myShimPopup");
            if (myShim!=null) myShim.parentNode.removeChild(myShim);
            myShim = null;
            return;
         }
         function RemoveIframe(frameObj)
         {
         if (frameObj!=null) frameObj.parentNode.removeChild(frameObj);
            frameObj = null;
            return;
         }
         
         function addIframePageCover(el)
         {
        var shim = document.createElement("iframe");
        shim.id = "myPageCoverFrame";
        shim.frameBorder = "0";
        shim.src = "BlankHTML.htm";
        shim.style.position = "absolute";
        shim.allowtransparency = "true";
        shim.style.zIndex = 1;
        shim.style.top  = el.offsetTop+'px';
        shim.style.left = el.offsetLeft+'px';
        shim.width  = el.offsetWidth - 3+'px';
        shim.height = el.offsetHeight - 3+'px';
        el.shimElement = shim;
        el.parentNode.insertBefore(shim, el);
        }
        // takes the object around which frame has to be plotted
        function addMsgFrame(obj)
        {
            var shim = document.createElement("iframe");
            shim.id = "myMsgShim";
            shim.frameBorder = "0";
            shim.src = "BlankHTML.htm";
            shim.style.position = "absolute";
            shim.allowtransparency = "true";
            shim.style.zIndex = 1;
            shim.style.top  = obj.offsetTop+'px';
            shim.style.left = obj.offsetLeft+'px';
            shim.width  = obj.offsetWidth - 3+'px';
            shim.height = obj.offsetHeight - 3+'px';
            obj.shimElement = shim;
            obj.parentNode.insertBefore(shim, obj);
        }
        // takes the frame object as an input parameter
        function RemoveMsgFrame(obj)
        {
         if (obj!=null) obj.parentNode.removeChild(obj);
            obj = null;
            return;
        }