var arrTickColors = new Array("blue", "orange")
var maxVoteScore = 5

function showVotes(strImgName, intSiteID, intScore, blClickable){
	// if blVoted is false, then intScore is the average of all votes 
	// taken. If blVoted is true, then we know this is the user's score, 
	// and thus we should make the colors different.
	
//	var currentVoteScore = intScore
	
	// tickColor refers to the color of our voting mark (tick)
	// if the user is able to vote, it is orange. If not, it is blue.
	var tickColor = arrTickColors[blClickable]
	
	for(var x = 1; x <= maxVoteScore; x++){
		if(blClickable){
			// This is a changable poll
			var postLink = "</a>"
			var preLink = "<a href=\"javascript:logVote(" + intSiteID + ", " + x + ")\" onMouseOver=\"highlightTicks(" + x + ", '" + strImgName + "_" + intSiteID + "', '" + tickColor + "'); return window.status='Vote for this site';\"  onMouseOut=\"unHighlightTicks(" + x + ", '" + strImgName + "_" + intSiteID + "', '" + tickColor + "', " + intScore + "); return window.status='Done'\">"
		}
		else{
			var preLink = ""
			var postLink = ""
		}
		
		if((intScore > x-1) && (intScore < x)){
			document.write(preLink + "<img src=/images/sites/site_" + tickColor + "_half_vote.gif width=8 height=8 hspace=0 vspace=2 name='" + strImgName + "_" + intSiteID + "_" + x + "' border=0 \/>" + postLink)
		}
		else if(intScore > x-1){
			document.write(preLink + "<img src=/images/sites/site_" + tickColor + "_full_vote.gif width=8 height=8 hspace=0 vspace=2 name='" + strImgName + "_" + intSiteID + "_" + x + "' border=0 \/>" + postLink)
		}
		else{
			document.write(preLink + "<img src=/images/sites/site_no_vote.gif width=8 height=8 hspace=0 vspace=2 name='" + strImgName + "_" + intSiteID + "_" + x + "' border=0 \/>" + postLink)
		}
	}
}


function logVote(intSiteID, intVote){
	var voteWin = window.open("/sites/logVote.asp?site_id=" + intSiteID + "&vote=" + intVote, voteWin,"toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=340,height=225")
	location.reload()
}


function highlightTicks(intPosition, strImgID, strTickColor){
	window.status = "Vote for this site"
	// Find out which selected tick Color this tick mark is and grab the opposite color
	var strOppTickColor
	if(strTickColor != 1){
		strOppTickColor = arrTickColors[1];
	}

	for(var x = 1; x <= maxVoteScore; x++){
		window.status = "Vote for this site"
		if(x <= intPosition){
			document.images[strImgID + '_' + x].src = "/images/sites/site_" + arrTickColors[1] + "_full_vote.gif";
		}
		else{
			document.images[strImgID + '_' + x].src = "/images/sites/site_no_vote.gif"
		}
	}
}


function unHighlightTicks(intPosition, strImgID, strTickColor, intSiteScore){
	window.status = "Vote for this site"
	for(var x = 1; x <= maxVoteScore; x++){
		if((intSiteScore > x-1) && (intSiteScore < x)){
			document.images[strImgID + '_' + x].src = "/images/sites/site_" + strTickColor + "_half_vote.gif"
		}
		else if(intSiteScore > x-1){
			document.images[strImgID + '_' + x].src = "/images/sites/site_" + strTickColor + "_full_vote.gif"
		}
		else{
			document.images[strImgID + '_' + x].src = "/images/sites/site_no_vote.gif"
		}
	}
}




// this following function isn't related to voting, but everywhere that a user 
// can vote on a site, they also have the ability to contact the reseller who owns 
// that site, so this function needs to be included:

function openMailWin(intSiteID){
	var emailWin = window.open("/sites/email_reseller.asp?site_id=" + intSiteID, "emailWin", "width=400,height=400,scrollbars=yes")
}