//--------------------------------------------------------------------
// password validation script for the memberaccess_old.html webpage
//--------------------------------------------------------------------
var count = 2;
function validate(un, pw) {
        var valid = false;
        var pwArray = ["forte", "piano"];  // the corresponding passwords;
		var pw=document.myform.pword.value

    for (var i=0; i <pwArray.length; i++) {
            if ((pw == pwArray[i])) {
		valid = true;
            }
        }
        if (valid) {
		if (navigator.appName=="Microsoft Internet Explorer") {
            document.URL="members.html";	
		}
		else {
			var NewWindow=window.open("members.html","Member Access Only","height=700,width=700,resizable=yes");
			if (window.focus) {NewWindow.focus()}
		}
		return false;
        }
        var t = " tries";
        if (count == 1) {t = " try"}
        if (count >= 1) {
            alert ("Invalid password.  You have " + count + t + " left.");
            document.myform.pword.value = "";
            setTimeout("document.myform.pword.focus()", 25);
            setTimeout("document.myform.pword.select()", 25);
            count --;
        }
        else {
            alert ("Still incorrect! You have no more tries left!");
            document.myform.pword.value = "";
            document.myform.pword.disabled = true;
            return false;
        }
}
//--------------------------------------------------------------------
// function to either close current tab or (if IE browaser) open index.html in current window 
//--------------------------------------------------------------------
function closememberpage() {
	if (navigator.appName=="Microsoft Internet Explorer") {
		document.URL="../index.html";
	}
	else {
		self.close()	
	}
	return false;
}

//--------------------------------------------------------------------
// set of 4 functions to rotate images in index.html webpage
// these functions rely on definition of the image ids and style
//--------------------------------------------------------------------
    var Temp;
    var timer;
    var timer_is_on=0;
    var pictures=Array('','choir2011','choir2010','choir2009','choir2008','choir2007','cabaret2009');
    var index=Array(0,10,10,10,10,10,20);
    function timedCount(id) {
        var i;
	if (id==0) {
	    Temp=index[6];
	    id = 1;
	    for (i=6;i>1;i--) {
		index[i]=index[i-1];
		if (index[i]==20) {
		    id=i;
		}
	    }
	    index[1]=Temp;
	}
	for (i=1;i<=6;i++) {
	    if (i==id) {
		index[i] = 20;
		document.getElementById(pictures[i]).style.zIndex = 20;
	    }
	    else {
		index[i] = 10;
		document.getElementById(pictures[i]).style.zIndex = 10;
	    }
	}
	timer=setTimeout("timedCount(0)",5000);
    }
    function StartRandomPictureRotation() {
	if (!timer_is_on) {
	   document.getElementById('stop').style.zIndex = 20;
	   document.getElementById('start').style.zIndex = 10;
	   timer_is_on=1;
	   timedCount(0);
	}
    }
    function StopPictureRotation() {
	if (timer_is_on) {
	   document.getElementById('start').style.zIndex = 20;
	   document.getElementById('stop').style.zIndex = 10;
	   clearTimeout(timer);
	}
	timer_is_on=0;
    }
    function StartPictureRotation(id) {
	if (timer_is_on) {
	   clearTimeout(timer);
	}
	document.getElementById('stop').style.zIndex = 20;
	document.getElementById('start').style.zIndex = 10;
	timer_is_on=1;
	timedCount(id);
    }
//--------------------------------------------------------------------
// this function was on the original SMC webpage, left it here since I'm not sure about its role
//--------------------------------------------------------------------
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
    MM_reloadPage(true);

    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-20477205-1']);
    _gaq.push(['_trackPageview']);

//--------------------------------------------------------------------
// function for Google analytics (paste in from web)
//--------------------------------------------------------------------
(function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

//--------------------------------------------------------------------
// function play an MP3 song at 'soundfilepath'
//--------------------------------------------------------------------
    function PlayMP3(soundfilepath){
      var htmlcontent = "<object id='mediaPlayer' width='300' height='45' ";
        htmlcontent += "classid='CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95' ";
        htmlcontent += "codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701' ";
        htmlcontent += "standby='Loading Microsoft Windows Media Player components...' type='application/x-oleobject'>";
        htmlcontent += "<param name='fileName' value=soundfilepath>";
        htmlcontent += "<param name='animationatStart' value='true'>";
        htmlcontent += "<param name='transparentatStart' value='true'>";
        htmlcontent += "<param name='autoStart' value='true'>";
        htmlcontent += "<param name='showControls' value='false'>";
        htmlcontent += "<param name='loop' value='true'>";
        htmlcontent += "<embed type='application/x-mplayer2' ";
        htmlcontent += "pluginspage='http://microsoft.com/windows/mediaplayer/en/download/'";
        htmlcontent += "bgcolor='101010' showcontrols='false' width='300' height='45'";
        htmlcontent += "src='"+soundfilepath+"' autostart='true' designtimesp='5311' loop='true'>";
        htmlcontent += "</embed>";
        htmlcontent += "</object>";
        alert("html " + htmlcontent + "Element_ID " + document.getElementById("messiah2010"));
        document.getElementById("messiah2010").innerHTML(htmlcontent);
    }

