﻿/* drop down menu script */
function showTipDiv(message, div, objectHovered, direction) {    
    var ObjPos = findPos(objectHovered);
    var left = ObjPos[0];
    var top = ObjPos[1];    
    var messages = new Array();
    messages[0] = '<img src="images/solero_srch.gif"/><br><br>The <b>Solero</b> format allows you to transpose, print, and play a MIDI version of the song.';
    messages[1] = '<img src="images/legacy_srch.gif"/><br><br>Legacy Editions are high-quality digital sheet music selections designed to preserve the musical integrity of the original work. Like any title purchased from FreeHandMusic.com, these editions can be downloaded, viewed and printed using the Solero Music Viewer or MusicPad Pro. However, in order to maintain playability and remain true to the composer`s original intentions, these items cannot be transposed and, due to this specialized format, MIDI playback is not available with these editions.';
    messages[2] = '<img src="images/collection_srch.gif"/><br/><br/>In some cases, the song you`re searching for may be included in a money-saving digital collection. To view the song within the contents of a collection, click on the item and select the song from the content listing.';
    messages[3] = '<b>View Opus</b><br/><br/>Check it if you want to see additional columns in search results, such as <b>Opus</b> and <b>Catalog Number</b>.';
    messages[4] = '<img src="images/solero_srch.gif"/><br><br><div class="bodysmall" align="center"><strong>Solero Editions</strong><br><br></div><div class="bodysmall" align="left">- <strong>Download and print</strong> using the Solero Music Viewer or MusicPad Pro<br /><br />- <strong>Transpose</strong> digital sheet music titles into any key or clef you choose<br /><br /> - <strong>Listen</strong> to your selections using the MIDI or MP3 samples<br /><br />- <strong>Adjust</strong> the playback tempo to suit your style, taste or learning needs</div>';
    messages[5] = '<img src="images/legacy_srch.gif"/><br><br><div class="bodysmall" align="center"><br><strong>Legacy Editions</strong> are high-quality digital sheet music selections designed to preserve the musical integrity of the original work. Like any title purchased from FreeHandMusic.com, these editions can be <strong>downloaded, viewed and printed</strong> using the Solero Music Viewer or MusicPad Pro. However, in order to maintain playability and remain true to the composer`s original intentions, these items cannot be transposed and, due to this specialized format, MIDI playback is not available with these editions.</div>'; 

    var tooltipWidth = document.getElementById(div).offsetWidth;
    var objectWidth = objectHovered.offsetWidth;    
    document.getElementById(div).style.marginTop = top +  "px";

    if (direction == 'left') {
        document.getElementById(div).style.marginLeft = left - tooltipWidth - 10 + "px";
    } else {
        document.getElementById(div).style.marginLeft = left + objectWidth + 10 + "px";    
    }
    
    
    document.getElementById('tipDiv2').innerHTML = messages[message];
    showMenu(div);
}

function showMenu(menuName) {
    hideAllMenus(menuName);
    //show iframe
    if (document.getElementById(menuName)) {
        document.getElementById(menuName).style.visibility = 'visible';
    }
    //adjust corresponding iframe height
    if (document.getElementById(menuName + "-iframe")) {
        document.getElementById(menuName + "-iframe").style.height = document.getElementById(menuName).offsetHeight - 13;
    }    
    if (document.getElementById(menuName + "-iframe")) {
        document.getElementById(menuName + "-iframe").style.visibility = 'visible';
    }    
}

function hideAllMenus(menuName) {
    if (document.getElementById(menuName)) {
        document.getElementById(menuName).style.visibility = 'hidden';
    }
    if (document.getElementById(menuName + "-iframe")) {
        document.getElementById(menuName + "-iframe").style.visibility = 'hidden';
    }
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	    do {
	        curleft += obj.offsetLeft;
	        curtop += obj.offsetTop;
	    } while (obj = obj.offsetParent);
	    return [curleft, curtop];
	} else {
	    return [oElement.x, oElement.y];
	}
}
