/* ************ PROFILE PAGE SHOW/HIDE *************** */



function doProfile(id,selected) {

	

	if (document.getElementById) {

		// sort out the right thing to display

		for ( var i = 0; i < 3; i++ ) {

			// hide all

		//	document.getElementById('heading' + i).style.display = 'none';

			document.getElementById('content' + i).style.display = 'none';

		}

		// show one with ID

		//document.getElementById('heading' + id).style.display = 'block';

		document.getElementById('content' + id).style.display = 'block';

		

		// get all links inside the right column

		var nav_box = document.getElementById("content_right_column");

		var links = nav_box.getElementsByTagName("a");	

		

		// set all the links classes to nothing

		for(var i=0; i<links.length; i++)

			links[i].className = "";

		

		// set selected link as selected

		selected.className = "selected";

		

		// purely cosmetic... (adjust right hand stripe and margins)

		 

		document.getElementById("content_right_column").style.margin = '0px 0 0 13px';

		if (id > 0) {

		 
			document.getElementById("content_right_column").style.margin = '0px 0 122px 13px';

		}

	} else

		alert('Please update your browser');

}

function showDay(length, active) {
	if ( active == '' ) active = 1;
	for ( var i = 1; i < length ; i++ ) {
		if ( document.getElementById("day" + i) != null )
			document.getElementById("day" + i).style.display = 'none';
	}
	document.getElementById("day" + active).style.display = 'block';
		
}



/* Contact Us Form ------------------            */
function validContact(contactForm) {
	
	if (contactForm.fullName.value == '') {
		alert("Please enter your full name");
		contactForm.fullName.focus();
		return false;
	}
	
	if (contactForm.occupation.value == '') {
		alert("Please enter your occupation");
		contactForm.occupation.focus();
		return false;
	}
	
	 
	if (contactForm.emailAddr.value == '') {
		alert("Please enter your email address");
		contactForm.emailAddr.focus();
		return false;
	}
	
	if (!validEmail(contactForm.emailAddr.value)) {
		contactForm.emailAddr.focus();
		return false;
	}
	
	if (contactForm.telNumber.value == '' || !validNum(contactForm.telNumber.value) ) {
		alert("Please enter a valid telephone number");
		contactForm.telNumber.focus();
		return false;
	}
	 
	
	if (contactForm.address.value == '') {
		alert("Please enter your address");
		contactForm.address.focus();
		return false;
	}
	
		if (contactForm.towncity.value == '') {
		alert("Please enter your Town / City");
		contactForm.towncity.focus();
		return false;
	}
	
	if (contactForm.postcode.value == '') {
		alert("Please enter your postcode");
		contactForm.postcode.focus();
		return false;
	}
 
	 if (contactForm.question.value == '') {
		alert("Please enter a question");
		contactForm.question.focus();
		return false;
	}
	
	if (contactForm.experience.value == '') {
		alert("Please enter your experience");
		contactForm.experience.focus();
		return false;
	}
	 
	 
	return true;
	
}

// checks for valid telephone characters
function validNum(telno) {
	
	var pattern = "0123456789+-)( ";
	var i = 0;
	
	do {
		var pos = 0;
		for ( var j = 0 ; j < pattern.length ; j++ )
			if ( telno.charAt(i) == pattern.charAt(j) )
				pos = 1;
		i++;
	}
	while ( pos == 1 && i < telno.length )
	
	if ( pos == 0 ) return false;
	
	return true;
}





// check email address pattern
function validEmail(addr) {
	
	var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
	
	if ( !regex.test(addr) ) {
		alert("Invalid email address");
		return false;
	}
	
	return true;
}
