﻿//string trimming.
String.prototype.Trim = function() { return this.replace(/^\s*|\s*$/g, ""); }

function SendToFriend(toEmailControlId) {
    var control = document.getElementById(toEmailControlId);
    if (control != null) {
        var email = control.value;
        var subject = 'You have received a video from Bizzibox';
        //var body_message = encodeURIComponent(window.location.href);
        var body_message = window.location.href;

        var mailto_link = 'mailto:' + email + '?subject=' + subject + '&body=' + body_message;
        win = window.open(mailto_link, '_EmailWindow');
        if (win && win.open && !win.closed) win.close();
    }
    return false;
}

function toggle() {
    var ele = document.getElementById("showdiv");
    var text = document.getElementById("displayText");
    if (ele.style.display == "block") {
        ele.style.display = "none";
        text.innerHTML = "More Choices";
    }
    else {
        ele.style.display = "block";
        text.innerHTML = "Fewer Choices";
    }
}

function tabClick(tabNumber) {
    var tabControlId, tabControl;
    var tabHrefControlId, tabHrefControl;

    for (var i = 1; i <= 5; i++) {
        tabControlId = 'tabCon' + i;
        tabHrefControlId = 'tabHref' + i;
        tabControl = document.getElementById(tabControlId);
        tabHrefControl = document.getElementById(tabHrefControlId);
        if ((tabControl != null) && (tabHrefControl != null)) {
            if (i == tabNumber) {
                tabControl.style.display = 'block';
                tabHrefControl.className = 'current';
            }
            else {
                tabControl.style.display = 'none';
                tabHrefControl.className = '';
            }
        }
    }
    return false;
}

function openTermsAndConditionRadWindow(url, id) {
    var oWnd = radopen(url, id);
    oWnd.Restore();
    return false;
}

function openUploadRadWindow(pageUrl, key, fileSaveAt) {
    var thisUrl = pageUrl + "?key=" + key + '&FileSaveAt=' + fileSaveAt;
    var oWnd = radopen(thisUrl, "uploadDialog");
    return false;
}

function openBusinessUploadRadWindow(key, asset, tab) {
    var thisUrl = "BusinessUpload.aspx?key=" + key + "&asset=" + asset + "&tab=" + tab;
    var oWnd = radopen(thisUrl, "businessUploadDialog");
    return false;
}

function CloseWindow(returnValue) {
    var oWindow = GetRadWindow();
    if (oWindow != null)
        oWindow.Close(returnValue);
    return false;
}

function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow)
        oWindow = window.radWindow;
    else if (window.frameElement.radWindow)
        oWindow = window.frameElement.radWindow;
    return oWindow;
}

function ShowUKNonUKListMyBusinessWindow(url) {
    var oWnd = radopen(url, "UKNonUKListMyBusiness");
    return false;
}

function ShowReportInappropriateWindow(url) {
    var oWnd = radopen(url, "ReportInAppropriate");
    return false;
}

function ShowAssetTranscriptWindow(url) {
    var oWnd = radopen(url, "TranscriptWindow");
    return false;
}

function BookMark() {
    var url = window.location.href;
    var title = document.title;
    if (window.sidebar) {//Firefox
        window.sidebar.addPanel(title, url, '');
    } else if (window.external) { // IE Favorite
        window.external.AddFavorite(url, title);
    }
    else {
        alert("Sorry! Your browser doesn't support this function. Please bookmark this page manually.");
        return false;
    }
    return false;
}

function Download(url) {
    window.open(url);
    return false;
}

function MouseOver(divId) {
    var div = document.getElementById(divId);
    if (div != null) {
        div.style.display = 'block';
    }
}

function MouseOut(divId) {
    var div = document.getElementById(divId);
    if (div != null) {
        div.style.display = 'none';
    }
}

function ShareVideo(url) {
    url = url.replace("[u]", encodeURIComponent(window.location.href));
    url = url.replace("[t]", encodeURIComponent(document.title));
    window.open(url, "_ShareVideo");
    return false;
}

function HidePanel(panelId) {
    var panel = document.getElementById(panelId);
    if (panel != null) {
        panel.style.display = "none"
    }
    return false;
}
function Back_OnClick(url) {
    window.location.href = url;
    return false;
}

/* added method - Amit Mishra */
function OpenRSSWindow(url) {
    window.open(url, "RSS");
    return false;
}


jQuery.extend({
    random: function(X) {
        return Math.floor(X * (Math.random() % 1));
    },
    randomBetween: function(MinV, MaxV) {
        return MinV + jQuery.random(MaxV - MinV + 1);
    }
});