/**************************************************************************************
# Author:	Alexander Geilhaupt <alex@geilhaupt.de>
# Datei:	/js/ajax.js
# Inhalt:	Ajax Bibliothek
#
# Copyright (c) 2001 - 2007 by Alexander Geilhaupt
# All Rights reserved. Unauthorized copying is a violance against applicable laws.
# You are not allowed to remove this comment.
#
**************************************************************************************/

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 restoreMsgRequest(id,requestType)
	{
	switch(requestType)
		{
		case 'checkUser':
			var msgRequest = "<a href=\"javascript:void(0);\" onclick=\"return loadMessage('checkUser','ajaxmessages.php','handle='+document.getElementById('handle').value);\">Benutzernamen überprüfen</a>";
		break;
		}
	document.getElementById(id).innerHTML = msgRequest;
	}

function loadMessage(id,file,queryString)
	{
	document.getElementById(id).innerHTML = "<img src=\"/GHCMS/templates/speedaf/images/misc/loadmsg.gif\" alt=\"Bitte warten\" />";
	if (xmlHttp) 
		{
		xmlHttp.open('GET', '/wortnetz/includes/'+file+'?'+queryString, true);
		xmlHttp.onreadystatechange = function () 
			{
			if (xmlHttp.readyState == 4) 
				{
				document.getElementById(id).innerHTML = xmlHttp.responseText;
				}
			};
		xmlHttp.send(null);
		}
	}
	
function getEntries(wordnetId, phrase, tagId)
	{
	if(xmlHttp) 
		{
		xmlHttp.open('GET', '/GHCMS/includes/dbresults.php?qtype=getEntries&phrase='+phrase+'&wordnet_id='+wordnetId, true);
		xmlHttp.onreadystatechange = function () 
			{
			if (xmlHttp.readyState == 4) 
				{
				if(xmlHttp.responseText == "")
					{
					document.getElementById(tagId).style.display = "none";
					}
				else
					{
					document.getElementById(tagId).style.display = "block";
					}
				document.getElementById(tagId).innerHTML = xmlHttp.responseText;
				}
			};
		xmlHttp.send(null);
		}
	}

function movePhrase(wordnetId, phrase, tagId)
	{
	if(xmlHttp) 
		{
		xmlHttp.open('GET', '/GHCMS/includes/dbresults.php?qtype=movePhrase&phrase='+phrase+'&wordnet_id='+wordnetId, true);
		xmlHttp.onreadystatechange = function () 
			{
			if (xmlHttp.readyState == 4) 
				{
				if(xmlHttp.responseText == "")
					{
					document.getElementById(tagId).style.display = "none";
					}
				else
					{
					document.getElementById(tagId).style.display = "block";
					}
				document.getElementById(tagId).innerHTML = xmlHttp.responseText;
				}
			};
		xmlHttp.send(null);
		}
	}

