


WMM.TimeoutHandler = (function()
{
  var self = {};

  self.showForm = function()
  {
    $("#movieContainer").hide();
    $('.timeoutOverlay').show("normal");
    $('#timeoutLoginForm_password').val("Wachtwoord");
    $('#timeoutLoginForm_password').addClass("autoVanishField");
  }

  self.hideForm = function()
  {
    $('.timeoutOverlay').hide("normal", function()
    {
      $("#movieContainer").show();
    });
  }

  self.handle = function()
  {
    //only do timeout stuff if there is a user at all.
    if(WMM.auth.isAuthenticated)
    {
      //for a user who is consciously logged in, we want different behaviour.
      if(WMM.auth.isLoggedIn)
      {
        self.showForm();

        $('#timeoutLoginForm').submit(function(e)
        {
          var req = new WMM.RESTRequest('json/login/', 'POST');

          req.handleExceptions = false;
          req.callback = function(response) {self.onResponse(req, response);};

          req.data =  'w_login_email='    + escape($('#timeoutLoginForm_email').val()) +
                     '&w_login_password=' + escape($('#timeoutLoginForm_password').val());

          req.xheaders = {'Content-Type': 'application/x-www-form-urlencoded'};
          req.send();
          return false;
        });
      }
      else //WMM.auth.isLoggedIn
      {
        //anonymous, but authenticated; we keep-alive automatically.

        var req = new WMM.RESTRequest('json/login/keepalive/', 'GET');
        req.callback = function(r) {};
        req.send();
      }
    }
  }

  self.onResponse = function(req, response)
  {
    try
    {
      req.searchForException(response);
    }
    catch(e)
    {
      //flash error message.
      $('#timeoutMsgBox_err').fadeOut(1);
      $('#timeoutMsgBox_err').show();
      $('#timeoutMsgBox_err span').text(e.message);
      $('#timeoutMsgBox_err').fadeIn('fast');
      return;
    }
    var data = WMM.parseJSON(response);
    if(data.authorId != WMM.auth.author.authorId)
    {
      self.hideForm();
      throw new Exception("Cannot authenticate as different user.");
    }

    self.hideForm();
  }

  return self
})();

//store the current sidebar page in a cookie.
WMM.globalState.sidebarPage = new WMM.GlobalState("sidebarPage", 'womima');


Sidebar = {};


Sidebar.Page = function(name)
{
  var self = this;
  this.name            = name;
  this.isSelected      = false;
  this.pageElement     = $('#sidebarContent_' + name);
  this.iconElement     = $('#menuIcon_' + name);
  this.pulldownElement = $('#pulldown_' + name);
  
  this.select = function()
  {
    if(Sidebar.Page.selectedInstance)
    {
      Sidebar.Page.selectedInstance.deselect();
    }
    Sidebar.Page.selectedInstance = self;
    self.isSelected = true;
    
    self.loadContent();
    
    self.pageElement.show();
    self.iconElement.addClass('isOn');
    self.iconElement.removeClass('isOut');
    self.iconElement.removeClass('isOver');
    
    WMM.globalState.sidebarPage.set(this.name);
    
    $('#pulldown_current').html(this.pulldownElement.text());
  };
  
  this.deselect = function()
  {
    self.isSelected = false;
    self.pageElement.hide();
    self.iconElement.addClass('isOut');
    self.iconElement.removeClass('isOn');
  };
  
  this.loadContent = function()
  {
    if(typeof(self.request[self.name]) == 'function')
    {
      var request = self.request[self.name]();
      if(request)
      {
        self.pageElement.html('loading...');
        request.callback = self.processContent;
        request.send();
      }
    }
  }
  
  this.processContent = function(responseText)
  {
    self.pageElement.html(responseText);
    onloadSnippet(self.pageElement);
    
    if(typeof(self.onload[self.name]) == 'function')
    {
      self.onload[self.name](self.pageElement);
    }
  }
  
  //functions that are called to request page content from the server.
  this.request = 
  {
    maps: function()
    {
      if(WMM.auth.isAuthenticated && !WMM.auth.author.isAnonymous)
      {
        var url = 'html/maps/';
        url +='authors=[' + WMM.auth.author.authorId + '];';
        
        var request = new WMM.RESTRequest(url, 'GET');
        return request;
      }
      else
      {
        return null;
      }
    },
    profile: function()
    {
      if(WMM.auth.isAuthenticated && !WMM.auth.author.isAnonymous)
      {
        var url = 'html/authors/id/';
        url    += WMM.auth.author.authorId + '/profile';
        
        var request = new WMM.RESTRequest(url, 'GET');
        return request;
      }
      else
      {
        return null;
      }
    },
    help: function()
    {
      var url = 'htmls/pages/page=sidebarHelp';
      var request = new WMM.RESTRequest(url, 'GET');
      return request;
    }
  };
  
  this.onload = 
  {
    maps: function(el)
    {
      Sidebar.Map.onloadSnippet($(el));
    },
    help: function(el)
    {
      if(WMM.currentHelpCategory)
      {
        $(el).find("li#question_" + WMM.currentHelpQuestion).addClass("currentQuestion");
        $(el).find("div#categoryFolder" + WMM.currentHelpCategory).toggle();
      }
    }
  }
}

Sidebar.Page.selectedInstance = null;
Sidebar.Page.instances = {};

Sidebar.Page.get = function(name)
{
  if(!Sidebar.Page.instances[name])
  {
    Sidebar.Page.instances[name] = new Sidebar.Page(name);
  }
  return Sidebar.Page.instances[name];
}


/// Sidebar.Map ///

Sidebar.Map = function(id)
{
  var self = this;
  this.mapId = id;
  this.url   = 'json/maps/' + this.mapId;
  
  this.select = function()
  {
    //WMM.selectedMap = self.mapId;
    WMM.selectMap(self.mapId, true);
    Sidebar.Map.updateSelectedMap();
    
    var movie = WMM.Zwoesjer.getMovieObject();
    
    if(movie)
    {
      //if the movie swf exists, only reload the movie swf
      movie.outerHTML = movie.outerHTML; 
    }
    else
    {
      //else, load the entire page containing the movie swf
      location.href = WMM.serverRoot;
    }
  }
  
  this.remove = function()
  {
    var request = new WMM.RESTRequest(this.url, 'DELETE');
    request.callback = function(r)
    {
      if(self.mapId == WMM.globalState.selectedMap.get())
      {
        WMM.selectMap(WMM.WOMIMAP); //reloads sidebar content
      }
      else
      {
        Sidebar.Page.get('maps').loadContent();
      }
    };
    request.send();
  }
  
  this.rename = function(name)
  {
    var request = new WMM.RESTRequest(this.url, 'PUT');
    request.data = {"name": name};
    request.callback = function(r)
    {
      Sidebar.Page.get('maps').loadContent();
      //alert(r);
    };
    request.send();
  }
}

Sidebar.Map.updateSelectedMap = function()
{
  $('li.map').removeClass('current');
  $('li.map[data-mapId=' + WMM.globalState.selectedMap.get() + ']').addClass('current');
}

Sidebar.Map.get = function(id)
{
  return new Sidebar.Map(id);
}

Sidebar.Map.getFromElement = function(el)
{
  var id = $(el).parents('li.map').attr('data-mapId');
  if(id)
  {
    return new Sidebar.Map(id);
  }
  else
  {
    throw new WMM.Exception('cannot find mapid for element');
  }
}

Sidebar.Map.onloadSnippet = function(element)
{
  
  //show notification if a newly created map was just selected.
  if(WMM.globalState.selectedMap.get() == WMM.globalState.latestCreatedMap.get())
  {
    WMM.Notify.show('newMapWasCreated', {mapId: WMM.globalState.latestCreatedMap.get()});
    WMM.globalState.latestCreatedMap.reset();
  }

  //show correct current map
  Sidebar.Map.updateSelectedMap();
  
  //set submit handler for rename forms
  element.find('form.mapRename').trybind('submit', function()
  {
    var el = $(this).find("input[name='name']");
    if(el)
    {
      var name = el.val();
      Sidebar.Map.getFromElement(this).rename(name);
    }
    return false;
  });
  
  element.find('a.mapDelete').trybind('click', function()
  {
    if(confirm('Weet je zeker dat je deze map wilt verwijderen?'))
    {
      Sidebar.Map.getFromElement(this).remove();
    }
  });
  
  element.find('a.mapSelect').trybind('click', function()
  {
    Sidebar.Map.getFromElement(this).select();
  });
}

Sidebar.icons = {}

Sidebar.icons.hoverOver = function()
{
  $(this).addClass('isOver')
  $(this).removeClass(Sidebar.icons.getPassiveIconClass(this));
}

Sidebar.icons.hoverOut = function()
{
  $(this).addClass(Sidebar.icons.getPassiveIconClass(this))
  $(this).removeClass('isOver');
}

Sidebar.icons.getPassiveIconClass = function(iconElement)
{
  var name = iconElement.id.match(/^menuIcon_(.*)$/)[1];
  if((Sidebar.Page.selectedInstance) && (Sidebar.Page.selectedInstance.name == name))
  {
    return 'isOn';
  }
  else
  {
    return 'isOut';
  }
}

Sidebar.switchToPage = function(pageName)
{
  var page = Sidebar.Page.get(pageName);
  $('#pulldown_current').trigger('click');
  page.select();
}

//an onload handler for sidebar-specific snippets
Sidebar.onload = function()
{
  var element = $('div.sideBar');
  
  //icon rollers, etcetera.
  element.find('a.rollableIcon').hover(
    Sidebar.icons.hoverOver,
    Sidebar.icons.hoverOut
  );
  
  //menu events
  element.find('a.menuIcon').trybind('click', function()
  {
    var pageName = this.id.match(/^menuIcon_(.*)$/)[1];
    var page = Sidebar.Page.get(pageName);
    page.select();
  });
  
  //pulldown events
  element.find('#menuPulldownList A').trybind('click', function()
  {
    var pageName = this.id.match(/^pulldown_(.*)$/)[1];
    Sidebar.switchToPage(pageName);
  });
  
  element.find('a.sidebarLink').trybind('click', function()
  {
    var pageName = $(this).attr('data-sidebarLinkTo');
    Sidebar.switchToPage(pageName);
  });
}

WMM.TimeoutHandler = (function()
{
  var self = {};

  self.showForm = function()
  {
    $("#movieContainer").hide();
    $('.timeoutOverlay').show("normal");
    $('#timeoutLoginForm_password').val("Wachtwoord");
    $('#timeoutLoginForm_password').addClass("autoVanishField");
  }

  self.hideForm = function()
  {
    $('.timeoutOverlay').hide("normal", function()
    {
      $("#movieContainer").show();
    });
  }

  self.handle = function()
  {
    //only do timeout stuff if there is a user at all.
    if(WMM.auth.isAuthenticated)
    {
      //for a user who is consciously logged in, we want different behaviour.
      if(WMM.auth.isLoggedIn)
      {
        self.showForm();

        $('#timeoutLoginForm').submit(function(e)
        {
          var req = new WMM.RESTRequest('json/login/', 'POST');

          req.handleExceptions = false;
          req.callback = function(response) {self.onResponse(req, response);};

          req.data =  'w_login_email='    + escape($('#timeoutLoginForm_email').val()) +
                     '&w_login_password=' + escape($('#timeoutLoginForm_password').val());

          req.xheaders = {'Content-Type': 'application/x-www-form-urlencoded'};
          req.send();
          return false;
        });
      }
      else //WMM.auth.isLoggedIn
      {
        //anonymous, but authenticated; we keep-alive automatically.

        var req = new WMM.RESTRequest('json/login/keepalive/', 'GET');
        req.callback = function(r) {};
        req.send();
      }
    }
  }

  self.onResponse = function(req, response)
  {
    try
    {
      req.searchForException(response);
    }
    catch(e)
    {
      //flash error message.
      $('#timeoutMsgBox_err').fadeOut(1);
      $('#timeoutMsgBox_err').show();
      $('#timeoutMsgBox_err span').text(e.message);
      $('#timeoutMsgBox_err').fadeIn('fast');
      return;
    }
    var data = WMM.parseJSON(response);
    if(data.authorId != WMM.auth.author.authorId)
    {
      self.hideForm();
      throw new Exception("Cannot authenticate as different user.");
    }

    self.hideForm();
  }

  return self
})();
function onloadSnippet(element)
{  
  //autoVanishField
  //support for fields whose content automatically vanishes once they are selectd
  element.find('input.autoVanishField').one("focus", function() {
    this.value = '';
    $(this).removeClass('autoVanishField');
  });

  //map edit rollers
  element.find('a.rollable').hover(
    function()
    {
      $(this).addClass('isOver')
      $(this).removeClass('isOut');
    },
    function()
    {
      $(this).addClass('isOut')
      $(this).removeClass('isOver');
    }
  );
  

  
  // expander
  // @param data may be either { collapse: true } or unspecified
  element.find('a.expander').click(function(e, data)
  {
    var el = $(this);
    if(el.attr('data-expandSelector'))
    {
      var expEl = $(el.attr('data-expandSelector'));
      if(expEl)
      {
        if(data && data.collapse)
        {
          $(this).removeClass('expanded');
          expEl.hide();
        }
        else
        {
          $(this).toggleClass('expanded');
          expEl.toggle();
        }
        
        //autoCollapse collapses the element if the user clicks anywhere in
        //the document
        if(el.hasClass('autoCollapse'))
        {
          function collapseHandler(e)
          {
            $('body').unbind('click.autoCollapse')
            el.trigger('click', {collapse: true});
          }
          
          if($(expEl).is(':visible'))
          {
            $('body').bind('click.autoCollapse', collapseHandler);
          }
          else
          {
            //always unbind if the element was just hidden, to prevent
            //a huge amount of useless collapseHandler calls.
            $('body').unbind('click.autoCollapse');
          }
          e.stopPropagation();
        }
      }
    }
  });
  
  //map edit rollers
  element.find('li.parentRollable').hover(
    function()
    {
      $(this).addClass('isOverParent')
      $(this).removeClass('isOutParent');
    },
    function()
    {
      $(this).addClass('isOutParent')
      $(this).removeClass('isOverParent');
    }
  );
  
  //tooltips
  element.find('.tooltipped').tooltip({ 
    track: true, 
    delay: 300, 
    showURL: false, 
    fade: 250,
    left: -120
  });
  

  //rounded corners
  //element.find('.rounded').corner("8px");
}
//
//WMM.handleTimeout = function()
//{
//  alert("timed out!");
//}

WMM.handleException = function(e)
{
  //compute the error messages, with support for exceptions that are not WMM.Exception
  var msg = e.message || 'Er is een onverwachte fout opgetreden. Onze excuses voor het ongemak.';
  var detailedMsg = (e.getDetailedString) ? e.getDetailedString() : JSON.stringify(e);

  //display the messages
  $('p#errorMessage_msg').html(msg);
  $('p#errorMessage_detailedMsg').html(detailedMsg);

  //hide everything in the main content field, except the error container.
  $('div.mainContentField').children().filter(':not(div#errorContainer)').hide();

  //show the error container.
  $('a#showDetailedError').show();
  $('div#errorContainer').show();
}

$(document).ready(function()
{
  onloadSnippet($(document.body));
  Sidebar.onload();

  //if we have to make a map-related notification, we want to load the maps
  //overview no matter what
  if(WMM.globalState.latestCreatedMap.get() == WMM.globalState.selectedMap.get())
  {
    Sidebar.Page.get("maps").select();
  }
  else
  {
    //otherwise, we load whatever page was displayed before.
    //Sidebar.Page.get(WMM.Ext.readCookieDefault('WMM_Sidebar_Page', 'womima')).select();
    Sidebar.Page.get(WMM.globalState.sidebarPage.get()).select();
  }
});

WMM.Exceptions.setHandler(WMM.handleException);
//WMM.Timeout.enable(0.05, WMM.TimeoutHandler.handle);

WMM.Timeout.enable(20, WMM.TimeoutHandler.handle); //show timeout window after 20 minutes; just below PHP's 24 minutes



WMM.Zwoesjer = {};

// FIXME: after launch, this goes via some resource so that Kees&Karel can easily customize it.
WMM.Zwoesjer.tempStartPhraseList = [

  'womima',
  'brein',
  'kring',
  'denken',
  'creativiteit',
  'beeld',
  'delen'
]

///@return WMM.RESTRequest
WMM.Zwoesjer.request_getAssociations = function(callData)
{
  //workaround: currently, the zwoesjer always expects 2 rings but only asks for 1.
  //we assume that 2 rings are required and that the same amount is requested for both.
  var amount1 = callData.ring.amount;
  var amount2 = callData.ring.amount;
  var url     = '';
  
  //alert(JSON.stringify(callData));
  
  if(callData.phraseFrom == '')
  {
    if(WMM.startAtPhrase)
    {
      callData.phraseFrom = WMM.startAtPhrase;
      //alert(callData.phraseFrom);
    }
    else
    {
      if(WMM.isWomimap())
      {
        var dayOfWeek = (new Date()).getDay();
        callData.phraseFrom = WMM.Zwoesjer.tempStartPhraseList[dayOfWeek];
      }
      else
      {
        //Zwoesjer asked for no phraseFrom, but we do have a current map selected;
        //then, we want to get the latest association from this map.
        url = 'json/maps/' + WMM.globalState.selectedMap.get() + '/latestAssociation/';
      }
    }
  }
  
  
  //create standard URL iff no URL has been set yet.
  if(url == '')
  {
    url = 'json/associations/' + urlencode(callData.phraseFrom) + '/amount=' + amount1 + ';';
    
    if(!WMM.isWomimap())
    {
      url += 'maps=[' + WMM.globalState.selectedMap.get() + '];';
    }
    
    url += '/twoRings/amount2=' + amount2 + ';';
  }
  
  return new WMM.RESTRequest(url, 'GET');
}

///@return WMM.RESTRequest
WMM.Zwoesjer.request_getRecentAssociations = function(callData)
{
  // for the rest, this function is modeled exactly after the
  // example WMM.Zwoesjer.request_getAssociations. 
  var amount1 = callData.ring.amount;
  var amount2 = callData.ring.amount;
  var url     = '';
  
  //alert(JSON.stringify(callData));
  //create standard URL iff no URL has been set yet.
  if(url == '')
  {
    url = 'json/recentAssociations/amount=' + amount1 + ';';
    
    //if(!WMM.isWomimap())
    //{
    //  url += 'maps=[' + WMM.globalState.selectedMap.get() + '];';
    //}
    // there used to be  a further extension of the url:
    //  url += '/twoRings/amount2=' + amount2 + ';
	// but this causes non-well formed url's in the case
	// of recentAssociations
  }
  
  return new WMM.RESTRequest(url, 'GET');
}


///recursively adds correct phraseFrom fields
WMM.Zwoesjer.unsparsify_phraseFrom = function(assocs, phraseFrom)
{
  for(var i in assocs)
  {
    assocs[i].phraseFrom = phraseFrom;
    if(assocs[i].ring && assocs[i].ring.length)
    {
      assocs[i].ring = WMM.Zwoesjer.unsparsify_phraseFrom(assocs[i].ring, assocs[i].phraseTo);
    }
  }
  //alert(JSON.stringify(assocs));
  return assocs;
}

///@return WMM.Callback
WMM.Zwoesjer.process_getAssociations = function(responseText, callData)
{
  //alert(responseText);

  var assocs = WMM.parseJSON(responseText);
  var phraseFrom = callData.phraseFrom;
  
  //maps/{mapId}/latestAssociations returns {phraseFrom: ..., ring: [AEC]} 
  //instead of just [AEC], so we fix that up
  if(assocs.phraseFrom)
  {
    phraseFrom = assocs.phraseFrom;
    assocs = assocs.ring;
  }
  
  //unsparsify data.
  assocs = WMM.Zwoesjer.unsparsify_phraseFrom(assocs, phraseFrom);
  
  //zwoesjer bug workaround: if at the initial request, no associations are found,
  //the zwoesjer crashes
  //if((assocs.length == 0) && (callData.phraseFrom == ""))
  //{
  //  assocs[0] = {phraseFrom: "banaan", phraseTo: "appel", ring: [], source: 1};
  //}
  
  //build response callback
  var responseCallback = new WMM.Callback("gotAssociations", assocs);
  
  return responseCallback;
}

///@return WMM.Callback
WMM.Zwoesjer.process_getRecentAssociations = function(responseText, callData)
{
  //alert(responseText);

  var assocs = WMM.parseJSON(responseText);
    
  //maps/{mapId}/latestAssociations returns {phraseFrom: ..., ring: [AEC]} 
  //instead of just [AEC], so we fix that up
  
  //unsparsify data.
  //assocs = WMM.Zwoesjer.unsparsify_phraseFrom(assocs, "niets");
  
  //zwoesjer bug workaround: if at the initial request, no associations are found,
  //the zwoesjer crashes
  //if((assocs.length == 0) && (callData.phraseFrom == ""))
  //{
  //  assocs[0] = {phraseFrom: "banaan", phraseTo: "appel", ring: [], source: 1};
  //}
  
  //build response callback
  var responseCallback = new WMM.Callback("gotAssociations", assocs);
  
  return responseCallback;
}
///@return WMM.Callback
WMM.Zwoesjer.request_getAuthInfo = function(callData)
{
  var authInfo = WMM.auth;
  
  var responseCallback = new WMM.Callback("gotAuthInfo", authInfo);
  return responseCallback;
}

///@return WMM.RESTRequest
WMM.Zwoesjer.request_createAssociation = function(callData)
{
  
  if((callData.phraseFrom != '') && (callData.phraseTo != ''))
  {
  
    WMM.debug.out('current map id: ' + WMM.globalState.selectedMap.get(), 'currentState');
    if(WMM.auth.author)
      WMM.debug.out('current author id: ' + WMM.auth.author.authorId, 'currentState');
    
    var computeURL = function()
    {
      var url = 'json/associations/' + urlencode(callData.phraseFrom) + '/' + urlencode(callData.phraseTo) + '/';
      if(WMM.auth.isAuthenticated)
      {
        url += 'authors=[' + WMM.auth.author.authorId + '];';
      }
      
      if(!WMM.isWomimap())
      {
        url += 'maps=[' + WMM.globalState.selectedMap.get() + '];';
      }
      
      return url;
    }
    
    var request = new WMM.RESTRequest('', 'POST');
    
    //set callback to recompute the URL, just in case authentication info changed
    //before this request got out of queue.
    request.beforeSend = function(req)
    {
      request.setURL(computeURL());
    };
    
    request.isSynchronous = true;
    
    return request;
  }
}

WMM.Zwoesjer.process_createAssociation = function(responseText, callData)
{
  var wasWomimap = WMM.isWomimap();

  createdInfo = WMM.parseJSON(responseText);
  WMM.selectMap(createdInfo.mapId, false);
  WMM.setAuthor(createdInfo.author, true);

  if (wasWomimap)
  {
    //WMM.Notify.show('newMapWasCreated', {mapId: createdInfo.mapId});
    
    //raise a flag that we have a newly created map.
    WMM.globalState.latestCreatedMap.set(createdInfo.mapId);
  }
}


///@return WMM.RESTRequest
WMM.Zwoesjer.request_deleteAssociation = function(callData)
{
  if((callData.phraseFrom != '') && (callData.phraseTo != ''))
  {
    if((WMM.auth.isAuthenticated) && (!WMM.isWomimap()))
    {
      var computeURL = function()
      {
        var url = 'json/associations/' + urlencode(callData.phraseFrom) + '/' + urlencode(callData.phraseTo) + '/';
        url += 'authors=[' + WMM.auth.author.authorId + '];';
        url += 'maps=[' + WMM.globalState.selectedMap.get() + '];';
        return url;
      }
      
      var request = new WMM.RESTRequest('', 'DELETE');
      
      //set callback to recompute the URL, just in case authentication info changed
      //before this request got out of queue.
      request.beforeSend = function(req)
      {
        req.setURL(computeURL());
        //alert(req.url);
      };
      
      request.isSynchronous = true;
      
      return request;
    }
  }
}


WMM.Zwoesjer.movieName = '';

WMM.Zwoesjer.doCallback = function(wmmCallback)
{
  var message = JSON.stringify(wmmCallback);
  var alreadyTriedReload = false;
  //if(movie)
  //{
    //alert(JSON.stringify(movie));
  var callFunc = function()
  {
    try
    {
      var movie = WMM.Zwoesjer.getMovieObject();
      movie.WMM_zwoesjerCallback(message);
    }
    catch(e)
    {
      if(!alreadyTriedReload)
      {
        movie.outerHTML = movie.outerHTML; 
        setTimeout(callFunc, 100);
      }
      alreadyTriedReload = true;
    }
  }
  callFunc();
  //}
  //else
  //{
  //  throw new WMM.Exception("Cannot access SWF object!");
  //}
}

WMM.Zwoesjer.getMovieObject = function()
{
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[WMM.Zwoesjer.movieName] : document[WMM.Zwoesjer.movieName];
}


