function openPanel(div){
	
		var state = document.getElementById(div).style.display;
				
		if (state == "none"){
			document.getElementById(div).style.display = "block";
			document.getElementById('theButton').innerHTML = "<a class=\"whiteButton\" type=\"button\" style=\"width:100px;float:right;\" onclick=\"openPanel('sendComment');\" href=\"#top\">Cancel</a><a class=\"whiteButton\" type=\"button\" style=\"width:100px;\" value=\"submit\" onclick=\"sendComment();\" href=\"#top\">Send</a>";
		} else {
			document.getElementById(div).style.display = "none";
			document.getElementById('theButton').innerHTML = "<a class=\"whiteButton\" type=\"button\" href=\"#bottom\" style=\"width:260px;\" onclick=\"openPanel('sendComment');\">Contact</a>";
		}
	
	}
	
	// trim spaces from "response" var
	function trim(stringValue){
		return stringValue.replace(/(^\s*|\s*$)/g, "");
	}
	
	function clearDiv(id){
		document.getElementById(id).style.display = "none";
		document.getElementById('theButton').innerHTML = "<a class=\"whiteButton\" type=\"button\" href=\"#bottom\" style=\"width:260px;\" onclick=\"openPanel('sendComment');\">Contact</a>";
	}
	
	function sendComment(){
		
		var username = document.getElementById('username').value;
		username = escape(username);
		var comments = document.getElementById('comment').value;
		comments = escape(comments);
		var eatit = "username="+username+"&comment="+comments;
		
		var handlerFunc = function(t) {
			
			// when response "x" is returned, do something
			var theResponse = trim(t.responseText);
			if (theResponse == "mail sent"){
		   		document.getElementById('sendComment').style.display = "none";
				document.getElementById('afterSend').innerHTML = "<fieldset style=\"padding:10px;font-size:13px;text-align:left;color:#000000;\"><br>Your message has been sent. Thanks.<br></fieldset>";
				document.getElementById('afterSend').style.display = "block";
				setTimeout("clearDiv('afterSend');",2500);
			} else {
				alert(theResponse);
			}
			
		};
		
		new Ajax.Request('send.php?task=sendComments&'+eatit,{onSuccess:handlerFunc, asynchronous:true});
	}
	
	function scrolltotop(){
		window.scrollTo(0, 1);
	}