function downloadShowStatistics(pid) {
    window.open('../services/downloadstatistics.aspx?pid=' + pid, '_blank');
}
function downloadAllQuiz(pid) {
    window.open('../services/downloadallquizresult.aspx?pid=' + pid, '_blank');
}
function fullScreenPlayer() {
    var d = document.getElementById('hostedPlayer');
    if (d != null) {
        var wh = GetHeight();
        var ww = GetWidth();
        var w = new sodaAjaxWindow();
        w.caption = 'Remote Control';
        w.height = wh - 20;
        w.width = ww - 20;
        addStyle('.hiddenwindowcontrol', 'display:block');
        createWindowFromElement('hostedPlayer', w);
    }
}
function closeFullScreenPlayer() {
    addStyle('.hiddenwindowcontrol', 'display:none');
    closeAjaxWindow();
}
function postCommentFromPlayer(test) {
    document.getElementById('comment').value = test;
    postComment();
}
function downloadQuizResult(id) {
    window.open('../services/downloadquizresult.aspx?id=' + id, '_blank');
}
function showAdvancedEmbed() {
    var w = new sodaAjaxWindow();
    w.caption = 'Embeded';
    w.height = 600;
    w.width = 640;
    createWindowFromUrl('../services/professionalembed.aspx?channelID=' + m_ChannelID + '&nick=' + nickName, w);
}
function deleteProgramQuiz(programId, id) {
    if (confirm(m_AreYouSure)) {
        openUrl('../services/deleteprogramquiz.aspx?pid=' + programId + '&id=' + id);
        openProgramSurveySheet(programId);
    }
}
function deleteProgramEvent(customerId, id) {
    if (confirm(m_AreYouSure)) {
        openUrl('../services/deleteprogramevent.aspx?cid=' + customerId + '&id=' + id);
        openProgramEvents(customerId);
    }
}
function deleteProgramLink(programId, id) {
    if (confirm(m_AreYouSure)) {
        openUrl('../services/deleteprogramlink.aspx?pid=' + programId + '&id=' + id);
        openProgramLink(programId);
    }
}
function deleteVideoLink(programId, url) {
    if (confirm(m_AreYouSure)) {
        openUrl('../services/deletevideourl.aspx?pid=' + programId + '&u=' + encodeURIComponent(url));
        openProgramVideo(programId);
    }
}
function askQuiz(pid, qid) {
    openUrl('../services/sendquiztoplayer.aspx?pid=' + pid + '&id=' + qid + '&cid=' + m_ChannelID);
}
function saveProgramUrlSheet(programId) {
    if (fnFormValidate()) {
        var result = "";
        result = sendDataRequest('programUrlSheet', '../services/updateprogramvideourl.aspx');
        if (result == "") {
            openProgramVideo(programId)
            closeAjaxWindow();
        }
        else {
            alert(result);
        }
    }
}
function saveProgramEventSheet(customerId) {
    if (fnFormValidate('eventSheet')) {
        var result = "";
        result = sendDataRequest('eventSheet', '../services/updateprogramevent.aspx');
        if (result == "") {
            openProgramEvents(customerId)
            closeAjaxWindow();
        }
        else {
            alert(result);
        }
    }
}
function saveNewProgram() {
    if (fnFormValidate('formNewProgram')) {
        var result = "";
        result = sendDataRequest('formNewProgram', '../services/createprogram.aspx');
        if (result == "") {
            closeAjaxWindow();
            window.location = '../director';
        }
        else {
            var l = document.getElementById('divErrorNew');
            if (l != null) {
                l.style.display = 'inline';
            }
            l.innerHTML = postUrl('../pages/template.aspx', 'id=' + result);
        }
    }
}
function createProgramSheet(cid, pid) {
    var w = new sodaAjaxWindow();
    w.caption = 'Show';
    w.height = 500;
    w.width = 800;
    createWindowFromUrl('../services/newprogramsheet.aspx?cid=' + cid + '&pid=' + pid + '&chid=' + m_ChannelID, w);
}

function editEvent(cid, id) {
    var w = new sodaAjaxWindow();
    w.caption = 'Event';
    w.height = 200;
    w.width = 500;
    createWindowFromUrl('../services/programeventsheet.aspx?cid=' + cid + '&id=' + id, w);
}
function editVideoLink(programId, url) {
    var w = new sodaAjaxWindow();
    w.caption = 'Video Link';
    w.height = 200;
    w.width = 500;
    createWindowFromUrl('../services/programvideourlsheet.aspx?pid=' + programId + '&u=' + encodeURIComponent(url), w);
}
function resultQuiz(quizId) {
    var w = new sodaAjaxWindow();
    w.caption = 'Quiz';
    w.height = 350;
    w.width = 500;
    createWindowFromUrl('../services/programquizresult.aspx?id=' + quizId, w);
}
function saveProgramSheet() {
    if (fnFormValidate()) {
        var result = "";
        result = sendDataRequest('formPostProgram', '../services/updateprogram.aspx');
        if (result == "") {
            alert('Done!');
        }
        else {
            l.innerHTML = postUrl('template.aspx', 'id=' + result);
        }
    }
}
function openProgramStatistics(pid) {
    var f = function (v) {
        var d = document.getElementById('divStatistics');
        if (d != null) {
            d.innerHTML = v;
        }
    }
    openAsyncUrl('../services/getprogramstatistics.aspx?pid=' + pid, f);
    var c = 'openProgramStatistics(\'' + pid + '\')';
    setTimeout(c, 1000 * 60);
}
function contentRepresenter(v) {
    var d = document.getElementById('divModuleContent');
    if (d != null) {
        d.innerHTML = v;
    }
}

function openProgramMembers(programId) {
    openAsyncUrl('../services/getprogrameventmembers.aspx?pid=' + programId, contentRepresenter);
}
function openProgramEvents(customerId) {
    openAsyncUrl('../services/getprogramevents.aspx?cid=' + customerId, contentRepresenter);
}
function openProgramInfoSheet(programId) {
    openAsyncUrl('../services/getprogramsheet.aspx?pid=' + programId, contentRepresenter);
}
function openProgramSurveySheet(programId) {
    openAsyncUrl('../services/getprogramsurveys.aspx?pid=' + programId, contentRepresenter);
}
function openProgramLink(programId) {
    openAsyncUrl('../services/getprogramlinks.aspx?pid=' + programId, contentRepresenter);
}
function openProgramVideo(programId) {
    openAsyncUrl('../services/getprogramvideos.aspx?pid=' + programId, contentRepresenter);
}
function editQuiz(programId, quizId) {
    var w = new sodaAjaxWindow();
    w.caption = 'Quiz';
    w.height = 540;
    w.width = 900;
    createWindowInFrame('../services/programquizsheet.aspx?pid=' + programId + '&id=' + quizId, w);
}
function editLink(programId, linkId) {
    var w = new sodaAjaxWindow();
    w.caption = 'Link';
    w.height = 300;
    w.width = 500;
    createWindowInFrame('../services/programlinksheet.aspx?pid=' + programId + '&id=' + linkId, w);
}
function openProgramSelection(customerId, keyword) {
    closeAjaxWindowSimple();
    var w = new sodaAjaxWindow();
    w.caption = 'Program Selection';
    w.height = 520;
    w.width = 900;
    var w2 = new sodaAjaxWindow();
    w2.height = w.height + 10;
    w2.width = w.width + 10;
    createWindowInFrame('../services/searchprogram.aspx?cid=' + customerId + '&q=' + encodeURIComponent(keyword), w, w2);
}
function openStreamDirector() {
    openWindow('../director', screen.availWidth, screen.availHeight, '');
}
var parentNode;
function closeFullScreenChat() {

    addStyle('.commentbox', 'width:431px; height:194px;');
    addStyle('#chatResultTable', 'font-size: 11px;width:' + m_TableWidth + 'px');
    addStyle('.chatUserLink0', 'font-size: 11px;');
    addStyle('.chatUserLink1', 'font-size: 11px;');
    addStyle('.chatUserLink0:hover', 'font-size: 11px;');
    addStyle('.chatUserLink1:hover', 'font-size: 11px;');
    addStyle('.lighttext', 'font-size: 11px;');
    addStyle('.hiddenwindowcontrol', 'display:none');

    closeAjaxWindow();
}
function fullScreenChat() {
    var d = document.getElementById('formComment');
    if (d != null) {
        var wh = GetHeight();
        var ww = GetWidth();
        var w = new sodaAjaxWindow();
        w.caption = 'Remote Control';
        w.height = wh - 20;
        w.width = ww - 20;
        addStyle('.commentbox', 'width:100%; height:' + (wh - 50) + 'px;');
        addStyle('#chatResultTable', 'font-size: 20px;width:' + (ww - 70) + 'px');
        addStyle('.chatUserLink0', 'font-size: 20px;');
        addStyle('.chatUserLink1', 'font-size: 20px;');
        addStyle('.chatUserLink0:hover', 'font-size: 20px;');
        addStyle('.chatUserLink1:hover', 'font-size: 20px;');
        addStyle('.lighttext', 'font-size: 20px;');
        addStyle('.hiddenwindowcontrol', 'display:block');



        createWindowFromElement('tdChatControl', w);

    }
}
function GetWidth() {
    var x = 0;
    if (self.innerHeight) {
        x = self.innerWidth;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
        x = document.documentElement.clientWidth;
    }
    else if (document.body) {
        x = document.body.clientWidth;
    }
    return x;
}
function GetHeight() {
    var y = 0;
    if (self.innerHeight) {
        y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) {
        y = document.documentElement.clientHeight;
    }
    else if (document.body) {
        y = document.body.clientHeight;
    }
    return y;
}
function openRemoteControl() {
    var w = new sodaAjaxWindow();
    w.caption = 'Remote Control';
    w.height = 543;
    w.width = 786;
    var w2 = new sodaAjaxWindow();
    w2.height = w.height + 10;
    w2.width = w.width + 10;
    createWindowInFrame2('../remote', w, w2);
}
function rssReader(url, oid, mid) {
    var f = function (v) {
        var d = document.getElementById(oid);
        if (d != null) {
            d.innerHTML = v;
        }
    }
    openAsyncUrl('../pages/rss.aspx?u=' + url + '&moduleId=' + mid, f);
}
function setDropdownItem(id, v) {
    var ddl = document.getElementById(id);
    if (ddl != null) {

        for (var i = 0; i < ddl.options.length; i++) {
            if (ddl.options[i].value.toLowerCase() == v.toString().toLowerCase()) {
                ddl.selectedIndex = i;
                break;
            }
        }
    }
}

function predefinedColors(color, nickName) {
    var val = new Array();
    switch (color) {
        case 'white':
            //Background
            val.push('#FFFFFF');
            //Text
            val.push('#777777');
            //Link
            val.push('#000000');
            //Image Border
            val.push('#F8F8F8');
            //ScrollBar
            val.push('#F1F1F1');
            //ScrollBar Background
            val.push('#FFFFFF');
            //Tab BackGround
            val.push('#F1F1F1');
            //Tab Text
            val.push('#A9A9A9');
            //Tab Selected Text
            val.push('#000000');
            //Chat Background
            val.push('#F1F1F1');
            //Chat Border
            val.push('#000000');
            //Chat Link
            val.push('#FFFFFF');
            //Chat Alternate Link
            val.push('#000000');
            break;
        case 'red':
            //Background
            val.push('#AB0005');
            //Text
            val.push('#FFFFFF');
            //Link
            val.push('#FFA780');
            //Image Border
            val.push('#F8F8F8');
            //ScrollBar
            val.push('#CB301C');
            //ScrollBar Background
            val.push('#AB0005');
            //Tab BackGround
            val.push('#FFFFFF');
            //Tab Text
            val.push('#000000');
            //Tab Selected Text
            val.push('#AB0005');
            //Chat Background
            val.push('#000000');
            //Chat Border
            val.push('#FFA780');
            //Chat Link
            val.push('#AB0005');
            //Chat Alternate Link
            val.push('#CB301C');
            break;

        case 'blue':
            //Background
            val.push('#2B8DCD');
            //Text
            val.push('#000000');
            //Link
            val.push('#FFFFFF');
            //Image Border
            val.push('#FFFFFF');
            //ScrollBar
            val.push('#87D8FF');
            //ScrollBar Background
            val.push('#2B8DCD');
            //Tab BackGround
            val.push('#000000');
            //Tab Text
            val.push('#FFFFFF');
            //Tab Selected Text
            val.push('#87D8FF');
            //Chat Background
            val.push('#FFFFFF');
            //Chat Border
            val.push('#87D8FF');
            //Chat Link
            val.push('#87D8FF');
            //Chat Alternate Link
            val.push('#000000');
            break;
        case 'gray':
            //Background
            val.push('#F1F1F1');
            //Text
            val.push('#777777');
            //Link
            val.push('#000000');
            //Image Border
            val.push('#F8F8F8');
            //ScrollBar
            val.push('#F9F9F9');
            //ScrollBar Background
            val.push('#E8E8E8');
            //Tab BackGround
            val.push('#FFFFFF');
            //Tab Text
            val.push('#777777');
            //Tab Selected Text
            val.push('#A0C12B');
            //Chat Background
            val.push('#FFFFFF');
            //Chat Border
            val.push('#E2E2E2');
            //Chat Link
            val.push('#A0C12B');
            //Chat Alternate Link
            val.push('#000000');
            break;
        case 'black':
            //Background
            val.push('#000000');
            //Text
            val.push('#777777');
            //Link
            val.push('#FFFFFF');
            //Image Border
            val.push('#FFFFFF');
            //ScrollBar
            val.push('#303030');
            //ScrollBar Background
            val.push('#000000');
            //Tab BackGround
            val.push('#303030');
            //Tab Text
            val.push('#777777');
            //Tab Selected Text
            val.push('#CCC12B');
            //Chat Background
            val.push('#000000');
            //Chat Border
            val.push('#303030');
            //Chat Link
            val.push('#CCC12B');
            //Chat Alternate Link
            val.push('#FFFFFF');
            break;
        case 'khaki':
            //Background
            val.push('#CBC12B');
            //Text
            val.push('#000000');
            //Link
            val.push('#FFFFFF');
            //Image Border
            val.push('#F8F8F8');
            //ScrollBar
            val.push('#000000');
            //ScrollBar Background
            val.push('#FFFFFF');
            //Tab BackGround
            val.push('#000000');
            //Tab Text
            val.push('#FFFFFF');
            //Tab Selected Text
            val.push('#CBC12B');
            //Chat Background
            val.push('#F1F1F1');
            //Chat Border
            val.push('#000000');
            //Chat Link
            val.push('#FFFFFF');
            //Chat Alternate Link
            val.push('#000000');
            break;
        case 'green':
            //Background
            val.push('#2BCB58');
            //Text
            val.push('#CBFEEF');
            //Link
            val.push('#007249');
            //Image Border
            val.push('#F8F8F8');
            //ScrollBar
            val.push('#CBFEEF');
            //ScrollBar Background
            val.push('#2BCB58');
            //Tab BackGround
            val.push('#FFFFFF');
            //Tab Text
            val.push('#00A477');
            //Tab Selected Text
            val.push('#000000');
            //Chat Background
            val.push('#2BCB58');
            //Chat Border
            val.push('#CBFEEF');
            //Chat Link
            val.push('#FFFFFF');
            //Chat Alternate Link
            val.push('#000000');
            break;
    }
    updateColorFields(val);
    updateEmbedCode(nickName);
}
function updateColorFields(a) {
    var d = document.getElementById('trConfiguration');
    if (d != null) {
        var coll = d.getElementsByTagName('INPUT');
        for (var i = 0; i < coll.length; i++) {
            coll[i].value = a[i];
        }
    }
}
function updateEmbedCode(nickName) {
    var defaultEmbed = '<iframe src="' + createPreviewUrl(nickName) + '" width="790" allowtransparency="true" vspace="0" hspace="0" marginheight="0" marginwidth="0" height="340" frameborder="0" scrolling="no"></iframe>';
    var d = document.getElementById('customizedEmbed');
    if (d != null) {
        d.value = defaultEmbed;
    }
}
function previewEmbedUrl(nickName) {
    openWindowWithScroll(createPreviewUrl(nickName), '790', '370', '');
}
var embedPrefix = 'embed';
function createPreviewUrl(nickName) {
    var url = m_ServerUrl + embedPrefix + '/' + nickName;
    var parameters = '';
    var d = document.getElementById('trConfiguration');
    if (d != null) {
        var coll = d.getElementsByTagName('INPUT');
        for (var i = 0; i < coll.length; i++) {
            if (parameters != '') parameters += '&';
            if (coll[i].id != '') {
                parameters += coll[i].id + '=' + encodeURIComponent(coll[i].value); //.replace('#', '');
            }
        }
    }
    var a = false;
    d = document.getElementById('trConfiguration2');
    if (d != null) {
        var coll = d.getElementsByTagName('INPUT');
        for (var i = 0; i < coll.length; i++) {
            a = false;
            if (coll[i].type == 'checkbox') {
                if (coll[i].checked) a = true;
            } else {
                a = true;
            }
            if (a) {
                if (parameters != '') parameters += '&';
                if (coll[i].id != '') {
                    parameters += coll[i].id + '=' + encodeURIComponent(coll[i].value); //.replace('#', '');
                }
            }
        }
    }
    return url + '?' + parameters;
}
function loginOpenID() {
    var w = new sodaAjaxWindow();
    w.caption = 'OpenID Login';
    w.height = 250;
    w.width = 550;
    createWindowInFrame('../services/openid.aspx', w);
}
function importContacts() {
    var l = document.getElementById('placeHolderImportFriend');
    if (l != null) {
        if (l.style.display == 'inline') {
            l.style.display = 'none';
        } else {
            l.style.display = 'inline';
        }
        var callBack = function (v) {
            var d = document.getElementById('placeHolderImportFriend');
            if (d != null) {
                d.innerHTML = v;
            }
        }
        l.innerHTML = createLoadingAnimation(100);
        openAsyncUrl('../services/findfriend.aspx', callBack);
    }
}
function authImportContacts() {
    var l = document.getElementById('divImportContractResult');
    if (l != null) {
        l.innerHTML = createLoadingAnimation(100);
        var r = sendDataRequest('divImportFriend', '../services/findfriendtable.aspx');
        l.innerHTML = r;
    }
}
function addImportedFriend(email) {
    var l = document.getElementById('inviteFriends');
    if (l != null) {
        if (l.innerHTML.toLowerCase().indexOf(email.toLowerCase()) == -1) {
            l.innerHTML += email + ',';
        }
    }
}
function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}

function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; }
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function MM_showHideLayers() { //v6.0
    var i, p, v, obj, args = MM_showHideLayers.arguments;
    for (i = 0; i < (args.length - 2); i += 3) if ((obj = MM_findObj(args[i])) != null) {
        v = args[i + 2];
        if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v; }
        obj.visibility = v;
    }
}
function MM_setTextOfTextfield(objName, x, newText) { //v3.0
    var obj = MM_findObj(objName); if (obj) obj.value = newText;
}

function MM_setTextOfLayer(objName, x, newText) { //v4.01
    if ((obj = MM_findObj(objName)) != null) with (obj)
        if (document.layers) { document.write((newText)); document.close(); }
        else innerHTML = unescape(newText);
}

function openModal(url, w_width, w_height, params) {
    if (params)
        params = '?' + params;
    window.name = 'random' + parseInt(Math.random() * 100000);
    window.showModalDialog(url + params, window, 'dialogHeight:' + w_height + 'px;dialogWidth:' + w_width + 'px;center:yes;status:no;resizeable:yes;scroll:no');
}
function openWindow(url, w_width, w_height, params) {
    if (params)
        params = '?' + params;
    var name = 'random' + parseInt(Math.random() * 100000);
    var w = window.open(url + params, name, 'menubar=0,resizable=0, scrollbars=0,top=0,left=0,width=' + w_width + ',height=' + w_height + ',left=' + parseInt((screen.availWidth - w_width) / 2) + ',top=' + parseInt((screen.availHeight - w_height) / 2));
    w.opener = self;
}
function openWindowWithScroll(url, w_width, w_height, params) {
    if (params)
        params = '?' + params;
    var name = 'random' + parseInt(Math.random() * 100000);
    var w = window.open(url + params, name, 'menubar=0,resizable=0, scrollbars=1,top=0,left=0,width=' + w_width + ',height=' + w_height + ',left=' + parseInt((screen.availWidth - w_width) / 2) + ',top=' + parseInt((screen.availHeight - w_height) / 2));
    w.opener = self;
}
var activityTimer = null;
function activityTracker() {
    var u = encodeURIComponent(window.location.href);
    openAsyncUrl2('../services/log.aspx?u=' + u);
    setTimeout('activityTracker()', 60000);
}
function shareIt() {
    var w = new sodaAjaxWindow();
    w.caption = 'Message';
    w.height = 550;
    w.width = 410;
    var parameters = '?u=' + encodeURIComponent(this.location.href) + '&title=' + encodeURIComponent(document.title);

    createWindowFromUrl('../services/sendmailform.aspx' + parameters, w);
}
function showCustomizeEmbed(nickName) {
    var w = new sodaAjaxWindow();
    w.caption = 'Embeded';
    w.height = 600;
    w.width = 640;
    createWindowFromUrl('../services/customizeembed.aspx?channelID=' + m_ChannelID + '&nick=' + nickName, w);
}
function showEmbed(programId) {
    var w = new sodaAjaxWindow();
    w.caption = 'Embeded';
    w.height = 400;
    w.width = 410;
    createWindowFromUrl('../services/embeded.aspx?channelID=' + m_ChannelID + '&programID=' + programId, w);
}
function showLiveAlert() {
    var w = new sodaAjaxWindow();
    w.caption = 'Live Alert';
    w.height = 400;
    w.width = 410;
    createWindowFromUrl('../services/livealert.aspx', w);
}
function showReminder(id, name, startdate) {
    var w = new sodaAjaxWindow();
    w.caption = 'Reminder';
    w.height = 340;
    w.width = 410;
    createWindowFromUrl('../services/reminder.aspx?programID=' + id + "&programName=" + encodeURIComponent(name) + "&startdate=" + startdate, w);
}
function showInviteFriend() {
    var w = new sodaAjaxWindow();
    w.caption = 'Invite Friends';
    w.height = 480;
    w.width = 410;
    createWindowFromUrl('../services/invite.aspx', w);
}
function showSendFeedBack(t) {
    var w = new sodaAjaxWindow();
    w.caption = 'Add Comment';
    w.height = 580;
    w.width = 410;
    createWindowFromUrl('../services/sendfeedback.aspx?type=' + t, w);
}
function addComment(customerID) {
    var w = new sodaAjaxWindow();
    w.caption = 'Add Comment';
    w.height = 400;
    w.width = 410;
    createWindowFromUrl('../services/profilecomment.aspx?customerID=' + customerID, w);
}
function showMomentImage(cid, programName, duration, imageUrl) {
    var w = new sodaAjaxWindow();
    w.caption = 'Show Image';
    w.height = 480;
    w.width = 470;
    imageUrl = imageUrl.toLowerCase().replace(/.jpg/g, '_big.jpg');
    createWindowFromUrl('../services/previewmoment.aspx?programName=' + encodeURIComponent(programName) + '&duration=' + duration + '&imageUrl=' + encodeURIComponent(imageUrl) + "&cid=" + cid, w);
}
function sendMessage(customerName) {
    var w = new sodaAjaxWindow();
    w.caption = 'Message';
    w.height = 540;
    w.width = 410;
    createWindowFromUrl('../services/sendmessage.aspx?customerName=' + customerName, w);
}
function showAbuse() {
    var w = new sodaAjaxWindow();
    w.caption = 'Embeded';
    w.height = 500;
    w.width = 410;
    createWindowFromUrl('../services/reportabuse.aspx', w);
}
function saveShareIt() {
    if (fnFormValidate()) {
        sendDataRequest('shareForm', '../services/sendmail.aspx');
        closeAjaxWindow();
    }
}
function closeShareIt() {
    var l = document.getElementById('shareItLayer');
    if (l != null) l.style.display = 'none';
}
function sendProfileComment() {
    if (fnFormValidate()) {
        sendDataRequest('formPostMessage', '../services/addprofilecomment.aspx');
        closeAjaxWindow();
    }
}
function sendDirectMessage() {
    if (fnFormValidate()) {
        sendDataRequest('formPostMessage', '../services/addmessage.aspx');
        closeAjaxWindow();
    }
}
function sendInvitation() {
    if (fnFormValidate()) {
        sendDataRequest('inviteForm', '../services/processinvite.aspx');
        closeAjaxWindow();
    }
}
function sendFeedback() {
    var ddl = document.getElementById('type');
    var hiddenField = document.getElementById('hiddenId');
    if ((ddl != null) && (hiddenField != null)) {
        hiddenField.value = ddl.options[ddl.selectedIndex].text;
    }
    if (fnFormValidate()) {
        sendDataRequest('sendfeedbackform', '../services/processfeedback.aspx');
        closeAjaxWindow();
    }
}
function sendReportAbuse() {
    var ddl = document.getElementById('subject');
    var hidden = document.getElementById('subjectField');
    if ((ddl != null) && (hidden != null)) {
        hidden.value = ddl.options[ddl.selectedIndex].text;
    }
    if (fnFormValidate()) {
        sendDataRequest('reportabuseForm', '../services/processreportabuse.aspx');
        closeAjaxWindow();
    }
}

function createCSS(selector, declaration) {
    // test for IE
    var ua = navigator.userAgent.toLowerCase();
    var isIE = (/msie/.test(ua)) && !(/opera/.test(ua)) && (/win/.test(ua));

    // create the style node for all browsers
    var style_node = document.createElement("style");
    style_node.setAttribute("type", "text/css");
    style_node.setAttribute("media", "screen");

    // append a rule for good browsers
    if (!isIE) style_node.appendChild(document.createTextNode(selector + " {" + declaration + "}"));

    // append the style node
    document.getElementsByTagName("head")[0].appendChild(style_node);

    // use alternative methods for IE
    if (isIE && document.styleSheets && document.styleSheets.length > 0) {
        var last_style_node = document.styleSheets[document.styleSheets.length - 1];
        if (typeof (last_style_node.addRule) == "object") last_style_node.addRule(selector, declaration);
    }
}
function translateContent(s) {
    return s.replace(/(&apos;)/g, '\'').replace(/(&quot;)/g, '"');
}

function layerCorrection(layer) {
    var l = document.getElementById(layer);
    if (l != null) {
        l.style.height = document.body.scrollHeight >= document.body.offsetHeight ? (document.body.scrollHeight + 32) + 'px' : document.body.offsetHeight + 'px';
    }
}
var m_FriendTextBox = '';
var m_FriendSearchPlaceHolder = '';
function searchFriendForm(placeHolder, textbox) {
    m_FriendTextBox = textbox;
    var d = document.getElementById(m_FriendSearchPlaceHolder);
    if ((m_FriendSearchPlaceHolder != placeHolder) && (m_FriendSearchPlaceHolder != '')) {
        d.style.display = 'none';
        d.innerHTML = '';
    }
    m_FriendSearchPlaceHolder = placeHolder;
    d = document.getElementById(m_FriendSearchPlaceHolder);
    if (d != null) {
        d.style.display = d.style.display == 'none' ? 'inline' : 'none';
        if (d.style.display == 'inline') {
            d.innerHTML = createLoadingAnimation(100); ;
            var cb = function (v) {
                var d = document.getElementById(m_FriendSearchPlaceHolder);
                if (d != null) {
                    d.innerHTML = v;
                    searchFriends();
                }
            }
            openAsyncUrl('../services/searchfriends.aspx', cb);
        } else {
            m_FriendTextBox = '';
        }
    }
}
var m_Searching = false;
function searchFriends() {
    var d = document.getElementById('searchFriendResult');
    if (d != null) {
        var keyword = document.getElementById('queryfriends');
        if (keyword != null) {
            var callBack = function (v) {
                var d = document.getElementById('searchFriendResult');
                if (d != null) {
                    d.innerHTML = v;
                    m_Searching = false;
                }
            }
            d.innerHTML = createLoadingAnimation(100); ;
            if (!m_Searching) {
                openAsyncUrl('../services/searchfriendstable.aspx?keyword=' + keyword.value, callBack);
                m_Searching = true;
            }
        }
    }
}
function addFriend(name) {
    name = trimAll(name);
    if (name) {
        var friends = document.getElementById(m_FriendTextBox);
        if (friends != null) {
            if (friends.value.indexOf(name + ', ') == -1) {
                friends.value += name + ', ';
            }
        }
    }
}
function trimAll(s) {
    while (s.substring(0, 1) == ' ') {
        s = s.substring(1, s.length);
    }
    while (s.substring(s.length - 1, s.length) == ' ') {
        s = s.substring(0, s.length - 1);
    }
    return s;
}
//Added by Robert Vastag 2008.03.04.
function saveChannelLogo(customerid, imageurl) {
    try {
        var result = '';
        result = postUrl('../services/updatechannellogo.aspx', 'customerid=' + customerid + '&imageurl=' + imageurl);

        closeAjaxWindow();
    }
    catch (e) {
        //alert(e.Message);
    }
}
function sendReminder() {
    var ddl = document.getElementById('reminder');
    var hidden = document.getElementById('reminderTime');
    if ((ddl != null) && (hidden != null)) {
        hidden.value = ddl.options[ddl.selectedIndex].text;
    }
    if (fnFormValidate()) {
        sendDataRequest('formReminder', '../services/processreminder.aspx');
        closeAjaxWindow();
    }
}
function changeLanguage(o) {
    if (o != null) {
        var u = '../pages/setlanguage.aspx?lang=' + o.options[o.selectedIndex].value + '&u=' + encodeURIComponent(window.location);
        window.location = u;
    }
}
