/** Copyright (C) 2007 Nicolas Haunold / Moe **/

var xmlHttp = false;

try {
    xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
    try {
        xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        xmlHttp  = false;
    }
}

if (!xmlHttp  && typeof XMLHttpRequest != 'undefined') {
    xmlHttp = new XMLHttpRequest();
}

function switchStar(id) {
    var phpStar=document.getElementById('phpStar'+id); 
    var jsStar=document.getElementById('jsStar'+id);
    var textDrive=document.getElementById('textDrive'+id);
    
    if(jsStar.style.display == "none") {
    	textDrive.innerHTML='Doch lieber nicht';
    	jsStar.style.display="";
    	phpStar.style.display="none";	
    } else {
    	textDrive.innerHTML='Jetzt Bewerten';
    	jsStar.style.display="none";
    	phpStar.style.display="";
    }
}

function hoverVote(qid,id) {
	switch(id) {
	    case "star1":
	        document.getElementById('star1'+qid).src='img/star_full.png';
	    break;
	    
	    case "star2":
	        document.getElementById('star1'+qid).src='img/star_full.png';
            document.getElementById('star2'+qid).src='img/star_full.png';
	    break;
	    
	    case "star3":
	    	document.getElementById('star1'+qid).src='img/star_full.png';
            document.getElementById('star2'+qid).src='img/star_full.png';
            document.getElementById('star3'+qid).src='img/star_full.png';
	    break;
	    
	    case "star4":
	    	document.getElementById('star1'+qid).src='img/star_full.png';
            document.getElementById('star2'+qid).src='img/star_full.png';
            document.getElementById('star3'+qid).src='img/star_full.png';
            document.getElementById('star4'+qid).src='img/star_full.png';
	    break;
	    
	    case "star5":
	    	document.getElementById('star1'+qid).src='img/star_full.png';
            document.getElementById('star2'+qid).src='img/star_full.png';
            document.getElementById('star3'+qid).src='img/star_full.png';
            document.getElementById('star4'+qid).src='img/star_full.png';
            document.getElementById('star5'+qid).src='img/star_full.png';
	    break;
	    
	    default:
	        
	    break;
	}
	
}

function restoreVote(qid,id) {
	switch(id) {
	    case "star1":
	        document.getElementById('star1'+qid).src='img/star_empty.png';
	    break;
	    
	    case "star2":
	        document.getElementById('star1'+qid).src='img/star_empty.png';
            document.getElementById('star2'+qid).src='img/star_empty.png';
	    break;
	    
	    case "star3":
	    	document.getElementById('star1'+qid).src='img/star_empty.png';
            document.getElementById('star2'+qid).src='img/star_empty.png';
            document.getElementById('star3'+qid).src='img/star_empty.png';
	    break;
	    
	    case "star4":
	    	document.getElementById('star1'+qid).src='img/star_empty.png';
            document.getElementById('star2'+qid).src='img/star_empty.png';
            document.getElementById('star3'+qid).src='img/star_empty.png';
            document.getElementById('star4'+qid).src='img/star_empty.png';
	    break;
	    
	    case "star5":
	    	document.getElementById('star1'+qid).src='img/star_empty.png';
            document.getElementById('star2'+qid).src='img/star_empty.png';
            document.getElementById('star3'+qid).src='img/star_empty.png';
            document.getElementById('star4'+qid).src='img/star_empty.png';
            document.getElementById('star5'+qid).src='img/star_empty.png';
	    break;
	    
	    default:
	        
	    break;
	}
	
}

function saveVote(qid,id) {
 document.getElementById('textDrive'+qid).innerHTML='Bitte Warten...';
 if (xmlHttp) {
     xmlHttp.open('POST', 'vote_ajax_quote.php');
     xmlHttp.onreadystatechange = function () {
         if (xmlHttp.readyState == 4) {
         	 
             document.getElementById("textDrive"+qid).innerHTML = xmlHttp.responseText;
         }
     };
 }
 document.getElementById('jsStar'+qid).style.display="none";
 document.getElementById('phpStar'+qid).style.display="";

}

