
function getE( e ) {
	if ( document.getElementById( e ) ) return document.getElementById( e );
	else return document[ e ];
	return false;
}


/*
	RATINGS FUNCTIONS
*/

function highlight( star, stars ) {
	for ( i=1, j=stars+1; i<j; i++ ) {
		if ( i <= star ) getE( "star_"+i ).className = "rating rated";
		else getE( "star_"+i ).className = "rating";
	}
}

function rate( rating ) {
	alert( rating );
}

function getRatings( rating, stars, div ) {
	displayDiv = div;
	params = "rating=" + rating + "&stars=" + stars;
	getPage( "rate.php", params );
}


/*

*/

var xmlhttp = null;
var displayDiv = "";
var seconds = new Array();

////////////////////////////////
//	BASIC AJAX LOADER					//
//		!!! POST METHOD !!!!		//
////////////////////////////////

function getPage( url, params ) {
	
	xmlhttp=null;
	if (window.XMLHttpRequest) {// code for all new browsers
  	xmlhttp=new XMLHttpRequest();
  }
	else if (window.ActiveXObject) {// code for IE5 and IE6
  	xmlhttp=new ActiveXObject( "Microsoft.XMLHTTP" );
  }
	if (xmlhttp!=null) {
// 		alert( params );
		xmlhttp.onreadystatechange=stateChange;
		xmlhttp.open('POST', url, true);
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", params.length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(params);
  }
	else {
  	alert( "Your browser does not support XMLHTTP." );
  }
}

////////////////////////////////
//	EVENT HANDLER FOR HTTP		//
//	STATE CHANGE							//
////////////////////////////////

function stateChange() {
	if (xmlhttp.readyState==4) {// 4 = "loaded"
		if (xmlhttp.status==200) {// 200 = OK
			e = getE( displayDiv );
			if ( e ) e.innerHTML = xmlhttp.responseText;
			if ( seconds.length ) {
				eval( seconds.shift() );
			}
		}
		else {
			alert("Problem retrieving XML data: " + xmlhttp.status );
		}
	}
}