function getXMLHttp() {
	if (typeof XMLHttpRequest == 'undefined') 
		XMLHttpRequest = function() {
		try { return new ActiveXObject('Msxml2.XMLHTTP.6.0') } catch(e) {}
		try { return new ActiveXObject('Msxml2.XMLHTTP.3.0') } catch(e) {}
		try { return new ActiveXObject('Msxml2.XMLHTTP') }     catch(e) {}
		try { return new ActiveXObject('Microsoft.XMLHTTP') }  catch(e) {}
	 };
	 
	var xmlHttp = new XMLHttpRequest();
	return xmlHttp;
}

function grabdata(url, div) {
	var xmlHttp = getXMLHttp();
 
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 1) {
			//outputstate('Loading', div);
		}
		if (xmlHttp.readyState == 4) {
			outputstate(xmlHttp.responseText, div);
		}
	}

	xmlHttp.open('GET', url, true);
	xmlHttp.send(null);
}

function outputstate(state, div) {
	document.getElementById(div).innerHTML = state;
}

function quote(id) {
	var qcomment = document.getElementById('comment_text_' + id).innerHTML;
	while (qcomment.indexOf('[QUOTE') != -1) {
		var qbegin = qcomment.indexOf('[QUOTE');
		var qend = qcomment.lastIndexOf('[/QUOTE]') + 8;
		qcomment = qcomment.substring(0, qbegin) + qcomment.substring(qend);
	}
	if (!document.getElementById('triggerform')) return;
	document.getElementById('triggermessage').value 
		+= '[QUOTE='+document.getElementById('comment_user_' + id).innerHTML+']'
		+qcomment
		+'[/QUOTE]\n';
	//location.href='#comments';
}

function showhide(div) {
	if (document.getElementById(div).style.display == 'none') { 
		document.getElementById(div).style.display = 'block'; 
	}
	else {
		document.getElementById(div).style.display = 'none'; 
	}
}

function edit(id) {
	showhide('comment_block_' + id);
	showhide('comment_edit_' + id);
}

function tl(field, ml) {
	if (field.value.length > ml) {
		field.value = field.value.substring(0, ml);
	}
}

function screenshot(id) {
	var popup = window.open(id,'screenshot','width=660,height=490,scrollbars=0,menubar=0,toolbar=0,location=0,status=0,resizable=0');
	popup.focus();
}
function video(id) {
	var popup = window.open(id,'video','width=660,height=529,scrollbars=0,menubar=0,toolbar=0,location=0,status=0,resizable=0');
	popup.focus();
}
function forgot(id) {
	var popup = window.open(id,'forgot','width=550,height=205,scrollbars=0,menubar=0,toolbar=0,location=0,status=0,resizable=0');
	popup.focus();
}
function profile(id) {
	var popup = window.open(id,'profile','width=550,height=495,scrollbars=1,menubar=0,toolbar=0,location=0,status=0,resizable=0');
	popup.focus();
}
function settings(id) {
	var popup = window.open(id,'settings','width=550,height=495,scrollbars=1,menubar=0,toolbar=0,location=0,status=0,resizable=0');
	popup.focus();
}
function password(id) {
	var popup = window.open(id,'password','width=550,height=240,scrollbars=0,menubar=0,toolbar=0,location=0,status=0,resizable=0');
	popup.focus();
}
function report(id) {
	var popup = window.open(id,'report','width=550,height=275,scrollbars=0,menubar=0,toolbar=0,location=0,status=0,resizable=0');
	popup.focus();
}