var todayOn;
function confirm_response()
{
var sLoc = document.location.toString();
var indx = sLoc.indexOf('?');
if (indx > -1)
{
	if (sLoc.substring(indx+1,sLoc.length) == 'comment=yes')
	{ alert ('Thanks for your comment!');
	window.location= sLoc.substring(0,indx);	
	}
}
}
function confirm_response_2()
{alert ('Thanks.  Your comment has been sent.');}
function confirm_response_3()
{alert ('Your request to order a print has been sent.');}
function validate_comment(f)
{
if (f.Comments.value == '')
{alert('Please enter a comment first.');
return false;}
else 
{
if (f.Comments.value.search(/<a/) >= 0 || f.Comments.value.search(/<A/) >= 0) {alert('Comments containing HTML are not allowed.');
return false;}
else return true;
}
}
function today_on()
{
arImg=new Array();
arImg[0] = 'http://montreal.mordac.org/thumbnails/montreal01bigger.jpg';
arImg[1] = 'http://mordac.org/calhoun/thumbnails/calhoun13.jpg';
arImg[2] = 'http://mordac.org/images/montreal17.jpg';
arImg[3] = 'http://mordac.org/tmbg/thumbnails/tmbg11.jpg'

arAlt=new Array();
arAlt[0] = 'Montreal Photos';
arAlt[1] = 'Lake Calhoun';
arAlt[2] = 'La Joute';
arAlt[3] = 'They Might Be Giants';
todayOn = Math.floor(Math.random()*arImg.length);
document.todayOnImg.src = arImg[todayOn];
document.todayOnImg.alt = arAlt[todayOn];
}
function click_today_on()
{
arPg=new Array();
arPg[0] = 'http://montreal.mordac.org/';
arPg[1] = 'http://mordac.org/calhoun/';
arPg[2] = 'http://montreal.mordac.org/joute.html';
arPg[3] = 'http://mordac.org/tmbg/';
window.location=  arPg[todayOn];
}

function next_pic()
{secs = interval;
if (pic<max_pics)
{	
	pic++;	
}
else
{
	pic=0;
}
update_pic();

}

function previous_pic()
{secs = interval;
if (pic>0) pic--;
else pic=max_pics;

update_pic();

}
// gallery functions
function update_pic()
{
	document.getElementById("fileName").innerHTML = arPics[pic][0];
	document.getElementById("pic_title").innerHTML = arPics[pic][1];
	document.getElementById("pic_comments").innerHTML = arPics[pic][2];
	
	document.getElementById("MainImg").src = arPics[pic][3] + arPics[pic][0];

// update arrows
	if (pic==max_pics) document.getElementById("next1").src = 'images/next_disabled.gif';
	else document.getElementById("next1").src = 'images/next.gif';

	if (pic==0) document.getElementById("previous1").src = 'images/previous_disabled.gif'
	else document.getElementById("previous1").src = 'images/previous.gif';

}
function pic_link()
{
	if (arPics[pic][4].length < 1)
		{ alert("Sorry, there is currently no link for this picture.");}
	else
		{ window.location.href = arPics[pic][4]+'?l=gallery'; return true;}
}

var secs;
var interval=5;
var timerID = null;
var timerRunning = false;
var delay = 1000;
var play = true;

function PlayPauseImg(state)
{	var newImg;
	if (play==false)	{if (state=='over') newImg = 'play_over.gif'; else newImg = 'play.gif';}
	else	{if (state=='over') newImg = 'pause_over.gif'; else newImg = 'pause.gif';}
	document.getElementById("pausePlay1").src = 'images/' + newImg;
}
function PlayPause()
{
	play = !play;
	if (play==true)	{next_pic();InitializeTimer();}
	else {StopTheClock();}

}

function InitializeTimer()
{
    // Set the length of the timer, in seconds
    secs = interval;
    StopTheClock();
    StartTheTimer();
}

function StopTheClock()
{
    if(timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}

function StartTheTimer()
{
    if (secs==0)
    {
        StopTheClock();
        next_pic();
	InitializeTimer();
    }
    else
    {
        self.status = secs;
        secs = secs - 1;
        timerRunning = true;
        timerID = self.setTimeout("StartTheTimer()", delay);
    }
}

function ValidateInteger(objElement)
{

var strString = objElement.value;
var strValidChars = '0123456789';

var strChar;
var blnResult = true;

for (i=0; i<strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strValidChars.indexOf(strChar) == -1)
{
blnResult = false;
}
}
if (blnResult == false) {
 objElement.value = '';
}

return blnResult;

}

 


// end gallery functions