//image mouseover


function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf('#')!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}

}

function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf('?'))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n); return x;
}


function highlightLockImg(status)
{
    var lockImg = document.getElementById("zoomLock");
    var lockImgSrc = lockImg.src;
    if (status == "on")
    {
        lockImgSrc = lockImgSrc.replace(".gif", "-on.gif");
    }
    else
    {
        lockImgSrc = lockImgSrc.replace("-on.gif", ".gif");
    }
    
    lockImg.src = lockImgSrc;
}



//thumb mouseover script

function highlightThumb(thumbID, status)
{
    if (thumbID != parseInt(currentPageIndex)) {
	    var let=document.getElementById('thumbLet_'+ thumbID);
	    var img = document.getElementById('thumbImg_'+ thumbID);
	    var letClassName = 'unselectedLetter';
	    if (document.getElementById("whichPage") != null)
	    {
	        if (document.getElementById("whichPage").value == "search")
	        {
	            letClassName = 'resultLink';
	        }
        }

	    if (status=='on') {
		    let.className='selectedLetter';
		    var readerView = currentSectionObj.Children[thumbID].ReaderView;
		    if (readerView == "L")
            {
                img.className = "thumbSelectedLeft";                
            }
            else if (readerView == "R")
            {
                img.className = "thumbSelectedRight";           
            }
            else
            {
                img.className = "thumbSelected";            
            }	    
	    }
	    else {
		    let.className=letClassName;
		    var readerView = currentSectionObj.Children[thumbID].ReaderView;
		    if (readerView == "L")
            {
                img.className = "thumbDefaultLeft";                
            }
            else if (readerView == "R")
            {
                img.className = "thumbDefaultRight";           
            }
            else
            {
                img.className = "thumbDefault";            
            }
	    }

	}
}

        function showHeadlines(divID, xCoord, yCoord)
        {
            //alert(xCoord + "," + yCoord);
            setDivVisibility();
            var theDiv = document.getElementById(divID);
            theDiv.style.left = parseInt(xCoord) + "px";
            theDiv.style.top = parseInt(yCoord) + "px";
            theDiv.style.visibility = "visible";            
        }
        
        function hideHeadlines()
        {
            var theDiv = document.getElementById("headlinesPopupDiv");
            theDiv.style.visibility = "hidden";
        }    
        
        function setDivVisibility()
        {
            var divArr = document.getElementsByTagName("div");

            for (i=0; i<divArr.length; i++)
            {
                var currDivID = divArr[i].id;
                if (currDivID.indexOf("headlinesPopupDiv_") >= 0)
                {
                    var currDiv = document.getElementById(currDivID);
                    currDiv.style.visibility = "hidden";
                }
            }
        } 
        
        
        function highlightSearchResult(e, imgID, status, searchResId, searchInfoId)
        {
            var img = document.getElementById(imgID);
            var imageID = imgID.replace("searchThumbImg_", "");
            var searchInfoDiv = document.getElementById(searchInfoId);
            
            if(window.console) {
		        window.console.log("status = " + status);
	        }             
            
            //if (navigator.userAgent.indexOf("Safari") < 0)
            //{
                if (status == "on")
                {
                    //img.className = "searchThumbSelected";
                    changeCursor();
                    var searchResDiv = document.getElementById(searchResId);
                    var posArr = findPos(searchResDiv);
                    var x = posArr[0];
                    var y = posArr[1]; 
                                            
                    if (navigator.userAgent.indexOf("Firefox/3") >= 0)
                    {
                        var hPos = y + 235;       // 60 + 175 - 175 is height of div, 60 is relative y position over thumb. 

                        if (hPos < clientHeight)
                        {      
                            //searchInfoDiv.style.left = (x + 90) + "px";
                            //searchInfoDiv.style.top = (y + 60) + "px";
                            searchInfoDiv.style.left = (x + 90) + "px";
                            searchInfoDiv.style.top = y + "px";                                                      
                        }
                        else
                        {
                            searchInfoDiv.style.left = (x + 90) + "px";
                            searchInfoDiv.style.top = (clientHeight - 200) + "px";               
                        }
                        searchInfoDiv.style.visibility = "visible"; 
                        searchInfoDiv.style.zIndex = "10000";
                        searchInfoDiv.style.position = "absolute";  
                        searchInfoDiv.style.overflow = "visible";
                    }
                    else if (navigator.userAgent.indexOf("Safari") >= 0)
                    {

                        var hPos = y + 175;       // 60 + 175 - 175 is height of div
                        document.getElementById("srchTxt_" + imageID).style.width = "210px";
                        document.getElementById("srchTxt_" + imageID).style.height = "160px";

                        if (hPos < clientHeight)
                        {                         
                            
                            searchInfoDiv.style.left = x + "px";
                            searchInfoDiv.style.top = y + "px";                 
                        }
                        else
                        {
                            searchInfoDiv.style.left = x + "px";
                            searchInfoDiv.style.top = (clientHeight - 230) + "px";                        
                        }
                        searchInfoDiv.style.visibility = "visible";                         
                        searchInfoDiv.style.zIndex = "100";
                        searchInfoDiv.style.position = "absolute";
                        
                        if(window.console) {
		                    window.console.log("pos = " + searchInfoDiv.style.left + "," + searchInfoDiv.style.top + " - " + searchInfoDiv.style.visibility + " - " + searchInfoDiv.style.zIndex);
	                    }  
                    }
                    else
                    {
                        var hPos = y + 235;       // 60 + 175 - 175 is height of div, 60 is relative y position over thumb. 
                        if (hPos < clientHeight)
                        {      
                            searchInfoDiv.style.left = (x + 90) + "px";
                            searchInfoDiv.style.top = (y + 60) + "px";
                            //searchInfoDiv.style.left = (x + 60) + "px";
                            //searchInfoDiv.style.top = (y - 160) + "px";                            
                        }
                        else
                        {
                            searchInfoDiv.style.left = (x + 90) + "px";
                            searchInfoDiv.style.top = (clientHeight - 200) + "px";               
                        }
                        searchInfoDiv.style.visibility = "visible"; 
                        searchInfoDiv.style.zIndex = "100";
                        searchInfoDiv.style.position = "absolute";                      
                    }
                    
                   

                }
                else //if (imageID != lastSelResult)
                {
                    //img.className = "searchThumbDefault";
                    restoreCursor();
                    if (searchInfoDiv != null)
                    {
                        searchInfoDiv.style.visibility = "hidden";
                    }
                }
            //}
        }
