/**

 * @author Rebekah

 */

 /**

 *Detect if IE

 */

/** function detectIE(){

* if (navigator.userAgent.indexOf('MSIE')!=-1){

* var linkRef = document.getElementsByTagName("link");

* var stylesheet = linkRef.href;

*	if(stylesheet="./stylesheets/musicstyle.css";)

*	{

*	stylesheet = "./stylesheets/ie_musicstyle.css";

*	}

*	if else(stylesheet="../stylesheets/musicstyle.css";)

*	{

*	stylesheet = "../stylesheets/ie_musicstyle.css";

*	}

 *}

 *else

 *{

 *return false;

 *}

 *}
*/
 

/**

 * Makes the div containing drop down links that is passed through visible

 * 

 * @param {Object} element

 */ 

function makeVisible(element) {



var links = document.getElementsByTagName("div");



for (var j = 0; j < links.length; j++) {

if (links[j].className == "Links") {

	links[j].style.display = "none";

	}

}



var linkDiv = document.getElementById(element);

linkDiv.style.display = "block";



}



/**

 * Makes drop down menus invisible

 */

function invisible() {

var divLinks = document.getElementsByTagName("div");



for (var i = 0; i < divLinks.length; i++) {

if (divLinks[i].className == "Links") {

	divLinks[i].style.display = "none";

	}

}

}



/**

 * Choose a form functions

 * 

 * @param {Object} ref

 * @param {Object} target

 */

function land(ref, target)

{

lowtarget=target.toLowerCase();

if (lowtarget=="_self") {window.location=loc;}

else {if (lowtarget=="_top") {top.location=loc;}

else {if (lowtarget=="_blank") {window.open(loc);}

else {if (lowtarget=="_parent") {parent.location=loc;}

else {parent.frames[target].location=loc;};

}}}

}

function jump(menu)

{

ref=menu.choice.options[menu.choice.selectedIndex].value;

splitc=ref.lastIndexOf("*");

target="";

if (splitc!=-1)

{loc=ref.substring(0,splitc);

target=ref.substring(splitc+1,1000);}

else {loc=ref; target="_self";};

if (ref != "") {land(loc,target);}

}

/**

 * Collapses info functions

 * @param {Object} image1

 * @param {Object} image2

 * @param {Object} element

 */

//See p407 of the Missing Manual



function ToggleVisibility(image1, image2, element){

	//Find the image.

	var image1 = document.getElementById(image1)

	var image2 = document.getElementById(image2)

	

	//Find the element to hide/unhide.

	var element = document.getElementById(element)

	

	//Check the element's current state.

	if (element.style.display === "none"){

		//If hidden, unhide it.

		element.style.display = "block"

		image1.style.display = "none"

		image2.style.display = "block"

	}

	else {

		//If not hidden, hide it.

		element.style.display = "none"

		image2.style.display = "none"

		image1.style.display = "block"

	}

}



 /**

  * Binds the MakeVisible function as the mouseover event to the element whose id is passed through

  * 

  * @param {Object} link The link that corresponds to the appearing div

  * @param {Object} element The element that will be passed through to the MakeVisible function

  */

 function bindMakeVisible(link, element){

 	if (!document.getElementById(link)){

		return false;

	}

	

	var chosenLink = document.getElementById(link);

	chosenLink.onmouseover = function(){

	makeVisible(element);	

	};

 }

 /**

  * Binds the Invisible function to the main-text element

  */

function bindInvisible(div){

	var area = document.getElementById(div);

	area.onmouseover=invisible;

	}



/**

 * Binds the jump function as the onclick event for "goButton"

 */

function bindJump(){

	if (!document.getElementById("goButton")) {

	return false;

	}

	var goButton = document.getElementById("goButton");

	goButton.onclick = function(){

		jump(this.form);

	};

}

/**

 * Binds the Toggle Visibility function to the "More or "Less" buttons

 */

function bindToggleVisibility(button){

	if(!document.getElementById(button)){

		return false;

	}

	var toggleButton = document.getElementById(button);

	toggleButton.onclick = function(){

		ToggleVisibility("more", "less", "info");

	}

}



 /** 

 * Checks that the required methods, getElementById and

 * getElementsByTagName, are available.

 * 

 * Returns true if the methods are available, false if they aren't.

 */ 

function detectMethods() {

	if (!document.getElementById) {

        return false;

    }

    if (!document.getElementsByTagName) {

        return false;

    }

	return true;

}



/** 

 * Performs method detection, then binds the form 

 * validation event handler and loads the email address

 * cookie, if there is one.

 */ 

function bindCommonEventHandlers() {

    if (!detectMethods()) {

		return false;

	}

	//alert("bindingCommonEventHandlers");

	invisible();


	bindInvisible("main-text");

	bindInvisible("headLogo");

	

	bindMakeVisible("bandMain", "Band");

	bindMakeVisible("paMain","PA");

	bindMakeVisible("directorsMain","Directors");

	

	bindToggleVisibility("more");

	bindToggleVisibility("less");

	

	bindJump();

	

}



/**

 * Binds function bindEventHandlers to window's onload event:

 * when browser finishes loading the page, it will 

 * call bindEventHandlers

 */    



window.onload = bindCommonEventHandlers;