// Thanks to all those  responsible for the indespensable getElementsByClassName function below; details of those honoured can be found here:
// http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/

function getElementsByClassName(oElm, strTagName, oClassNames){
    var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    var arrRegExpClassNames = new Array();
    if(typeof oClassNames == "object"){
        for(var i=0; i<oClassNames.length; i++){
            arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames[i].replace(/\-/g, "\\-") + "(\\s|$)"));
        }
    }
    else{
        arrRegExpClassNames.push(new RegExp("(^|\\s)" + oClassNames.replace(/\-/g, "\\-") + "(\\s|$)"));
    }
    var oElement;
    var bMatchesAll;
    for(var j=0; j<arrElements.length; j++){
        oElement = arrElements[j];
        bMatchesAll = true;
        for(var k=0; k<arrRegExpClassNames.length; k++){
            if(!arrRegExpClassNames[k].test(oElement.className)){
                bMatchesAll = false;
                break;                      
            }
        }
        if(bMatchesAll){
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}

//and now my code...

function hideEmGood() {
		
			
 	pullDowns = getElementsByClassName(document, "div", "expanded");
	
	for (var i=0; i < pullDowns.length; i++) {
		
		pullDowns[i].style.display = "none";
	};
	
}



function slide(d,target){
	
	if (d.innerHTML == 'Read More'){
		
		d.innerHTML = "Shrink";	
		
	}
	
	else if(d.innerHTML == 'Shrink'){
		
		d.innerHTML = "Read More";	
		
	}
	
	Effect.toggle(target,'blind'); 
	
}

function backtrack(obj){
	
scrollToMe = obj;

scrollTarg = scrollToMe.substring(0, scrollToMe.length-3);


new Effect.ScrollTo(scrollToMe);


setTimeout("slide(scrollToMe,scrollTarg)",1000);

}

function popitup(url) {
	
	x = (screen.height-200)/2;
	y = (screen.width-580)/2;
	
	newwindow=window.open(url,'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	
	return false;
}



function displayscore (theForm){
	
	for (Count = 0; Count < 2; Count++) {
		if (theForm.rad[Count].checked)
			break;
		}
		
		var trackNumber = Count+1;
		
		
	if(Count == 0){
		document.getElementById('scoreNotation').innerHTML = "<table class=\"fourFour\" cellspacing=\"0\"><tr><td bgcolor=\"#d2eaed\">1</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">2</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">3</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">4</td><td>e</td><td>&amp;</td><td>a</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>ta</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>ta</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>pa</td><td>ta</td></tr><tr><td>gun</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>gun</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>gun</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
	}
	else if(Count == 1){
		document.getElementById('scoreNotation').innerHTML = "<table class=\"fourFour\" cellspacing=\"0\"><tr><td bgcolor=\"#d2eaed\">1</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">2</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">3</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">4</td><td>e</td><td>&amp;</td><td>a</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>go</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>go</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>do</td></tr><tr><td>&nbsp;</td><td>ta</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>ta</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>ta</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
	}
	
	else if(Count == 2){
		document.getElementById('scoreNotation').innerHTML = "<table class=\"fourFour\" cellspacing=\"0\"><tr><td bgcolor=\"#d2eaed\">1</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">2</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">3</td><td>e</td><td>&amp;</td><td>a</td><td bgcolor=\"#d2eaed\">4</td><td>e</td><td>&amp;</td><td>a</td></tr><tr><td>&nbsp;</td><td>do</td><td>go</td><td>&nbsp;</td><td>go</td><td>do</td><td>&nbsp;</td><td>do</td><td>go</td><td>&nbsp;</td><td>go</td><td>do</td><td>&nbsp;</td><td>do</td><td>&nbsp;</td><td>do</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr></table>";
	}
	else {
		alert("somethings not working quite how it should... contact me!");
	}
	
	
	var R = theForm.one.checked+','+theForm.two.checked+','+theForm.three.checked;

	switch(R) {

	case "false,true,true": document.standard.SetURL("../sound/f-t-t.m4a"); document.standard.Stop(); 
	break;
	
	case "false,false,true":  document.standard.SetURL("../sound/f-f-t.m4a"); 	document.standard.Stop();
	break;
	
	case "false,false,false":  alert("Please select a part to play :)");
	break;
	
	case "true,true,true":  document.standard.SetURL("../sound/t-t-t.m4a"); 	document.standard.Stop();
	break;
	
	case "true,true,false": document.standard.SetURL("../sound/t-t-f.m4a"); 	document.standard.Stop();
	break;
	
	case "true,false,false": document.standard.SetURL("../sound/t-f-f.m4a"); 	document.standard.Stop();
	break;
	
	case "true,false,true":  document.standard.SetURL("../sound/t-f-t.m4a"); 	document.standard.Stop();
	break;
	
	case "false,true,false":  document.standard.SetURL("../sound/f-t-f.m4a"); 	document.standard.Stop();
	break;
	
	default: alert('function displayscore of juntion.js not working, email me! tech@newheartbeat.com');
	
	}
	return false;
}

function genhear(url) {
	
	geniform = document.getElementById('genform');
	
	x = (screen.height-200)/2;
	y = (screen.width-580)/2;
	
	for (Count = 0; Count < 3; Count++) {
		if (geniform.rad[Count].checked)
			break;
		}
	
	if(Count == 0){ 
	
		var filePoint = "t-f-f.m4a";
		
	}
	else if(Count == 1){
		
		var filePoint = "f-t-f.m4a";
	}
	
	else if(Count == 2){
		
		var filePoint = "f-f-t.m4a";
	}
	
	else{
		alert("genhear of junction.js isn't working... email me! tech@newheartbeat.com")
	}
		
	newwindow=window.open(url+"?track="+filePoint,'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	return false;

}

function lessonTrack(url,file) {
	
	x = (screen.height-200)/2;
	y = (screen.width-580)/2;
	
	newwindow=window.open(url+"?track="+file,'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	return false;
	
}


function checksetup(number){ 
	
	var genform = document.getElementById('genform');
	
	switch(number){ 
	
	case "0":
			genform.one.checked = false;
			genform.two.checked = true;
			genform.three.checked = true;
			
	break;
	
	case "1":
			genform.one.checked = true;
			genform.two.checked = false;
			genform.three.checked = true;

	break;
	
	case "2":
			genform.one.checked = true;
			genform.two.checked = true;
			genform.three.checked = false;
	
	break;
	
	default:
		alert('switch in checksetup is broken');
	
	}
}

function checkView(theForm){
	
	x = (screen.height-200)/2;
	y = (screen.width-580)/2;
	url = "pop/genpop/more.php";
	
	var R = theForm.one.checked+','+theForm.two.checked+','+theForm.three.checked;

	switch(R) {

	case "false,true,true": 	newwindow=window.open(url+"?track=f-t-t.m4a",'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
		if (window.focus) {newwindow.focus()}
		return false;	
	break;
	
	case "false,false,true":  newwindow=window.open(url+"?track=f-f-t.m4a",'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	return false;
	
	case "false,false,false":  alert("You have to select at least one part for it to work :)");
	break;
	
	case "true,true,true":  newwindow=window.open(url+"?track=t-t-t.m4a",'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	return false;
	break;
	
	case "true,true,false": newwindow=window.open(url+"?track=t-t-f.m4a",'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	return false;
	break;
	
	case "true,false,false": newwindow=window.open(url+"?track=t-f-f.m4a",'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	return false;
	break;
	
	case "true,false,true":  newwindow=window.open(url+"?track=t-f-t.m4a",'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	return false;
	break;
	
	case "false,true,false":  newwindow=window.open(url+"?track=f-t-f.m4a",'name','height=200,width=580,resizable=no,scrollbars=no,top='+x+',left='+y+'');
	if (window.focus) {newwindow.focus()}
	return false;
	break;
	
	default: alert('function checkview of juntion.js not working...email me! tech@newheartbeat.com');
	
	}

	
	
}


