//addOnloadEvent(initialise);
function initialise() 
{
	var closeButton = document.getElementById("close_window");
	var ratingDevice = document.getElementById("rating_device");
	var voted = document.getElementById("voted");
	
	if (null != voted) {
		window.close();
	}
	
	if (null != ratingDevice) 
	{
		var stars = ratingDevice.getElementsByTagName("img");
		var rating = document.getElementById("vote");
		
		
		var clickHandler = function(e) 
		{
			for (var j = 0; stars.length > j; j++) 
			{
				stars[j].src = "images/rating/off.gif";
			}
			var currentVote = 0;
			for (var j = 0; stars.length > j; j++) 
			{
				currentVote += 1;
				stars[j].src = "images/rating/on.gif";
				if (this == stars[j]) 
				{
					break;
				}
			}
			rating.value = currentVote;
		}
		
		for (var i = 0; stars.length > i; i++) 
		{
			stars[i].onclick = clickHandler;
		}
	}
	
	if (null != closeButton) {
		closeButton.onclick = function(e) {
			window.close();
		}
	}
}
	

function addOnloadEvent(fnc)
{
  if ( typeof window.addEventListener != "undefined" )
  {
    window.addEventListener( "load", fnc, false );
  }
  else if ( typeof window.attachEvent != "undefined" ) 
  {
    window.attachEvent( "onload", fnc );
  }
  else 
  {
    if ( window.onload != null ) 
    {
      var oldOnload = window.onload;
      window.onload = function ( e ) 
      {
        oldOnload( e );
        window[fnc]();
      };
    }
    else
    { 
      window.onload = fnc;
    }
  }
}