function addbookmark(bookmarkurl,bookmarktitle){
if (document.all)
window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

wmtt = 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 (wmtt != null) {
		wmtt.style.left = (x - 0) + "px";
		wmtt.style.top 	= (y - 150) + "px";
	}
}

function showWMTT(id) {
	wmtt = document.getElementById(id);
	wmtt.style.display = "block"
}

function hideWMTT() {
	wmtt.style.display = "none";
}


function showArea(id) {
	if (document.getElementById) {
                 document.getElementById(id).style.display='inline';
	}
}

function hideArea(id) {
	if (document.getElementById) {
                 document.getElementById(id).style.display='none';
	}
}


function clone_this(objButton)
{
    var tmpNode = objButton.form.elements[0].parentNode.cloneNode(true);
    tmpNode.style.display = 'block';
    tmpNode.childNodes[9].style.display='inline';
    var tmpElm = document.createElement('input');
    tmpElm.type = objButton.form.elements[0].type;
    tmpElm.name = objButton.form.elements[0].name;
    tmpNode.replaceChild(tmpElm,tmpNode.getElementsByTagName('input')[0]);
    objButton.form.insertBefore(tmpNode,objButton);
}

function remove_this(obj)
{
  obj.form.removeChild(obj.parentNode);
}

// Ajax Funktionen

function createRequestObject (){
         httpRQ = false;
         if (window.XMLHttpRequest) { // Mozilla, Safari,...
                 httpRQ = new XMLHttpRequest();
                 if (httpRQ.overrideMimeType) {
                         // set type accordingly to anticipated content type
                         //httpRQ.overrideMimeType('text/xml');
                         httpRQ.overrideMimeType('text/html');
                 }
         } else if (window.ActiveXObject) { // IE
                 try {
                         httpRQ = new ActiveXObject("Msxml2.XMLHTTP");
                 } catch (e) {
                         try {
                                 httpRQ = new ActiveXObject("Microsoft.XMLHTTP");
                         } catch (e) {}
                 }
         }
         return httpRQ;
         if (!httpRQ) {
                 alert('Fehler: es kann keine XMLHTTP instance ausgebaut werden!');
                 return false;
         }

}
var httpRQ = createRequestObject();

function makePOSTRequest(url, parameters) {
	httpRQ.onreadystatechange = alertContents;
      	httpRQ.open('POST', url, true);
      	httpRQ.setRequestHeader("Content-type", "application/x-www-form-urlencoded", "charset=iso-8859-1");
      	httpRQ.setRequestHeader("Content-length", parameters.length);
      	httpRQ.setRequestHeader("Connection", "close");
      	httpRQ.send(parameters);
}

function alertContents() {
      	if (httpRQ.readyState == 4) {
            	if (httpRQ.status == 200) {
            	   	//alert(httpRQ.responseText);
            		result = httpRQ.responseText;
            		document.getElementById('ergebnis').innerHTML = result;
         	} else {
            	       	alert('Es gab ein Fehler bei der Anfrage.');
         	}
      	}
}

// microblogging
function get(obj) {
      var poststr =  "&MBuser=" + encodeURI( document.getElementById("MBuser").value ) +
                    "&MBtext=" + encodeURI( document.getElementById("MBtext").value );
      makePOSTRequest('../microblog.php?job=eintrag', poststr);
}

// TV-Termine
function loadTermin(ttag){
 if (httpRQ) {
 	httpRQ.open('GET', '../tvplaner_termine.php?tag='+ttag, true);
         httpRQ.onreadystatechange = function () {
         	if (httpRQ.readyState == 4) {
             		document.getElementById("tvtermine").innerHTML = httpRQ.responseText;
         	}
     	};
     	httpRQ.send(null);
 }
}

// Voting
function DoVoting(obj) {
      var poststr =  "&Vote=" + encodeURI( document.getElementsByName("voting").value ) +
                     "&VoteUser=" + encodeURI( document.getElementById("VotingUser").value ) +
                     "&VoteCID=" + encodeURI( document.getElementById("cid").value );
      makePOSTRequest('../voting2.php', poststr);
}

function loadData(wieviele){
 if (httpRQ) {
 	httpRQ.open('GET', '../microblog.php?limit='+wieviele, true);
         httpRQ.onreadystatechange = function () {
         	if (httpRQ.readyState == 4) {
             		document.getElementById("microblog").innerHTML = httpRQ.responseText;
         	}
     	};
     	httpRQ.send(null);
 }
}