function AddPhotos() 
{
  var ni = document.getElementById('photos');
  var numi = document.getElementById('photocounter');
  var num = (document.getElementById('photocounter').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'Photo'+num+'s';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = '<br class="clear-both" /><input type="file" name="photo'+num+'" id="photo'+num+'" style="margin-left:160px;" />';
  ni.appendChild(newdiv);
}

function AddWebSites() 
{
  var ni = document.getElementById('websites');
  var numi = document.getElementById('websitecounter');
  var num = (document.getElementById('websitecounter').value -1)+ 2;
  numi.value = num;
  var newdiv = document.createElement('div');
  var divIdName = 'Website'+num+'Counter';
  newdiv.setAttribute('id',divIdName);
  newdiv.innerHTML = '<br class="clear-both" /><input type="text" name="website'+num+'" id="website'+num+'" style="margin-left:160px;" />';
  ni.appendChild(newdiv);
}

function imposeMaxLength(Object, MaxLen)
{
  return (Object.value.length <= MaxLen);
}

function ShowEditSection(SectionToShow)
{
	if(SectionToShow == "PersonalDetails")
	{
		$('#personaldetails').slideDown("slow");
		$('#currentphotos').slideUp("slow");
		$('#locations').slideUp("slow");
		$('#currentwebsites').slideUp("slow");
		$('#music').slideUp("slow");
	}
	
	else if(SectionToShow == "CurrentPhotos")
	{
		$('#currentphotos').slideDown("slow");
		$('#personaldetails').slideUp("slow");
		$('#locations').slideUp("slow");
		$('#currentwebsites').slideUp("slow");
		$('#music').slideUp("slow");
	}
	
	else if(SectionToShow == "Locations")
	{
		$('#locations').slideDown("slow");
		$('#personaldetails').slideUp("slow");
		$('#currentphotos').slideUp("slow");
		$('#currentwebsites').slideUp("slow");
		$('#music').slideUp("slow");
	}
	
	else if(SectionToShow == "CurrentWebsites")
	{
		$('#currentwebsites').slideDown("slow");
		$('#currentphotos').slideUp("slow");
		$('#personaldetails').slideUp("slow");
		$('#locations').slideUp("slow");
		$('#music').slideUp("slow");
	}
	
	else if(SectionToShow == "CurrentMusic")
	{
		$('#music').slideDown("slow");
		$('#currentwebsites').slideUp("slow");
		$('#currentphotos').slideUp("slow");
		$('#personaldetails').slideUp("slow");
		$('#locations').slideUp("slow");
	}
}

function checkAll(field)
{
	for (i = 0; i < field.length; i++)
	field[i].checked = true ;
}

function SearchBands()
{
	document.getElementById('action').value = 'bands';
	document.searchform.submit();
}

function SearchFestivals()
{
	document.getElementById('action').value = 'festivals';
	document.searchform.submit();
}

function checkboxlimit(checkgroup, limit){
	var checkgroup=checkgroup
	var limit=limit
	for (var i=0; i<checkgroup.length; i++){
		checkgroup[i].onclick=function(){
		var checkedcount=0
		for (var i=0; i<checkgroup.length; i++)
			checkedcount+=(checkgroup[i].checked)? 1 : 0
		if (checkedcount>limit){
			alert("You can select a maximum of "+limit+" music types")
			this.checked=false
			}
		}
	}
}
