// JavaScript Document
/* Code for article feedback form */
 // needs to be global
 var done = false;

function ratingAddStar(id) {
  if (done == true) {
    return;
  }
	for (i=1;i<=id;i++) {
		document.getElementById("star"+i).src = "images/starblue_select.png";
	}
}
/*******************************************************/
function ratingRemoveStar(id) 
{
	if (done == true) {
		return;
	}
	for (i=1;i<=id;i++) {
		document.getElementById("star"+i).src = "images/starblue.png";
		}
}
/*******************************************************/
function ratingVote(rating, id) 
{
	if (done == true) {
		return;
	}
	done = true;
	
	// select amount of stars
	for (i=1;i<=rating;i++) {
		document.getElementById("star"+i).src = "images/starblue_select.png";
		}

	request.open("GET", "support_files/ajax.php?mode=rateArticle&articleID="+id+"&rating="+rating, true);
	request.onreadystatechange = ratingAJAXResponse;
	request.send(null);
	
	
}
/*******************************************************/

function ratingAJAXResponse()
{
	// process response from ajax.php
	if (request.readyState == 4 && request.status == 200) {
		document.getElementById("starRatingResult").innerHTML = request.responseText;
	}
}
/*******************************************************/		

function popUp(URL) 
{
	// popup window support
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=270');");
}
/*******************************************************/	

function preload(image)
{
	if (document.images) {
		pic = new Image(); 
		pic.src=image;
	}
}
/*******************************************************/	

function rollImage(id, imagePath)
{
	var btn = document.getElementById(id);
	btn.src = imagePath;
}
	
