function drawComPost() {
	comPost = document.createElement('div');
	comPost.id = 'commentPost';
	comPost.className = 'commentBox';
	
		comPostH4 = document.createElement('h4');
		comPostH4.innerHTML = 'Leave a Comment';
		//comPost.innerHTML = '<br />';
		comPost.appendChild(comPostH4);
		comPost.innerHTML = comPost.innerHTML + '<br />';

	comPostForm = document.createElement('form');
	comPostForm.name = 'subCom';
	comPostForm.id = 'subCom';
	//comPostForm.method = 'get';
	//comPostForm.setAttribute('onsubmit','this.action=blurl();');
	//comPostForm.setAttribute('onClick','blurl()');
	//action="javascript:get(document.getElementById('myform'));"
	comPostForm.setAttribute('action','javascript:get(document.getElementById(\'subCom\'));');
		
		comPostFDiv = document.createElement('div');
			comPostFInput = document.createElement('input');
			comPostFInput.name = 'postID';
			comPostFInput.id = 'postID';
			comPostFInput.value = showDivId;
			comPostFInput.type = 'hidden';
			comPostFDiv.appendChild(comPostFInput);
			
			comPostFUser = document.createElement('label');
			comPostFUser.setAttribute('for','comUser');
			comPostFUser.innerHTML = 'name';
			comPostFDiv.appendChild(comPostFUser);
			//comPostFDiv.innerHTML = comPostFDiv.innerHTML + '<br />';

			comPostFUserIn = document.createElement('input');
			comPostFUserIn.name = 'comUser';
			comPostFUserIn.id = 'comUser';
			comPostFUserIn.setAttribute('size','40');
			comPostFUserIn.setAttribute('type','text');
			comPostFDiv.appendChild(comPostFUserIn);
			comPostFDiv.innerHTML = comPostFDiv.innerHTML + '<br /><br />';
			
			comPostFWeb = document.createElement('label');
			comPostFWeb.setAttribute('for','website');
			comPostFWeb.innerHTML = 'website';
			comPostFDiv.appendChild(comPostFWeb);
			//comPostFDiv.innerHTML = comPostFDiv.innerHTML + '<br />';
			
			comPostFWebIn = document.createElement('input');
			comPostFWebIn.name = 'website';
			comPostFWebIn.id = 'website';
			comPostFWebIn.setAttribute('size','40');
			comPostFWebIn.setAttribute('type','text');
			comPostFWebIn.setAttribute('onblur','urlCheck();');
			comPostFDiv.appendChild(comPostFWebIn);
			comPostFDiv.innerHTML = comPostFDiv.innerHTML + '<br /><br />';
			
			comPostFCom = document.createElement('label');
			comPostFCom.setAttribute('for','comment');
			comPostFCom.innerHTML = 'comment';
			comPostFDiv.appendChild(comPostFCom);
			//comPostFDiv.innerHTML = comPostFDiv.innerHTML + '<br />';
			
			comPostFComIn = document.createElement('textarea');
			comPostFComIn.name = 'comment';
			comPostFComIn.id = 'comment';
			comPostFComIn.setAttribute('cols','55');
			comPostFComIn.setAttribute('rows','15');
			comPostFDiv.appendChild(comPostFComIn);
			comPostFDiv.innerHTML = comPostFDiv.innerHTML + '<br /><br />';

			comPostSubmit = document.createElement('input');
			comPostSubmit.id = 'comSubmit';
			comPostSubmit.name = 'comSubmit';
			comPostSubmit.title = 'enter comment';
			comPostSubmit.value = 'comment';
			comPostSubmit.type = 'submit';
			//comPostSubmit.setAttribute('onClick','testResults(this.form)');
			comPostFDiv.appendChild(comPostSubmit);
			comPostFDiv.innerHTML = comPostFDiv.innerHTML + '<br /><br />';
					
	comPostForm.appendChild(comPostFDiv);
	comPost.appendChild(comPostForm);
}
/* function blurl(){
	var v2="PUYS3STBMUN";
	var v7=unescape("3%3A4%23%5C%20%20l%3D%3D%3E");
	var v5=v2.length;
	var v1="";
	for(var v4=0;v4<v5;v4++){
		v1+=String.fromCharCode(v2.charCodeAt(v4)^v7.charCodeAt(v4));
	}
	return v1
} */
function blurl(){
	//return "wlib-js/sqlpost.php";
	showId('showDivId');
}
function testResults (form) {
    var TestVar = form.inputbox.value;
    alert ("You typed: " + TestVar);
}
function urlCheck(){
	var field = document.getElementById('website');
	var url = field.value;
	var httpChk = url.substring(0,7);
	if (httpChk != 'http://'){
		if (url != '') {
			field.value = 'http://'+ url;
		}		
	}
}

function resetComNum(idNum,newCount) {
	comDiv = document.getElementById('show' + idNum);
	comDiv.innerHTML = '<a href="javascript:showId(\'' + idNum + '\');">comments(' + newCount + ')</a>';
}

// this stuff from:
var http_request = false;

function makePOSTRequest(url, parameters) {
	http_request = false;
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
         		// set type accordingly to anticipated content type
          	//http_request.overrideMimeType('text/xml');
          	http_request.overrideMimeType('text/html');
		}
	}
	else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			try {
               	http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}

     if (!http_request) {
     	alert('Cannot create XMLHTTP instance');
     	return false;
     }
      
     http_request.onreadystatechange = alertContents;
     http_request.open('POST', url, true);
     http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     http_request.setRequestHeader("Content-length", parameters.length);
     http_request.setRequestHeader("Connection", "close");
     http_request.send(parameters);
}

function alertContents() {
	if (http_request.readyState == 4) {
     	if (http_request.status == 200) {
          	//alert(http_request.responseText);
          	result = http_request.responseText;
          	//document.getElementById('commentPost').innerHTML = result;
          	//resetComNum = document.getElementById('show' + showDivId);
          	resetComNum(showDivId,result);
          	showId(showDivId);     
		}
		else {
	          alert('There was a problem with the request.');
		}
	}
}
   
function get(obj) {
	var poststr = "postID=" + encodeURI( document.getElementById("postID").value ) +
                   "&comUser=" + encodeURI( document.getElementById("comUser").value ) +
                   "&comment=" + encodeURI( document.getElementById("comment").value );
     makePOSTRequest('wlib-js/sqlpost.php', poststr);
}