// GSPBFA-AJAX-STUFF by Sebastian Kobbe!

Infowmtt = null;

document.onmousemove = updateWMTT;

function updateWMTT(e)
 {
     x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;                                                                  
     y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
     if (Infowmtt != null)
      {
          Infowmtt.style.left = (x ) + "px";
          Infowmtt.style.top  = (y+20)+"px"; //(y + 20) + "px";
      }                                                                                                                                            }

function showWMTT(id)
 {
			Infowmtt = document.getElementById("ToolTipDiv");
			Infowmtt.innerHTML="<b>Lade Daten vom Server..</b><br><br>Bitte einen Moment Geduld!<br><br>";
			Infowmtt.style.display = "block";
			httpReceiveInfo.abort();

			receiveInfo(id);
 }


function showWMTT_static(text)
 {
			Infowmtt = document.getElementById("ToolTipDiv");
			Infowmtt.innerHTML=text;
			Infowmtt.style.display = "block";
			httpReceiveInfo.abort();

 }

function showWMTT_static_gal(id,titel,kommentar,kommentare)
 {
			Infowmtt = document.getElementById("ToolTipDiv");
			Infowmtt.innerHTML="<h3>"+titel+"</h3>"+( (kommentare == 0) ? "Keine Kommentare" : kommentare+" Kommentare" )+"<br><img src=\"/pics/galerie_"+id+".jpg\" height=\"300px\"><br>"+kommentar+"<br>";
			Infowmtt.style.display = "block";
			httpReceiveInfo.abort();

 }



 function hideWMTT()
 {
	Infowmtt.style.display = "none";
	httpReceiveInfo.abort();
 }




var GetInfourl = "/getAjaxInfo.php";

//initiates the first data query
function receiveInfo(id) {
	if (httpReceiveInfo.readyState == 4 || httpReceiveInfo.readyState == 0) 
	{
	    httpReceiveInfo.open("GET",GetInfourl + '?ID=' + URLencode(id), true);
    	    httpReceiveInfo.onreadystatechange = handlehHttpReceiveInfo; 
  	    httpReceiveInfo.send(null);
	}
}

//deals with the servers reply to requesting new content
function handlehHttpReceiveInfo()
{
  if (httpReceiveInfo.readyState == 4)
  {
    results = httpReceiveInfo.responseText;
    if(Infowmtt)
    {
    	oDiv = document.getElementById("ToolTipDiv");
    	oDiv.innerHTML=results;
    }
  }
}


//initiates the XMLHttpRequest object
//as found here: http://www.webpasties.com/xmlHttpRequest
function getHTTPObject() {
  var xmlhttp;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.

    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
@end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}


// initiates the two objects for sending and receiving data
var httpReceiveInfo= getHTTPObject();

function URLencode(sStr)
 {
    return sStr.replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27').replace(/\//g,'%2F');
  }

