// ############################################################################
// #
// # (c)   Markus Wolf, 1998-2006  |  info@interaktiv.net
// #       iAn interAKTIVnet GmbH  |  http://www.interaktiv.net
// #       Tel. 07031-714740       |  Fax. 07031-714744
// #
// ############################################################################
// #
// #  Diese Software ist das Eigentum der iAn interAKTIVnet GmbH und nach dem 
// #  Urheberrecht geschützt - es  handelt sich NICHT um Freeware. Jede Nutzung 
// #  der Software ohne eine gültige Lizenzvereinbarung, wird zivil- und 
// #  strafrechtlich verfolgt.
// #
// #  This Software is the property of iAn interAKTIVnet GmbH and is protected 
// #  by copyright law - it is NOT Freeware. Any unauthorized use of this 
// #  software without a valid license is a violation of the license agreement 
// #  and will be prosecuted by civil and criminal law.
// #
// #  Dieses Script darf von jedermann kostenlos benutzt und geändert werden, 
// #  solange dieser Copyright-Verweis, der Link bei der Ausgabe und die 
// #  restlichen Kommentare erhalten  bleiben. Mit dem Einsatz dieses Skripts 
// #  akzeptieren Sie, daß die interAKTIVnet GmbH von jeglicher Haftung und 
// #  Gewährleistung hinsichtlich des Einsatzes befreit ist.
// #
// #  Weitere Infos : http://www.perlunity.de/perl/scripts/download.shtml
// # 
// #  Der Verkauf dieses Skripts, auch in modifizierter Form, ist ohne
// #  vorherige Absprache ausdrücklich untersagt.
// # 
// #  Um dieses Skript über das Internet oder irgendein anderes Medium
// #  weiterzuverbreiten, benötigen Sie vorher meine Erlaubnis. In jeden Fall
// #  müssen der Copyright-Verweis und die restlichen Kommentare erhalten 
// #  bleiben.
// #
// ############################################################################
// #
// #  PERLUNITY.DE : perlunity.ajax.shoutbox
// #
// ############################################################################


// Perl-Script-URL
var scriptURL = '../../cgi-bin/shoutbox/shoutbox.cgi' ;

// Refreshrate in Sekunden
var scriptREFRESH = 10 ;

// XMLHttpRequest-Instanz
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();
}


// aktuelle Daten laden
loadShoutbox();


// Box-Refresh
setInterval( "loadShoutbox()" , scriptREFRESH*1000 );


// Shoutbox laden
function loadShoutbox() {
	
 	if (xmlHttp) {
 	
 		var timestamp = new Date().getTime() ;
     	xmlHttp.open('GET' , scriptURL + '?func=shoutout&nocache=' + timestamp , true) ;
     	xmlHttp.onreadystatechange = function () {
        
    	    if (xmlHttp.readyState == 4) {
        		document.getElementById("shoutbox_outputtext").innerHTML = xmlHttp.responseText ;
			}
    	}
    
        xmlHttp.send(null) ;
 	}
}


// Shoutbox speichern
function saveShoutbox() {

	if (xmlHttp) {

		// Timestamp für Nocache    
    	var timestamp = new Date().getTime() ;
    	
    	// Post absetzen
    	xmlHttp.open('POST', scriptURL) ;
    	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') ;

		// Textfeld leeren und Focus setzen
		xmlHttp.onreadystatechange = function () {
        
    	    if (xmlHttp.readyState == 4) {
        		
        		document.ShoutboxForm.shouttext.value = '' ;
        		
        		if (!document.ShoutboxForm.shoutname.value) {
        			document.ShoutboxForm.shoutname.focus() ;
        		} else {
					document.ShoutboxForm.shouttext.focus() ;
				}
	
				// Box direkt neu laden			
				loadShoutbox() ;
			}
    	}
    	
    	// Parameter schicken
    	xmlHttp.send('sbname='+document.ShoutboxForm.shoutname.value+'&sbtext='+document.ShoutboxForm.shouttext.value+'&nocache='+timestamp) ;
	}
}


//END - AJAX -PERL - SHOUTBOX