var set=false;
var v=0;
var a;
function loadStars()
{
star1 = new Image();
star1.src = "http://www.gurux.fi/gxstarrate/star1.gif";
star2 = new Image();
star2.src= "http://www.gurux.fi/gxstarrate/star2.gif";
}

function highlight(x)
{
if (set==false)
	{
	y=x*1+1
	switch(x)
		{
		case "1": document.getElementById(x).src= star2.src;
		break;
		case "2":for (i=1;i<y;i++)
		{
		document.getElementById(i).src= star2.src;
		}
		break;
		case "3":for (i=1;i<y;i++)
		{
		document.getElementById(i).src= star2.src;
		}
		break;
		case "4":for (i=1;i<y;i++)
		{
		document.getElementById(i).src= star2.src;
		}
		break;
		case "5":for (i=1;i<y;i++)
		{
		document.getElementById(i).src= star2.src;
		}
		break;
		}
	}
}
function losehighlight(x)
{
if (set==false)
	{
	for (i=1;i<6;i++)
		{
		document.getElementById(i).src=star1.src;
		}
	}
}
function setStar(x)
{
y=x*1+1
if (set==false)
	{
	switch(x)
		{
		case "1": a="1" 
		flash(a);
		break;
		case "2": a="2" 
		flash(a);
		break;
		case "3": a="3" 
		flash(a);
		break;
		case "4":a="4" 
		flash(a);
		break;
		case "5":a="5" 
		flash(a);
		break;
		}
	//set=true;
	//window.location = "http://www.gurux.fi/index.html?star="+a+"&page=tämäsivu"
	var xmlhttp=false;
    /*@cc_on @*/
    /*@if (@_jscript_version >= 5)
    // JScript gives us Conditional compilation, we can cope with old IE versions.
    // and security blocked creation of the objects.
     try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (e) {
      try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
       xmlhttp = false;
      }
     }
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
	var iframe1 = document.getElementById('TopicContent');
	//var loc = iframe1.document.URL;
	var loc = window.frames["TopicContent"].document.URL;
    currentPage = loc.substring(loc.lastIndexOf('/')+1, loc.lastIndexOf('.'));
	xmlhttp.open("GET", "http://www.gurux.fi/gxstarrate/remote.php?page="+currentPage+"&stars=" + x,true);
    xmlhttp.onreadystatechange=function() 
    {
	    if (xmlhttp.readyState==4) 
	    {
		    //alert(xmlhttp.responseText)
	    }
    }
    xmlhttp.send(null)
	}	
}
function sendFeedback(feedback, submitter)
{
	var xmlhttp=false;
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	    try {
		    xmlhttp = new XMLHttpRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
    if (!xmlhttp && window.createRequest) {
	    try {
		    xmlhttp = window.createRequest();
	    } catch (e) {
		    xmlhttp=false;
	    }
    }
	var fb = feedback.replace("\'", "?");
	fb = fb.replace("\"", "?");
	var sb = submitter.replace("\'", "?");
	sb = sb.replace("\"", "?");
	var iframe1 = document.getElementById('TopicContent');
	//var loc = iframe1.document.URL;
	var loc = window.frames["TopicContent"].document.URL;
    var currentPage = loc.substring(loc.lastIndexOf('/')+1, loc.lastIndexOf('.'));
	xmlhttp.open("POST", "http://www.gurux.fi/gxstarrate/remote.php" ,true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.send("page="+currentPage+"&feedback=" + encodeURIComponent(fb) + "&submitter=" + encodeURIComponent(sb));
}
function flash()
{
y=a*1+1
switch(v)
	{
	case 0:
	for (i=1;i<y;i++)	
		{
		document.getElementById(i).src= star1.src;
		}
	v=1
	setTimeout(flash,200)
	break;
	case 1:	
	for (i=1;i<y;i++)	
		{
		document.getElementById(i).src= star2.src;
		}
	v=2
	setTimeout(flash,200)
	break;
	case 2:
	for (i=1;i<y;i++)	
		{
		document.getElementById(i).src= star1.src;
		}
	v=3
	setTimeout(flash,200)
	break;
	case 3:
	for (i=1;i<y;i++)	
		{
		document.getElementById(i).src= star2.src;
		}
	v=4
	setTimeout(flash,200)
	break;
	case 4:
	for (i=1;i<y;i++)	
		{
		document.getElementById(i).src= star1.src;
		}
	v=5
	setTimeout(flash,200)
	break;
	case 5:
	/*for (i=1;i<y;i++)	
		{
		document.getElementById(i).src= star2.src;
		}*/
	v=0
	//setTimeout(flash,200)
	break;
	}
}
var FloatLayers       = new Array();
var FloatLayersByName = new Array();

function FloatLayer(name, offX, offY, speed) {
this.index = FloatLayers.length;

FloatLayers.push(this);
FloatLayersByName[name] = this;

this.name    = name;
this.floatX  = 0;
this.floatY  = 0;
this.tm      = null;
this.steps   = speed;
this.alignHorizontal = (offX >= 0) ? leftFloater : rightFloater;
this.alignVertical   = (offY >= 0) ? topFloater : bottomFloater;
this.ifloatX = Math.abs(offX);
this.ifloatY = Math.abs(offY);
}

