


function resize(element){

	
		//iHeight += 400;
		iHeight = document.viewport.getHeight();
		iHeight+=100;
		contentHeight = $(element).getHeight();
		contentHeight+=300;

		if(contentHeight > iHeight){
		$("wrap").style.height = contentHeight;
			$("wrap").setStyle({
 height: contentHeight + "px"
});
		} else {
				$("wrap").setStyle({
 height: iHeight + "px"
});
			
	}
	
}
	
/*=========================
Ajax
=========================*/	
sendRequest = function(url,params,hf,ef){
	//alert("send");
new Ajax.Request(
	url,
	{
		method: 'post',
		parameters: params,
		onSuccess: hf,
		onFailure: ef
		});
}
	
	
	
/*=========================
Contact Form
=========================*/
submitContactForm = function(){
	//alert("send");
	var isvalid = validateForm("contact");
//if form is valid
if(isvalid){
var params = Form.serialize($('contact'));
//document.write(params);
var url = 'http://www.cataract.org.uk/ajax/ajax.contact.php';
	$('contact').disable();

//$("submit").innerHTML ='<a class="send" title="Processing">Processing</a></p>';
newAjax = sendRequest(url,params,contactHandler,serverError);
}
}

contactHandler = function(t){
	//	alert(t.responseText);
if(t.responseText == 0){
	serverError();

} else {
	location.href="http://www.cataract.org.uk/contact-me/thankyou/";
	
}
}

serverError = function(){
	$("errorbox").innerHTML = 'Sorry, there was a server error while processing your form. Please try again.';
	setFormStatus(false)
	$('contact').enable();
	$("submit").innerHTML ='<a href="#" onclick="submitContactForm(); return false;" class="send" title="Send">Send</a>';
	
}
