/**
* <pre>
* System:        Radio Station CMS Photo Competitions Module
* File:          /photocompetitions/js/photocomp.js
* Description:   Javascript required to support the photo competitions module.
* </pre>
*
* @package    radio-cms
* @subpackage photocomps-module
* @author     Ben Gibbard <ben@sad.ukrd.com>
* @version    1.0.0
* @filesource
*/

// forms module object...
var objPhotoComps = new photocomps();

/**
* Class to support the photocomps module...
*/
function photocomps()
{
    // This!
    var $this = this;
    
    this.fadeStarsIn = function(intStar, strIDAppend)
    {        
        // Bind mouse over event...
        $("#photocompEntryRating" + strIDAppend + intStar).bind("mouseenter", {star:intStar}, function(e) {
            $this.highlightStars(e.data.star);
        });
        
        // Fade the star in...
        $("#photocompEntryRating" + strIDAppend + intStar).fadeIn(750);
        if (intStar < 10) {
            window.setTimeout("objPhotoComps.fadeStarsIn(" + (intStar + 1) + ", \"" + strIDAppend + "\")", 150);
        }
        
        return true;
    }
    
    this.highlightStars = function(intStars)
    {
        for (var intStar = 1; intStar <= 10; intStar++) {
            if (intStar <= intStars) {
                // Gold star...
                $("#photocompEntryRating" + intStar + " > a > img").attr("src", "/photocompetitions/images/star.gif");
            } else {
                // Grey star...   
                $("#photocompEntryRating" + intStar + " > a > img").attr("src", "/photocompetitions/images/greystar.gif");
            }
        }
    }
}