
 if (typeof console == "undefined") var console = { log: function() {} };
function gc(Name) {  var search = Name + "=";  var returnvalue = "";  if (document.cookie.length > 0) { offset = document.cookie.indexOf(search); if (offset != -1) {   offset += search.length; end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length;  returnvalue=unescape(document.cookie.substring(offset, end)) } }  return returnvalue; }
var urchinTracker; var is_fb_user;
var gk=gc('gk').split("|"); var p=gk[0]; var t=gk[1]; var http_request = false; function penumbra() {}; shadow=new penumbra();
function $(el) { return document.getElementById(el); }
function isset(x) { return (x=='' || x==undefined || !x) ? false : true; }
penumbra.prototype.request=function(vars, handlerObj, handlerFunction) {
  http_request = false;
  if (window.XMLHttpRequest) {
    http_request = new XMLHttpRequest();  if (http_request.overrideMimeType) {  http_request.overrideMimeType('text/xml');  }
  } else if (window.ActiveXObject) {
    try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {   try {     http_request = new ActiveXObject("Microsoft.XMLHTTP");    } catch (e) {}    } }
  if (!http_request) {  alert('Cannot create a way to communicate with the server.'); return false; }
  http_request.open('POST', t, true); var varStr=''; for (field in vars) {  var cField=pStr(vars[field]); varStr+=field + "=" + cField + "&"; if (vars[field] !='' && field !='content' && field !='projectOutline' && typeof(vars[field])!='function') {   http_request.setRequestHeader(field, cField);     } }
  varStr+='s=' + p; if (vars['trackID']!=undefined  && isset(urchinTracker)) {  urchinTracker(vars['trackID']); }
  http_request.onreadystatechange=eval(handlerObj)[handlerFunction];
  http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  http_request.send(varStr);
}

penumbra.prototype.irequest=function(vars, handlerObj, handlerFunction) {
  this.http_request = false;
  if (window.XMLHttpRequest) {
    this.http_request = new XMLHttpRequest(); if (this.http_request.overrideMimeType) { this.http_request.overrideMimeType('text/xml'); }
  } else if (window.ActiveXObject) {
    try { this.http_request = new ActiveXObject("Msxml2.XMLHTTP");  } catch (e) {   try {     this.http_request = new ActiveXObject("Microsoft.XMLHTTP");   } catch (e) {}    } }
  if (!this.http_request) { alert('Cannot create a way to communicate with the server.'); return false; }
  this.http_request.open('POST', t, true);  var varStr=''; for (field in vars) { if (typeof(vars[field])=='function') { continue; } var cField=pStr(vars[field]); varStr+=field + "=" + cField + "&"; if (vars[field] !='' && field !='content' && field !='projectOutline' && typeof(vars[field])!='function') {   this.http_request.setRequestHeader(field, cField);      } }
  varStr+='s=' + p; if (vars['trackID']!=undefined && isset(urchinTracker)) { urchinTracker(vars['trackID']); }
  var req=this; req.handlerObj=handlerObj;  req.handlerFunction=handlerFunction;
  req.http_request.onreadystatechange=function(handlerObj, handlerFunction) {
    if (req.http_request.readyState == 4) {
      if (req.http_request.status == 200) {   eval(req.handlerObj)[req.handlerFunction](req.http_request);  } else {  plotbot.error();  }
    } else {
      //Still waiting...
    }
  }

  this.http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  this.http_request.send(varStr);
}

penumbra.prototype.collect_form=function(o, e) {
  for (var form_element in e) {
    if (isset(e[form_element]) && isset(e[form_element].value) && isset(e[form_element].name)) {
      o[e[form_element].name]=e[form_element].value;
    }
  }
  return o
}

penumbra.prototype.error=function(id) {
  alert('Sorry! There was a problem with your request--we\'re not sure why! Please report what happened in the bug manager at the bottom of the page. If your page has not already automatically refreshed, please reload the page.')
}

if (!isset(translations)) { var translations=new Object(); }

translations['saving']="Sparar...";
translations['deleting']="Raderar...";
translations['loading']="laddar...";


function turnOnDebug() {var myStyle = document.getElementById('debugger').style; if(myStyle.visibility=="visible") { myStyle.visibility = "none"; } else { myStyle.visibility = "visible"; } }
function pStr(s) { if (typeof(s)=="string" && s !='' && s !=undefined) { return encodeURIComponent(s); } else { return s; } }

function strToURL(s) {
  var t=s.replace(/\s/gmi,"_");
  return t.replace(/\W/gmi,"");
}

function cleanStr(s) {
  if (typeof(s)=="string" && s !='' && s !=undefined) {
    ns=s.replace(/\r|\n|\r\n/g," ");
    cs=ns.replace(/(<center>)|(<\/center>)/gmi, "\r");
    bs=cs.replace(/\'/g,"&#39;");
    return bs;
  } else {
    return s;
  }
}
function projectSelect() { var project_url=document.forms['projectSelector']['project_url'].value; if (isset(project_url)) {  window.location=project_url;  } }

function core() { this.tipManager=new Object(); this.htmlStorage=new Object(); this.editManager=new Object(); this.sceneManager=new Object(); this.commentManager=new Object(); }
core.prototype=new penumbra(); plotbot=pb=new core();
core.prototype.expandSession=function(sessionID) { var myStyle = document.getElementById('session_' + sessionID).style;
if(myStyle.visibility=="visible") { myStyle.visibility = "hidden"; myStyle.height="0px"; document.getElementById('button_' + sessionID).innerHTML="<img src='/imgs/view.details.gif'>";
} else { myStyle.visibility = "visible"; myStyle.height="auto"; document.getElementById('button_' + sessionID).innerHTML="<img src='/imgs/hide.details.gif'>"; }}
core.prototype.expandProjectActivity=function() { var myStyle = document.getElementById('project_activity').style; if(myStyle.display=='block') { myStyle.display = 'none'; myStyle.height="0px"; document.getElementById('project_activity_button').innerHTML="<img src='/imgs/view.details.gif'>";
} else { myStyle.display = 'block'; myStyle.height="auto"; document.getElementById('project_activity_button').innerHTML="<img src='/imgs/hide.details.gif'>";} }

core.prototype.collapseHeader=function() {

  var h = document.getElementById('plotbot_header').style;
  if(h.visibility!="hidden") { h.visibility = "hidden"; h.height="0px"; var s=0; } else { h.visibility = "visible"; h.height="auto"; var s=1; }

  var arrow = new Image();
  arrow.src="/imgs/header.";
  arrow.src+=(s==0) ? "show" : "hide";
  arrow.src+=".gif";
  document["toggle_header"].src=arrow.src;

  o=[];
  o.requestType='showHeader';
  o.dir=s;
  this.irequest(o, 'plotbot', 'populateHeader');
}

core.prototype.populateHeader=function(obj) {
  var rHTML=obj.responseText
  if (rHTML !='') {
    document.getElementById('plotbot_header').innerHTML=rHTML
    var so = new SWFObject("/swf/header.swf?userData=" + obj.getResponseHeader("header_string"), "_header", "100%", "122", "7", "#FFFFFF");
    so.write("flashcontent");
  } else {
    document.getElementById('plotbot_header').innerHTML="<div style='height:0px;'></div>";
  }
}


function trace_object(o) {
  var s="";
  for (var p in o) { s+=p + " = " + o[p] + "\n";  }
  alert(s);
}

core.prototype.resize=function(f) {
  if (!isset(f)) { return false; }
  a = f.value.split('\n');
  b=1;  var n=a.length; var i=0
  do { if (a[i].length >= f.cols) { b+= Math.floor(a[i].length/f.cols); } } while (++i < n);
  b+= a.length;
  if (b > f.rows) { f.rows = b; }

}
core.prototype.hide=function(d, s) {
  if (isset($(d))) {
    var h = $(d).style;
    if(h.display!='none' || s) { h.display = 'none'; } else { h.display = 'auto'; }
  }
}

core.prototype.vanish=function(d) {
  if (isset($(d))) {
    $(d).innerHTML='';
    var h = $(d).style;
    if(h.visibility!='none') { h.visibility = 'none'; h.height="0px"; } else { h.visibility = "visible"; h.height="auto";  }
  }
}

core.prototype.wait=function(id, type) {
  if ($(id)) {
    this.htmlStorage[id]=$(id).innerHTML
    $(id).innerHTML="<span class='small'>" + translations['loading'] + "</span>";
  } else {
    //alert ("Trying to wait for ID >" + id + "< but it doesn't exist")
  }
}

function facebook_connect_onclick() {
  try { $('flash_demo').innerHTML=""; } catch (e) { } //Flash overlaps FB connect.
  ensure_init(function() {
      FB.Facebook.get_sessionState().waitUntilReady(function() {
          var user = FB.Facebook.apiClient.get_session() ? FB.Facebook.apiClient.get_session().uid : null;

          // probably should give some indication of failure to the user
          if (!user) { return; }

          // The Facebook Session has been set in the cookies,
          // which will be picked up by the server on the next page load
          // so refresh the page, and let all the account linking be
          // handled on the server side

          // This could be done a myriad of ways; for a page with more content,
          // you could do an ajax call for the account linking, and then
          // just replace content inline without a full page refresh.
          refresh_page();
        });
    });
}


function facebook_onload(already_logged_into_facebook) {
  if (auto_start_screenplay) { init_screenplay_demo(); }
  ensure_init(function() {
      FB.Facebook.get_sessionState().waitUntilReady(function(session) {
          var is_now_logged_into_facebook = session ? true : false;
          is_fb_user = (is_now_logged_into_facebook)
          if (is_now_logged_into_facebook == already_logged_into_facebook) {
            return;
          }
          // otherwise, refresh to pick up the state change

          refresh_page();
        });
    });
}

function ensure_init(callback) {
  if(!window.api_key) {
    window.alert("Facebook api_key is not set");
  }

  if(window.is_initialized) {
    callback();
  } else {
    FB_RequireFeatures(["XFBML", "CanvasUtil"], function() {
       FB.FBDebug.logLevel = 0;
       FB.FBDebug.isEnabled = false;
       FB.init(window.api_key, "http://www.plotbot.com/connect/xd_receiver.html");
       window.is_initialized = true;
       callback();
     });
  }
}

function refresh_page() {
  window.location = window.location;
}

function pb_signout() {
  if (is_fb_user) {
    FB.Connect.logout(function() { do_pb_signout(); })
  } else {
    do_pb_signout()
  }
}

function do_pb_signout() {
  window.location="/signout";
}

function stop_waiting(e) {
  $(e).innerHTML=""
  return true;
}

function pb_go_to(u) {
  window.location="/" + u;
}

function pb_debug(s, level) {
 try {
  console.log(s);
 } catch (e) {

 }
}




/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;