
function HideShow(id)
{
	var obj = document.getElementById(id);
	
	if(obj.style.display == "block")
	{
		obj.style.display = "none";
	}
	else
	{	
		obj.style.display = "block";
	}
}

function privacy() 
{
	window.open('privacy.html','privacy','toolbar=no,location=no,status=no,scrollbars=yes,resizable=yes,width=500,height=425'); 
} 



/***********************************************
* Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function ajaxAddComment(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				//alert("Your browser broke!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('ajaxDiv');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			if(document.getElementById('success')) {
			ajaxShowNewComment();
			}
		}
	}
	
	var comment = document.getElementById('comment').value;
	comment = comment.replace(/ /g, "+");
	comment = comment.replace(/\n/g, "##");
	var name = document.getElementById('name').value;
	name = name.replace(/ /g, "+");
	var cryptic = document.getElementById('cryptic').value;
	var listing = document.getElementById('listing').value;
	var queryString = "comment=" + comment + "&name=" + name + "&cryptic=" + cryptic + "&listing=" + listing;
	
	ajaxRequest.open("POST", "/ajaxcomment.asp", true);
	ajaxRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	ajaxRequest.send(queryString); 
}

function ajaxShowNewComment(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				//alert("Your browser broke!");
				return false;
			}
		}
	}
	
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			document.getElementById('commentform').innerHTML = "";
			var ajaxDisplay = document.getElementById('newcomment');
			ajaxDisplay.className = "none";
			ajaxDisplay.style.color = "rgb(255,255,255)";
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
			fadein();
		}
	}
	
	var listing = document.getElementById('listing').value;
	var queryString = "listing=" + listing;
	
	ajaxRequest.open("POST", "/ajaxshownewcomment.asp", true);
	ajaxRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	ajaxRequest.send(queryString); 
}

function fadein(){
	var colornum = document.getElementById('newcomment').style.color;
	colornum = colornum.substring(4,colornum.indexOf(","));
	colornum = colornum - 3;
	document.getElementById('newcomment').style.color = "rgb(" + colornum + "," + colornum + "," + colornum + ")";
	if (colornum > 5) {	setTimeout("fadein()",1) }
}