/*
Comment Challenge
*/
function mtHide(id) {
    var el = (typeof id == "string") ? document.getElementById(id) : id;
    if (el) el.style.display = 'none';
}

function mtShow(id) {
    var el = (typeof id == "string") ? document.getElementById(id) : id;
    if (el) el.style.display = 'block';
}

/*
Search Form
*/

function clearText(thefield){
        if (thefield.defaultValue==thefield.value)
thefield.value = ""
} 


/*
Cookie Monster
*/


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function hideComments(com) {
	//alert("in hide comments(): " + com + ", hiding: " + com + '-comments');
	//var el = document.getElementById(com + '-comments');
	//if (el) el.style.display = 'none';
	// var el = ( com + '-comments').toString();
	// alert(el);

	hideDocumentElement(com + '-comments');
	hideDocumentElement(com + '-comments_on');
	showDocumentElement(com + '-comments_off');
	createCookie(com + '-comments','hide');
}
function showComments(com) {
	
	showDocumentElement(com + '-comments');
	hideDocumentElement(com + '-comments_off');
	showDocumentElement(com + '-comments_on');
	createCookie(com + '-comments','show');
}

function autoCommentsContent(entry) {

	var checkcomments = readCookie(entry +'-comments');
	if (checkcomments == "show" ) {
		showComments(entry);
	} else {
		hideComments(entry);
	}

}

