// CTracker_Ignore: File Checked By Human
// Tell the Security Scanner that reachable code in this file is not a security issue
/***************************************************************************
 *                                 func.js
 *                            -------------------
 *   begin                : Wednesday, May 30, 2007
 *   copyright            : (C) 2007 websHoX.org
 *   email                : jojoponn139@googlemail.com
 *   package 		  : Advanced Guestbook for phpBB2 VERSION 3.1.6
 *
 ***************************************************************************/
var xmlHttp = false;

try {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        xmlHttp  = false;
    }
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}

function check_cap()
{
	if(xmlHttp) {
		if(document.book.cap.value.length == 6) {
			document.getElementById("ajax_inf").style.display = "none";
			xmlHttp.open('POST', 'gb-data/cap_answ.'+phpEx+'?mode=cap&gbd='+gbd);
			xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttp.send('code='+document.book.cap.value);
			xmlHttp.onreadystatechange = function () {
				if (xmlHttp.readyState == 4) {
					document.getElementById("answer").innerHTML = '';
					document.getElementById("answer").innerHTML = xmlHttp.responseText;
				}
			};
		} else {
			document.getElementById("answer").innerHTML = '';
			document.getElementById("answer").innerHTML = cap_tl;
		}
	}
}

function check_version()
{
	if(xmlHttp) { 
		try {
			xmlHttp.open('POST', '../gb-data/version.'+phpEx);
			xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttp.send('code=gb_vers');
			xmlHttp.onreadystatechange = function () {
				if (xmlHttp.readyState == 4) {
					if (xmlHttp.responseText == '') {
						document.getElementById("version_ip").style.display = "none";
						document.getElementById("version_im").style.display = "block";
					}
					else if(xmlHttp.responseText.length > 10) {
						document.getElementById("version_ip").style.display = "none";
						document.getElementById("version_im").style.display = "block";
					}
					else {
						if (xmlHttp.responseText == gb_version) {
							document.getElementById("version_ip").style.display = "none";
							document.getElementById("version_ok").style.display = "block";
						}
						else {
							document.getElementById("version_ip").style.display = "none";
							document.getElementById("version_bd").style.display = "block";
						}
					}
				}
			};
		} catch(e) {
	        document.getElementById("version_ip").style.display = "none";
			document.getElementById("version_im").style.display = "block";
		}
	}
}

function check_com()
{
	var min = t_min;
	var max = t_max;
	if(document.book.gb_comment.value.length < min) {
		document.getElementById("check_comment").innerHTML = m_min;
	} else {
		if(document.book.gb_comment.value.length > max) {
			document.getElementById("check_comment").innerHTML = m_max;
		} else {
			document.getElementById("check_comment").innerHTML = '';
		}
	}
}

function show_ajax_inf()
{
	document.getElementById("ajax_inf").style.display = "block";
}

