﻿
// Access types
var atPublic = 1;
var atPPV = 2;
var atPrivate = 3;

//Securable Object Type - Client-side definition only
//New types must first be defined in the core object
var SecurableObjectType= new Array(); 
SecurableObjectType["BroadcastProfile"] = 0;     // Specifies object is a Broadcast Profile 
SecurableObjectType["RecordedPresentation"] = 1; // Specifies object is a Recorded Presentation 
SecurableObjectType["Blog"] = 2;                 // Specifies object is the Blog Page 
SecurableObjectType["Podcast"] = 3;              // Specifies object is the Blog Page  
SecurableObjectType["MusicPage"] = 4;            // Specifies object is the Music Page 
SecurableObjectType["VideosPage"] = 5;           // Specifies object is the Videos Page 
SecurableObjectType["PicturesPage"] = 6;         // Specifies object is the Pictures Page 
SecurableObjectType["VideoClip"] = 7;            // Specifies object is a Video Clip
SecurableObjectType["AudioClip"] = 8;            // Specifies object is an Audio Clip
SecurableObjectType["Picture"] = 9;              // Specifies object is a Picture
SecurableObjectType["SharedVaultFolder"] = 10;   // Specifies object is a Shared Vault Folder 
SecurableObjectType["BlogEntry"] = 11;           // Specifies object is a Blog Entry
SecurableObjectType["PodcastEpisode"] = 12;      // Specifies object is a Podcast Episode

// Payment modes
var pmNoPayment = 0;
var pmSingleView = 1;
var pmMultiView = 2;


function initPageGeneral()
{
    buildMenus();
	initShortcutsMenu();
    window.onresize = windowResized;
    
    if (document.getElementById('imPagerMenu')) {
        startIM();
    }
    
	if (typeof(initIndividualPage)!="undefined") initIndividualPage();
	
	//Set alert handling
	window.alert = showAlert;
}

function windowResized() {
    if (typeof(winCustomPage)!="undefined" && winCustomPage!=null) {
        var pageSize = WindowUtilities.getPageSize();
        winCustomPage.setSize(pageSize.windowWidth * 0.90, pageSize.windowHeight * 0.90);
        try {
            winCustomPage._center();
        }
        catch(e) {/* cannot center window */}
    }
    
    if (typeof(resizeHandler)!="undefined") resizeHandler();
    
    if (typeof(broadcasterPopupWindow)!="undefined" && broadcasterPopupWindow!=null) {
        try {
            broadcasterPopupWindow._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(broadcastViewerPopupWindow)!="undefined" && broadcastViewerPopupWindow!=null) {
        try {
            broadcastViewerPopupWindow._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(recordedViewerPopupWindow)!="undefined" && recordedViewerPopupWindow!=null) {
        try {
            recordedViewerPopupWindow._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(vaultPopupWindow)!="undefined" && vaultPopupWindow!=null) {
        try {
            vaultPopupWindow._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(recordPopupWindow)!="undefined" && recordPopupWindow!=null) {
        try {
         recordPopupWindow._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(uploadPopupWindow)!="undefined" && uploadPopupWindow!=null) {
        try {
            uploadPopupWindow._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(winMTPlayer)!="undefined" && winMTPlayer!=null) {
        try {
            winMTPlayer._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(winMTTVPlayer)!="undefined" && winMTTVPlayer!=null) {
        try {
            winMTTVPlayer._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(winChangePwd)!="undefined" && winChangePwd!=null) {
        try {
            winChangePwd._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(winLogin)!="undefined" && winLogin!=null) {
        try {
            winLogin._center();
        }
        catch(e) {/* cannot center window */}
    }
    
    if (typeof(winLoginViewer)!="undefined" && winLoginViewer!=null) {
        try {
            winLoginViewer._center();
        }
        catch(e) {/* cannot center window */}
    }
    
    if (typeof(winEmailMember)!="undefined" && winEmailMember!=null) {
        try {
            winEmailMember._center();
        }
        catch(e) {/* cannot center window */}
    }
    if (typeof(winAddComment)!="undefined" && winAddComment!=null) {
        try {
            winAddComment._center();
        }
        catch(e) {/* cannot center window */}
    }
}

/* new compacted function */
function tabMouseOver(e) {
    document.getElementById(e).className = "MenuStripLinkContainer MenuStripTabBox MenuStripTabSelected MenuStripTabSelectedBgColor MenuStripTabSelectedBorderColor";
}

function tabMouseOut(e,s) {
    if (selectedTabIndex != s) {
    document.getElementById(e).className = "MenuStripLinkContainer MenuStripTabBox MenuStripTab MenuStripTabBgColor MenuStripTabBorderColor";
    }
}

/* These functions below were replaced by the two functions above!!!
function tabTVMouseOver() {
    document.getElementById("menuStripTVTab").className = "MenuStripTabHelloTVSelected MenuStripTabSelectedBgColor MenuStripTabSelectedBorderColor";
}

function tabTVMouseOut() {
    if (selectedTabIndex != 0) {
        document.getElementById("menuStripTVTab").className = "MenuStripTabHelloTV MenuStripTabBgColor MenuStripTabBorderColor";
    }
}

function tabStudioMouseOver() {
    document.getElementById("menuStripStudioTab").className = "MenuStripTabHelloStudioSelected MenuStripTabSelectedBgColor MenuStripTabSelectedBorderColor";
}

function tabStudioMouseOut() {
    if (selectedTabIndex != 1) {
        document.getElementById("menuStripStudioTab").className = "MenuStripTabHelloStudio MenuStripTabBgColor MenuStripTabBorderColor";
    }
}

function tabMembersMouseOver() {
    document.getElementById("menuStripMembersTab").className = "MenuStripTabHelloMembersSelected MenuStripTabSelectedBgColor MenuStripTabSelectedBorderColor";
}

function tabMembersMouseOut() {
    if (selectedTabIndex != 2) {
        document.getElementById("menuStripMembersTab").className = "MenuStripTabHelloMembers MenuStripTabBgColor MenuStripTabBorderColor";
    }
}

function tabMyWorldMouseOver() {
    document.getElementById("menuStripMyWorldTab").className = "MenuStripTabMyWorldSelected MenuStripTabSelectedBgColor MenuStripTabSelectedBorderColor";
}

function tabMyWorldMouseOut() {
    if (selectedTabIndex != 3) {
        document.getElementById("menuStripMyWorldTab").className = "MenuStripTabMyWorld MenuStripTabBgColor MenuStripTabBorderColor";
    }
}

function tabSignupMouseOver() {
    document.getElementById("menuStripSignupTab").className = "MenuStripTabSignupSelected MenuStripTabSelectedBgColor MenuStripTabSelectedBorderColor";
}

function tabSignupMouseOut() {
    if (selectedTabIndex != 3) {
        document.getElementById("menuStripSignupTab").className = "MenuStripTabSignup MenuStripTabBgColor MenuStripTabBorderColor";
    }
}

function tabLoginMouseOver() {
    document.getElementById("menuStripLoginTab").className = "MenuStripTabLoginSelected MenuStripTabSelectedBgColor MenuStripTabSelectedBorderColor";
}

function tabLoginMouseOut() {
    if (selectedTabIndex != 3) {
        document.getElementById("menuStripLoginTab").className = "MenuStripTabLogin MenuStripTabBgColor MenuStripTabBorderColor";
    }
}*/

// Tab bars functionality...

function helloLogoClicked() {
    window.parent.location.href = siteRoot + "./";
}

function helloTVTabClicked() {
    window.location.href = siteRoot + "tv_home.aspx";
}

function helloStudioTabClicked() {
    window.location.href = siteRoot + "studio_home.aspx";
}

function helloMembersTabClicked() {
    window.location.href = siteRoot + "members_home.aspx";
}

function myWorldTabClicked() {
    jumpToMyWorld();
}

function signupTabClicked() {
    window.location.href = siteRoot + signupURL;
}

function loginTabClicked() {
    loginUser();
}


// Jump To... Menu functionality
function initShortcutsMenu() {
    if (TransMenu.isSupported()) {
	    TransMenu.initialize();
    }
}

function jumpToHomepage() {
    window.location.href="./";
}

function jumpToMyWorld() {
    window.location.href= absoluteRoot + "members_myworld.aspx?loggedUser=true";
}

function jumpToInbox() {
    var fNewWindowNeeded = false;
    
    if(!parent.frames["fraVarContainer"]) {
        // If we're at this point, and not framed,
        // force open mail in a new window 
        fNewWindowNeeded = true;
    }
    
    if (fNewWindowNeeded || !enableFramingOfVideoMail || launchMailInSeparateWindow) {

        if (parent.frames["fraVarContainer"]) {
            if (parent.frames["fraVarContainer"].objVideoMailWindow) {
                if (!parent.frames["fraVarContainer"].objVideoMailWindow.closed) {
                    parent.frames["fraVarContainer"].objVideoMailWindow.focus();
                }
                else {
                    fNewWindowNeeded = true;
                }
            }
            else {
                fNewWindowNeeded = true;
            }
        }
        else {
            fNewWindowNeeded = true;
        }
        
        if (fNewWindowNeeded) {
            if (parent.frames["fraVarContainer"]) {
                parent.frames["fraVarContainer"].objVideoMailWindow = window.open(absoluteRoot + 'root.iframes/global_login_vmail.aspx?app=mail', 'HelloWorldMail', 'toolbar=0,directories=0,location=0,resizable=1,width='+screen.width+',height='+screen.height);
                parent.frames["fraVarContainer"].objVideoMailWindow.moveTo(0,0);
            }
            else {
                objVideoMailWindow = window.open(absoluteRoot + 'root.iframes/global_login_vmail.aspx?app=mail', 'HelloWorldMail', 'toolbar=0,directories=0,location=0,resizable=1,width='+screen.width+',height='+screen.height);
                objVideoMailWindow.moveTo(0,0);
            }
        }
    }
    
    else {
        // Do we have a container for mail?
        if (parent.frames["fraMailContainer"]) {
            
            fNewWindowNeeded = false;
            // Let's get mail going...
            parent.frames["fraMailContainer"].location.href = absoluteRoot + 'root.iframes/global_login_vmail.aspx?app=mail';            
            
            switchApplicationPanes(true, 0,100);
        }
    }
}

function jumpToStudio() {
    window.location.href = siteRoot + "studio_home.aspx";
}

function jumpToVideoIM() {
    //window.open(siteRoot+'root.iframes/global_login_im.aspx', 'HelloWorldIm', 'width=280,height=640,toolbar=0,directories=0,menubar=0,status=0,location=0,scrollbars=0,resizable=1');
    if (gotoGroupChats) gotoGroupChats();
}

function jumpToRightNow() {
    window.open(siteRoot+'root.iframes/global_login_rightnow.aspx', 'RightNowWindow', 'width=640,height=400,toolbar=1,directories=0,menubar=1,status=1,location=0,resizable=1');
}

function jumpToOrganizeFriends() {
    window.location.href = siteRoot + "studio_home.aspx?target=friends";
}

function jumpToContacts() {

    var fNewWindowNeeded = false;
    if (parent.frames["fraVarContainer"].objVideoMailWindow) {
        if (!parent.frames["fraVarContainer"].objVideoMailWindow.closed) {
            parent.frames["fraVarContainer"].objVideoMailWindow.focus();
        }
        else {
            fNewWindowNeeded = true;
        }
    }
    else {
        fNewWindowNeeded = true;
    }
    
    if (fNewWindowNeeded) {
        parent.frames["fraVarContainer"].objVideoMailWindow = window.open(absoluteRoot + 'root.iframes/global_login_vmail.aspx?app=contacts', 'HelloWorldMail', 'toolbar=0,directories=0,location=0,resizable=1,width='+screen.width+',height='+screen.height);
        objVideoMailWindow.moveTo(0,0);
    }
}

function jumpToCalendar() {

    var fNewWindowNeeded = false;
    if (parent.frames["fraVarContainer"].objVideoMailWindow) {
        if (!parent.frames["fraVarContainer"].objVideoMailWindow.closed) {
            parent.frames["fraVarContainer"].objVideoMailWindow.focus();
        }
        else {
            fNewWindowNeeded = true;
        }
    }
    else {
        fNewWindowNeeded = true;
    }
    
    if (fNewWindowNeeded) {
        parent.frames["fraVarContainer"].objVideoMailWindow = window.open(absoluteRoot + 'root.iframes/global_login_vmail.aspx?app=calendar', 'HelloWorldMail', 'toolbar=0,directories=0,location=0,resizable=1,width='+screen.width+',height='+screen.height);
        objVideoMailWindow.moveTo(0,0);
    }
}

function jumpToNewEmail() {

    var fNewWindowNeeded = false;
    if (parent.frames["fraVarContainer"].objVideoMailWindow) {
        if (!parent.frames["fraVarContainer"].objVideoMailWindow.closed) {
            parent.frames["fraVarContainer"].objVideoMailWindow.focus();
        }
        else {
            fNewWindowNeeded = true;
        }
    }
    else {
        fNewWindowNeeded = true;
    }
    
    if (fNewWindowNeeded) {
        parent.frames["fraVarContainer"].objVideoMailWindow = window.open(absoluteRoot + 'root.iframes/global_login_vmail.aspx?app=mail&view=compose&to=&Subject=', 'HelloWorldMail', 'toolbar=0,directories=0,location=0,resizable=1,width='+screen.width+',height='+screen.height);
        objVideoMailWindow.moveTo(0,0);
    }
}

function jumpToNewContact() {

    var fNewWindowNeeded = false;
    if (parent.frames["fraVarContainer"].objVideoMailWindow) {
        if (!parent.frames["fraVarContainer"].objVideoMailWindow.closed) {
            parent.frames["fraVarContainer"].objVideoMailWindow.focus();
        }
        else {
            fNewWindowNeeded = true;
        }
    }
    else {
        fNewWindowNeeded = true;
    }
    
    if (fNewWindowNeeded) {
        parent.frames["fraVarContainer"].objVideoMailWindow = window.open(absoluteRoot + 'root.iframes/global_login_vmail.aspx?app=contacts', 'HelloWorldMail', 'toolbar=0,directories=0,location=0,resizable=1,width='+screen.width+',height='+screen.height);
        objVideoMailWindow.moveTo(0,0);
    }
}

function jumpToNewBlog() {
    window.location.href = siteRoot + "studio_home.aspx?target=newBlog";
}

function jumpToNews() {
}

function switchApplicationPanes(fShowTopNavigation, targetLeftWidth, targetRightWidth) {
    
    if (fShowTopNavigation) {
        parent.document.getElementById("framesetProductsWindow").rows = '30,*';
    }
    else {
        parent.document.getElementById("framesetProductsWindow").rows = '0,*';
    }

    var newWidth=targetLeftWidth+"%";
    if (parent.document.getElementById("framesetProducts").cols.substring(0,newWidth.length)!=newWidth) {
        //for (iCntr=0; iCntr<100; iCntr++) {
            parent.document.getElementById("framesetProducts").cols = targetLeftWidth+'%,' + targetRightWidth+'%';
        //}
    }
    
}

function showHomeFlashApp(bShow) {
    //if(window.frames['ifrFlashApp']) {
    if(document.getElementById("ifrFlashApp")) {
        if(bShow) {
            document.getElementById("ifrFlashApp").style.display = "block";
        }
        else {
            document.getElementById("ifrFlashApp").style.display = "none";
        }
    }
}


var winLogin;

function loginUser() {
    //if (!fLoggedIn) {
        showHomeFlashApp(false);
	    winLogin = new Window('dialog4', {className: "alphacube", title: ResourceManager.GetResource("GR_titleUserLogin"), 
								      width:360, height:201, 
								      resizable: false, draggable: false, closable: false,
								      minimizable: false, maximizable: false,
								      hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
								      url: absoluteRoot + "root.iframes/global_login.aspx"});
        winLogin.setDestroyOnClose();
	    winLogin.showCenter(true);
    //}
}

function loginUserCompleted() {
    var currentLocation = window.location.href;
    
    // Are we framed?    
    if(!parent.frames["fraVarContainer"]) {
        window.location.href = absoluteRoot + "global_frameset.aspx?target=studio";
    }
    else {    
        window.location.href = absoluteRoot + "studio_home.aspx";
    }
    
    if (enableFramingOfVideoMail && launchMailInSeparateWindow) {
        if (parent.frames["fraMailContainer"]) {
            parent.frames["fraMailContainer"].location.href = absoluteRoot + 'root.iframes/global_login_vmail.aspx?app=mail';
        }
    }
    
    showHomeFlashApp(true);
}

function loginUserCanceled() {
    Windows.close(winLogin.getId());
    if (fNeedsAccount && !fLoggedIn) {
        window.location.href = siteRoot;
    }
    showHomeFlashApp(true);
}

function loginHelpNeeded() {
    Windows.close(winLogin.getId());
    showCustomPage('contact.aspx?subject=Password%20Assistance%20Request%20HW' + ((currentUICulture) ? '%20-%20' + currentUICulture.toUpperCase() : ''), ResourceManager.GetResource("GR_titleContactingUs"));
    if (fNeedsAccount && !fLoggedIn) {
        window.location.href = siteRoot;
    }
    showHomeFlashApp(true);
}

function logoutUser() {
    if (fLoggedIn) {
        ajaxCall("root.ajax/global_logout.aspx",
                 "param=nothing",
                 true, logoutUserCompleted, logoutUserError);
    }
    
    if (enableFramingOfVideoMail) {
        if (parent.frames["fraMailContainer"]) {
            parent.frames["fraMailContainer"].location.href = '';
        }
    }
}

function logoutUserCompleted(objResult) {
    window.location.href = "./";
}

function logoutUserError(objResult) {
    alert(ResourceManager.GetResource("GR_alertLogOutUserError") + ' ' + ResourceManager.GetResource("GR_alertPleaseTryAgain"));
}


function isViewerAuthorized(bID, worldID, objectType, objectID, callbackFunction) {

    ajaxCall(absoluteRoot+"root.ajax/global_is_viewer_authorized.aspx",
             "bID=" + escape(bID) + "&worldID="+escape(worldID)+"&objectType="+escape(objectType)+"&objectID="+escape(objectID),
             true, callbackFunction, isViewerAuthorizedError);
             
}

function isViewerAuthorizedCompleted(objResult) {
}

function isViewerAuthorizedError(objResult) {
}

var winLoginViewer;
function loginViewer(worldID, objectType, objectID) {
    if (worldID && worldID.length > 0) {
        winLoginViewer = new Window('winLoginViewer', {className: "alphacube", title: ResourceManager.GetResource("GR_titleUserViewerLogin"), 
							          width:310, height:150, 
							          resizable: false, draggable: false, closable: false,
							          minimizable: false, maximizable: false,
							          hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
							          url: absoluteRoot + "root.iframes/global_login_viewer.aspx?worldID="+worldID});
        winLoginViewer.setDestroyOnClose();
        winLoginViewer.showCenter(true);
    }
}

function loginViewerCompleted(worldID, objectType, objectID) {
    Windows.close(winLoginViewer.getId());
}

function loginViewerCanceled() {
    Windows.close(winLoginViewer.getId());
}




var winChangePwd;

function changePwd() {
    if (fLoggedIn) {
	    winChangePwd = new Window('winChangePwd', {className: "alphacube", title: ResourceManager.GetResource("GR_titleChangePassword"), 
								      width:400, height:170, 
								      resizable: false, draggable: false, closable: false,
								      minimizable: false, maximizable: false,
								      hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
								      url: absoluteRoot + "root.iframes/studio_change_password.aspx"});
        debugger;
        winChangePwd.setDestroyOnClose();
	    winChangePwd.showCenter(true);
    }
}

function changePwdCompleted() {
    Windows.close(winChangePwd.getId());
}

function changePwdCanceled() {
    Windows.close(winChangePwd.getId());
}



var winHelp;
function showHelp() {
    if (!document.getElementById("winHelp")) {
        winHelp = new Window('winHelp', {className: "alphacube", title: ResourceManager.GetResource("GR_titleContextHelp"), 
							          width:350, height:350, left: document.body.clientWidth - 370, top:10,
							          resizable: true, draggable: true, closable: true,
							          minimizable: false, maximizable: false,
							          hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
							          url: absoluteRoot + "root.help/helpitem.htm"});
        winHelp.setDestroyOnClose();
        winHelp.show();
    }
}


function resizeHelp(newWidth, newHeight, newLeft, newTop) {
    if (winHelp) {
        winHelp.setSize(newWidth,newHeight);
        if (typeof(newLeft) != "undefined" && typeof(newTop) != "undefined") {
            winHelp.setLocation(newTop, newLeft);
        }
        else {
            winHelp.setLocation(10, document.body.clientWidth - newWidth-20);
        }
    }
}


// Show a media title player
var winMTPlayer;
function showMTPlayer(mtID, worldID) {

    winMTPlayer = new Window('winMTPlayer', {className: "NBPopup", title: ResourceManager.GetResource("GR_titleMediaViewer"), 
						          width:300, height:310,
						          resizable: false, draggable: true, closable: true,
						          minimizable: false, maximizable: false,
						          hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
						          url: absoluteRoot + "root.iframes/global_mt_player.aspx?mtID="+escape(mtID)+"&worldID="+escape(worldID)});
    winMTPlayer.setDestroyOnClose();
    winMTPlayer.showCenter(true);
}


function adjustMTPlayer(playerTitle, playerWidth, playerHeight) {
    if (winMTPlayer) {
        var newTitle = playerTitle;
        if (playerTitle.length > 25) {
            newTitle = playerTitle.substring(0, 25)+"...";
        }
        winMTPlayer.setTitle(newTitle);
        winMTPlayer.setSize(playerWidth,playerHeight);
        //winMTPlayer.setLocation((document.body.clientHeight - playerHeight) / 2, (document.body.clientWidth - playerWidth) / 2);
        winMTPlayer._center();
    }
}




// Show TV media title player
var winMTTVPlayer;
function showMTTVPlayer(clipID) {

    winMTTVPlayer = new Window('winMTTVPlayer', {className: "NBPopup", title: ResourceManager.GetResource("GR_titleMediaViewer"), 
						          width:300, height:310,
						          resizable: false, draggable: true, closable: true,
						          minimizable: false, maximizable: false,
						          hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
						          url: absoluteRoot + "root.iframes/global_mt_tv_player.aspx?clipID="+escape(clipID)});
    winMTTVPlayer.setDestroyOnClose();
    winMTTVPlayer.showCenter(true);
}


function adjustMTTVPlayer(playerTitle, playerWidth, playerHeight) {
    if (winMTTVPlayer) {
        var newTitle = playerTitle;
        if (playerTitle.length > 25) {
            newTitle = playerTitle.substring(0, 25)+"...";
        }
        winMTTVPlayer.setTitle(newTitle);
        winMTTVPlayer.setSize(playerWidth,playerHeight);
        //winMTTVPlayer.setLocation((document.body.clientHeight - playerHeight) / 2, (document.body.clientWidth - playerWidth) / 2);
        //winMTTVPlayer();
    }
}



function underConstruction() {
    alert(ResourceManager.GetResource("GR_alertThisFeatureUnavailableWorkingToBringBackOnLine"));
}


// Show TOS
var winCustomPage;
function showCustomPage(pageName, windowTitle) {
    var pageSize = WindowUtilities.getPageSize();
    winCustomPage = new Window('winCustomPage', {className: "alphacube", title: windowTitle, 
						          width:pageSize.windowWidth * 0.90, height:pageSize.windowHeight * 0.90,
						          resizable: false, draggable: true, closable: true,
						          minimizable: false, maximizable: true,
						          hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
						          url: absoluteRoot + "root.custom/"+customFolder+"/"+currentUICulture+"/"+pageName});
    winCustomPage.setDestroyOnClose();
    winCustomPage.showCenter(true);
}

function showCustomPageNoCulture(pageName, windowTitle) {
    var pageSize = WindowUtilities.getPageSize();
    winCustomPage = new Window('winCustomPage', {className: "alphacube", title: windowTitle, 
						          width:pageSize.windowWidth * 0.90, height:pageSize.windowHeight * 0.90,
						          resizable: false, draggable: true, closable: true,
						          minimizable: false, maximizable: true,
						          hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
						          url: absoluteRoot + "root.custom/"+customFolder+"/"+pageName});
    winCustomPage.setDestroyOnClose();
    winCustomPage.showCenter(true);
}


function closeCustomPage() {
    if (winCustomPage) {
        Windows.close(winCustomPage.getId());
    }
}

var objSystemTestWindow = null;
function showSystemTestPopup() {
    objSystemTestWindow = window.open(siteRoot + 'root.popups/system_test_start.aspx', 'SystemTestWindow', 'toolbar=0,directories=0,location=0,resizable=0,width=600,height=450');
    objSystemTestWindow.moveTo((screen.width - 600) / 2, (screen.height - 450) / 2);
    objSystemTestWindow.focus();
}


// Show TOS
var winEmailMember;
function showEmailMemberWindow(memberID) {
    var pageSize = WindowUtilities.getPageSize();
    winEmailMember = new Window('winEmailMember', {className: "alphacube", title: ResourceManager.GetResource("GR_titleSendEmailMessage"), 
						          width:500, height:300,
						          resizable: false, draggable: true, closable: true,
						          minimizable: false, maximizable: false,
						          hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
						          url: absoluteRoot + "root.iframes/global_im_send_email.aspx?memberID="+escape(memberID)});
    winEmailMember.setDestroyOnClose();
    winEmailMember.showCenter(true);
}


function closeEmailMemberWindow() {
    if (winEmailMember) {
        Windows.close(winEmailMember.getId());
    }
}


// Show TOS
var winAddComment;
function showCommentWindow(entryType, entryID, entryTitle, param1, param2) {
    var pageSize = WindowUtilities.getPageSize();
    winAddComment = new Window('winAddComment', {className: "alphacube", title: ResourceManager.GetResource("GR_titleAddComment"), 
						          width:400, height:280,
						          resizable: false, draggable: true, closable: true,
						          minimizable: false, maximizable: false,
						          hideEffect:Element.hide, showEffect:Element.show, recenterAuto: true,
						          url: absoluteRoot + "root.iframes/global_add_comment.aspx?entryType="+escape(entryType)+"&entryID="+escape(entryID)+"&entryTitle="+escape(entryTitle)+"&param1="+escape(param1)+"&param2="+escape(param2)});
    winAddComment.setDestroyOnClose();
    winAddComment.showCenter(true);
}


function closeCommentWindow(entryType, entryID, fResult) {
    if (winAddComment) {
        Windows.close(winAddComment.getId());
    }
    if (entryType=='blog') {
        window.frames['section_contents'].frames['section_contents'].addCommentResult(fResult);
    }
}



var broadcastViewerPopupWindow;
function joinBroadcast(worldID, profileID, windowTitle) {

    broadcastViewerPopupWindow = new Window('broadcastViewerPopupWindow', {className: "NBPopup", title: windowTitle, 
						          width:786, height:610, 
						          resizable: false, draggable: false, closable: true,
						          minimizable: false, maximizable: false, recenterAuto: true,
						          url: absoluteRoot+'root.iframes/members_broadcast_viewer.aspx?worldID='+worldID+'&rand='+Math.random(),
						          hideEffect:Element.hide, showEffect:Element.show
						          });
    broadcastViewerPopupWindow.toFront();
    broadcastViewerPopupWindow.setDestroyOnClose();
    broadcastViewerPopupWindow.showCenter(true);

}

function joinBroadcastCallback() {
}

function hideBroadcastViewerWindow() {
    Windows.close(broadcastViewerPopupWindow.getId());
}


var recordedViewerPopupWindow;
function viewRecordedPresentation(worldID, presentationID, windowTitle) {
    recordedViewerPopupWindow = new Window('recordedViewerPopupWindow', {className: "NBPopup", title: windowTitle, 
							      width:786, height:460, 
							      resizable: false, draggable: false, closable: true,
							      minimizable: false, maximizable: false, recenterAuto: true,
							      url: absoluteRoot + 'root.iframes/members_recorded_viewer.aspx?worldID='+worldID+'&presentationID='+presentationID+'&rand='+Math.random(),
							      hideEffect:Element.hide, showEffect:Element.show
							      });
	recordedViewerPopupWindow.toFront();
    recordedViewerPopupWindow.setDestroyOnClose();
    recordedViewerPopupWindow.showCenter(true);
}


function hideRecordedPresentationWindow() {
    Windows.close(recordedViewerPopupWindow.getId());
}



var tourPopupWindow;
function showTourWindow() {

    
    tourPopupWindow = new Window('tourPopupWindow', {className: "NBPopup", title: 'Take the tour...', 
							      width:650, height:510, 
							      resizable: false, draggable: false, closable: true,
							      minimizable: false, maximizable: false, recenterAuto: true,
							      hideEffect:Element.hide, showEffect:Element.show
							      });
						
						
                    
    var so = new SWFObject('http://ravenas.razorstream.com:80/eve-service/objects/flvplayer.swf','mpl','640','505','7','0x000000');
    so.addParam('width','640');
    so.addParam('height','425');
    so.addParam('salign','LT');
    so.addParam('quality','high');
    so.addParam('scale','noscale');
    so.addParam('bgcolor','#000000');
    so.addVariable('MM_ComponentVersion','1');
    so.addVariable('skinName',escape('http://ravenas.razorstream.com:80/eve-service/objects/large_controls'));
    so.addVariable('streamName','http://www.helloworld.com/root.flash/flvs/'+currentUICulture+'/helloWorldTour.flv');
    so.addVariable('autoPlay','true');
    so.addVariable('autoRewind','false');
    
    so.write(tourPopupWindow.getContent());
							      
	//tourPopupWindow.getContent().innerHTML="";
	
	tourPopupWindow.toFront();
    tourPopupWindow.setDestroyOnClose();
    tourPopupWindow.showCenter(true);
}

//Show a Portal alert window
function showAlert(message, config) { 
    var PortalWin = new PortalWindow();
    PortalWin.Alert(message, config);
}

// A language was selected from the language selector drop down
function languageMenuSelected(newLanguage) {
    var currentLocation = window.location.href;
    if (currentLocation.indexOf("?") > 0) {
        if (currentLocation.indexOf("lang=") > 0) {
            window.location.href = currentLocation.substring(0, currentLocation.indexOf("lang=") + 5) + newLanguage;
        }
        else {
            window.location.href = currentLocation+"&lang="+newLanguage;
        }
    }
    else {
        window.location.href = currentLocation+"?lang="+newLanguage;
    }
}