<!--
function historyFunction(){
	var obj = document.getElementById('history');
	var obj2 = document.getElementById('history_img');
	if(obj.style.display=="none"){
		obj.style.display = "";
		obj2.src = "design/images/history_minus.gif";
	} else {
		obj.style.display = "none";
		obj2.src = "design/images/history_plus.gif";
	}
}

function checkForm(){
	var obj = document.pastebin_form;
	var ret = true;
	
	if(ret && obj.code.value==''){
		//alert('Please enter a code!');
		obj.code.focus();
		ret = false;
	}
	
	if(ret && obj.typ.value=='null'){
		//alert('Please select a syntax highlighting!');
		obj.typ.focus();
		ret = false;
	}
	
	if(ret && obj.emailnotify.checked&&obj.email.value==''){
		//alert('Please enter your e-mail address to receive e-mail notifications!');
		obj.email.focus();
		ret = false;
	}
	
	if(ret && obj.kennwortschutz.checked&&obj.kennwort.value==''){
		//alert('Please enter a password to protect the post and its replies!');
		obj.kennwort.focus();
		ret = false;
	}
	
	if(ret && obj.gencode_active.value=='1'){
		if(obj.gencode.value==''){
			//alert('Please select a syntax highlighting!');
			obj.gencode.focus();
			ret = false;
		} else {
			if(obj.gencode.value.length<6){
				obj.gencode.focus();
				ret = false;
			}
		}
	}
	
	if(ret){
		obj.spongebob.name = 'action';
		obj.submit();
	} else {
		obj.action.name = 'spongebob';
	}
}

/*function xstooltip_findPosX(obj){
	var curleft = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	} else if(obj.x){
		curleft += obj.x;
	}
	return curleft;
}

function xstooltip_findPosY(obj){
	var curtop = 0;
	if(obj.offsetParent){
		while(obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	} else if(obj.y) {
		curtop += obj.y;
	}
	return curtop;
}

function xstooltip_show(tooltipId, parentId, posX, posY){
	it = document.getElementById(tooltipId);
	
	if((it.style.top == '' || it.style.top == 0)&&(it.style.left == '' || it.style.left == 0)){
		// need to fixate default size (MSIE problem)
		it.style.width = it.offsetWidth + 'px';
		it.style.height = it.offsetHeight + 'px';
		
		img = document.getElementById(parentId); 
		
		// if tooltip is too wide, shift left to be within parent 
		if(posX + it.offsetWidth > img.offsetWidth){
			posX = img.offsetWidth - it.offsetWidth;
		}
		if(posX < 0 ){
			posX = 0;
		}
	
		x = xstooltip_findPosX(img) + posX;
		y = xstooltip_findPosY(img) + posY;
		
		it.style.top = y + 'px';
		it.style.left = x + 'px';
	}
	
	it.style.visibility = 'visible'; 
}

function xstooltip_hide(id){
	it = document.getElementById(id); 
	it.style.visibility = 'hidden'; 
}*/

function showTooltip(id){
		document.getElementById('tooltip_master').innerHTML = document.getElementById(id).innerHTML;
		document.getElementById('tooltip_master').style.visibility = 'visible';
}

function hideTooltip(){
	document.getElementById('tooltip_master').style.visibility = 'hidden';
}

function submitDropdown(obj, obj_form){
	if(obj.value!='null' && obj.value!='null2'){
			obj_form.submit();
	}
}

var xmlHttp = false;

// Internet Exxplorer
try {
	xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
	try {
		xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
	} catch(e) {
		xmlHttp  = false;
	}
}
// Mozilla, Opera, Safari...
if(!xmlHttp&&typeof XMLHttpRequest!='undefined'){
	xmlHttp = new XMLHttpRequest();
}

function reloadLatestPosts(){
	if(xmlHttp){
		xmlHttp.open('GET','ajax.php',true);
		xmlHttp.onreadystatechange = function(){
			//alert(xmlHttp.readyState);
			if(xmlHttp.readyState == 4){
				document.getElementById("div_recentposts").innerHTML = xmlHttp.responseText;
			}
		};
		xmlHttp.send(null);
	}
}

function tdHighlight(obj, mode){
	obj.style.backgroundColor  = (mode=='c') ? '#DEEEFC' : '';
}

function insertSmile(aTag, eTag, question, local) {
	if(local){
		//var input = window.opener.document.forms['pastebin_form'].elements['beschreibung'];
		var input = window.opener.document.getElementById('beschreibung');
	} else {
		//var input = document.forms['pastebin_form'].elements['beschreibung'];
		var input = document.getElementById('beschreibung');
	}
	input.focus();
	
	/* für Internet Explorer */
	if(typeof document.selection != 'undefined') {
		/* Einfügen des Formatierungscodes */
		var range = document.selection.createRange();
		var insText = range.text;
		range.text = aTag + insText + eTag;
		/* Anpassen der Cursorposition */
		range = document.selection.createRange();
		if(insText.length == 0) {
			range.move('character', -eTag.length);
		} else {
			range.moveStart('character', aTag.length + insText.length + eTag.length);      
		}
		range.select();
	}
	/* für neuere auf Gecko basierende Browser */
	else if(typeof input.selectionStart != 'undefined') {
		/* Einfügen des Formatierungscodes */
		var start = input.selectionStart;
		var end = input.selectionEnd;
		var insText = input.value.substring(start, end);
		input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
		/* Anpassen der Cursorposition */
		var pos;
		if(insText.length == 0) {
			pos = start + aTag.length;
		} else {
		pos = start + aTag.length + insText.length + eTag.length;
		}
		input.selectionStart = pos;
		input.selectionEnd = pos;
	}
	/* für die übrigen Browser */
	else {
	/* Abfrage der Einfügeposition */
		var pos;
		var re = new RegExp('^[0-9]{0,3}$');
		while(!re.test(pos)) {
			pos = prompt("Einfügen an Position (0.." + input.value.length + "):", "0");
		}
		if(pos > input.value.length) {
			pos = input.value.length;
		}
		/* Einfügen des Formatierungscodes */
		var insText = prompt("Bitte geben Sie den zu formatierenden Text ein:");
		input.value = input.value.substr(0, pos) + aTag + insText + eTag + input.value.substr(pos);
	}
}

var popupwin = 0;

function showPopup(url,width,height){
	var mleft = (screen.availWidth - width) / 2;
	var mtop = (screen.availHeight - height) / 2;

	if(popupwin!=0){
		popupwin.close();
	}

	popupwin = window.open(url,"popup",'location=no,menubar=no,toolbar=no,status=no,resizable=no,scrollbars=no,left='+mleft+',top='+mtop+',width='+width+',height='+height);
}

function pruefeKennwortfeld(){
	var obj = document.pastebin_form;
	
	obj.kennwort.disabled = !obj.kennwortschutz.checked;
	obj.kennwort.focus();
}

function pruefeLoeschenFeld(){
	var obj = document.pastebin_form;
	
	obj.deletepostafter.disabled = !obj.deletepost.checked;
	obj.deletepostafter.focus();
}
//-->