﻿/* 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="http://cdn.freehandmusic.com/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="http://cdn.freehandmusic.com/images/legacy_srch.gif"/><br><br><b>Legacy Editions</b> are high-quality digital sheet music selections that cannot be transposed and do not contain MIDI.';
    messages[2] = '<img src="http://cdn.freehandmusic.com/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="http://cdn.freehandmusic.com/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="http://cdn.freehandmusic.com/images/legacy_srch.gif"/><br><br><div class="bodysmall" align="center"><br><strong>Legacy Editions</strong> are high-quality digital sheet music selections that cannot be transposed and do not contain MIDI.</div>';
    if (document.getElementById(div) == undefined) {
        $('<div/>', { "id": div }).appendTo("body");
    }
    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(div).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];
	}
}

