////////////////////////////////////////////	SUBMENU setup

function subMenu(x) {
//		0 = Home
//		1 = About
//		2 = Portfolio
//		3 = Musical services
//		4 = Links
//		5 = Resources
var subMenuItems = new Array(
'<a href="http://www.andrewbatterham.com/index.html">Home</a>::<a href="http://www.andrewbatterham.com/contact.html">Contact</a>::<a href="http://www.andrewbatterham.com/sitemap.html">Site map</a>',
'<a href="http://www.andrewbatterham.com/biography.html">Biography</a>::<a href="http://www.andrewbatterham.com/works.html">List of Works</a>::<a href="http://www.andrewbatterham.com/presskit.html">Press kit</a>::<a href="http://www.andrewbatterham.com/discography.html">Discography</a>::<a href="http://www.andrewbatterham.com/affiliations.html">Affiliations</a>',
'<a href="http://www.andrewbatterham.com/portfolio_sheet.html">Sheet music</a>::<a href="http://www.andrewbatterham.com/portfolio_audio.html">Audio samples</a>::<a href="http://www.andrewbatterham.com/testimonials.html">Testimonials and Reviews</a>',
'<a href="http://www.andrewbatterham.com/composing.html">Composing</a>::<a href="http://www.andrewbatterham.com/arranging.html">Arranging</a>::<a href="http://www.andrewbatterham.com/quote.html">Quote form</a>',
'<a href="http://www.andrewbatterham.com/links.html#music">Music</a>::<a href="http://www.andrewbatterham.com/links.html#web">Web design</a>::<a href="http://www.andrewbatterham.com/links.html#education">Education</a>::<a href="http://www.andrewbatterham.com/links.html#time">Passing time</a>',
'<a href="http://www.andrewbatterham.com/brass/">Brass instruments</a>::<a href="http://www.andrewbatterham.com/resources.html">Resources</a>::<a href="http://www.andrewbatterham.com/terms/">Musical terms</a>');

document.getElementById('subMenuContent').innerHTML = subMenuItems[x];
}

////////////////////////////////////////////	NEWS_BOX date, content and rotation

monthname = new Array('January','February','March','April','May','June','July','August','September','October','November','December')
today = new Date();
year = today.getFullYear();
day = today.getDate();
month = monthname[today.getMonth()];
theDate = day+' '+month+' '+year;

news_items = new Array(
'<strong>St Johns Lutheran Church</strong> have commissioned Andrew to write a work for the inaugural airing of the Church\'s new oboe da caccias, made by <a href="http://www.baroqueoboes.com">Sand Dalton</a> in the USA.<br />The work will be premiered in April',				   
'<strong>Duke\'s Crusade,</strong> for alto saxophone and piano, has been added to the alto saxophone AMEB syllabus for Grade 7. Published by Reed Music.<br /><br />Visit their website:<br /><a href="http://www.reedmusic.com/">www.reedmusic.com</a>',
'Reed Music will soon publish <strong>Young Prince of Tyre,</strong> a vocal setting of an Ern Malley poem for baritone and piano.<br /><br />This work is under consideration to join the AMEB vocal syllabus',
'Jazz icon James Morrison performed <strong>Funkathon</strong> with the Camberwell High School big band at the Hawthorn Town Hall.<br /><br /><strong>Funkathon</strong> is distributed by <a href="http://www.futuremusic.com.au">Future Music</a>',
'Melbourne music publishers Reed Music have published <strong>A Golden Summer Day</strong> for trumpet and piano.<br /><br />Visit their website:<br /><a href="http://www.reedmusic.com/">www.reedmusic.com</a>',
'<strong>A Golden Summer Day</strong> has also been added to the Victorian Certificate of Education (VCE) Solo Performance Units 3 + 4 syllabus for trumpet.<br /><br />View the syllabus <a href="http://www.vcaa.vic.edu.au/vce/studies/musicsolo/units34soloworks/sololist/trumpet.pdf">here</a>',
'The Symphonic Band of Caulfield Grammar School have premiered <strong>Vanguard</strong> as part of their overseas tour.<br /><br />Other recent school commissions include work for Xavier College and Balwyn High School');

var n = 0;
function rotate_news(){
document.getElementById('news_info').innerHTML = news_items[n];
n = n+1;
if(n==news_items.length)n=0;
var news_timer = setTimeout('rotate_news()',8000)
}

////////////////////////////////////////////	PICTURE BOXES content and rotation

pics = new Array(
'images/arrange.jpg',
'images/arrange2.jpg',
'images/performer.jpg',
'images/performer2.jpg',
'images/performer3.jpg');

var p = 0;
function rotate_pictures(){
document.images.pictures.src = pics[p];
p = p+1;
if(p==pics.length)p=0;
var picture_timer = setTimeout('rotate_pictures()',5000)
}

composer_pics = new Array(
'images/compose.jpg',
'images/compose2.jpg',
'images/music5.jpg');

var q = 0;
function rotate_composing(){
document.images.composer_image.src = composer_pics[q];
q = q+1;
if(q==composer_pics.length)q=0;
var composer_timer = setTimeout('rotate_composing()',5000)
}

arranger_pics = new Array(
'images/music6.jpg',
'images/music7.jpg',
'images/music8.jpg');

var r = 0;
function rotate_arranging(){
document.images.arranger_image.src = arranger_pics[r];
r = r+1;
if(r==arranger_pics.length)r=0;
var arranger_timer = setTimeout('rotate_arranging()',5000)
}

links_pics = new Array(
'images/music1.jpg',
'images/music2.jpg',
'images/music3.jpg',
'images/music4.jpg');

var s = 0;
function rotate_links(){
document.images.links_image.src = links_pics[s];
s = s+1;
if(s==links_pics.length)s=0;
var links_timer = setTimeout('rotate_links()',5000)
}


////////////////////////////////////////////	 TOGGLE scripts

function toggle(id){
if(document.getElementById(id).style.display == 'block'){
	document.getElementById(id).style.display = 'none';
	} else
	document.getElementById(id).style.display = 'block';
}


var ids = new Array('first','second','third','fourth','fifth');
function swap(id){
    for(i=0;i<ids.length;i++){
    document.getElementById(ids[i]).style.display = 'none';
    }
document.getElementById(id).style.display = 'block';
}


////////////////////////////////////////////	 CLIENT AREA scripts



function jobFinder(url){
job = document.usernameForm.jobName.value;
location.href = url + '?' + escape(job);
}


/*
To add or remove a job:
	1)	Add the user name to the namez[i] array
	2)	Add the file link to the jobz[i] array
	3)	Make sure the index numbers are the same
	4)	Add the user name to the list commented below
*/


namez = new Array();
namez[0] = 'andrew';
namez[1] = 'client1';
namez[2] = 'client2';

jobz = new Array();
jobz[0] = '<a href\=\"\#\">Link to andrew\'s job<\/a>';
jobz[1] = '<a href\=\"\#\">Link to client1\'s job<\/a>';
jobz[2] = '<a href\=\"\#\">Link to client2\'s job<\/a>';


function displayJob(url){
if(location.href.indexOf('?')>0){
  url = location.href;
  job = url.substring(url.indexOf('?')+1,url.length);
  
  //	This is the list
  
	if(job == 'andrew' || job == 'client1' || job == 'client2'){
	document.getElementById('welcome').innerHTML = 'Welcome, <strong>'+job+'.<\/strong> Please find your job below';
    document.usernameForm.style.display = 'none';
		for(i=0;i<namez.length;i++){
			if(job == namez[i]){
			document.getElementById('jobBox').innerHTML = jobz[i];
			}
		}
	} else {
	document.getElementById('welcome').style.color = 'red';
	document.getElementById('welcome').style.fontWeight = 'bold';
	document.getElementById('welcome').innerHTML = 'Invalid username';
	document.usernameForm.jobName.focus();
	}
  }
}




////////////////////////////////////////////	 GENERAL scripts



function permission(){
permit = confirm('This site may contain content not suitable for children.\n\nDo you wish to continue?');
if(permit == true)
	return (true);
else
	return (false);
}


function enableForm(){
	for(i=0;i<document.quote.elements.length;i++){
	document.quote.elements[i].disabled = 0;
	}
}

function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}

function toCount(entrance,exit,text,characters) {
  var entranceObj=getObject(entrance);
  var exitObj=getObject(exit);
  var length=characters - entranceObj.value.length;
  if(length <= 0) {
    length=0;
    text='<span class="exceeded"> '+text+' </span>';
    entranceObj.value=entranceObj.value.substr(0,characters);
  }
  exitObj.innerHTML = text.replace("{CHAR}",length);
}

function validator(){
contact = document.quote.contact;
email = document.quote.email;
if(contact.value == ''){
     alert('Please include contact details');
     contact.focus();
     return false;
     }
if(email.value == ''){
     alert('Please enter a valid email address');
     email.focus();
     return false;
     } else if(email.value.indexOf('@')<0){
     alert('Email address must contain \@');
     email.focus();
     return false;
     }
window.location = 'submit.html'
}


function key_sniffer(x){		// keys and titles array numbers correspond, DO NOT CHANGE!
var keys = new Array(
'../images/keys/none.gif','../images/keys/1_sharp.gif',
'../images/keys/2_sharps.gif','../images/keys/3_sharps.gif',
'../images/keys/4_sharps.gif','../images/keys/5_sharps.gif',
'../images/keys/6_sharps.gif','../images/keys/7_sharps.gif',
'../images/keys/1_flat.gif','../images/keys/2_flats.gif',
'../images/keys/3_flats.gif','../images/keys/4_flats.gif',
'../images/keys/5_flats.gif','../images/keys/6_flats.gif',
'../images/keys/7_flats.gif');
var titles = new Array(
'None: C major, A minor','1 sharp: G major, E minor','2 sharps: D major, B minor','3 sharps: A major, F# minor',
'4 sharps: E major, C# minor','5 sharps: B major, G# minor','6 sharps: F# major, D# minor','7 sharps: C# major, A# minor','1 flat: F major, D minor','2 flats: B flat major, G minor','3 flats: E flat major, C minor','4 flats: A flat major, F minor','5 flats: D flat major, B flat minor','6 flats: G flat major, E flat minor','7 flats: C flat major, A flat minor');
	if(x != ''){
	document.answer.src = keys[x];
	document.answer.title = titles[x];
	}
}


function termFinder(url,term){
	location.href = url + '?' + escape(term);
}

function termRetriever(){
	if(location.href.indexOf('?')>0){
	address = document.URL;
	term = address.substring(address.indexOf('?')+1,address.length)
	term = unescape(term);
	document.getElementById(term).style.backgroundColor = '#99ccff';
	document.getElementById(term).style.color = '#003399';
	}
}


/*			FONT RESIZER								*/
/*			with thanks to www.fernando-graphics.com	*/

// retrieve cookie.
function getCookie(name){
  var cname = name + "=";
  var dc = document.cookie;
  if (dc.length > 0) {
    begin = dc.indexOf(cname);
    if (begin != -1) {
      begin += cname.length;
      end = dc.indexOf(";", begin);
      if (end == -1) end = dc.length;
        return unescape(dc.substring(begin, end));
    }
  }
  return null;
}

// set cookie.
function setCookie(name, value, expires, path, domain, secure) {
  document.cookie = name + "=" + escape(value) +
  ((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
  ((path == null) ? "" : "; path=" + path) +
  ((domain == null) ? "" : "; domain=" + domain) +
  ((secure == null) ? "" : "; secure");
}

// delete cookie.
function delCookie (name,path,domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path == null) ? "" : "; path=" + path) +
    ((domain == null) ? "" : "; domain=" + domain) +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

var firstCall = true;

function changeFontsize(fSize, increment) {
  if (firstCall) {
    firstCall = false;
    if (increment != "")
      changeFontsize('14', '');
  }
  
// original script modified from here

  if (document.getElementById) {
    var mainDiv = document.getElementById('content');
      var currentFontSize, fontIncrease, newFontSize;
        if (increment != "") {
          currentFontSize = parseInt(mainDiv.style.fontSize);
          fontIncrease = parseInt(increment);
          newFontSize = currentFontSize + fontIncrease;
          }
        else if (fSize != "")
          newFontSize = parseInt(fSize);
          mainDiv.style.lineHeight = Math.round(newFontSize*1.5) + "px";
          mainDiv.style.fontSize = newFontSize + "px";
          setCookie('fontSize', newFontSize);
  }
}

function fontReset(){
	if(document.getElementById) {
	document.getElementById('content').style.fontSize = '13px';
	document.getElementById('content').style.lineHeight = '20px';
	}
}