/*Form Logic -  The Script below is broken up into four parts:
Part 1 - Provides the Fade for the Separate areas of the Nav
There is also an additional part which provides a demo of the form errors generated by the server.
*/

//* * Part 1 - Provides the Fade for the Separate areas of the form * * * * * * * * * * * * * * * * * * 
//This provides the fade for the opacity
function opacity(id, opacStart, opacEnd, millisec) {
	//speed for each frame
	var speed = Math.round(millisec / 100);
	var timer = 0;

	//determine the direction for the blending, if start and end are the same nothing happens
	if(opacStart > opacEnd) {
		for(i = opacStart; i >= opacEnd; i--) {
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	} else if(opacStart < opacEnd) {
		for(i = opacStart; i <= opacEnd; i++)
			{
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
			timer++;
		}
	}
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

//controls the opacity for each section
function show(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
		document.getElementById(id);{
		opacity(id, 0, 100, millisec);
		}
}

function hide(id, millisec) {
	//if an element is invisible, make it visible, else make it ivisible
		document.getElementById(id);{
		opacity(id, 100, 0, millisec);
		}
}



// Tab Check

function tabcheck(where) {

	if (where == 'Home') {
		document.getElementById(where).style.background="url('Global/Nav-Bar/Nav-1-Home-over.jpg') center center no-repeat";
		document.getElementById(where).style.color="#00bbf1";
	} else if (where == 'About') {
		document.getElementById(where).style.background="url('Global/Nav-Bar/Nav-2-About-over.jpg') center center no-repeat";
		document.getElementById(where).style.color="#00bbf1";
	} else if (where == 'Technology') {
		document.getElementById(where).style.background="url('Global/Nav-Bar/Nav-3-Technology-over.jpg') center center no-repeat";
		document.getElementById(where).style.color="#00bbf1";
	} else if (where == 'Music') {
		document.getElementById(where).style.background="url('Global/Nav-Bar/Nav-4-Music-over.jpg') center center no-repeat";
		document.getElementById(where).style.color="#00bbf1";
	} else if (where == 'Gallery') {
		document.getElementById(where).style.background="url('Global/Nav-Bar/Nav-5-Gallery-over.jpg') center center no-repeat";
		document.getElementById(where).style.color="#00bbf1";
	} else if (where == 'Contact') {
		document.getElementById(where).style.background="url('Global/Nav-Bar/Nav-6-Contact-over.jpg') center center no-repeat";
		document.getElementById(where).style.color="#00bbf1";
	} else {
		document.getElementById(where).style.background="url('Global/Nav-Bar/Nav-7-Press-over.jpg') center center no-repeat";
		document.getElementById(where).style.color="#00bbf1";
	}	
}

// Form Elements - shows & hides individual blocks of the form

function formelements(Seb) {
	document.getElementById('EventContainer').style.display="none";
	document.getElementById('GeneralContainer').style.display="block";
	document.getElementById('SubmitBtn').style.display="block";
	document.getElementById(Seb).style.display="Block";
}

//Validates the contact us form
function validateForm() 
{
 var okSoFar=true
 with (document.phpformmailer)
 {
  var foundAt = email.value.indexOf("@",0)
  if (foundAt < 1 && okSoFar)
  {
    okSoFar = false
    alert ("Please enter a valid email address.")
    email.focus()
  }
  if (thesubject.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter a subject.")
    thesubject.focus()
  }
  if (themessage.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter the details for your enquiry.")
    themessage.focus()
  }
  if (okSoFar==true)  
  {
   block_spam_bots.value=4*3;//spam bots currently can not read JavaScript, if could then they'd fail the maths!
   submit();                  // do check for updatea often at:  www.TheDemoSite.co.uk 
  } 
 }
}