﻿// JScript File

var RatingNames = new Array(5); 
RatingNames[0] = 'Very Poor';
RatingNames[1] = 'Poor';
RatingNames[2] = 'Average';
RatingNames[3] = 'Good';
RatingNames[4] = 'Excellent';
var un = 'Reviews/Control/star.gif'
var sel = 'Reviews/Control/star_sel.gif'
var ho = 'Reviews/Control/star_hover.gif'


function mouseX(evt) 
{
    if (evt.pageX) 
        return evt.pageX;
    else if (evt.clientX)
        return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    else return null;
}

function mouseY(evt) 
{
    if (evt.pageY) 
        return evt.pageY;
    else if (evt.clientY)
        return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    else return null;
}

function moveTip(cntrl, e)
{
    var T = document.getElementById(cntrl + '_divToolTip');
    T.style.left = mouseX(e);// e.x+15+document.body.scrollLeft;
    T.style.top = mouseY(e); // e.y+document.body.scrollTop;

}


function RankingOver(cntrl, id, e)
{
    var CurrentScore = document.getElementById(cntrl + '_txtValue').value
    for (i=1; i<=id; i++)
    {
        if (i>CurrentScore)
            document.getElementById(cntrl + '_Star' + i).src = jsImagePath + ho;
        else
            document.getElementById(cntrl + '_Star' + i).src = jsImagePath + sel;
    }
    ShowTT(cntrl, id, e)
}

function RankingOut(cntrl)
{
    var CurrentScore = document.getElementById(cntrl + '_txtValue').value
    for (i=1; i<=5; i++)
        document.getElementById(cntrl + '_Star' + i).src = jsImagePath + un;
    for (i=1; i<=CurrentScore; i++)
        document.getElementById(cntrl + '_Star' + i).src = jsImagePath + sel;
    HideTT(cntrl);
}

function RankingClick(cntrl, id)
{
    if (id != 0)
    {
        var CurrentScore = id
        for (i=1; i<=CurrentScore; i++)
            document.getElementById(cntrl + '_Star' + i).src = jsImagePath + sel;
        for (i=CurrentScore+1; i<=5; i++)
            document.getElementById(cntrl + '_Star' + i).src = jsImagePath + un;
    
        document.getElementById(cntrl + '_spnCurrent').innerHTML =  RatingNames[CurrentScore-1];
        document.getElementById(cntrl + '_spnCurrent').className = 'RatingCaptionText';
        document.getElementById(cntrl + '_txtValue').value = CurrentScore;
    }
    HideTT(cntrl);
}

function ShowTT(cntrl, id, e)
{
    //moveTip(cntrl, e);
    //document.getElementById(cntrl + '_divToolTip').style.visibility = 'visible';
    //document.getElementById(cntrl + '_clTip').innerHTML = RatingNames[id-1];
}

function HideTT(cntrl)
{
    document.getElementById(cntrl + '_divToolTip').style.visibility = 'hidden';
}
        
        