/*
 * Functions to write the HTML for the navigation menu at the top of each
 * page.
 */
function menu (url)
{
	if (url != "") {
        if (url.indexOf(".htm") != -1) {
	        window.location = url;
        } else {
            window.location = url + ".htm";
        }
	}
}

function write_menu (visible, selected, path_to_root)
{
    var str = "";
    
    if (!path_to_root) {
        path_to_root = "";
    }

    if (selected == "index") {
        /*
         * For the index page, just create a blank box with no
         * background.
         */
        str += '<div id="menu" style="background: none">';
        str += '</div>';
    } else {
        /*
         * For all other pages, write out the horizontal links box,
         * and the right-hand drop-down menu.
         */
        str =  '<div id="menu">';

        str += '<div id="toplinks">';
        str += '<a href="' + path_to_root + 'index.htm">Home</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'news.htm">News</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'introduction.htm">Introduction</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'biography.htm">Biography</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'compositions.htm">Compositions</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'reviews.htm">Reviews</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'performances.htm">Performances</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'talks.htm">Talks</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'recordings.htm">Recordings</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'youtube.htm">YouTube</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'commissions.htm">Commissions</a>';
        str += ' | ';
        str += '<a href="' + path_to_root + 'music_scores.htm">Music Scores</a>';
        str += '</div>';
        
        /*
        str += '<div id="dropdownmenu">';
        str += '<select name="navmenu" id="navmenu" onchange="menu(\'' + path_to_root + '\' + this.options[this.selectedIndex].value)">';
        str += '<option value="index" ' + (selected == 'index'?'selected="selected"':'') + '>Navigation Menu</option>';
        str += '<option></option>';
        str += '<option value="news" ' + (selected == 'news'?'selected="selected"':'') + '>News</option>';
        str += '<option value="introduction" ' + (selected == 'introduction'?'selected="selected"':'') + '>Introduction</option>';
        str += '<option value="biography" ' + (selected == 'biography'?'selected="selected"':'') + '>Biography</option>';
        str += '<option value="compositions" ' + (selected == 'compositions'?'selected="selected"':'') + '>Compositions</option>';
        str += '<option value="reviews" ' + (selected == 'reviews'?'selected="selected"':'') + '>Reviews</option>';
        str += '<option value="articles" ' + (selected == 'articles'?'selected="selected"':'') + '>Articles</option>';
        str += '<option value="performances" ' + (selected == 'performances'?'selected="selected"':'') + '>Performances</option>';
        str += '<option value="links" ' + (selected == 'links'?'selected="selected"':'') + '>Links</option>';
        str += '<option value="sales_ordering" ' + (selected == 'sales_ordering'?'selected="selected"':'') + '>Sales and Ordering</option>';
        str += '</select>';
        str += '</div>';
        */
        
        str += '<div id="clearer">&nbsp;</div>';

        str += '</div>';
    }

    document.writeln (str);
}

function write_footer ()
{
    var lastupdate = new Array("Friday", "14", "th", "April", "2006");

    // lup = lastupdate[0] + ' ' + lastupdate[1] + lastupdate[2] + ' ' + lastupdate[3] + ' ' + lastupdate[4];

    lupfull = lastupdate[0] + ' ' + lastupdate[1] + '<sup>' + lastupdate[2] + '</sup> ' + lastupdate[3] + ' ' + lastupdate[4];

    //document.writeln("<div id=\"lastupdated\">Last Updated: " + lupfull + "</div>");
    
    document.writeln("<div id=\"footer\">&copy; Ian Venables 2009, iv@ianvenables.com</div>");
}

function write_music_sample ()
{
    str =  "<div id=\"musicsample\">";
	          
    str += "	<object data=\"music/fp.mp3\" width=\"200\" height=\"46\" standby=\"Loading music sample\" type=\"audio/mp3\">";
    str += "	  <param name=\"FileName\" value=\"music/fp.mp3\" />";
    str += "    <param name=\"AutoRewind\" value=\"true\" />";
    str += "    <param name=\"AutoStart\" value=\"false\" />";
    str += "    <param name=\"Volume\" value=\"0\" />";
    str += "    <param name=\"ShowControls\" value=\"true\" />";
    str += "    <param name=\"ShowTracker\" value=\"true\" />";
    str += "    <param name=\"ShowPositionControls\" value=\"false\" />";
    str += "    <param name=\"ShowDisplay\" value=\"false\" />";
    str += "    <param name=\"EnableContextMenu\" value=\"false\" />";
    str += "    <param name=\"SendKeyboardEvents\" value=\"false\" />";
    str += "    <param name=\"SendMouseMoveEvents\" value=\"false\" />";
    str += "    <param name=\"SendMouseClickEvents\" value=\"false\" />";				
    str += "	</object>";

    str += "</div>";

    document.writeln(str);
}

function write_banner ()
{
    str =  "<div id=\"banner\">";

    str += "  <div id=\"albumcover\">";
    str += "    <img src=\"images/cd_art_2.jpg\" width=\"177\" height=\"176\" />";
    str += "  </div>";
        
    str += "  <div id=\"flashthing\">";
    str += "    <object data=\"flash/reviews_fade.swf\" width=\"505\" height=\"127\" type=\"application/x-shockwave-flash\">";
    str += "      <param name=\"movie\" value=\"flash/reviews_fade.swf\">";
    str += "      <param name=\"quality\" value=\"high\">";
    str += "    </object>";
    str += "  </div>";
        
    str += "  <div class=\"clearboth\">&nbsp;</div>";
    str += "</div>";

    document.writeln(str);
}

function focusthing (num)
{
	if (parent.frames["topFrame"]) {
		if (parent.frames["topFrame"].document &&
			parent.frames["topFrame"].document.form1 &&
		    parent.frames["topFrame"].document.form1.NavMenu) {
      		parent.frames["topFrame"].document.form1.NavMenu.selectedIndex = num;
	    }
    } else {
        return false;
    }
  
	if (parent.frames["mainFrame"])
	{
		parent.frames["mainFrame"].focus();
	}
	
	return true;
}

function timer ()
{
	a = parseInt(document.getElementById("t").innerHTML);
	
	a = a - 1;
	
	if (!a) {
		menu("sales_ordering");
	} else {
	    document.getElementById("t").innerHTML = a;
	    setTimeout(timer, 1000);
	}
}

function ivdblclick ()
{
	if (parent.frames["mainFrame"]) {
		parent.frames["mainFrame"].location.href = "../private/private.htm";
		parent.frames["mainFrame"].focus();
	}
}
