//
// Form Plugin Javascript Library
//

var form = {
    setStar : function(elementId, setWidth, clear) 
    {
        var updateElementId = '';
        var totalWidth = 0;
        var bgPosition = '';
        
        if(clear == true)
        {
            for(i = 1; i < 6;i++)
            {
                updateElementId = 'star'+i+'-'+elementId;
                totalWidth = i * 30;
                
                if(i <= setWidth)
                {
                    bgPosition = 'center';
                } else
                {
                    bgPosition = 'top';
                }
                
                $(updateElementId).setStyle(
                {
                    'width':totalWidth +"px",
                    'left': '0',
                    'background' : "url('/img/starrating.gif') left "+bgPosition+" repeat-x"
                });
            } 
            this.setStar(elementId, setWidth, false);
        }
        
        totalWidth = setWidth * 30;
        var zIndex = 101 - setWidth; 

        updateElementId = 'star'+setWidth+'-'+elementId;
        
        $(updateElementId).setStyle({
            'width':totalWidth +"px",
            'left': '0',
            'background' : "url('/img/starrating.gif') left center repeat-x",
            'z-index' : zIndex
            });
            
        // Now update the hidden element
        var hiddenInput = 'hidden'+elementId;
        $(hiddenInput).value = setWidth; 
    }
}

