﻿
//
//
var SERVICE_BRAND = "Masher";
var SERVICE_BRAND_DISPLAY_NAME = "Masher";
//
//
var SERVICE_ADMIN_EMAIL = "support@masher.com";
var SERVICE_INFO_EMAIL = "support@masher.com";
var SERVICE_SUPPORT_EMAIL = "support@masher.com";
//
//
var LANG_CODE = "en";
//
// service URL stuff
var SERVICE_WWW_ROOT = "";
//
// number type names
var NUM_TYPE_UNDEFINED = -1;
var NUM_TYPE_BYTE = 0;
var NUM_TYPE_DOUBLE = 1;
var NUM_TYPE_FLOAT = 2;
var NUM_TYPE_INT = 3;
var NUM_TYPE_LONG = 4;
var NUM_TYPE_SHORT = 5;
//
//
var THUMB_FILE_POSTFIX=".thumb.jpeg";
var SCRSHOT_FILE_POSTFIX=".scrshot.jpeg";
var VIDEO_FILE_POSTFIX=".flv";
var AUDIO_FILE_POSTFIX=".mp3";
//
//
//
//
var filePathDelimChar = "\\";
if (navigator.platform=="Win32") {
	filePathDelimChar = "\\";
}
else {
	filePathDelimChar = "/";
}
//
//
var RESERVED_ACCOUNT_IDS=new Array(
"admin",
"administrator",
"moderator",
"info",
"reporting",
SERVICE_BRAND_DISPLAY_NAME,
"staff",
"support",
"system",
"root",
"webmaster"
);
//
//
var ACCOUNT_ACTIVATION_MESSAGE_SENDER = "Masher HQ <support@masher.com>";

var ACCOUNT_ACTIVATION_SUBJECT = "Welcome to Masher! Please activate your account.";

function getAccountActivationMessage(zoneName, serviceWwwRoot, showContactUs) {
    var localZoneName = zoneName;
    var localServiceWwwRoot = serviceWwwRoot;
    var localShowContactUs = showContactUs;
    if(!localZoneName) {
        localZoneName = ZONE_NAME;
    }
    if(!localServiceWwwRoot) {
        localServiceWwwRoot = SERVICE_WWW_ROOT;
    }
    if(localShowContactUs == undefined || localShowContactUs == null) {
        localShowContactUs = true;
    }
    var retValue = "Welcome to Masher!\n\n"+

                  "You're now registered. Just click the below Activation link, or copy and paste it to your browser, to activate your Masher account.\n\n"+

                  localZoneName + localServiceWwwRoot + "/activate.jsp?key=ACCOUNT_VALIDATION_DATA_INSERT\n\n" +

                  "We love Masher, and hope you do too. Have fun mashing, and we can't wait to see what you create.\n\n" +

                  "---------------------\n\n"+

                  "The bits you need to remember -\n\n" +

                  "Your Masher username is: PRINCIPAL_NAME_INSERT\n\n" +

                  "Please make a note of your Masher username. You'll need it to log in and to use all of Masher's features.\n\n" +

                  "Again, a big masher welcome from us to you... now, enough chat, go and get Mashing... mix, mash and share!\n\n" +

                  "Over and out,\n\n" +

                  "\n\n" +

                  "The Masher Team\n\n" +
                  
                  "www.masher.com\n\n" +

                  "-------------------------------------------------------------------------------------------\n\n"+

                  "NOTE: Please do not reply to this e-mail -- we are not able to respond personally to messages sent to this address.\n\n";
    if(localShowContactUs == true) {
                  retValue += "To contact us or send feedback, please click here to " + localZoneName + localServiceWwwRoot + "/contactUs.jsp\n";
    }
    return retValue;
}

//
// NOTE! ACCOUNT_ACTIVATION_MESSAGE is deprecated, use getAccountActivationMessage function instead
//
var ACCOUNT_ACTIVATION_MESSAGE = "Welcome to Masher!\n\n"+

                  "You're now registered. Just click the below Activation link, or copy and paste it to your browser, to activate your Masher account.\n\n"+

                  ZONE_NAME + SERVICE_WWW_ROOT + "/activate.jsp?key=ACCOUNT_VALIDATION_DATA_INSERT\n\n" +

                  "We love Masher, and hope you do too. Have fun mashing, and we can't wait to see what you create.\n\n" +

                  "---------------------\n\n"+

                  "The bits you need to remember -\n\n" +

                  "Your Masher username is: PRINCIPAL_NAME_INSERT\n\n" +

                  "Please make a note of your Masher username. You'll need it to log in and to use all of Masher's features.\n\n" +

                  "Again, a big masher welcome from us to you... now, enough chat, go and get Mashing... mix, mash and share!\n\n" +

                  "Over and out,\n\n" +

                  "\n\n" +

                  "The Masher Team\n\n" +

                  "www.masher.com\n\n" +

                  "-------------------------------------------------------------------------------------------\n\n"+

                  "NOTE: Please do not reply to this e-mail -- we are not able to respond personally to messages sent to this address.\n\n" +

                  "To contact us or send feedback, please click here to " + ZONE_NAME + SERVICE_WWW_ROOT + "/contactUs.jsp\n";

var ACCOUNT_ACTIVATION_MESSAGE_TYPE="text/plain";
//
//
var ACCOUNT_ACTIVATION_PAGE_INTRO_MESSAGE = '<p>Thank you for Signing up with Masher.</p>'+
                                            '<p>We have sent an activation email to the address you provided. To complete the process please click the activation link in the email.</p>'+
                                            '<p>Please check that your email is correct and click resend if you haven\'t received the email within 5 minutes from your registration.</p>';
var ACCOUNT_ACTIVATION_PAGE_RESULT_MESSAGE = '<p>Your account has been activated</p>'+
                                             '<p>Thanks for verifying your Masher account. Now <a href="/studio.jsp">Go get Mashing!</a></p>';

//
//
var REQUEST_CONNECT_AS_FRIENDS_SENDER = "info@masher.com";
var REQUEST_CONNECT_AS_FRIENDS_SUBJECT = "You have a new friend request on masher.com";
var REQUEST_CONNECT_AS_FRIENDS_MESSAGE = "SRC_DISPLAY_NAME_INSERT wants to be your friend on masher.com.\n\n"+
                                          "Click here to accept the request " + ZONE_NAME+SERVICE_WWW_ROOT + "/#openMyProfile \n\n" +
                                          "Thanks,\n\n"+
                                          "masher.com\n";
var REQUEST_CONNECT_AS_FRIENDS__MESSAGE_TYPE = "text/plain";

var siteLanguage="en";
//
// main resourcebundle that holds all languages
var propertyResourceBundle=new Hashtable();
//
// name says it all
var englishBundle=new Hashtable();
propertyResourceBundle.putEntry("en",englishBundle);
//
// each widget has its own bundle
var EntryWidgetBundle=new Hashtable();
EntryWidgetBundle.putEntry("shareMessage","Hi! \n Check out this ride \nLINK_INSERT\n");
EntryWidgetBundle.putEntry("shareMessageSubject","Check this out!");
englishBundle.putEntry("EntryWidget", EntryWidgetBundle);
//
//
var SERVICE_NAMES_GENERAL_FRIENDS_BUNDLE_ID = "Friends";
var FriendsBundle = new Hashtable();
FriendsBundle.putEntry("REQUEST_CONNECT_AS_FRIENDS_SENDER", REQUEST_CONNECT_AS_FRIENDS_SENDER);
FriendsBundle.putEntry("REQUEST_CONNECT_AS_FRIENDS_SUBJECT", REQUEST_CONNECT_AS_FRIENDS_SUBJECT);
FriendsBundle.putEntry("REQUEST_CONNECT_AS_FRIENDS_MESSAGE", REQUEST_CONNECT_AS_FRIENDS_MESSAGE);
FriendsBundle.putEntry("REQUEST_CONNECT_AS_FRIENDS__MESSAGE_TYPE", REQUEST_CONNECT_AS_FRIENDS__MESSAGE_TYPE);
englishBundle.putEntry(SERVICE_NAMES_GENERAL_FRIENDS_BUNDLE_ID, FriendsBundle);
//
//
var RegistrationWidgetBundle = new Hashtable();
RegistrationWidgetBundle.putEntry("ACCOUNT_ACTIVATION_MESSAGE_SENDER", ACCOUNT_ACTIVATION_MESSAGE_SENDER);
RegistrationWidgetBundle.putEntry("ACCOUNT_ACTIVATION_SUBJECT", ACCOUNT_ACTIVATION_SUBJECT);
RegistrationWidgetBundle.putEntry("ACCOUNT_ACTIVATION_MESSAGE", ACCOUNT_ACTIVATION_MESSAGE);
RegistrationWidgetBundle.putEntry("ACCOUNT_ACTIVATION_MESSAGE_FUNCTION", getAccountActivationMessage);
RegistrationWidgetBundle.putEntry("ACCOUNT_ACTIVATION_PAGE_INTRO_MESSAGE", ACCOUNT_ACTIVATION_PAGE_INTRO_MESSAGE);
RegistrationWidgetBundle.putEntry("ACCOUNT_ACTIVATION_PAGE_RESULT_MESSAGE", ACCOUNT_ACTIVATION_PAGE_RESULT_MESSAGE);
RegistrationWidgetBundle.putEntry("ACCOUNT_ACTIVATION_MESSAGE_TYPE", ACCOUNT_ACTIVATION_MESSAGE_TYPE);
englishBundle.putEntry("RegistrationWidget", RegistrationWidgetBundle);

englishBundle.putEntry("AccountActivationWidget", RegistrationWidgetBundle);

//
//
var InviteFriendsWidgetBundle = new Hashtable();

InviteFriendsWidgetBundle.putEntry("INVITATION_EMAIL_MESSAGE",
    "Masher is a new website where you can create your own videos online in minutes. And you don't need to be a techie, it's really, really easy!\n\n" +
    "Simply mix and mash video clips, photos, music with some effects and you'll be sending your friends a video in minutes.\n\n" +
    "To give you a taster, here are 5 things you can do on Masher and all for FREE!!\n" +
    " 1. Upload photos of your holiday*, add some music, some text, and capture that special moment as a video\n" +
    " 2. Create a video card to send to somebody to wish them happy birthday or good luck\n" +
    " 3. Mix in video clips from BBC Motion Gallery (we have tonnes for you to use on Masher)\n" +
    " 4. Add music tracks (we also have tonnes of these on Masher)\n" +
    " 5. Post your video to sites such as Facebook and MySpace in seconds\n\n" +
    "And there's a lot more to do on Masher!\n\n" +
    "So click here to join the Masher revolution: " + ZONE_NAME + "\n\n" +
    "Don't make it.  Mash it!\n\n" +
    "The Masher Team\n\n" +
    "* a night out / a wedding / a birthday party / your cat / your dog / your new baby boy / your new baby girl... you get the picture, you can Mash anything!");
englishBundle.putEntry("InviteFriendsWidget",InviteFriendsWidgetBundle);
//
//
var MobileFirstLoginWidgetBundle = new Hashtable();
MobileFirstLoginWidgetBundle.putEntry("ACCOUNT_ACTIVATION_MESSAGE_SENDER", SERVICE_INFO_EMAIL);
MobileFirstLoginWidgetBundle.putEntry("ACCOUNT_ACTIVATION_SUBJECT", ACCOUNT_ACTIVATION_SUBJECT);
MobileFirstLoginWidgetBundle.putEntry("ACCOUNT_ACTIVATION_MESSAGE", "Thanks for registering at " + SERVICE_BRAND_DISPLAY_NAME + "\n\n"+
                                                                    "\tYour username is \tACCOUNT_ID_INSERT\n"+
                                                                    "\tYour password is \tPASSWORD_INSERT\n\n"+
                                                                    "If you have any questions or need help, just email us at " + SERVICE_INFO_EMAIL);
englishBundle.putEntry("MobileFirstLoginWidget",MobileFirstLoginWidgetBundle);
//
//
var ContactUsWidgetBundle = new Hashtable();
ContactUsWidgetBundle.putEntry("CONTACT_US_MESSAGE_RECIPIENT", "support@masher.com");
ContactUsWidgetBundle.putEntry("CONTACT_US_MESSAGE_SUBJECT", "From a Masher user");
ContactUsWidgetBundle.putEntry("CONTACT_US_MESSAGE_DEFAULT_SENDER", "anonymous@masher.com");


englishBundle.putEntry("ContactUsWidget",ContactUsWidgetBundle);

function getResourceString(widget,resourceId){
    var retValue = null;
    var lan=propertyResourceBundle.getEntry(siteLanguage);
    if(lan){
        var bundle=lan.getEntry(widget.className);
        if(bundle){
            return bundle.getEntry(resourceId);
        }
    }	
}// 
// page level widgets
var indexPage;
var samplePage;
var studioPage;
var mashPage;
var myProfilePage;
var editMyProfilePage;
var myMediaPage;
var faqPage;
var registrationPage;
var inviteFriendsPage;
var loginPage;
var galleryPage;
var aboutPage;
var contactUsPage;
var contactUsResultPage;
var termsPage;
var privacyPage;
var cocPage;
var sharePage;
var youtubeSharePage;
var forgotPasswordWidget;
var globalLoginRequiredWidget = null;
var activationWidget = null;
var hotmailImportContactsResultHandlerWidget = null;

//
//
var openWidgetsMap = new OneToManyMap();
var loginLogoutNavigation = new Object();
var accountActivatedEventHandler = new Object();
var blockRefreshCurrentContent = false;
var indexPageContentRotationTimer = null;
//
// handle login events on application specific way and globally
loginLogoutNavigation.loginStateChangedEventHandler=function(object,evtObject){
    if(isLoggedIn()){
        //
        //
        createMashesFromGuestMashes();
        //
        //
        window.location.href = '/mystuff.jsp';
    }
    else{
        var currentSessionShorName = getSessionShortName();        
        if(currentSessionShorName != null && emailValidationRequired==true && emailValidated==false){
            window.location.href = '/activate.jsp';
        }
        else {
            window.location.href = '/login.jsp';
        }
    }
}
loginFailedMessage="Sorry, your login has failed.\nPlease check that your username and password are typed correctly. If you have forgotten your password, click on 'forgot Password?'.";
//
//
var handlingLoginRequired=false;
//
//
accountActivatedEventHandler.onAccountActivated = function(sourceObjectInstance, evtObjectInstance) {
    if(evtObjectInstance) {
        if(evtObjectInstance.activationResult==true) {
            createMashesFromGuestMashes();
			//
            //
            window.location.href = '/index.jsp';
        }
        /*
        defaultLoginResultHandler(evtObjectInstance.loginResult, principalName, evtObjectInstance.returnParameterValue);*/
		
    }
}
//
// bubbling event handling setup
var bubbleEventHandler=new Object();
bubbleEventHandler.handle=function(obj,evtObj){
    if(evtObj.type=="onBubbleEvent"){
        if(evtObj.originalEvtObject && evtObj.originalEvtObject.type=="onLoginRequired"){
            if(handlingLoginRequired==false){
                handlingLoginRequired=true;
                var w = getGlobalLoginRequiredWidget();
                w.isOpen=true;
                var handlerObj=new Object();
                handlerObj.widgetClosed=function(handlerObj,evtObj){
                    handlingLoginRequired=false;
                }
                w.events.onClose.addListener(handlerObj,handlerObj.widgetClosed);
                obj.setStackedWidget(w);
            }
        }
    }
}
//
// application main entry point called from index.html body onload event
function init(){
    //
    //
    emailValidationRequired=true;
    caseSensitivePrincipalName=false;

    //
    // hook listener into login events
    loginStateChanged.addListener(loginLogoutNavigation,loginLogoutNavigation.loginStateChangedEventHandler);

}
//
//
function startIndexPageContentRotationUpdateTimer() {
    indexPageRotateContentTimer(1);
}
function stopIndexPageContentRotationUpdateTimer() {
    if(indexPageContentRotationTimer) {
        clearTimeout(indexPageContentRotationTimer);
        indexPageContentRotationTimer = null;
    }
}
//
//
function indexPageRotateContentTimer(rotatePhaseIndex) {
    if(indexPageContentRotationTimer) {
        houseAdContentDiv = document.getElementById("homePageHouseAd");
        homePageContentDiv = document.getElementById("homePageContentElement");
        if(houseAdContentDiv && homePageContentDiv) {
            if(rotatePhaseIndex == 1) {
                houseAdContent =
                    '<div style="height:83px">' +
                    '<img class="content" src="/images/homePageContent_rightPanelDots2.jpg" alt="" title=""/>' +
                    '<br class="clearThis" />' +
                    '<div class="content homePageFontSet_2" style="height:65px;margin-top:6px;">' +
                    'Featuring:' +
                    '</div>' +
                    '<br/>' +
                    '</div>' +
                    '<div class="content homePageFontSet_0" style="height:155px;">' +
                    'Mash of the week' +
                    '</div>' +
                    '</br>' +
                    '<a href="javascript:openMashPage(' + "'" + mashOfTheWeekId + "'" + ',2)"><img src="/images/homePageContent_watchLink.png" alt="Watch" title="Watch"/></a>';
                houseAdContentDiv.innerHTML = houseAdContent;
                homePageContentDiv.className="homePageContent houseAd2";
                rotatePhaseIndex = 0;
            }
            else {
                houseAdContent =
                    '<img class="content" src="/images/homePageContent_rightPanelDots.jpg" alt="" title=""/>' +
                    '<br class="clearThis" />' +
                    '<div class="content homePageFontSet_2">' +
                    'Featured:' +
                    '</div>' +
                    '<div class="content homePageFontSet_3" style="height:68px">' +
                    'Thousands of free video clips from the BBC to Mash a video' +
                    '</div>' +
                    '<img src="/images/homePageContent_BBCSamples.jpg" style="margin-top:5px;" alt="" title=""/>' +
                    '<img src="/images/homePageContent_BBCLogo.png" style="margin-top: 8px;margin-left:30px;" alt="BBC Motion Gallery" title=""/>';
                houseAdContentDiv.innerHTML = houseAdContent;
                homePageContentDiv.className="homePageContent";
                rotatePhaseIndex = 1;
            }
        }
    }
    indexPageContentRotationTimer = setTimeout("indexPageRotateContentTimer(" + rotatePhaseIndex + ")", 15000);
}
//
//
function delayedOpenMashPage_s1(mashId){
    setTimeout('openMashPage("' + mashId + '",1)',1);	
    return 0;
}
function delayedOpenMashPage(mashId){
    setTimeout('openMashPage("' + mashId + '")',1);	
    return 0;
}
function openMashPage(mashId,adScheme){
    
	if(adScheme==null || adScheme==undefined){ 
		adScheme=0;
	}
   window.location.href = "/player.jsp?key="+mashId+"&adScheme="+adScheme;
}

var mashDetails;
function overlayCallFromFlash(args){
    //alert("overlayCall");
    mashDetails = args;
	
    showMashPreview();
}
function showMashPreview()
{
		
    //alert("show start");
    //*** open the preview in div page ****
    // open Preview .... 25_03_08
    var flashVars="userId=&folder=&action=mash&mashid=&checkXMLFlag=0&playerType=new";
    if(isLoggedIn()==true){
        var mId="";
        if(mashDetails && mashDetails.id){
            mId=mashDetails.id;
        }
        var checkXML="0";
        if(mashDetails.mashSavedStatus == "saved"){
            checkXML="1";
        }
        flashVars="userId="+getSessionShortName()+"&folder=&action=mash&mashid="+mId+"&checkXMLFlag="+checkXML+"&playerType=new";
    }
	
	
    flashCont ='<object style="float:left;" type="application/x-shockwave-flash" data="../flash/mashPreview.swf?'+flashVars+'" width="535" height="605" id="previewWindow" tabindex="31">';
    flashCont +=		'<param name="movie" value="../flash/mashPreview.swf?'+flashVars+'"/> ';
    flashCont +=	'<param name="quality" value="high" />';
    flashCont +='<param name="bgcolor" value="#bcbcbc" />';
    flashCont +='<embed src="../flash/mashPreview.swf?'+flashVars+'" quality="high" bgcolor="#bcbcbc" width="535" height="605" tabindex="31" name="previewWindow" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
    flashCont +='</object>';
	
	var adCont='';
	adCont+='<div style="float:right;margin-top:120px;margin-right:40px;" id="overlay_adbannersideDiv" class="adbannerside">';
    adCont+=	'<iframe id="overlay_adbannersideDiv_iframe" src="/advertisement_300x250.html" width="300" height="250" scrolling="no" frameborder="0"></iframe>';
    adCont+='</div>';
	
    var d=document.getElementById("overlay");
    if(!d){
        d=document.createElement("div");
        d.id="overlay";
        document.body.appendChild(d);
    }
    d.innerHTML = '<div class="bg">&nbsp;</div><div class="content">'+flashCont+adCont+'<br style="clear:left;"/></div>';
    d.style.display = "block";
    d.style.visibility = "visible";
    // mac have resolved screen probelm show myflash need to hide - varathan 08_04_08 
    // ************ don't use hidden property use collapse - 16_04_08
    //document.getElementById('editorFlashDiv').style.visibility = "hidden";
    /*document.getElementById('editorFlashDiv').style.visibility = "collapse";
	window.scrollTo(0,0)
	
	document.getElementById("sponsoredDiv").style.display = "none";*/
    
    //
    // google analytics
    try {
        if(isLoggedIn())
        {
            pageTracker._trackPageview("/loggedIn/mashPreviewPage");
        }
        else
        {
            pageTracker._trackPageview("/mashPreviewPage");
        }
    }
    catch(gatException) {
    }

}
function closeFFK(mashIdFromFlash){
    // update the editor flash variable "mashIdGlobal" 04_04_08
    //var editorFlashObj=document.getElementById('myEditorFlash')
    //alert("editorFlashObj>>" + editorFlashObj)
    //editorFlashObj.SetVariable("dlObj.mashIdFromPrev", mashIdFromFlash)
    //alert("close")
	
    //document.body.className ="body"
    // disable Preview .... 25_03_08
    //document.getElementById("vlogoImage").src="../images/logoMasher.png"
    //document.getElementById('editorFlashDiv').style.visibility = "visible";
    if(mashIdFromFlash != undefined) {
        var movie;
        if(navigator.appName.indexOf("Microsoft") != -1) {
            //alert("IE");
            movie = window["studioPage_editorWidget_swf"];
            //alert("this.movie: "+this.movie);
        } else {
            movie = document["studioPage_editorWidget_swf"];
        }
        if(movie && movie.SetVariable){
            try {
                movie.SetVariable("dlObj.mashIdFromPrev", mashIdFromFlash);
            }
            catch(setVariableE) {
            }
        }
    }
    var d=document.getElementById("overlay");
	if(d){
    	d.style.visibility = "hidden";
	}
	
		
    // disable adbanner .... 17_03_08
	
    //document.getElementById("sponsoredDiv").style.display = "block";
	
    //document.getElementById("adbannerDiv").innerHTML = topadbannersideDivContent
	
    /// ****** end of disable
	
	
	
	
    return ;
}
function updateXmlTOFlash(){

    var flashObj =  document.getElementById('previewWindow');
    // call action script

    //alert("mashName " + mashName)
    //alert(mashDetails.thumbNail)
    flashObj.updateXmlFromJavascipt(mashDetails);
}
var rememberToSaveYourMash_callerFunc=null;
var rememberToSaveYourMash_callerArgs=null;
var rememberToSaveYourMash_calledAlready=false;
function rememberToSaveYourMash(callerFunc,args){
    rememberToSaveYourMash_callerArgs=null;
    rememberToSaveYourMash_callerFunc=null;
    if(rememberToSaveYourMash_calledAlready===true){
        rememberToSaveYourMash_calledAlready=false;
        return true;
    }
    rememberToSaveYourMash_callerFunc=callerFunc;
    rememberToSaveYourMash_callerArgs=args;
    var c=openWidgetsMap.containsValue("content",studioPage);
    if(c>=0){
        var checkSaveStatus=true;
        var d=document.getElementById("overlay");
        try {
            if(d && d.style.visibility=="visible"){
                var previewFlashObj = document.getElementById("previewWindow");
                if(previewFlashObj){
                    checkSaveStatus = previewFlashObj.checkSaveBeforeFromFlash();
                }
            }
            else{
                var movie;
                if(navigator.appName.indexOf("Microsoft") != -1) {
                    //alert("IE");
                    movie = window["studioPage_editorWidget_swf"];
                    //alert("this.movie: "+this.movie);
                } else {
                    movie = document["studioPage_editorWidget_swf"];
                }
                if(movie){
                    movie.SetVariable("dlObjForceSave.mashIdFromfroceSave", "varathan");
                    checkSaveStatus  = movie.GetVariable("dlObjForceSaveReturn") ;
                }
            }
        }
        catch(e){
			
        }
        finally {
            if(checkSaveStatus==true || checkSaveStatus=="true"){
				//this should not be here since it's a side effect but yet it is cause this method is already called where the code is needed
				var d=document.getElementById("overlay");
				if(d){
					d.style.visibility = "hidden";
				}
                return true;	
            }
            else{
                return	false;
            }
        }
    }
    return true;
}
function goToLinkInJS(valFromFlash){
    //rememberToSaveYourMash_callerFunc(); 
    rememberToSaveYourMash_calledAlready=true;
    if(rememberToSaveYourMash_callerFunc){
        if(rememberToSaveYourMash_callerArgs!=null && rememberToSaveYourMash_callerArgs!=undefined){
            setTimeout(function(){rememberToSaveYourMash_callerFunc.call(null,rememberToSaveYourMash_callerArgs);},1);
        }
        else{
            setTimeout(rememberToSaveYourMash_callerFunc,1);
        }
		//this should not be here since it's a side effect but yet it is cause this method is already called where the code is needed
		setTimeout(function(){var d=document.getElementById("overlay");if(d){d.style.visibility = "hidden";}},1);
    }
    return 0;
    //alert("go away")
    //	document.location = vcurrentLinkClick
    //vcurrentLinkClick = ""
	
}
//
// Flash dependency to masher js when uploading
var flashUploadStatus = false;  
function updateFlashUploadStatus(val, flashUploadedAsset)
{
   flashUploadStatus = val;
}//
//
RegistrationPageWidget.prototype.displayName = null;
RegistrationPageWidget.prototype.profileId = null;
RegistrationPageWidget.prototype.registeredEmailAddressProvider = null;
RegistrationPageWidget.prototype.importedInviteeSerializationTemplate = null;
RegistrationPageWidget.prototype.importedInviteesHolderElementId = null;
RegistrationPageWidget.prototype.currentStep = -1;
RegistrationPageWidget.prototype.addImportedContactsByDefault = true;
//
//
function RegistrationPageWidget(id, domContainer, parentWidget) {
    //
    //
    RegistrationPageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.childWidgets[this.id + "_registrationWidget"] = new RegistrationWidget(this.id+"_registrationWidget", this.id+"_registrationWidget_Holder", this);
    this.childWidgets[this.id + "_registrationWidget"].isOpen=true;
    this.childWidgets[this.id + "_registrationWidget"].events.registrationComplete.addListener(this, this.registrationCompleteEventHandler);
    //
    //
//    this.childWidgets[this.id + "_inviteFriendsWidget"] = new InviteFriendsWidget(this.id+"_inviteFriendsWidget", this.id+"_inviteFriendsWidget_Holder", this);
//    this.childWidgets[this.id + "_inviteFriendsWidget"].isOpen=true;
//    this.childWidgets[this.id + "_inviteFriendsWidget"].alwaysUseServiceInfoEmailAsSender = true;
//    this.childWidgets[this.id + "_inviteFriendsWidget"].events.invitationSent.addListener(this, this.friendsInvitedEventHandler);
//    this.childWidgets[this.id + "_inviteFriendsWidget"].events.invitationSkipped.addListener(this, this.friendsInvitationSkippedEventHandler);
//    this.childWidgets[this.id + "_inviteFriendsWidget"].events.contactsImported.addListener(this, this.inviteeAddressesImportedEventHandler);
    //
    //
//    this.importedInviteeSerializationTemplate =
//        "<div class=\"left\"><input class=\"invitee\" id=\"" + this.id + "_importedInvitee{index}\" " +
//        "type=\"checkbox\" name=\"Invitee {index}: {contactName}\" " +
//        "value=\"{contactEmail}\" checked=\"true\" " +
//        "onclick=\"if(this.checked){javascript:document.widgets['" + this.id + "'].addInvitee('{contactEmail}');}else{javascript:document.widgets['" + this.id + "'].removeInvitee('{contactEmail}');}\" >" +
//        "{contactName} &lt;{contactEmail}&gt;" +
//        "</input></div><br/>";
//    this.importedInviteesHolderElementId = this.id + "_importedInviteeListHolder";
    //
    //
    this.currentStep = 1;
}
//
//
copyPrototype(RegistrationPageWidget, ContainerWidget);
//
//
RegistrationPageWidget.prototype.superClass=ContainerWidget.prototype;
//
//
RegistrationPageWidget.prototype.registrationCompleteEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    //
    //
    var err_field = null;
    var s = null;
    //
    //
    if(eventObjectInstance && 0==eventObjectInstance.code) {
        if(eventObjectInstance.type && eventObjectInstance.type=="registrationComplete") {
            //eventObjectInstance.login;
            //eventObjectInstance.password;
			err_field=document.getElementById(this.id+"_registrationWidget_DONT_SEND_ERROR_INFO");
			if(err_field){
				
				err_field.className+=" hidden";
				err_field.innerHTML="";
			}
            this.showStep(2);
        }
    }
	else{
		if(eventObjectInstance && eventObjectInstance.message){
			var message=eventObjectInstance.message;
            var field = null;
			if(message.indexOf("Sign Up failed due to following error(s): \r\n")!=-1){
				message=message.replace("Sign Up failed due to following error(s): \r\n","");
			}
			if(message.toLowerCase().indexOf("email")!=-1){
				field=document.getElementById(this.id + "_registrationWidget_EMAIL");
				if(field){
					field.className+=" error";
				}
			}
			if(message.toLowerCase().indexOf("account with the name")!=-1){
				field=document.getElementById(this.id + "_registrationWidget_primaryPrincipal");
				if(field){
					field.className+=" error";
				}
				this.showStep(1);
			}
			err_field = document.getElementById(this.id+"_registrationWidget_DONT_SEND_ERROR_INFO");
			if(err_field){
				s = err_field.className;
				s=s.replace(/hidden/g,"");
				err_field.className=s;
				err_field.innerHTML=eventObjectInstance.message;
			}
			else{
				showAlert(eventObjectInstance.message);
			}
		}
		else{
			err_field=document.getElementById(this.id+"_registrationWidget_DONT_SEND_ERROR_INFO");
			if(err_field){
        		s = err_field.className;
				s = s.replace(/hidden/g,"");
				err_field.className=s;
				err_field.innerHTML="We are sorry but something went wrong and we could not create your account.\n\rPlease check that your input is correct an try again.";
			}
			else{
				showAlert("We are sorry but something went wrong and we could not create your account.\n\rPlease check that your input is correct an try again.");	
			}
		}
	}
}
//
//
RegistrationPageWidget.prototype.showStep = function(stepNumber, displayAllProviders) {
    //
    //
    var d1 = document.getElementById(this.id+'_registrationWidget_step1');
    var d2 = document.getElementById(this.id+'_registrationWidget_step2');
    var d3 = document.getElementById(this.id+'_inviteFriendsWidget');
    var d4 = document.getElementById(this.id+'_registrationWidget_step4');
    var dt = document.getElementById(this.id+'_stepTitle');
	//
    //
    this.currentStep = stepNumber;
    //
    //
    if(!displayAllProviders) {
        displayAllProviders = false;
    }
    //
    //
    if(d1){
        //
        //
        if(stepNumber==1) {
            //hideElement(d2);
            //hideElement(d3);
            hideElement(d4);
            showElement(d1);
        }
        /*
        else if(stepNumber==2) {
            //
            //
            var stepOneParameters = getAccountParamsToSubmit( document.getElementById(this.id + "_registrationWidget" + "_registrationFields") , this.id + "_registrationWidget" + "_");
            var password = stepOneParameters.accountParamsHashtable.getEntry("PASSWORD");
            var passwordConfirmed = stepOneParameters.accountParamsHashtable.getEntry("PASSWORD_CONFIRMED");
            if(!password || password!=passwordConfirmed) {
                var errMsg = "Sorry, the given passwords do not match!\r\nPlease retype passwords before continuing.";
				var vd=document.getElementById(this.id+"_registrationWidget_DONT_SEND_ERROR_INFO");
				var vd1=document.getElementById(this.id+"_registrationWidget_PASSWORD");
				var vd2=document.getElementById(this.id+"_registrationWidget_PASSWORD_CONFIRMED");
				if(vd1){
					vd1.className+=" error";	
				}
				if(vd2){
					vd2.className+=" error";	
				}
				if(vd){
					var s=vd.className;
					s=s.replace(/hidden/g,"");
					vd.className=s;
					vd.innerHTML=errMsg;
				}
				else{
                	showAlert(errMsg)
				}
            }
            else {
				var vd=document.getElementById(this.id+"_registrationWidget_DONT_SEND_ERROR_INFO");
				if(vd){
					vd.className+=" hidden";
					vd.innerHTML="";
				}
				var vd1=document.getElementById(this.id+"_registrationWidget_PASSWORD");
				var vd2=document.getElementById(this.id+"_registrationWidget_PASSWORD_CONFIRMED");
				if(vd1){
					var s=vd1.className;
					s=s.replace(/error/g,"");
					vd1.className=s;	
				}
				if(vd2){
					var s=vd2.className;
					s=s.replace(/error/g,"");
					vd2.className=s;
				}
                //
                //
                hideElement(document.getElementById(this.id + "_introText"));
                hideElement(d1);
                hideElement(d3);
                hideElement(d4);
                showElement(d2);
            }
        }
        else if(stepNumber==3) {
            //
            //
            var firstNameElement = document.getElementById(this.id + "_registrationWidget_FIRST_NAME");
            var lastNameElement = document.getElementById(this.id + "_registrationWidget_LAST_NAME");
            var emailElement = document.getElementById(this.id + "_registrationWidget_EMAIL");
            var firstName = null;
            var lastName = null;
            var email = null;
            if(firstNameElement)
                firstName = firstNameElement.value;
            if(lastNameElement)
                lastName = lastNameElement.value;
            if(emailElement)
                email = emailElement.value;
            var displayName = "";
            if(firstName != null || lastName != null) {
                if(firstName != null)
                    displayName += firstName + " ";
                if(lastName != null)
                    displayName += lastName;
            }
            else if(email != null) {
                displayName = email;
            }
            else {
                displayName = "New Masher member";
            }
            var inviterNameElement = document.getElementById(this.id + "_inviteFriendsWidget_inviteFriendsName");
            if(inviterNameElement) {
                inviterNameElement.value = displayName;
            }
            //
            //
            this.childWidgets[this.id + "_inviteFriendsWidget"].show();
            var registeredEmailAddressProviderLookupElement = document.getElementById(this.id + "_importFromRegisteredEmailProviderHolder");
            var allSupportedProvidersLookupElement = document.getElementById(this.id + "_importFromSupportedProvidersHolder");
            //
            //
            var email = this.childWidgets[this.id + "_registrationWidget"].email;
            registeredEmailAddressProvider = null;
            if(email && email.toLowerCase) {
                var emailLowerCase = email.toLowerCase();
                if(emailLowerCase) {
                    if(emailLowerCase.indexOf("@hotmail.co") > 0) {
                        registeredEmailAddressProvider = "Hotmail";
                    }
                    else if(emailLowerCase.indexOf("@yahoo.co") > 0) {
                        registeredEmailAddressProvider = "Yahoo";
                    }
                    else if(emailLowerCase.indexOf("@gmail.com") > 0) {
                        registeredEmailAddressProvider = "Gmail";
                    }
                }
            }
            var emailProviderDomElement = document.getElementById(this.id + "_inviteFriendsWidget_emailProviderName");
            if(registeredEmailAddressProvider && !displayAllProviders) {
                //
                //
                this.childWidgets[this.id + "_inviteFriendsWidget"].setThirdPartyAddressBookProviderName(registeredEmailAddressProvider);
                //
                //
                if(emailProviderDomElement) {
                    emailProviderDomElement.innerHTML = registeredEmailAddressProvider;
                }
                //
                //
                if(registeredEmailAddressProviderLookupElement) {
                    showElement(registeredEmailAddressProviderLookupElement);
                }
                if(allSupportedProvidersLookupElement) {
                    hideElement(allSupportedProvidersLookupElement);
                }
            }
            else {
                //
                //
                if(emailProviderDomElement) {
                    emailProviderDomElement.innerHTML = "email";
                }
                //
                //
                if(registeredEmailAddressProviderLookupElement) {
                    hideElement(registeredEmailAddressProviderLookupElement);
                }
                if(allSupportedProvidersLookupElement) {
                    showElement(allSupportedProvidersLookupElement);
                }
            }
            //
            //
            hideElement(d1);
            hideElement(d2);
            hideElement(d4);
            showElement(d3);
        }
        */
        else if(stepNumber==2) {
            //
            //
            hideElement(document.getElementById(this.id + "_introText"));
            //
            //
            var displayNameInsertElement = document.getElementById(this.id + "_registrationWidget_displayNameInsert");
            if(displayNameInsertElement) {
                displayNameInsertElement.innerHTML = this.childWidgets[this.id + "_registrationWidget"].accountParameters.accountParamsHashtable.getEntry("DISPLAY_NAME");
            }
            var emailInsertElement = document.getElementById(this.id + "_registrationWidget_emailInsert");
            if(emailInsertElement) {
                emailInsertElement.innerHTML = this.childWidgets[this.id + "_registrationWidget"].email;
            }
            //
            //
            hideElement(d1);
            hideElement(d2);
            hideElement(d3);
            showElement(d4);
        }
        if(dt){
            dt.innerHTML="Step " + stepNumber + " of 2";
        }
    }
}

/**
 * Event handler that gets called from ImportContacts.js method handleContactsImportedFrom3rdPartyServiceResult,
 * that in turn is called from contact import result page. For genericity, this method passes the event to the
 * child InviteFriendsWidget without doing anything else in this handler.
 */
RegistrationPageWidget.prototype.contactsImportedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    this.childWidgets[this.id + "_inviteFriendsWidget"].contactsImportedEventHandler(sourceObjectInstance, eventObjectInstance);
}

RegistrationPageWidget.prototype.friendsInvitedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    this.showStep(4);
    //
    // google analytics
    try {
        pageTracker._trackPageview("/friendsInvited");
    }
    catch(gatException) {
    }
}

RegistrationPageWidget.prototype.friendsInvitationSkippedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    this.showStep(4);
    //
    // google analytics
    try {
        pageTracker._trackPageview("/friendsInvitationSkipped");
    }
    catch(gatException) {
    }
}

/**
 * Open the invitation page without preselected provider
 */
RegistrationPageWidget.prototype.inviteMoreFriends = function() {
    this.showStep(3, true);
}

/**
 * Initiating importing contacts to which send invitations
 */
RegistrationPageWidget.prototype.importInviteeAddresses = function(provider) {
    if(!provider) {
        provider = registeredEmailAddressProvider;
    }
    if(provider) {
        this.childWidgets[this.id + "_inviteFriendsWidget"].importContacts(provider, this.id);
    }
}

/**
 * Event handler that receives imported addresses after process started by calling importInviteeAddresses is completed
 */
RegistrationPageWidget.prototype.inviteeAddressesImportedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    //
    //
    if(this.importedInviteesHolderElementId && this.importedInviteeSerializationTemplate) {
        //
        //
        var importedInviteesHolderElement = document.getElementById(this.importedInviteesHolderElementId);
        if(importedInviteesHolderElement) {
            //
            //
            var importedInviteesHtml = "";
            //
            //
            var invitees = eventObjectInstance.contactsArray;
            for(var i = 0; i < invitees.length; i++) {
                var invitee = invitees[i];
                if(invitee) {
                    var inviteeEmail = invitee.email;
                    var inviteeName = invitee.name;
                    if(inviteeEmail) {
                        if(!inviteeName) {
                            inviteeName = "";
                        }
                        var serializedInvitee = this.importedInviteeSerializationTemplate;
                        serializedInvitee = serializedInvitee.replace(/{contactEmail}/g, inviteeEmail);
                        serializedInvitee = serializedInvitee.replace(/{contactName}/g, inviteeName);
                        serializedInvitee = serializedInvitee.replace(/{index}/g, i);
                        //
                        //
                        importedInviteesHtml += serializedInvitee;
                        //
                        //
                        if(this.addImportedContactsByDefault) {
                            this.addInvitee(inviteeEmail);
                        }
                    }
                }
            }
            //
            //
            importedInviteesHolderElement.innerHTML = importedInviteesHtml;
        }
    }
}

/**
 * 
 */
RegistrationPageWidget.prototype.addInvitee = function(email) {
    this.childWidgets[this.id + "_inviteFriendsWidget"].addInvitee(email);
}

/**
 *
 */
RegistrationPageWidget.prototype.removeInvitee = function(email) {
    this.childWidgets[this.id + "_inviteFriendsWidget"].removeInvitee(email);
}

//
//
LoginPageWidget.prototype.principalName = null;
//
//
function LoginPageWidget(id, domContainer, parentWidget) {
    //
    //
    LoginPageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.childWidgets[this.id + "_loginWidget"] = new LoginWidget(this.id+"_loginWidget", this.id+"_loginWidgetHolder", this);
    this.childWidgets[this.id + "_loginWidget"].isOpen=true;
}
//
//
copyPrototype(LoginPageWidget, ContainerWidget);
//
//
LoginPageWidget.prototype.superClass=ContainerWidget.prototype;

LoginPageWidget.prototype.open=function(){
	LoginPageWidget.prototype.superClass.open.call(this);
	//this.childWidgets[this.id + "_loginWidget"].redraw();
	if(isLoggedIn()){
		hideElementById(this.id + "_loginWidget_state_0");
		showElementById(this.id + "_loginWidget_state_1");
        hideElementById("logInLink");
        showElementById("logOutLink");
	}
	else{
		hideElementById(this.id + "_loginWidget_state_1");
		showElementById(this.id + "_loginWidget_state_0");
        showElementById("logInLink");
        hideElementById("logOutLink");
	}
}//
//
StudioPageWidget.prototype.shortName = null;
StudioPageWidget.prototype.storageFolderPath = null;
StudioPageWidget.prototype.mashId = null;
StudioPageWidget.prototype.checkXmlFlag = "0";
StudioPageWidget.prototype.flashConfigPath = "/static/flash/config.xml";
//
//
function StudioPageWidget(id, domContainer, parentWidget) {
    //
    //
    StudioPageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    
    /*
     * <object type="application/x-shockwave-flash" data="../flash/editor.swf?jsessionid=VQnDLLBZJTTcnQmLtJFQ9KtJg11JLD2xXnmmnDYTch3JHJLfNyFQ!1344929263!1221116217122&userId=&folder=&action=mash&mashid=&checkXMLFlag=0&defaultPage=&playerType=new" width="818" id="myEditorFlash" height="600">
          <param name="movie" value="../flash/editor.swf?jsessionid=VQnDLLBZJTTcnQmLtJFQ9KtJg11JLD2xXnmmnDYTch3JHJLfNyFQ!1344929263!1221116217122&userId=&folder=&action=mash&mashid=&checkXMLFlag=0&defaultPage=&playerType=new"/>
          <param name="quality" value="high" />
          <param name="wmode" value="transparent" />
          <embed src="../flash/editor.swf?jsessionid=VQnDLLBZJTTcnQmLtJFQ9KtJg11JLD2xXnmmnDYTch3JHJLfNyFQ!1344929263!1221116217122&userId=&folder=&action=mash&mashid=&checkXMLFlag=0&defaultPage=&playerType=new" quality="high" bgcolor="#bcbcbc" width="818" height="600" swliveconnect="true"  name="myEditorFlash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />    
      </object>
     */
    this.childWidgets[this.id + "_editorWidget"] = new FlashWidget(this.id+"_editorWidget",this.id+"_editorWidgetHolder",this);
    this.childWidgets[this.id + "_editorWidget"].isOpen=true;
    
   
    
    this.childWidgets[this.id+"_editorWidget"].flashVersion="9.0.0";
    this.childWidgets[this.id+"_editorWidget"].setSwfUrl("/static/editor/editor.swf");
   /* this.childWidgets[this.id+"_editorWidget"].defaultFlashParams["wmode"] = "transparent";*/
}
//
//
copyPrototype(StudioPageWidget, ContainerWidget);
//
//
StudioPageWidget.prototype.superClass=ContainerWidget.prototype;


StudioPageWidget.prototype.show=function(){
	if(this.childWidgets[this.id+"_editorWidget"]){
		var flashEmbedAttr = new Object();
		flashEmbedAttr["width"] = 818;
		flashEmbedAttr["height"] = 600;
		flashEmbedAttr["id"] = this.id + "_editorWidget_swf";
		flashEmbedAttr["name"] = this.id + "_editorWidget_swf";
		flashEmbedAttr["allowScriptAccess"]	= "always";
		
                flashEmbedAttr["configUrl"] = this.flashConfigPath;
		flashEmbedAttr["profileId"] = this.shortName;
		flashEmbedAttr["profileIdentifierName"] = "shortName";
                flashEmbedAttr["logFirebugConsole"] = true;
                flashEmbedAttr["logVerbosityForAll"] = 4;
                if(this.mashId && this.mashId.length > 0) {
                    flashEmbedAttr["editUrl"] = "/getMash.jsp?mashId=" + this.mashId;
                    flashEmbedAttr["editId"] = this.mashId;
                }
                flashEmbedAttr["defaultExtensionForVideoMedia"] = ".flv";
                flashEmbedAttr["omitAudioEntryDoubleExtension"] = ".mp3";
                flashEmbedAttr["autoPlay"] = false;
		this.childWidgets[this.id+"_editorWidget"].setFlashVars(flashEmbedAttr);
	}
	StudioPageWidget.prototype.superClass.show.call(this);
}
StudioPageWidget.prototype.showChild=function(){
	if(this.childWidgets[this.id+"_editorWidget"]){
		var flashEmbedAttr = new Object();
		flashEmbedAttr["width"] = 818;
		flashEmbedAttr["height"] = 600;
		flashEmbedAttr["id"] = this.id + "_editorWidget_swf";
		flashEmbedAttr["name"] = this.id + "_editorWidget_swf";
		flashEmbedAttr["allowScriptAccess"]	= "always";
		
                flashEmbedAttr["configUrl"] = this.flashConfigPath;
		flashEmbedAttr["profileId"] = this.shortName;
		flashEmbedAttr["profileIdentifierName"] = "shortName";
                flashEmbedAttr["logFirebugConsole"] = true;
                flashEmbedAttr["logVerbosityForAll"] = 4;
                if(this.mashId && this.mashId.length > 0) {
                    flashEmbedAttr["editUrl"] = "/getMash.jsp?mashId=" + this.mashId;
                    flashEmbedAttr["editId"] = this.mashId;
                }
                flashEmbedAttr["defaultExtensionForVideoMedia"] = ".flv";
                flashEmbedAttr["omitAudioEntryDoubleExtension"] = ".mp3";
                flashEmbedAttr["autoPlay"] = false;
		this.childWidgets[this.id+"_editorWidget"].setFlashVars(flashEmbedAttr);
	}
	StudioPageWidget.prototype.superClass.showChild.call(this);
}
//
//
MyMediaPageWidget.prototype.shortName = null;
MyMediaPageWidget.prototype.profileId = null;
MyMediaPageWidget.prototype.configPath = null;
//
//
function MyMediaPageWidget(id, domContainer, parentWidget, groupId) {
    //
    //
    MyMediaPageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.childWidgets[this.id + "_myMediaLibraryWidget"] = new FlashWidget(this.id+"_myMediaLibraryWidget", this.id+"_myMediaLibraryWidgetHolder", this);
    this.childWidgets[this.id + "_myMediaLibraryWidget"].isOpen=true;
    this.childWidgets[this.id+"_myMediaLibraryWidget"].flashVersion="8";
    this.childWidgets[this.id+"_myMediaLibraryWidget"].setSwfUrl("/static/flash/contentPanelShell.swf");
    this.childWidgets[this.id+"_myMediaLibraryWidget"].defaultFlashParams["wmode"] = "transparent";
    this.childWidgets[this.id+"_myMediaLibraryWidget"].defaultFlashParams["flashConfigPath"] = "/static/flash/config.xml";
    //
    // Galleries for MyStuffPage
    //
    //
    this.childWidgets[this.id + "_myMashes"] = new GalleryWidget(this.id+"_myMashes", this.id+"_myMashesHolder", this);
    this.childWidgets[this.id + "_myMashes"].isOpen=true;
    this.childWidgets[this.id + "_myMashes"].rangeSize = 5;
    this.childWidgets[this.id + "_myMashes"].galleryViewDOMModelBaseURL="/galleryQuery.jsp?all=true";

    if(groupId && groupId.length > 1) {
        this.childWidgets[this.id + "_myMashes"].groupId = groupId;
    }
    //
    //
    this.childWidgets[this.id + "_featuredMashes"] = new GalleryWidget(this.id+"_featuredMashes", this.id+"_featuredMashesHolder", this);
    this.childWidgets[this.id + "_featuredMashes"].isOpen=true;
    this.childWidgets[this.id + "_featuredMashes"].rangeSize = 6;
    this.childWidgets[this.id + "_featuredMashes"].galleryViewDOMModelBaseURL="/galleryQueryFeatured.jsp?all=true";
    if(groupId && groupId.length > 1) {
        this.childWidgets[this.id + "_featuredMashes"].groupId = groupId;
    }
}
//
//
copyPrototype(MyMediaPageWidget, ContainerWidget);
//
//
MyMediaPageWidget.prototype.superClass=ContainerWidget.prototype;
//
//
MyMediaPageWidget.prototype.show=function(){
    if(this.childWidgets[this.id+"_myMediaLibraryWidget"]){
        //
        //
        var flashEmbedAttr = new Array();
        flashEmbedAttr["width"] = 508;
        flashEmbedAttr["height"] = 269;
        flashEmbedAttr["id"] = this.id + "_myMediaLibraryWidget_swf";
        flashEmbedAttr["name"] = this.id + "_myMediaLibraryWidget_swf";
        flashEmbedAttr["allowScriptAccess"]	= "always";
        flashEmbedAttr["userId"] = this.shortName;
        flashEmbedAttr["folder"] = this.storageFolderPath;
        flashEmbedAttr["configPath"] = this.configPath;
        this.childWidgets[this.id+"_myMediaLibraryWidget"].setFlashVars(flashEmbedAttr);
    }
    MyMediaPageWidget.prototype.superClass.show.call(this);
}
//
//
MyMediaPageWidget.prototype.showChild=function(){
    if(this.childWidgets[this.id+"_myMediaLibraryWidget"]){
        //
        //
        var flashEmbedAttr = new Array();
        flashEmbedAttr["width"] = 508;
        flashEmbedAttr["height"] = 269;
        flashEmbedAttr["id"] = this.id + "_myMediaLibraryWidget_swf";
        flashEmbedAttr["name"] = this.id + "_myMediaLibraryWidget_swf";
        flashEmbedAttr["allowScriptAccess"]	= "always";
        flashEmbedAttr["userId"] = this.shortName;
        flashEmbedAttr["folder"] = this.storageFolderPath;
        flashEmbedAttr["configPath"] = this.configPath;
        this.childWidgets[this.id+"_myMediaLibraryWidget"].setFlashVars(flashEmbedAttr);
    }
    MyMediaPageWidget.prototype.superClass.showChild.call(this);
}
MyMediaPageWidget.prototype.loginStateChangedEventHandler = function() {
    if(this.queryParams && this.queryParams.loadDomModel==true){
        if(this.queryParams.contentURL!=null){ 
            this.reloadDomModel(true);	
            this.redraw();
        }
    }
}
//
//
function createOrUpdateMash(entryParams, entryType, entryId) {
    //
    //
    var retValue = false;
    if(!entryParams) return retValue;
    if(!entryType) entryType="Mash";
    //
    //
    var cmdData = "";
    var cmdXML = "<COMMANDS PROPAGATE=\"true\">";
    cmdXML += "<COMMAND CLASS_NAME=\"com.masher.command.CreateOrUpdateMash\" ENTRY_TYPE=\"" + entryType + "\" ENTRY_ID=\"" + entryId + "\"><DATA>";
    cmdData = encode64("<ENTRY_DATA>" + entryParams.toXML() + "</ENTRY_DATA>");
    cmdXML += cmdData;
    cmdXML += "</DATA></COMMAND></COMMANDS>";
    //
    //
    retValue = singleCommandRequest(cmdXML);
    //
    //
    return retValue;
}
//
//
function createMashesFromGuestMashes() {
    //
    //
    var retValue = false;
    //
    //
    var nonAuthenticatedSessionUUIDCookie = getCookie("nonAuthenticatedSessionId");
    if(nonAuthenticatedSessionUUIDCookie)
    {
        nonAuthenticatedSessionUUIDCookie = nonAuthenticatedSessionUUIDCookie.split("\"").join("");
        //
        //
        var nonAuthenticatedSessionUUID = nonAuthenticatedSessionUUIDCookie.split(", V=");
        //
        if(nonAuthenticatedSessionUUID && nonAuthenticatedSessionUUID.length && nonAuthenticatedSessionUUID.length > 0 && nonAuthenticatedSessionUUID[0])
        {
            if(nonAuthenticatedSessionUUID[0].indexOf(",", 0) > -1)
            {
                //
                // try UrlEncoded
                nonAuthenticatedSessionUUID = nonAuthenticatedSessionUUIDCookie.split(",");
            }
            //
            //
            var cmdXML = "<COMMANDS PROPAGATE=\"true\"><COMMAND CLASS_NAME=\"com.masher.command.CreateMashesFromGuestMashes\" NONAUTHENTICATED_SESSION_UUID=\"" + nonAuthenticatedSessionUUID[0] + "\" /></COMMANDS>";
            //retValue = singleCommandRequest(cmdXML);
            retValue = asyncCommandRequest(cmdXML, null, null)
        }
    }

    //
    //
    return retValue;
}

/**
 * Delete a Mash.
 * @param entryId Id for existing mash to delete.
 * @param entryType "MashEntry" supported.
 * @param deleteFiles Boolean flag to control if files associated with entry should also be deleted, optional
 * @param fileExtensions Array of file extension names that indicate derived media assets for delete operation, optional
 * @return true for success false for failure.
 */
function deleteMash(entryId, entryType, deleteFiles, fileExtensions) {
    //
    //
    var retValue = false;
    if(!entryId || !entryType) {
        return retValue;
    }
    //
    //
    var cmd = new Array();
    cmd[cmd.length] = '<COMMANDS PROPAGATE="true">';
    cmd[cmd.length] = '<COMMAND CLASS_NAME="com.tenduke.masher.command.DeleteMash" ';
    cmd[cmd.length] = ' ENTRY_ID="' + entryId + '" ';
    cmd[cmd.length] = ' ENTRY_TYPE="' + entryType + '" ';
    if(true==deleteFiles) {
        cmd[cmd.length]= ' DELETE_STORED_OBJECTS="' + true + '"';
    }
    if(fileExtensions && fileExtensions.length>0) {
        cmd[cmd.length]= ' STORED_OBJECT_FORMAT_EXTENSIONS="' + fileExtensions.join(",") + '"';
    }
    cmd[cmd.length] = ' /></COMMANDS>';
    //
    //
    retValue = singleCommandRequest(cmd.join(""));
    //
    //
    return retValue;
}

/**
 * Publish a mash to youtube.
 * @param mashId The identifier of the mash to publish
 * @param youtubeUserName user name to use when uploading to youtube (optional)
 * @param youtubePassword The identifier of the mash to publish
 * @return true if job was accepted
 */
function publishToYoutube(mashId, youtubeUserName, youtubePassword) {
    //
    //
    var retValue = false;
    //
    //
    var outputWidth = "308";
    var outputHeight = "270";
    //
    //
    var cmdXml = "<COMMANDS PROPAGATE=\"false\">";
    cmdXml += "<COMMAND CLASS_NAME=\"com.tenduke.masher.command.ConvertMashUploadToYoutube\"";
    if(youtubeUserName && youtubePassword) {
        cmdXml += " YOUTUBE_DETAILS_ARE_ENCODED=\"true\"";
        cmdXml += " YOUTUBE_ACCOUNT_USERNAME=\"" + encode64(youtubeUserName) + "\"";
        cmdXml += " YOUTUBE_ACCOUNT_PASSWORD=\"" + encode64(youtubePassword) + "\"";
    }
    cmdXml += " ENTRY_ID=\"" + mashId + "\"";
    cmdXml += " INPUT_FORMAT=\".swf\"";
    cmdXml += " TARGET_FORMAT=\".flv\"";
    cmdXml += " TARGET_TYPE=\"video\"";
    cmdXml += " BASE_URL=\"" + encode64(ZONE_NAME + "/flash/") + "\"";
    cmdXml += " ORIGINAL_URL=\"" + encode64(ZONE_NAME + "/flash/mashPlayerForVideoExport.swf") + "\"";
    cmdXml += " WIDTH=\"308\"";
    cmdXml += " HEIGHT=\"270\"";
    cmdXml += " CUSTOM_ARGUMENTS=\"" + encode64("FlashVars=width=" + outputWidth + "&height=" + outputHeight + "&mashId=" + mashId) + "\"";
    cmdXml += " FRAME_RATE=\"25\"";
    cmdXml += " OBJECT_PATH=\"" + encode64("/export/masher/" + mashId + ".swf") + "\"";
    cmdXml += " OBJECT_NAME=\"" + encode64(mashId + ".swf") + "\" />";
    cmdXml += "</COMMANDS>";
    //
    //
    retValue = singleCommandRequest(cmdXml);
    //
    //
    return retValue;
}
//
//
function MashEntryWidget(id, domContainer, parentWidget) {
    //
    //
    MashEntryWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
}
//
//* MashEntryWidget initialize prototype
copyPrototype(MashEntryWidget,EntryWidget);

/** MashEntryWidget class hierarchy */
MashEntryWidget.prototype.superClass = EntryWidget.prototype;
//
//
MashEntryWidget.prototype.deleteEntry=function() {
    //
    // request entry delete
    var confirmResult = this.confirmDeleteEntry();
    if(confirmResult) {
      //
      //
      var deleteResult = deleteMash(this.entryId, this.entryType, this.deleteFiles, this.entryFileExtensionNames);
      //
      // fire deleted event
      var evtobj = new Object();
      evtobj.code = 0;
      evtobj.deleteResult = deleteResult;
      evtobj.type	= "onEntryDeleted";
      this.events.onEntryDeleted.fireEvent(this, evtobj);
  }
}
//
//
MashEntryWidget.prototype.setPublicity = function(isPublic) {
    //
    //
    var evtobj = new Object();
    var entryParams = new Properties();
    entryParams.setParametersAreEncoded(true);
    entryParams.setRootElementName("ENTRY");
    evtobj.entryId = this.entryId;
    entryParams.setValue("ENTRY_ID", this.entryId);
    //
    //
    entryParams.setValue("IS_PUBLIC", "" + isPublic);
    var result = createOrUpdateMash(entryParams, this.entryType,this.entryId);
    //
    // fire deleted event
    if(!result){
      	evtobj.code = -1;
    }
    else{
      	evtobj.code = 0;
    }
    evtobj.isPublic = isPublic;
    evtobj.type	= "onEntryPublicityChanged";
    this.events.onEntryPublicityChanged.fireEvent(this, evtobj);
}//
//
function MasherProfilePageWidget(id, domContainer, parentWidget){
    //
    //
    MasherProfilePageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.childWidgets[this.id+"_displayName"]=new TextFieldWidget(this.id+"_displayName", this.id+"_displayNameHolder",this);
    this.childWidgets[this.id+"_displayName"].isOpen=true;
    this.childWidgets[this.id+"_displayName"].setUserFormatter(null);
    //
    //
    this.childWidgets[this.id + "_description"] = new MetaTextWidget(this.id + "_description", this.id + "_descriptionHolder", this);
    this.childWidgets[this.id + "_description"].isOpen = true;
}
//
//
copyPrototype(MasherProfilePageWidget, ProfilePageWidget);
//
//
MasherProfilePageWidget.prototype.superClass = ProfilePageWidget.prototype;
//
//
MasherProfilePageWidget.prototype.loginStateChangedEventHandler = function() {
    if(this.queryParams && this.queryParams.loadDomModel==true){
        if(this.queryParams.contentURL!=null){ 
            this.reloadDomModel(true);	
            this.redraw();
        }
    }
}

/** */
function MasherImageWidget(id,domContainer,parentWidget){
    //
    //
    MasherImageWidget.prototype.superClass.constructor.call(this,id,domContainer,parentWidget);
    //
    //
    var flashImage=new FlashWidget(this.id+"_flashImage",this.id+"_flashImageHolder",this);
    flashImage.setSwfUrl('/static/flash/MasherImageTransformer.swf');
    this.flashImageAttr=new Array();
    this.flashImageAttr["width"]=490;
    this.flashImageAttr["height"]=368;
    this.flashImageAttr["widgetID"]=this.id;
	this.flashImageAttr["preLoaderURL"]="/static/flash/RotatingPreLoader.swf";
    //this.flashImageAttr["widgetID"]=this.id;
    //this.flashImageAttr["clickHandler"]="FlashRatingWidget_flash_rater_clicked";
    flashImage.setFlashVars(this.flashImageAttr);
    flashImage.isOpen=true;
    flashImage.setFlashParam("wmode","transparent");
    this.childWidgets[this.id+"_flashImage"]=flashImage;
}

/** ImageWidget initialize prototype */
copyPrototype(MasherImageWidget,FlashImageWidget);
/** ImageWidget class hierarchy */
MasherImageWidget.prototype.superClass=FlashImageWidget.prototype;
/** */

MashPlayerWidget.prototype.mashID=null;
MashPlayerWidget.prototype.flashConfigPath = "/static/flash/config.xml";
//
//
function MashPlayerWidget(id,domContainer,parentWidget){
	//
	//
	MashPlayerWidget.prototype.superClass.constructor.call(this,id,domContainer,parentWidget);
	//
	//
	this.swfUrl="/static/flash/mashPlayerView.swf";
	//
	//
	this.flashContainerID 							= 	this.id+"_swf";
	this.defaultFlashParams							=	new Object();
	this.defaultFlashParams["allowfullscreen"]		=	"false";
	this.defaultFlashParams["allowscriptaccess"]	=	"true";
	this.defaultFlashParams["wmode"]				=	"transparent";
	this.defaultFlashParams["redirectUrl"]			=	"http://www.macromedia.com/go/getflashplayer";
    this.defaultFlashParams["configPath"]			=	this.flashConfigPath;
	//
	//

	this.flashVars=new Array();

}
//
//
copyPrototype(MashPlayerWidget,FlashWidget);
//
//
MashPlayerWidget.prototype.superClass=FlashWidget.prototype;
//
//
MashPlayerWidget.prototype.setMashID=function(id){
	this.mashID=id;
	if(this.movie){
		this.movie.flashUpdateMash(this.mashID);
	}
}
MashPlayerWidget.prototype.embedFlashPlayer=function(){
	MashPlayerWidget.prototype.superClass.embedFlashPlayer.call(this);
	//this.movie.flashUpdateMash(this.mashID);
}
//
//
function MasherTextFieldWidget(id,domContainer,parentWidget){
    MasherTextFieldWidget.prototype.superClass.constructor.call(this,id,domContainer,parentWidget);
}
//
//
copyPrototype(MasherTextFieldWidget,TextFieldWidget);
//
//
MasherTextFieldWidget.prototype.superClass=TextFieldWidget.prototype;


MasherTextFieldWidget.prototype.updateRemote=function(target_Id,target_type,cid,metaText_type,textString){
	MasherTextFieldWidget.prototype.superClass.updateRemote.call(this,target_Id,target_type,cid,metaText_type,textString);
	if(target_type=="Mash"){
        var entryParams = new Properties();
        entryParams.setParametersAreEncoded(true);
        entryParams.setRootElementName("ENTRY");
        entryParams.setValue("ENTRY_ID", target_Id);
        //entrySetParams.setValue("PROFILE_ID", this.profileId);
        if(metaText_type=="displayName"){	
            entryParams.setValue("DISPLAY_NAME", textString);
        }
        if(metaText_type=="description"){	
            entryParams.setValue("DESCRIPTION", textString);
        }
        //entrySetParams.setValue("IS_PUBLIC", "true");
        createOrUpdateMash(entryParams, target_type,target_Id);
        this.updateRemoteHandler();
    }

    //setMetaText(target_Id,target_type,cid,metaText_type,textString);
}//
//
function MashGalleryPageWidget(id, domContainer, parentWidget, groupId) {
    //
    //
    MashGalleryPageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.childWidgets[this.id + "_mostViewedMashes"] = new GalleryWidget(this.id+"_mostViewedMashes", this.id+"_mostViewedMashesHolder", this);
    this.childWidgets[this.id + "_mostViewedMashes"].isOpen=true;
    this.childWidgets[this.id + "_mostViewedMashes"].rangeSize = 13;
    this.childWidgets[this.id + "_mostViewedMashes"].galleryViewDOMModelBaseURL="/galleryQuery.jsp?all=true";

    if(groupId && groupId.length > 1) {
        this.childWidgets[this.id + "_mostViewedMashes"].groupId = groupId;
    }
    //
    //
    this.childWidgets[this.id + "_featuredMashes"] = new GalleryWidget(this.id+"_featuredMashes", this.id+"_featuredMashesHolder", this);
    this.childWidgets[this.id + "_featuredMashes"].isOpen=true;
    this.childWidgets[this.id + "_featuredMashes"].rangeSize = 3;
    this.childWidgets[this.id + "_featuredMashes"].galleryViewDOMModelBaseURL="/galleryQueryFeatured.jsp?all=true";
    if(groupId && groupId.length > 1) {
        this.childWidgets[this.id + "_featuredMashes"].groupId = groupId;
    }
}
//
//
copyPrototype(MashGalleryPageWidget, ContainerWidget);
//
//
MashGalleryPageWidget.prototype.superClass=ContainerWidget.prototype;

//
//
IndexPageWidget.prototype.shortName = null;
IndexPageWidget.prototype.storageFolderPath = null;
//IndexPageWidget.prototype.mashId = null;
IndexPageWidget.prototype.checkXmlFlag = "0";
//
//
function IndexPageWidget(id, domContainer, parentWidget) {
    //
    //
    IndexPageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //    
    this.childWidgets[this.id + "_mashPlayer"] = new FlashWidget(this.id+"_mashPlayer",this.id+"_mashPlayerHolder",this);
    var mashPlayerChild = this.childWidgets[this.id + "_mashPlayer"];
    mashPlayerChild.isOpen=true;
	mashPlayerChild.setSwfUrl("/static/flash/intro_.swf");
	mashPlayerChild.defaultFlashParams["wmode"]	="opaque";
    //
    //    
    //mashPlayerChild.flashContainerID = mashPlayerChild.id + "_swf";
   // mashPlayerChild.swfUrl="/flash/mashPlayerView.swf";
    //mashPlayerChild.defaultFlashParams = new Object();
    //mashPlayerChild.defaultFlashParams["allowfullscreen"] = "false";
    //mashPlayerChild.defaultFlashParams["allowscriptaccess"] = "true";
    //mashPlayerChild.defaultFlashParams["wmode"] = "transparent";
    //mashPlayerChild.defaultFlashParams["redirectUrl"] = "http://www.macromedia.com/go/getflashplayer";
    //mashPlayerChild.flashVars = new Array();
    //this.childWidgets[this.id+"_mashPlayer"].flashVersion="8";
}
//
//
copyPrototype(IndexPageWidget, ContainerWidget);
//
//
IndexPageWidget.prototype.superClass=ContainerWidget.prototype;


IndexPageWidget.prototype.show=function(){
    if(this.childWidgets[this.id+"_mashPlayer"]){
        var flashEmbedAttr = new Object();
        flashEmbedAttr["width"] = 378;
        flashEmbedAttr["height"] = 328;
        flashEmbedAttr["id"] = this.id + "_mashPlayer_swf";
        flashEmbedAttr["name"] = this.id + "_mashPlayer_swf";
        flashEmbedAttr["allowScriptAccess"] = "always";  
        //flashEmbedAttr["mashid"] = this.mashId;
        //flashEmbedAttr["standalone"] = "true";
        this.childWidgets[this.id+"_mashPlayer"].setFlashVars(flashEmbedAttr);
    }
    IndexPageWidget.prototype.superClass.show.call(this);
}
IndexPageWidget.prototype.showChild=function(){
    if(this.childWidgets[this.id+"_mashPlayer"]){
        var flashEmbedAttr = new Object();
        flashEmbedAttr["width"] = 378;
        flashEmbedAttr["height"] = 328;
        flashEmbedAttr["id"] = this.id + "_mashPlayer_swf";
        flashEmbedAttr["name"] = this.id + "_mashPlayer_swf";
        flashEmbedAttr["allowScriptAccess"] = "always";        
        //flashEmbedAttr["mashid"] = this.mashId;
        //flashEmbedAttr["standalone"] = "true";
        this.childWidgets[this.id+"_mashPlayer"].setFlashVars(flashEmbedAttr);
    }
    IndexPageWidget.prototype.superClass.showChild.call(this);
   // this.setMashPlayerMashId(this.mashId);
}
//
//
/*IndexPageWidget.prototype.setMashPlayerMashId = function(aMashId) {
    this.mashId = aMashId;
    if(this.childWidgets[this.id+"_mashPlayer"]){
        if(this.childWidgets[this.id+"_mashPlayer"].movie) {
            //this.childWidgets[this.id+"_mashPlayer"].movie.flashUpdateMash(this.mashId);
        }
    }
}*/

MashPlayerStubLauncher.prototype.mashID=null;
//
//
function MashPlayerStubLauncher(id,domContainer,parentWidget){
	//
	//
	MashPlayerStubLauncher.prototype.superClass.constructor.call(this,id,domContainer,parentWidget);
	//
	//
	this.swfUrl="/static/flash/stublauncher_.swf";
	//
	//
	this.flashContainerID 							= 	this.id+"_swf";
	this.defaultFlashParams							=	new Object();
	this.defaultFlashParams["allowfullscreen"]		=	"false";
	this.defaultFlashParams["allowscriptaccess"]	=	"true";
	this.defaultFlashParams["wmode"]				=	"transparent";
	this.defaultFlashParams["redirectUrl"]			=	"http://www.macromedia.com/go/getflashplayer";
	//
	//
	this.flashVars=new Array();
	
}
//
//
copyPrototype(MashPlayerStubLauncher,FlashWidget);
//
//
MashPlayerStubLauncher.prototype.superClass=FlashWidget.prototype;
//
//
MashPlayerStubLauncher.prototype.setMashID=function(id){
	this.mashID=id;
	if(this.movie){
		this.movie.flashUpdateMash(this.mashID);
	}
}
MashPlayerStubLauncher.prototype.embedFlashPlayer=function(){
	MashPlayerStubLauncher.prototype.superClass.embedFlashPlayer.call(this);
	//this.movie.flashUpdateMash(this.mashID);
}
//
//
InviteFriendsPageWidget.prototype.displayName = null;
InviteFriendsPageWidget.prototype.profileId = null;
InviteFriendsPageWidget.prototype.registeredEmailAddressProvider = null;
InviteFriendsPageWidget.prototype.importedInviteeSerializationTemplate = null;
InviteFriendsPageWidget.prototype.importedInviteesHolderElementId = null;
InviteFriendsPageWidget.prototype.addImportedContactsByDefault = true;
InviteFriendsPageWidget.prototype.inviterGivenName = null;
InviteFriendsPageWidget.prototype.inviterFamilyName = null;
InviteFriendsPageWidget.prototype.inviterEmail = null;
//
//
function InviteFriendsPageWidget(id, domContainer, parentWidget) {
    //
    //
    InviteFriendsPageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.childWidgets[this.id + "_inviteFriendsWidget"] = new InviteFriendsWidget(this.id+"_inviteFriendsWidget", this.id+"_inviteFriendsWidget_Holder", this);
    this.childWidgets[this.id + "_inviteFriendsWidget"].isOpen=true;
    this.childWidgets[this.id + "_inviteFriendsWidget"].hideOnInvitationsSent = false;
    this.childWidgets[this.id + "_inviteFriendsWidget"].hideOnSkip = false;
    this.childWidgets[this.id + "_inviteFriendsWidget"].alwaysUseServiceInfoEmailAsSender = true;
    this.childWidgets[this.id + "_inviteFriendsWidget"].events.invitationSent.addListener(this, this.friendsInvitedEventHandler);
    this.childWidgets[this.id + "_inviteFriendsWidget"].events.invitationSkipped.addListener(this, this.friendsInvitationSkippedEventHandler);
    this.childWidgets[this.id + "_inviteFriendsWidget"].events.contactsImported.addListener(this, this.inviteeAddressesImportedEventHandler);
    //
    //
    this.importedInviteeSerializationTemplate = 
        "<div class=\"left\"><input class=\"invitee\" id=\"" + this.id + "_importedInvitee{index}\" " +
        "type=\"checkbox\" name=\"Invitee {index}: {contactName}\" " +
        "value=\"{contactEmail}\" checked=\"true\" " +
        "onclick=\"if(this.checked){javascript:document.widgets['" + this.id + "'].addInvitee('{contactEmail}');}else{javascript:document.widgets['" + this.id + "'].removeInvitee('{contactEmail}');}\" >" +
        "{contactName} &lt;{contactEmail}&gt;" +
        "</input></div><br/>";
    this.importedInviteesHolderElementId = this.id + "_importedInviteeListHolder";
    //
    //
    this.currentStep = 1;
}
//
//
copyPrototype(InviteFriendsPageWidget, ContainerWidget);
//
//
InviteFriendsPageWidget.prototype.superClass=ContainerWidget.prototype;
//
//
/**
 * Event handler that gets called from ImportContacts.js method handleContactsImportedFrom3rdPartyServiceResult,
 * that in turn is called from contact import result page. For genericity, this method passes the event to the
 * child InviteFriendsWidget without doing anything else in this handler.
 */
InviteFriendsPageWidget.prototype.contactsImportedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    this.childWidgets[this.id + "_inviteFriendsWidget"].contactsImportedEventHandler(sourceObjectInstance, eventObjectInstance);
}

InviteFriendsPageWidget.prototype.friendsInvitedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    //
    //
    var pageTitleElement = document.getElementById(this.id + "_title");
    if(pageTitleElement) {
        pageTitleElement.innerHTML = "Your invitations have been sent";
    }
    var inviteMoreTextElement = document.getElementById(this.id + "_inviteFriendsWidget_inviteMoreText");
    if(inviteMoreTextElement) {
        inviteMoreTextElement.innerHTML = "Do you want to invite more friends?";
    }
}

InviteFriendsPageWidget.prototype.friendsInvitationSkippedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    //
}

/**
 * Open the invitation page without preselected provider
 */
InviteFriendsPageWidget.prototype.inviteMoreFriends = function() {
    //
}

/**
 * Initiating importing contacts to which send invitations
 */
InviteFriendsPageWidget.prototype.importInviteeAddresses = function(provider) {
    if(!provider) {
        provider = registeredEmailAddressProvider;
    }
    if(provider) {
        this.childWidgets[this.id + "_inviteFriendsWidget"].importContacts(provider, this.id);
    }
}

/**
 * Event handler that receives imported addresses after process started by calling importInviteeAddresses is completed
 */
InviteFriendsPageWidget.prototype.inviteeAddressesImportedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    //
    //
    if(this.importedInviteesHolderElementId && this.importedInviteeSerializationTemplate) {
        //
        //
        var importedInviteesHolderElement = document.getElementById(this.importedInviteesHolderElementId);
        if(importedInviteesHolderElement) {
            //
            //
            var importedInviteesHtml = "";
            //
            //
            var invitees = eventObjectInstance.contactsArray;
            for(var i = 0; i < invitees.length; i++) {
                var invitee = invitees[i];
                if(invitee) {
                    var inviteeEmail = invitee.email;
                    var inviteeName = invitee.name;
                    if(inviteeEmail) {
                        if(!inviteeName) {
                            inviteeName = "";
                        }
                        var serializedInvitee = this.importedInviteeSerializationTemplate;
                        serializedInvitee = serializedInvitee.replace(/{contactEmail}/g, inviteeEmail);
                        serializedInvitee = serializedInvitee.replace(/{contactName}/g, inviteeName);
                        serializedInvitee = serializedInvitee.replace(/{index}/g, i);
                        //
                        //
                        importedInviteesHtml += serializedInvitee;
                        //
                        //
                        if(this.addImportedContactsByDefault) {
                            this.addInvitee(inviteeEmail);
                        }
                    }
                }
            }
            //
            //
            importedInviteesHolderElement.innerHTML = importedInviteesHtml;
        }
    }
}

/**
 * 
 */
InviteFriendsPageWidget.prototype.addInvitee = function(email) {
    this.childWidgets[this.id + "_inviteFriendsWidget"].addInvitee(email);
}

/**
 *
 */
InviteFriendsPageWidget.prototype.removeInvitee = function(email) {
    this.childWidgets[this.id + "_inviteFriendsWidget"].removeInvitee(email);
}

/**
 *
 */
InviteFriendsPageWidget.prototype.setInviterGivenName = function(name) {
    this.inviteeGivenName = name;
}

/**
 *
 */
InviteFriendsPageWidget.prototype.setInviterFamilyName = function(name) {
    this.inviteeFamilyName = name;
}

/**
 *
 */
InviteFriendsPageWidget.prototype.setInviterEmail = function(email) {
    this.inviteeEmail = email;
}

InviteFriendsPageWidget.prototype.setInviterName = function() {
    var displayName = "";
    if(this.inviteeGivenName != null || this.inviteeFamilyName != null) {
        if(this.inviteeGivenName != null)
            displayName += this.inviteeGivenName + " ";
        if(this.inviteeFamilyName != null)
            displayName += this.inviteeFamilyName;
    }
    else if(this.inviteeEmail != null) {
        displayName = this.inviteeEmail;
    }
    else {
        displayName = "New Masher member";
    }
    var inviterNameElement = document.getElementById(this.id + "_inviteFriendsWidget_inviteFriendsName");
    if(inviterNameElement) {
        inviterNameElement.value = displayName;
    }
}

//
//
function HotmailImportContactsResultHandlerWidget(id, domContainer, parentWidget) {
    //
    //
    HotmailImportContactsResultHandlerWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.events.contactsImported = new Delegate();
}
//
//
copyPrototype(HotmailImportContactsResultHandlerWidget, Widget);
//
//
HotmailImportContactsResultHandlerWidget.prototype.superClass=Widget.prototype;
//
//
HotmailImportContactsResultHandlerWidget.prototype.contactsImportedEventHandler = function(sourceObjectInstance, eventObjectInstance) {
    this.events.contactsImported.fireEvent(this, eventObjectInstance);
}//
//
function MashIndexGalleryPage(id, domContainer, parentWidget, groupId) {
    //
    //
    MashIndexGalleryPage.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.childWidgets[this.id + "_mostViewedMashes"] = new GalleryWidget(this.id+"_mostViewedMashes", this.id+"_mostViewedMashesHolder", this);
    this.childWidgets[this.id + "_mostViewedMashes"].isOpen=true;
    this.childWidgets[this.id + "_mostViewedMashes"].rangeSize = 6;
    if(groupId && groupId.length > 1) {
        this.childWidgets[this.id + "_mostViewedMashes"].groupId = groupId;
    }
    //
    //
    this.childWidgets[this.id + "_featuredMashes"] = new GalleryWidget(this.id+"_featuredMashes", this.id+"_featuredMashesHolder", this);
    this.childWidgets[this.id + "_featuredMashes"].isOpen=true;
    this.childWidgets[this.id + "_featuredMashes"].rangeSize = 6;
    if(groupId && groupId.length > 1) {
        this.childWidgets[this.id + "_featuredMashes"].groupId = groupId;
    }
}
//
//
copyPrototype(MashIndexGalleryPage, ContainerWidget);
//
//
MashIndexGalleryPage.prototype.superClass=ContainerWidget.prototype;

//
//
function MashPlayerPage(id, domContainer, parentWidget, groupId) {
    //
    //
    MashPlayerPage.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
    //
    //
    this.childWidgets[this.id + "_mostViewedMashes"] = new GalleryWidget(this.id+"_mostViewedMashes", this.id+"_mostViewedMashesHolder", this);
    this.childWidgets[this.id + "_mostViewedMashes"].isOpen=true;
    this.childWidgets[this.id + "_mostViewedMashes"].rangeSize = 13;
    this.childWidgets[this.id + "_mostViewedMashes"].galleryViewDOMModelBaseURL="/galleryQuery.jsp?all=true";

    if(groupId && groupId.length > 1) {
        this.childWidgets[this.id + "_mostViewedMashes"].groupId = groupId;
    }
    //
    //
    this.childWidgets[this.id + "_featuredMashes"] = new GalleryWidget(this.id+"_featuredMashes", this.id+"_featuredMashesHolder", this);
    this.childWidgets[this.id + "_featuredMashes"].isOpen=true;
    this.childWidgets[this.id + "_featuredMashes"].rangeSize = 3;
    this.childWidgets[this.id + "_featuredMashes"].galleryViewDOMModelBaseURL="/galleryQueryFeatured.jsp?all=true";
    if(groupId && groupId.length > 1) {
        this.childWidgets[this.id + "_featuredMashes"].groupId = groupId;
    }
    //
    //
    this.childWidgets[this.id + "_mashPlayer"] = new MashPlayerWidget(this.id+"_mashPlayer", this.id+"_mashPlayerHolder", this);
    this.childWidgets[this.id + "_mashPlayer"].isOpen=true;
}
//
//
copyPrototype(MashPlayerPage, ContainerWidget);
//
//
MashPlayerPage.prototype.superClass=ContainerWidget.prototype;

//
// Configuration
MasherEmailPageWidget.prototype.subjectTemplate=null;
MasherEmailPageWidget.prototype.messageBodyTemplate=null;
MasherEmailPageWidget.prototype.senderNameFieldId=null;
MasherEmailPageWidget.prototype.recipientsFieldId=null;
MasherEmailPageWidget.prototype.subjectFieldId=null;
MasherEmailPageWidget.prototype.userMessageFieldId=null;
MasherEmailPageWidget.prototype.sendEntryTitle=null;
MasherEmailPageWidget.prototype.sendEntryLink=null;
MasherEmailPageWidget.prototype.recipientSeparator=",";
MasherEmailPageWidget.prototype.senderEmail=null;
//
// Values entered by user
MasherEmailPageWidget.prototype.sender=null;
MasherEmailPageWidget.prototype.recipients=null;
MasherEmailPageWidget.prototype.userSubject=null;
MasherEmailPageWidget.prototype.userMessage=null;
//
//
function MasherEmailPageWidget(id,domContainer,parentWidget){
    //
    //
    MasherEmailPageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
	//
	//
}
//
//
copyPrototype(MasherEmailPageWidget, ContainerWidget);
//
//
MasherEmailPageWidget.prototype.superClass=ContainerWidget.prototype;
//
//
MasherEmailPageWidget.prototype.sendEmail = function() {
    //
    // Read field values
    this.sender = "";
    if(this.senderNameFieldId) {
        var senderElement = document.getElementById(this.senderNameFieldId);
        if(senderElement) {
            this.sender = senderElement.value;
        }
    }
    this.recipients = "";
    if(this.recipientsFieldId) {
        var recipientsElement = document.getElementById(this.recipientsFieldId);
        if(recipientsElement) {
            this.recipients = recipientsElement.value;
        }
    }
    this.userSubject = "";
    if(this.subjectFieldId) {
        var userSubjectElement = document.getElementById(this.subjectFieldId);
        if(userSubjectElement) {
            this.userSubject = userSubjectElement.value;
        }
    }
    this.userMessage = "";
    if(this.userMessageFieldId) {
        var userMessageElement = document.getElementById(this.userMessageFieldId);
        if(userMessageElement) {
            this.userMessage = userMessageElement.value;
        }
    }
    //
    // Format message
    var subject = this.userSubject;
    if(this.subjectTemplate) {
        subject = this.formatByTemplate(this.subjectTemplate);
    }
    var messageBody = this.userMessage;
    if(this.messageBodyTemplate) {
        messageBody = this.formatByTemplate(this.messageBodyTemplate);
    }
    var recipientArray = null;
    if(this.recipients) {
        recipientArray = this.recipients.split(this.recipientSeparator);
        if(recipientArray) {
            for(var i=0; i < recipientArray.length; i++) {
                recipientArray[i] = recipientArray[i].trim();
            }
        }
    }
    //
    //
    var senderEmail = this.senderEmail;
    if(!senderEmail) {
        senderEmail = SERVICE_INFO_EMAIL;
    }
    if(recipientArray && recipientArray.length > 0 && senderEmail) {
        sendEmail(recipientArray, subject, messageBody, "text/plain", false, senderEmail, true);
    }
}
//
//
MasherEmailPageWidget.prototype.formatByTemplate = function(template) {
    var formatted = template;
    if(formatted) {
        var value = this.sender;
        if(!value) {
            value = "";
        }
        formatted = formatted.split("(((senderName)))").join(value);
        value = this.recipients;
        if(!value) {
            value = "";
        }
        formatted = formatted.split("(((recipients)))").join(value);
        value = this.userSubject;
        if(!value) {
            value = "";
        }
        formatted = formatted.split("(((userSubject)))").join(value);
        value = this.userMessage;
        if(!value) {
            value = "";
        }
        formatted = formatted.split("(((userMessage)))").join(value);
        value = this.sendEntryTitle;
        if(!value) {
            value = "";
        }
        formatted = formatted.split("(((sendEntryTitle)))").join(value);
        value = this.sendEntryLink;
        if(!value) {
            value = "";
        }
        formatted = formatted.split("(((sendEntryLink)))").join(value);
    }
    return formatted;
}
//
//
//
//
function MasherSharePageWidget(id,domContainer,parentWidget){
    //
    //
    MasherSharePageWidget.prototype.superClass.constructor.call(this, id, domContainer, parentWidget);
	//
	//
}
//
//
copyPrototype(MasherSharePageWidget, ContainerWidget);
//
//
MasherSharePageWidget.prototype.superClass=ContainerWidget.prototype;
//
//
//
//
