﻿// JScript File
function RTCSubmitCB(result) {
    if (result) {
        if (result.value) {
            AL(result.value);
        }
    }
}

function RTCSubmit(clientId, contentId) {

    var rtc = dge(clientId + "_RTC");

    if (rtc) {

        var r = -1;
        var rl = rtc.getElementsByTagName('input');
        
        if (rl) {
            for (i=0; i<rl.length; i++) {
                if (rl[i]) {
                    if (rl[i].checked) {
                        r = i;
                    }
                }
            }
        }
        
        Webscene.UI.RTC.RTCSubmit(sessionId, nodeId, contentId, r, RTCSubmitCB, clientId);

    }    
}

function RTCMO(obj, value) {

    var o = obj;
    
    for(var i=0;i<10;i++) {
        if (o.parentNode) {
            o = o.parentNode;
            if (o.tagName.toUpperCase()=="DIV") {
                break;
            }
        } else {
            o = null;
            break;
        }
    }
    
    if (o) {
        o.className = 'RTCTbl' + parseInt(value);
        if (o.style) {
            
            //o.style.backgroundImage = "url('Images/Rating/star" + parseInt(value) + ".gif')";
            //o.style.backgroundRepeat = 'no-repeat';
        }
    }

}

function GetRatingCB(result) {
    if (result) {
        var clientId = result.context;
        if (result.value) {
            var rs = dge(clientId); 
            if (rs) {
                rs.innerHTML = result.value;       
            } 
        }
    }
}

function RTCClCB(result) {
    if (result) {
        var clientId = result.context;
        var contentId = gs(clientId,'cid');
        if (result.value) {
            var pList = result.value.split("|");
            if (pList.length>2) {
                AL(pList[2]);
                Webscene.UI.RTC.GetRating(parseInt(pList[0]), '', true, pList[1], clientId, contentId, GetRatingCB, clientId);
            }            
        }
    }    
}

function RTCCl(obj, clientId, contentId, value) {
    ss(clientId,'cid',contentId);
    Webscene.UI.RTC.RTCSubmit(sessionId, nodeId, contentId, parseInt(value/20), RTCClCB, clientId);
}
  
  
  
