function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function validateAddMessageForm()
{
	var strMessage = new String(document.forms['addMessage'].elements['message'].value);
	if(document.forms['addMessage'].elements['name'].value == "")
	{
		alert("Please enter your name.");
	}
	else if(document.forms['addMessage'].elements['message'].value == "")
	{
		alert("Please enter a message.");
	}	
	else
	{
		document.forms['addMessage'].submit();
	}
}

function validateReplyToMessageForm()
{
	var strMessage = new String(document.forms['replyToMessage'].elements['message'].value);
	if(document.forms['replyToMessage'].elements['name'].value == "")
	{
		alert("Please enter your name.");
	}
	else if(document.forms['replyToMessage'].elements['message'].value == "")
	{
		alert("Please enter a message.");
	}	
	else
	{
		document.forms['replyToMessage'].submit();
	}
}

function showProfile(id)
{
	var strURL = new String("bandProfiles_" + id + ".asp") ;
	
	profileWindow = window.open(strURL, 'profileWindow','width=400,height=380,scrollbars=yes,toolbar=no,resizable=no,status=no,left=440,top=250,screenX=400,screenY=100') ;
	
	if(profileWindow != null && !profileWindow.closed)
	{
		if(id == 'all')
		{
			profileWindow.close();
		}
		else
		{
			profileWindow.focus();
		}
	}
}

function showReview(id)
{
	var strURL = new String("review_" + id + ".asp") ;
	window.open(strURL, '','width=400,height=200,scrollbars=yes,toolbar=no,resizable=no,status=no') ;
}

function showNews(id)
{
	var strURL = new String("newsDetail.asp?id=" + id) ;
	window.open(strURL, '','width=300,height=500,scrollbars=yes,toolbar=no,resizable=no,status=no') ;
}

function showLyrics(id)
{
	var strURL = new String("lyrics.asp?id=" + id) ;
	window.open(strURL, '','width=400,height=600,scrollbars=yes,toolbar=no,resizable=no,status=no') ;
}

function showGigInfo(id)
{
	var strURL = new String("gigInfo.asp?id=" + id) ;
	window.open(strURL, '','width=400,height=200,scrollbars=no,toolbar=no,resizable=no,status=no') ;
}

function getGallery()
{
	var strGallery = document.frmGallery.selGallery.options[document.frmGallery.selGallery.options.selectedIndex].value ;
	if(strGallery == ""){ document.frmGallery.action="gallery.asp" }
	else{ document.frmGallery.action="gallery.asp?folder=" + strGallery }
	document.frmGallery.submit();
}

function addGig()
{
	document.frmGigAdmin.action = "addgig.asp";
	document.frmGigAdmin.submit();
}

function editGig()
{
	var id = -1;
	
	for(var i=0; i<=document.frmGigAdmin.gigGroup.length-1; i++)
	{
		if(document.frmGigAdmin.gigGroup[i].checked)
		{id = document.frmGigAdmin.gigGroup[i].id;}
	}
	
	if(id != -1)
	{
		document.frmGigAdmin.action = "editgig.asp?id=" + id;
		document.frmGigAdmin.submit();
	}
	else
	{
		alert("You've forgotten to select a gig to edit .... tosser!");
	}
}

function deleteGig()
{
	var id = -1;
	
	for(var i=0; i<=document.frmGigAdmin.gigGroup.length-1; i++)
	{
		if(document.frmGigAdmin.gigGroup[i].checked)
		{id = document.frmGigAdmin.gigGroup[i].id;}
	}
	
	if(id != -1)
	{
		if(confirm("Are you sure you want to delete the selected gig?"))
		{
			document.frmGigAdmin.action = "processDeleteGig.asp?id=" + id;
			document.frmGigAdmin.submit();
		}
	}
	else
	{
		alert("You've forgotten to select a gig to delete .... tosser!");
	}
}

function addEmail()
{
	document.frmEmailAdmin.action = "addEmail.asp";
	document.frmEmailAdmin.submit();
}

function editEmail()
{
	var id = -1;
	
	for(var i=0; i<=document.frmEmailAdmin.emailGroup.length-1; i++)
	{
		if(document.frmEmailAdmin.emailGroup[i].checked)
		{id = document.frmEmailAdmin.emailGroup[i].id;}
	}
	
	if(id != -1)
	{
		document.frmEmailAdmin.action = "editEmail.asp?id=" + id;
		document.frmEmailAdmin.submit();
	}
	else
	{
		alert("You've forgotten to select an email address to edit .... tosser!");
	}
}

function deleteEmail()
{
	var id = -1;
	
	for(var i=0; i<=document.frmEmailAdmin.emailGroup.length-1; i++)
	{
		if(document.frmEmailAdmin.emailGroup[i].checked)
		{id = document.frmEmailAdmin.emailGroup[i].id;}
	}
	
	if(id != -1)
	{
		if(confirm("Are you sure you want to delete the selected email address?"))
		{
			document.frmEmailAdmin.action = "processDeleteEmail.asp?id=" + id;
			document.frmEmailAdmin.submit();
		}
	}
	else
	{
		alert("You've forgotten to select an email address to delete .... tosser!");
	}
}

function addNews()
{
	document.frmNewsAdmin.action = "addNews.asp";
	document.frmNewsAdmin.submit();
}

function editNews()
{
	var id = -1;

	for(var i=0; i<=document.frmNewsAdmin.newsGroup.length-1; i++)
	{
		if(document.frmNewsAdmin.newsGroup[i].checked)
		{id = document.frmNewsAdmin.newsGroup[i].id;}
	}
	
	if(id != -1)
	{
		document.frmNewsAdmin.action = "editNews.asp?id=" + id;
		document.frmNewsAdmin.submit();
	}
	else
	{
		alert("You've forgotten to select a news item to edit .... tosser!");
	}
}

function deleteNews()
{
	var id = -1;
	
	for(var i=0; i<=document.frmNewsAdmin.newsGroup.length-1; i++)
	{
		if(document.frmNewsAdmin.newsGroup[i].checked)
		{id = document.frmNewsAdmin.newsGroup[i].id;}
	}
	
	if(id != -1)
	{
		if(confirm("Are you sure you want to delete the selected news item?"))
		{
			document.frmNewsAdmin.action = "processDeleteNews.asp?id=" + id;
			document.frmNewsAdmin.submit();
		}
	}
	else
	{
		alert("You've forgotten to select a news item to delete .... tosser!");
	}
}

function emailSubscribe()
{
	if(document.forms['frmMailingList'].elements['ename'].value == "")
	{
		alert("Please enter your name.");
	}
	else if(document.forms['frmMailingList'].elements['emailaddress'].value == "")
	{
		alert("Please enter your email address.");
	}	
	else
	{
		document.frmMailingList.submit();
	}	
}

function changeProfile(nom)
{
	document.images["profile"].src = "../images/profile_" + nom + ".jpg";
	document.images["profile"].useMap = '#' + nom;
	//setTimeout("showProfile('" + nom + "')", 2000);
	var strURL = new String("bandProfiles_" + nom + ".asp") ;
	var profileTextDiv = document.getElementById("profiletext");
	profileTextDiv.style.visibility = "visible";
	profileTextDiv.innerHTML = "<iframe visible=\"true\" frameborder=\"0\" width=\"100%\" height=\"100%\" src=\"" + strURL + "\"></iframe>"
}

function onSubmitForm() {
    var formDOMObj = document.frmSend;
    if (formDOMObj.attach1.value == "" && formDOMObj.attach2.value == "" && formDOMObj.attach3.value == "" && formDOMObj.attach4.value == "" )
        alert("Please press the browse button and pick a file.")
    else
        return true;
    return false;
}

function show(object) 
{
	if (document.layers && document.layers[object])
	{    
      document.layers[object].visibility =  'visible';
  	}
	else if (document.all)
   {	
		document.all[object].style.visibility = 'visible';
	}
	else if (document.getElementById(object))
	{
		document.getElementById(object).style.visibility = 'visible';
	}
}

function hide(object) 
{
	if (document.layers && document.layers[object])
	{    
      document.layers[object].visibility =  'hidden';
  	}
	else if (document.all)
   {	
		document.all[object].style.visibility = 'hidden';
	}
	else if (document.getElementById(object))
	{
		document.getElementById(object).style.visibility = 'hidden';
	}
}

function showContent(id)
{
	var newcontent = document.getElementById(id).innerHTML;
	var newcontentHead = document.getElementById(id+'head').innerHTML;
	document.getElementById('content').innerHTML = newcontent;
	document.getElementById('contentHeader').innerHTML = newcontentHead;
}