// www.pflanzen-bild.de
// direktes voting ermöglichen
// wird eingebunden, wenn image
// Daten übergabe :: mit escape() zur Sicherheit
var WERT1 = "" ;
var WERT2 = "" ;
function wert_uebergeben(WERT1 , WERT2) {
  wert_global = WERT2 ;
  if (window.ActiveXObject) {
	try {   xmlHttp= new ActiveXObject("Msxml2.XMLHTTP");}
	catch (e) {
		  try {
			xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (e) {
		  }
	}
  } else if (window.XMLHttpRequest) {
	try {
		  xmlHttp= new XMLHttpRequest();
		} catch (e) {
	}
}

// Daten Übergabe :: mit escape() zur Sicherheit
if (xmlHttp) {
	// Anfrage für Voting ::
	WERT2  = Number(WERT2);
	if( isNaN(WERT2) == false ) {
		// alert(WERT2) ;
//		var file = "./ajax.php?bild_id=" + escape(WERT1) + "&voting=" + escape(WERT2) + "" ;
		var file = "http://www.pflanzen-bild.de/ajax.php?bild_id=" + escape(WERT1) + "&voting=" + escape(WERT2) + "" ;
//		var file = "http://localhost/www.pflanzen-bild.de/ajax.php?bild_id=" + escape(WERT1) + "&voting=" + escape(WERT2) + "" ;
	}
//	alert( file ) ;
	xmlHttp.open("GET", file , true  ) ;
	xmlHttp.onreadystatechange = daten ;
	xmlHttp.setRequestHeader("Content-Type", "text/html" ) ; // hilft im Explorer nicht !
	xmlHttp.send(null);
  }
	function daten() {
		var TEXT = "" ;
		if (xmlHttp.readyState == 4) {
			TEXT = xmlHttp.responseText ; // codierung
			// Text auflösen :: 	// statusmeldung=Vielen Dank für Ihre Bewertung|vote=3|bild_id=624
			// 1. | variablen auflösen
			// alert(TEXT) ;
			var current_rating = 0 ;

			var TEXTTEILE = TEXT.split("|");

			for (var i = 0 ; i < TEXTTEILE.length ; i++) {
				var VARIABLE = TEXTTEILE[i].split("=") ;
				var JSVARIABLE = VARIABLE[0] ;
				var WERT = VARIABLE[1] ;

				if ( JSVARIABLE == 'vote' ) {
					current_rating = (100 / 5 * WERT) ; // 100 pixel durch anzahl der sterne mal bewertungen
				}
				if ( JSVARIABLE == 'bild_id' ) {
					var bi = document.getElementById('currentrating' + WERT1);
					//alert(bi);
					bi.style.width = current_rating+"px"  ;  // Zahl ? ja 20 - 100
				}
				if ( JSVARIABLE == 'statusmeldung' ) {
					var el = document.getElementById('statusmeldung' + WERT1);
					//alert(WERT);
					el.innerHTML = '' + unescape(WERT) + ''	;	// unescape(WERT)
					el.style.background = '#FEFED7'	;
					el.style.display = 'block'	;
					el.style.visibility = 'visible'	;
					el.style.width = '200px'	;
					el.style.padding = '2px'	;
					el.style.position = 'absolute'	;
					el.style.top = '24px'	;
					el.style.textAlign = 'left'	;
					el.style.left = '0px'	;
					el.style.height = '28px'	;
					el.style.zIndex = 90	;
					setTimeout('hide('+WERT1+')' , 1000 );
				} // end if VARIABLE
				
				
			} // end for textteile |
		} // end if readyState
	} // end function daten
} // end if xmlHttp

function hide(WERT1) {
	//alert(WERT1);
	var el = document.getElementById('statusmeldung' + WERT1);
	el.style.visibility = 'hidden'	;
	el.style.display = 'none'	;
}

