//SHORT CUTS
function ID(id) {
	return document.getElementById(id);
}

function isEmpty(id) {
    if(document.getElementById(id).value == '') {
		return true;
	} else {
		return false;
	}
}

function Empty(id, comment) {
	if(id.value == comment) {
		id.value = '';
	} /*else if(id.value == '') {
		id.value = comment;
	}*/
}


//SPINE FUNCTIONS
function Load(page) {
	ID('load').style.visibility ='visible';
	
	new Ajax('pages/'+page+'.php', {
	method: 'post',
	//if method is post, you can write parameters here.  
	//Can be a querystring, an object or a Form element.
	postBody: '',
	//$(element) to insert the response text of the XHR into, upon completion of the request.
	update: $('info'),
	//Execute scripts in the response text onComplete.
	onComplete: function() {setTimeout("ID('load').style.visibility ='hidden'",250); },
	
	evalScripts: true
}).request();	
	
}

//CONTACT FUNCTIONS

function SendComment() {
	if(!CommentValidate()) {
		ID('contactValidate').className = 'error';
		ID('contactValidate').innerHTML = 'Please enter your details.'
		ID('contactValidate').style.visibility ='visible';
	} else {
		ID('contactValidate').style.visibility ='hidden';
		ID('load').style.visibility ='visible';
	new Ajax('processes/sendemail.php', {
	method: 'post',
	//if method is post, you can write parameters here.  
	//Can be a querystring, an object or a Form element.
	postBody: 'name='+ID('name').value+'&email='+ID('email').value+'&phone='+ID('phone').value+'&message='+ID('message').value+'&ref='+ID('ref').value,
	//$(element) to insert the response text of the XHR into, upon completion of the request.
	update: $('contactValidate'),
	//Execute scripts in the response text onComplete.
	onComplete: function() {setTimeout("ID('load').style.visibility ='hidden';ID('contactValidate').className = 'sent';ID('contactValidate').style.visibility ='visible';",250); },
	
	evalScripts: true
}).request();	
	}
}
	
	function CommentValidate() {
		
		if(isEmpty('name') || isEmpty('email') || isEmpty('phone') || isEmpty('message')) {
		return false;
		} else {
		return true	
		}
	
}