/**
 * @author PacMan / Bob
 */

var xmlhttp_edittut;
function editTut_AJAX(id){
	xmlhttp_edittut = null;
	if (window.XMLHttpRequest){// code for all new browsers
		xmlhttp_edittut = new XMLHttpRequest();
	}else if (window.ActiveXObject){// code for IE5 and IE6
		xmlhttp_edittut = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp_edittut!=null){
		var title = Base64.encode(document.getElementById('et_title').value);
		var cat = document.getElementById('et_cat').value;
		var forum = document.getElementById('et_forum').value;
		var cont = Base64.encode(document.getElementById('et_cont').value);
		var emot = document.getElementById('et_emoticons').checked;
		var bb = document.getElementById('et_bbcode').checked;
		var html = document.getElementById('et_html').checked;
		url = "js/AJAX/et_edit.php?id="+id+"&title="+title+"&cat="+cat+"&forum="+forum+"&cont="+cont+"&emot="+emot+"&bb="+bb+"&html="+html;
		xmlhttp_edittut.onreadystatechange=state_Change_editTut;
		xmlhttp_edittut.open("GET",url,true);
		xmlhttp_edittut.send(null);
		return false;
	}else{
		alert("Your browser does not support XMLHTTP.");
	}
}

function state_Change_editTut(){
	if(xmlhttp_edittut.readyState==4){// 4 = "loaded"
		if(xmlhttp_edittut.status==200){// 200 = "OK"
			eval(xmlhttp_edittut.responseText)
		}else{
			alert("Problem retrieving XML data:" + xmlhttp_edittut.statusText);
		}
	}
}


var xmlhttp_edittutpreview;
function edittutPreview_AJAX(){
	xmlhttp_edittutpreview = null;
	if (window.XMLHttpRequest){// code for all new browsers
		xmlhttp_edittutpreview = new XMLHttpRequest();
	}else if (window.ActiveXObject){// code for IE5 and IE6
		xmlhttp_edittutpreview = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp_edittutpreview!=null){
		var cont = Base64.encode(document.getElementById('et_cont').value);
		var emot = document.getElementById('et_emoticons').checked;
		var bb = document.getElementById('et_bbcode').checked;
		var html = document.getElementById('et_html').checked;
		url = "js/AJAX/at_preview.php?cont="+cont+"&emot="+emot+"&bb="+bb+"&html="+html;
		xmlhttp_edittutpreview.onreadystatechange=state_Change_addTutPreview;
		xmlhttp_edittutpreview.open("GET",url,true);
		xmlhttp_edittutpreview.send(null);
		return false;
	}else{
		alert("Your browser does not support XMLHTTP.");
	}
}

function state_Change_addTutPreview(){
	if(xmlhttp_edittutpreview.readyState==4){// 4 = "loaded"
		if(xmlhttp_edittutpreview.status==200){// 200 = "OK"
			eval(xmlhttp_edittutpreview.responseText)
		}else{
			alert("Problem retrieving XML data:" + xmlhttp_edittutpreview.statusText);
		}
	}
}