
var sMax;	// Isthe maximum number of stars
var holder; // Is the holding pattern for clicked state
var preSet; // Is the PreSet value onces a selection has been made
var rated;
var saved_rating;

// Rollover for image Stars //
function rating(num, one_or_two){
	document.getElementById("rateStatus" + one_or_two).style.color = "#333";
	sMax = 0;	// Isthe maximum number of stars
	for(n=0; n<num.parentNode.childNodes.length; n++){
		if(num.parentNode.childNodes[n].nodeName == "A"){
			sMax++;	
		}
	}
	
	
		s = num.id.replace("rating_" + one_or_two, ''); // Get the selected star
		a = 0;
		for(i=1; i<=sMax; i++){		
			if(i<=s){
				document.getElementById("rating_" + one_or_two +i).className = "on";
				document.getElementById("rateStatus"+ one_or_two).innerHTML = num.title;	
				holder = a+1;
				a++;
			}else{
				document.getElementById("rating_" + one_or_two +i).className = "";
			}
		}
	
}

// For when you roll out of the the whole thing //
function off(me, one_or_two){
	
		if(!preSet){	
			for(i=1; i<=sMax; i++){		
				document.getElementById("rating_" + one_or_two +i).className = "";
				if (me.parentNode.title!="") { document.getElementById("rateStatus" + one_or_two).innerHTML = me.parentNode.title; } 
				else { 
				document.getElementById("rateStatus" + one_or_two).innerHTML = "";	
				//document.getElementById("rateStatus" + one_or_two).innerHTML = "<img src=\"http://www.allakartor.se/graphics/small_left_arrow.gif\"> klicka på en stjärna!";
				} 
				
			}
		}else{
			rating(preSet, one_or_two);
			document.getElementById("rateStatus" + one_or_two).innerHTML = saved_rating;
		}
	
}

// When you actually rate something //
function rateIt(me, one_or_two){
	
		if ( document.getElementById("post") ) { document.getElementById("post").style.border = "1px solid #777"; }
		
		document.getElementById("rateStatus" + one_or_two).innerHTML = me.title;
		saved_rating = me.title;
		preSet = me;
		rated=1;
		sendRate(me);
		rating(me, one_or_two);
		
		// if (comment_part_2_loaded=="no" && one_or_two=="_1_") 
		// { load_textarea_box(); comment_part_2_loaded="yes"; }
	
}

// Send the rating information somewhere using Ajax or something like that.
function sendRate(sel){
	our_review_grade = sel.title;
	//alert("Your rating was: "+sel.title);
}

function thumb_1(thumb_id, thumb_action){
	document.getElementById("thumb_alarm_" + thumb_id).style.backgroundColor='#FFF';
	document.getElementById("thumb_alarm_" + thumb_id).style.color='#333';
	if(thumb_action==3){document.getElementById("thumb_alarm_" + thumb_id).innerHTML = "&nbsp;" + text_follow_it + ".&nbsp;";}
	if(thumb_action==2){document.getElementById("thumb_alarm_" + thumb_id).innerHTML = "&nbsp;" + text_thumbs_up + "!&nbsp;";}
	if(thumb_action==1){document.getElementById("thumb_alarm_" + thumb_id).innerHTML = "&nbsp;" + text_thumbs_down + ".&nbsp;";}
	if(thumb_action==0){document.getElementById("thumb_alarm_" + thumb_id).innerHTML = "&nbsp;" +  text_thumbs_flag + ".&nbsp;";}
}
function thumb_0(thumb_id){
	document.getElementById("thumb_alarm_" + thumb_id).innerHTML = "";
}