window.onerror = function(messsage, url, line) {    
    if (typeof(console) != "undefined") {
        console.log('Exception ' + url + ' on line ' + line + ': "' + messsage + '"');
    }
    return true;
};// Flash Player Version Detection - Rev 1.6
// Detect Client Browser type
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
    var version;
    var axo;
    var e;

    // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

    try {
        // version will be set for 7.X or greater players
        axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
        version = axo.GetVariable("$version");
    } catch (e) {
    }

    if (!version)
    {
        try {
            // version will be set for 6.X players only
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

            // installed player is some revision of 6.0
            // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
            // so we have to be careful.

            // default to the first public version
            version = "WIN 6,0,21,0";

            // throws if AllowScripAccess does not exist (introduced in 6.0r47)
            axo.AllowScriptAccess = "always";

            // safe to call for 6.0r47 or greater
            version = axo.GetVariable("$version");

        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 4.X or 5.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = axo.GetVariable("$version");
        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 3.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
            version = "WIN 3,0,18,0";
        } catch (e) {
        }
    }

    if (!version)
    {
        try {
            // version will be set for 2.X player
            axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
            version = "WIN 2,0,0,11";
        } catch (e) {
            version = -1;
        }
    }

    return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
    // NS/Opera version >= 3 check for Flash plugin in plugin array
    var flashVer = -1;

    if (navigator.plugins != null && navigator.plugins.length > 0) {
        if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
            var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
            var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
            var descArray = flashDescription.split(" ");
            var tempArrayMajor = descArray[2].split(".");
            var versionMajor = tempArrayMajor[0];
            var versionMinor = tempArrayMajor[1];
            var versionRevision = descArray[3];
            if (versionRevision == "") {
                versionRevision = descArray[4];
            }
            if (versionRevision[0] == "d") {
                versionRevision = versionRevision.substring(1);
            } else if (versionRevision[0] == "r") {
                versionRevision = versionRevision.substring(1);
                if (versionRevision.indexOf("d") > 0) {
                    versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
                }
            }
            var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
            //alert("flashVer="+flashVer);
        }
    }
    // MSN/WebTV 2.6 supports Flash 4
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    // WebTV 2.5 supports Flash 3
    else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    // older WebTV supports Flash 2
    else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    else if ( isIE && isWin && !isOpera ) {
        flashVer = ControlVersion();
    }
    return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
    versionStr = GetSwfVer();
    if (versionStr == -1 ) {
        return false;
    } else if (versionStr != 0) {
        if(isIE && isWin && !isOpera) {
            // Given "WIN 2,0,0,11"
            tempArray         = versionStr.split(" ");  // ["WIN", "2,0,0,11"]
            tempString        = tempArray[1];           // "2,0,0,11"
            versionArray      = tempString.split(",");  // ['2', '0', '0', '11']
        } else {
            versionArray      = versionStr.split(".");
        }
        var versionMajor      = versionArray[0];
        var versionMinor      = versionArray[1];
        var versionRevision   = versionArray[2];

            // is the major.revision >= requested major.revision AND the minor version >= requested minor
        if (versionMajor > parseFloat(reqMajorVer)) {
            return true;
        } else if (versionMajor == parseFloat(reqMajorVer)) {
            if (versionMinor > parseFloat(reqMinorVer))
                return true;
            else if (versionMinor == parseFloat(reqMinorVer)) {
                if (versionRevision >= parseFloat(reqRevision))
                    return true;
            }
        }
        return false;
    }
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?');
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
    var str = '';
    if (isIE && isWin && !isOpera)
    {
        str += '<object ';
        for (var i in objAttrs)
            str += i + '="' + objAttrs[i] + '" ';
        for (var i in params)
            str += '><param name="' + i + '" value="' + params[i] + '" /> ';
        str += '></object>';
    } else {
        str += '<embed ';
        for (var i in embedAttrs)
            str += i + '="' + embedAttrs[i] + '" ';
        str += '> </embed>';
    }

    document.write(str);
}

function AC_FL_RunContent(){
  var ret =
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();

    switch (currArg){
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "id":
      case "width":
      case "height":
      case "align":
      case "vspace":
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;
// -----------------------------------------------------------------------------

// Version check based upon the values entered above in "Globals"
var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

// Check to see if the version meets the requirements for playback
if (!hasReqestedVersion) {
    location.href = 'getflash.html';
}

requiredMajorVersion = 9;
requiredMinorVersion = 0;
requiredRevision = 115;
hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

/* 
 * flowplayer.js 3.2.4. The Flowplayer API
 * 
 * Copyright 2009 Flowplayer Oy
 * 
 * This file is part of Flowplayer.
 * 
 * Flowplayer is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Flowplayer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Flowplayer.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Date: 2010-08-25 12:48:46 +0000 (Wed, 25 Aug 2010)
 * Revision: 551 
 */
(function(){function g(o){console.log("$f.fireEvent",[].slice.call(o))}function k(q){if(!q||typeof q!="object"){return q}var o=new q.constructor();for(var p in q){if(q.hasOwnProperty(p)){o[p]=k(q[p])}}return o}function m(t,q){if(!t){return}var o,p=0,r=t.length;if(r===undefined){for(o in t){if(q.call(t[o],o,t[o])===false){break}}}else{for(var s=t[0];p<r&&q.call(s,p,s)!==false;s=t[++p]){}}return t}function c(o){return document.getElementById(o)}function i(q,p,o){if(typeof p!="object"){return q}if(q&&p){m(p,function(r,s){if(!o||typeof s!="function"){q[r]=s}})}return q}function n(s){var q=s.indexOf(".");if(q!=-1){var p=s.slice(0,q)||"*";var o=s.slice(q+1,s.length);var r=[];m(document.getElementsByTagName(p),function(){if(this.className&&this.className.indexOf(o)!=-1){r.push(this)}});return r}}function f(o){o=o||window.event;if(o.preventDefault){o.stopPropagation();o.preventDefault()}else{o.returnValue=false;o.cancelBubble=true}return false}function j(q,o,p){q[o]=q[o]||[];q[o].push(p)}function e(){return"_"+(""+Math.random()).slice(2,10)}var h=function(t,r,s){var q=this,p={},u={};q.index=r;if(typeof t=="string"){t={url:t}}i(this,t,true);m(("Begin*,Start,Pause*,Resume*,Seek*,Stop*,Finish*,LastSecond,Update,BufferFull,BufferEmpty,BufferStop").split(","),function(){var v="on"+this;if(v.indexOf("*")!=-1){v=v.slice(0,v.length-1);var w="onBefore"+v.slice(2);q[w]=function(x){j(u,w,x);return q}}q[v]=function(x){j(u,v,x);return q};if(r==-1){if(q[w]){s[w]=q[w]}if(q[v]){s[v]=q[v]}}});i(this,{onCuepoint:function(x,w){if(arguments.length==1){p.embedded=[null,x];return q}if(typeof x=="number"){x=[x]}var v=e();p[v]=[x,w];if(s.isLoaded()){s._api().fp_addCuepoints(x,r,v)}return q},update:function(w){i(q,w);if(s.isLoaded()){s._api().fp_updateClip(w,r)}var v=s.getConfig();var x=(r==-1)?v.clip:v.playlist[r];i(x,w,true)},_fireEvent:function(v,y,w,A){if(v=="onLoad"){m(p,function(B,C){if(C[0]){s._api().fp_addCuepoints(C[0],r,B)}});return false}A=A||q;if(v=="onCuepoint"){var z=p[y];if(z){return z[1].call(s,A,w)}}if(y&&"onBeforeBegin,onMetaData,onStart,onUpdate,onResume".indexOf(v)!=-1){i(A,y);if(y.metaData){if(!A.duration){A.duration=y.metaData.duration}else{A.fullDuration=y.metaData.duration}}}var x=true;m(u[v],function(){x=this.call(s,A,y,w)});return x}});if(t.onCuepoint){var o=t.onCuepoint;q.onCuepoint.apply(q,typeof o=="function"?[o]:o);delete t.onCuepoint}m(t,function(v,w){if(typeof w=="function"){j(u,v,w);delete t[v]}});if(r==-1){s.onCuepoint=this.onCuepoint}};var l=function(p,r,q,t){var o=this,s={},u=false;if(t){i(s,t)}m(r,function(v,w){if(typeof w=="function"){s[v]=w;delete r[v]}});i(this,{animate:function(y,z,x){if(!y){return o}if(typeof z=="function"){x=z;z=500}if(typeof y=="string"){var w=y;y={};y[w]=z;z=500}if(x){var v=e();s[v]=x}if(z===undefined){z=500}r=q._api().fp_animate(p,y,z,v);return o},css:function(w,x){if(x!==undefined){var v={};v[w]=x;w=v}r=q._api().fp_css(p,w);i(o,r);return o},show:function(){this.display="block";q._api().fp_showPlugin(p);return o},hide:function(){this.display="none";q._api().fp_hidePlugin(p);return o},toggle:function(){this.display=q._api().fp_togglePlugin(p);return o},fadeTo:function(y,x,w){if(typeof x=="function"){w=x;x=500}if(w){var v=e();s[v]=w}this.display=q._api().fp_fadeTo(p,y,x,v);this.opacity=y;return o},fadeIn:function(w,v){return o.fadeTo(1,w,v)},fadeOut:function(w,v){return o.fadeTo(0,w,v)},getName:function(){return p},getPlayer:function(){return q},_fireEvent:function(w,v,x){if(w=="onUpdate"){var z=q._api().fp_getPlugin(p);if(!z){return}i(o,z);delete o.methods;if(!u){m(z.methods,function(){var B=""+this;o[B]=function(){var C=[].slice.call(arguments);var D=q._api().fp_invoke(p,B,C);return D==="undefined"||D===undefined?o:D}});u=true}}var A=s[w];if(A){var y=A.apply(o,v);if(w.slice(0,1)=="_"){delete s[w]}return y}return o}})};function b(q,G,t){var w=this,v=null,D=false,u,s,F=[],y={},x={},E,r,p,C,o,A;i(w,{id:function(){return E},isLoaded:function(){return(v!==null&&v.fp_play!==undefined&&!D)},getParent:function(){return q},hide:function(H){if(H){q.style.height="0px"}if(w.isLoaded()){v.style.height="0px"}return w},show:function(){q.style.height=A+"px";if(w.isLoaded()){v.style.height=o+"px"}return w},isHidden:function(){return w.isLoaded()&&parseInt(v.style.height,10)===0},load:function(J){if(!w.isLoaded()&&w._fireEvent("onBeforeLoad")!==false){var H=function(){u=q.innerHTML;if(u&&!flashembed.isSupported(G.version)){q.innerHTML=""}if(J){J.cached=true;j(x,"onLoad",J)}flashembed(q,G,{config:t})};var I=0;m(a,function(){this.unload(function(K){if(++I==a.length){H()}})})}return w},unload:function(J){if(this.isFullscreen()&&/WebKit/i.test(navigator.userAgent)){if(J){J(false)}return w}if(u.replace(/\s/g,"")!==""){if(w._fireEvent("onBeforeUnload")===false){if(J){J(false)}return w}D=true;try{if(v){v.fp_close();w._fireEvent("onUnload")}}catch(H){}var I=function(){v=null;q.innerHTML=u;D=false;if(J){J(true)}};setTimeout(I,50)}else{if(J){J(false)}}return w},getClip:function(H){if(H===undefined){H=C}return F[H]},getCommonClip:function(){return s},getPlaylist:function(){return F},getPlugin:function(H){var J=y[H];if(!J&&w.isLoaded()){var I=w._api().fp_getPlugin(H);if(I){J=new l(H,I,w);y[H]=J}}return J},getScreen:function(){return w.getPlugin("screen")},getControls:function(){return w.getPlugin("controls")._fireEvent("onUpdate")},getLogo:function(){try{return w.getPlugin("logo")._fireEvent("onUpdate")}catch(H){}},getPlay:function(){return w.getPlugin("play")._fireEvent("onUpdate")},getConfig:function(H){return H?k(t):t},getFlashParams:function(){return G},loadPlugin:function(K,J,M,L){if(typeof M=="function"){L=M;M={}}var I=L?e():"_";w._api().fp_loadPlugin(K,J,M,I);var H={};H[I]=L;var N=new l(K,null,w,H);y[K]=N;return N},getState:function(){return w.isLoaded()?v.fp_getState():-1},play:function(I,H){var J=function(){if(I!==undefined){w._api().fp_play(I,H)}else{w._api().fp_play()}};if(w.isLoaded()){J()}else{if(D){setTimeout(function(){w.play(I,H)},50)}else{w.load(function(){J()})}}return w},getVersion:function(){var I="flowplayer.js 3.2.4";if(w.isLoaded()){var H=v.fp_getVersion();H.push(I);return H}return I},_api:function(){if(!w.isLoaded()){throw"Flowplayer "+w.id()+" not loaded when calling an API method"}return v},setClip:function(H){w.setPlaylist([H]);return w},getIndex:function(){return p},_swfHeight:function(){return v.clientHeight}});m(("Click*,Load*,Unload*,Keypress*,Volume*,Mute*,Unmute*,PlaylistReplace,ClipAdd,Fullscreen*,FullscreenExit,Error,MouseOver,MouseOut").split(","),function(){var H="on"+this;if(H.indexOf("*")!=-1){H=H.slice(0,H.length-1);var I="onBefore"+H.slice(2);w[I]=function(J){j(x,I,J);return w}}w[H]=function(J){j(x,H,J);return w}});m(("pause,resume,mute,unmute,stop,toggle,seek,getStatus,getVolume,setVolume,getTime,isPaused,isPlaying,startBuffering,stopBuffering,isFullscreen,toggleFullscreen,reset,close,setPlaylist,addClip,playFeed,setKeyboardShortcutsEnabled,isKeyboardShortcutsEnabled").split(","),function(){var H=this;w[H]=function(J,I){if(!w.isLoaded()){return w}var K=null;if(J!==undefined&&I!==undefined){K=v["fp_"+H](J,I)}else{K=(J===undefined)?v["fp_"+H]():v["fp_"+H](J)}return K==="undefined"||K===undefined?w:K}});w._fireEvent=function(Q){if(typeof Q=="string"){Q=[Q]}var R=Q[0],O=Q[1],M=Q[2],L=Q[3],K=0;if(t.debug){g(Q)}if(!w.isLoaded()&&R=="onLoad"&&O=="player"){v=v||c(r);o=w._swfHeight();m(F,function(){this._fireEvent("onLoad")});m(y,function(S,T){T._fireEvent("onUpdate")});s._fireEvent("onLoad")}if(R=="onLoad"&&O!="player"){return}if(R=="onError"){if(typeof O=="string"||(typeof O=="number"&&typeof M=="number")){O=M;M=L}}if(R=="onContextMenu"){m(t.contextMenu[O],function(S,T){T.call(w)});return}if(R=="onPluginEvent"||R=="onBeforePluginEvent"){var H=O.name||O;var I=y[H];if(I){I._fireEvent("onUpdate",O);return I._fireEvent(M,Q.slice(3))}return}if(R=="onPlaylistReplace"){F=[];var N=0;m(O,function(){F.push(new h(this,N++,w))})}if(R=="onClipAdd"){if(O.isInStream){return}O=new h(O,M,w);F.splice(M,0,O);for(K=M+1;K<F.length;K++){F[K].index++}}var P=true;if(typeof O=="number"&&O<F.length){C=O;var J=F[O];if(J){P=J._fireEvent(R,M,L)}if(!J||P!==false){P=s._fireEvent(R,M,L,J)}}m(x[R],function(){P=this.call(w,O,M);if(this.cached){x[R].splice(K,1)}if(P===false){return false}K++});return P};function B(){if($f(q)){$f(q).getParent().innerHTML="";p=$f(q).getIndex();a[p]=w}else{a.push(w);p=a.length-1}A=parseInt(q.style.height,10)||q.clientHeight;E=q.id||"fp"+e();r=G.id||E+"_api";G.id=r;t.playerId=E;if(typeof t=="string"){t={clip:{url:t}}}if(typeof t.clip=="string"){t.clip={url:t.clip}}t.clip=t.clip||{};if(q.getAttribute("href",2)&&!t.clip.url){t.clip.url=q.getAttribute("href",2)}s=new h(t.clip,-1,w);t.playlist=t.playlist||[t.clip];var I=0;m(t.playlist,function(){var K=this;if(typeof K=="object"&&K.length){K={url:""+K}}m(t.clip,function(L,M){if(M!==undefined&&K[L]===undefined&&typeof M!="function"){K[L]=M}});t.playlist[I]=K;K=new h(K,I,w);F.push(K);I++});m(t,function(K,L){if(typeof L=="function"){if(s[K]){s[K](L)}else{j(x,K,L)}delete t[K]}});m(t.plugins,function(K,L){if(L){y[K]=new l(K,L,w)}});if(!t.plugins||t.plugins.controls===undefined){y.controls=new l("controls",null,w)}y.canvas=new l("canvas",null,w);u=q.innerHTML;function J(L){var K=w.hasiPadSupport&&w.hasiPadSupport();if(/iPad|iPhone|iPod/i.test(navigator.userAgent)&&!/.flv$/i.test(F[0].url)&&!K){return true}if(!w.isLoaded()&&w._fireEvent("onBeforeClick")!==false){w.load()}return f(L)}function H(){if(u.replace(/\s/g,"")!==""){if(q.addEventListener){q.addEventListener("click",J,false)}else{if(q.attachEvent){q.attachEvent("onclick",J)}}}else{if(q.addEventListener){q.addEventListener("click",f,false)}w.load()}}setTimeout(H,0)}if(typeof q=="string"){var z=c(q);if(!z){throw"Flowplayer cannot access element: "+q}q=z;B()}else{B()}}var a=[];function d(o){this.length=o.length;this.each=function(p){m(o,p)};this.size=function(){return o.length}}window.flowplayer=window.$f=function(){var p=null;var o=arguments[0];if(!arguments.length){m(a,function(){if(this.isLoaded()){p=this;return false}});return p||a[0]}if(arguments.length==1){if(typeof o=="number"){return a[o]}else{if(o=="*"){return new d(a)}m(a,function(){if(this.id()==o.id||this.id()==o||this.getParent()==o){p=this;return false}});return p}}if(arguments.length>1){var t=arguments[1],q=(arguments.length==3)?arguments[2]:{};if(typeof t=="string"){t={src:t}}t=i({bgcolor:"#000000",version:[9,0],expressInstall:"http://static.flowplayer.org/swf/expressinstall.swf",cachebusting:true},t);if(typeof o=="string"){if(o.indexOf(".")!=-1){var s=[];m(n(o),function(){s.push(new b(this,k(t),k(q)))});return new d(s)}else{var r=c(o);return new b(r!==null?r:o,t,q)}}else{if(o){return new b(o,t,q)}}}return null};i(window.$f,{fireEvent:function(){var o=[].slice.call(arguments);var q=$f(o[0]);return q?q._fireEvent(o.slice(1)):null},addPlugin:function(o,p){b.prototype[o]=p;return $f},each:m,extend:i});if(typeof jQuery=="function"){jQuery.fn.flowplayer=function(q,p){if(!arguments.length||typeof arguments[0]=="number"){var o=[];this.each(function(){var r=$f(this);if(r){o.push(r)}});return arguments.length?o[arguments[0]]:new d(o)}return this.each(function(){$f(this,k(q),p?k(p):{})})}}})();(function(){var h=document.all,j="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",e=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,b={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:true,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:false,cachebusting:false};if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){}})}function i(m,l){if(l){for(var f in l){if(l.hasOwnProperty(f)){m[f]=l[f]}}}return m}function a(f,n){var m=[];for(var l in f){if(f.hasOwnProperty(l)){m[l]=n(f[l])}}return m}window.flashembed=function(f,m,l){if(typeof f=="string"){f=document.getElementById(f.replace("#",""))}if(!f){return}if(typeof m=="string"){m={src:m}}return new d(f,i(i({},b),m),l)};var g=i(window.flashembed,{conf:b,getVersion:function(){var m,f;try{f=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(o){try{m=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");f=m&&m.GetVariable("$version")}catch(n){try{m=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");f=m&&m.GetVariable("$version")}catch(l){}}}f=e.exec(f);return f?[f[1],f[3]]:[0,0]},asString:function(l){if(l===null||l===undefined){return null}var f=typeof l;if(f=="object"&&l.push){f="array"}switch(f){case"string":l=l.replace(new RegExp('(["\\\\])',"g"),"\\$1");l=l.replace(/^\s?(\d+\.?\d+)%/,"$1pct");return'"'+l+'"';case"array":return"["+a(l,function(o){return g.asString(o)}).join(",")+"]";case"function":return'"function()"';case"object":var m=[];for(var n in l){if(l.hasOwnProperty(n)){m.push('"'+n+'":'+g.asString(l[n]))}}return"{"+m.join(",")+"}"}return String(l).replace(/\s/g," ").replace(/\'/g,'"')},getHTML:function(o,l){o=i({},o);var n='<object width="'+o.width+'" height="'+o.height+'" id="'+o.id+'" name="'+o.id+'"';if(o.cachebusting){o.src+=((o.src.indexOf("?")!=-1?"&":"?")+Math.random())}if(o.w3c||!h){n+=' data="'+o.src+'" type="application/x-shockwave-flash"'}else{n+=' classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'}n+=">";if(o.w3c||h){n+='<param name="movie" value="'+o.src+'" />'}o.width=o.height=o.id=o.w3c=o.src=null;o.onFail=o.version=o.expressInstall=null;for(var m in o){if(o[m]){n+='<param name="'+m+'" value="'+o[m]+'" />'}}var p="";if(l){for(var f in l){if(l[f]){var q=l[f];p+=f+"="+(/function|object/.test(typeof q)?g.asString(q):q)+"&"}}p=p.slice(0,-1);n+='<param name="flashvars" value=\''+p+"' />"}n+="</object>";return n},isSupported:function(f){return k[0]>f[0]||k[0]==f[0]&&k[1]>=f[1]}});var k=g.getVersion();function d(f,n,m){if(g.isSupported(n.version)){f.innerHTML=g.getHTML(n,m)}else{if(n.expressInstall&&g.isSupported([6,65])){f.innerHTML=g.getHTML(i(n,{src:n.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title})}else{if(!f.innerHTML.replace(/\s/g,"")){f.innerHTML="<h2>Flash version "+n.version+" or greater is required</h2><h3>"+(k[0]>0?"Your version is "+k:"You have no flash plugin installed")+"</h3>"+(f.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+j+"'>here</a></p>");if(f.tagName=="A"){f.onclick=function(){location.href=j}}}if(n.onFail){var l=n.onFail.call(this);if(typeof l=="string"){f.innerHTML=l}}}}if(h){window[n.id]=document.getElementById(n.id)}i(this,{getRoot:function(){return f},getOptions:function(){return n},getConf:function(){return m},getApi:function(){return f.firstChild}})}if(c){jQuery.tools=jQuery.tools||{version:"3.2.4"};jQuery.tools.flashembed={conf:b};jQuery.fn.flashembed=function(l,f){return this.each(function(){$(this).data("flashembed",flashembed(this,l,f))})}}})();/*
    http://www.JSON.org/json2.js
    2009-09-21

    Public Domain.

    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

    See http://www.JSON.org/js.html

    This file creates a global JSON object containing two methods: stringify
    and parse.

        JSON.stringify(value, replacer, space)
            value       any JavaScript value, usually an object or array.

            replacer    an optional parameter that determines how object
                        values are stringified for objects. It can be a
                        function or an array of strings.

            space       an optional parameter that specifies the indentation
                        of nested structures. If it is omitted, the text will
                        be packed without extra whitespace. If it is a number,
                        it will specify the number of spaces to indent at each
                        level. If it is a string (such as '\t' or '&nbsp;'),
                        it contains the characters used to indent at each level.

            This method produces a JSON text from a JavaScript value.

            When an object value is found, if the object contains a toJSON
            method, its toJSON method will be called and the result will be
            stringified. A toJSON method does not serialize: it returns the
            value represented by the name/value pair that should be serialized,
            or undefined if nothing should be serialized. The toJSON method
            will be passed the key associated with the value, and this will be
            bound to the value

            For example, this would serialize Dates as ISO strings.

                Date.prototype.toJSON = function (key) {
                    function f(n) {
                        // Format integers to have at least two digits.
                        return n < 10 ? '0' + n : n;
                    }

                    return this.getUTCFullYear()   + '-' +
                         f(this.getUTCMonth() + 1) + '-' +
                         f(this.getUTCDate())      + 'T' +
                         f(this.getUTCHours())     + ':' +
                         f(this.getUTCMinutes())   + ':' +
                         f(this.getUTCSeconds())   + 'Z';
                };

            You can provide an optional replacer method. It will be passed the
            key and value of each member, with this bound to the containing
            object. The value that is returned from your method will be
            serialized. If your method returns undefined, then the member will
            be excluded from the serialization.

            If the replacer parameter is an array of strings, then it will be
            used to select the members to be serialized. It filters the results
            such that only members with keys listed in the replacer array are
            stringified.

            Values that do not have JSON representations, such as undefined or
            functions, will not be serialized. Such values in objects will be
            dropped; in arrays they will be replaced with null. You can use
            a replacer function to replace those with JSON values.
            JSON.stringify(undefined) returns undefined.

            The optional space parameter produces a stringification of the
            value that is filled with line breaks and indentation to make it
            easier to read.

            If the space parameter is a non-empty string, then that string will
            be used for indentation. If the space parameter is a number, then
            the indentation will be that many spaces.

            Example:

            text = JSON.stringify(['e', {pluribus: 'unum'}]);
            // text is '["e",{"pluribus":"unum"}]'


            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'

            text = JSON.stringify([new Date()], function (key, value) {
                return this[key] instanceof Date ?
                    'Date(' + this[key] + ')' : value;
            });
            // text is '["Date(---current time---)"]'


        JSON.parse(text, reviver)
            This method parses a JSON text to produce an object or array.
            It can throw a SyntaxError exception.

            The optional reviver parameter is a function that can filter and
            transform the results. It receives each of the keys and values,
            and its return value is used instead of the original value.
            If it returns what it received, then the structure is not modified.
            If it returns undefined then the member is deleted.

            Example:

            // Parse the text. Values that look like ISO date strings will
            // be converted to Date objects.

            myData = JSON.parse(text, function (key, value) {
                var a;
                if (typeof value === 'string') {
                    a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
                    if (a) {
                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
                            +a[5], +a[6]));
                    }
                }
                return value;
            });

            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
                var d;
                if (typeof value === 'string' &&
                        value.slice(0, 5) === 'Date(' &&
                        value.slice(-1) === ')') {
                    d = new Date(value.slice(5, -1));
                    if (d) {
                        return d;
                    }
                }
                return value;
            });


    This is a reference implementation. You are free to copy, modify, or
    redistribute.

    This code should be minified before deployment.
    See http://javascript.crockford.com/jsmin.html

    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
    NOT CONTROL.
*/

/*jslint evil: true */

/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
    lastIndex, length, parse, prototype, push, replace, slice, stringify,
    test, toJSON, toString, valueOf
*/


// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.

if (!this.JSON) {
    this.JSON = {};
}

(function () {

    function f(n) {
        // Format integers to have at least two digits.
        return n < 10 ? '0' + n : n;
    }

    if (typeof Date.prototype.toJSON !== 'function') {

        Date.prototype.toJSON = function (key) {

            return isFinite(this.valueOf()) ?
                   this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z' : null;
        };

        String.prototype.toJSON =
        Number.prototype.toJSON =
        Boolean.prototype.toJSON = function (key) {
            return this.valueOf();
        };
    }

    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap,
        indent,
        meta = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        rep;


    function quote(string) {

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.

        escapable.lastIndex = 0;
        return escapable.test(string) ?
            '"' + string.replace(escapable, function (a) {
                var c = meta[a];
                return typeof c === 'string' ? c :
                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            }) + '"' :
            '"' + string + '"';
    }


    function str(key, holder) {

// Produce a string from holder[key].

        var i,          // The loop counter.
            k,          // The member key.
            v,          // The member value.
            length,
            mind = gap,
            partial,
            value = holder[key];

// If the value has a toJSON method, call it to obtain a replacement value.

        if (value && typeof value === 'object' &&
                typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }

// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.

        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }

// What happens next depends on the value's type.

        switch (typeof value) {
        case 'string':
            return quote(value);

        case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

            return isFinite(value) ? String(value) : 'null';

        case 'boolean':
        case 'null':

// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.

            return String(value);

// If the type is 'object', we might be dealing with an object or an array or
// null.

        case 'object':

// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.

            if (!value) {
                return 'null';
            }

// Make an array to hold the partial results of stringifying this object value.

            gap += indent;
            partial = [];

// Is the value an array?

            if (Object.prototype.toString.apply(value) === '[object Array]') {

// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }

// Join all of the elements together, separated with commas, and wrap them in
// brackets.

                v = partial.length === 0 ? '[]' :
                    gap ? '[\n' + gap +
                            partial.join(',\n' + gap) + '\n' +
                                mind + ']' :
                          '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }

// If the replacer is an array, use it to select the members to be stringified.

            if (rep && typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    k = rep[i];
                    if (typeof k === 'string') {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {

// Otherwise, iterate through all of the keys in the object.

                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }

// Join all of the member texts together, separated with commas,
// and wrap them in braces.

            v = partial.length === 0 ? '{}' :
                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
                        mind + '}' : '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }

// If the JSON object does not yet have a stringify method, give it one.

    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function (value, replacer, space) {

// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.

            var i;
            gap = '';
            indent = '';

// If the space parameter is a number, make an indent string containing that
// many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }

// If the space parameter is a string, it will be used as the indent string.

            } else if (typeof space === 'string') {
                indent = space;
            }

// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.

            rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                    (typeof replacer !== 'object' ||
                     typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.

            return str('', {'': value});
        };
    }


// If the JSON object does not yet have a parse method, give it one.

    if (typeof JSON.parse !== 'function') {
        JSON.parse = function (text, reviver) {

// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.

            var j;

            function walk(holder, key) {

// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.

                var k, v, value = holder[key];
                if (value && typeof value === 'object') {
                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }


// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.

            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function (a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }

// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.

// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

            if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                j = eval('(' + text + ')');

// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.

                return typeof reviver === 'function' ?
                    walk({'': j}, '') : j;
            }

// If the text is not JSON parseable, then a SyntaxError is thrown.

            throw new SyntaxError('JSON.parse');
        };
    }
}());
/*
 * Local use only: returns an XMLHttpRequest object, dealing with browser issues.
 */

function XHR() {
	/* Create a new XMLHttpRequest object to talk to the Web server */
	var xmlHttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try {
  		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
  		try {
    			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  		} catch (e2) {
    			xmlHttp = false;
  		}
	}
	@end @*/

	if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
  		xmlHttp = new XMLHttpRequest();
	}
 	
	return xmlHttp;
}

/* 
 * Process an Eiserne AJAX request.
 *
 * The first argument is the AJAX method, and the second is the object that will be JSONized.
 * The result is the response object de-JSONized.
 *
 * (In the async version, of course, no response is returned.)
 */

function EiserneRequest(method, request)
{
	var xmlHttp = XHR();
	xmlHttp.open("POST", "/ajax/" + method, false);
        var str_request = JSON.stringify(request);
	xmlHttp.send(str_request);
        var response = JSON.parse(xmlHttp.responseText);
	return response;
}

function EiserneAsyncRequest(method, request, callback)
{
	var xmlHttp = XHR();
	xmlHttp.onreadystatechange = function() { 
		if (xmlHttp.readyState != 4) return;
		if (callback != null) { 
			callback(JSON.parse(xmlHttp.responseText)); 
		} 
	}
	xmlHttp.open("POST", "/ajax/" + method, true);
	xmlHttp.send(JSON.stringify(request));
}

var EiserneTicks;

function EiserneTick(id)
{
	if ($f().getState() == 3) {
		EiserneTicks++;
		if ((EiserneTicks % 10) == 0) {
			EiserneAsyncRequest('tick', { id: id, secs: EiserneTicks }, null);
		}
	}
	setTimeout('EiserneTick("' + id + '")', 1000);		/* reschedule */
}

function EiserneSetSessionAttr(name, value)
{
	var request = { };
 	request[name] = value;
	EiserneRequest('set_session_attrs', request);
}


function EiserneGetSessionAttr(name)
{
	var response = EiserneRequest('get_session_attrs', { });
	for (key in response) {
		if (key == name) return response[key];
	}
	return null;
}

function EiserneSessionInfo() { return EiserneRequest('session_info', {}); }
function EiserneUserInfo() { return EiserneRequest('user_info', {}); }

function EiserneInclude(path)
{
	var xmlHttp = XHR();
	xmlHttp.open("GET", path, false);
	xmlHttp.send(null);
	document.write(xmlHttp.responseText);
}

function EiserneLoad(path)
{
	var xmlHttp = XHR();
	xmlHttp.open("GET", path, false);
	xmlHttp.send(null);
	return xmlHttp.responseText;
}

function Querystring() { // optionally pass a querystring to parse
        this.params = {};

        qs = window.location.hash;
        if (qs.length == 0) return;

	qs = qs.substring(1, qs.length);
        var args = qs.split(':'); // parse out name/value pairs separated via &

        for (var i = 0; i < args.length; i++) {
                var pair = args[i].split('=');
                var name = decodeURIComponent(pair[0]);

                var value = (pair.length==2)
                        ? decodeURIComponent(pair[1])
                        : name;

                this.params[name] = value;
        }
}

Querystring.prototype.get = function(key, default_) {
        var value = this.params[key];
        return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
        var value = this.params[key];
        return (value != null);
}

/**
 * sprintf() for JavaScript v.0.4
 *
 * Copyright (c) 2007 Alexandru Marasteanu <http://alexei.417.ro/>
 * Thanks to David Baird (unit test and patch).
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */

function str_repeat(i, m) { for (var o = []; m > 0; o[--m] = i); return(o.join('')); }

function sprintf () {
  var i = 0, a, f = arguments[i++], o = [], m, p, c, x;
  while (f) {
    if (m = /^[^\x25]+/.exec(f)) o.push(m[0]);
    else if (m = /^\x25{2}/.exec(f)) o.push('%');
    else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
      if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) throw("Too few arguments.");
      if (/[^s]/.test(m[7]) && (typeof(a) != 'number'))
        throw("Expecting number but found " + typeof(a));
      switch (m[7]) {
        case 'b': a = a.toString(2); break;
        case 'c': a = String.fromCharCode(a); break;
        case 'd': a = parseInt(a); break;
        case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break;
        case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break;
        case 'o': a = a.toString(8); break;
        case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break;
        case 'u': a = Math.abs(a); break;
        case 'x': a = a.toString(16); break;
        case 'X': a = a.toString(16).toUpperCase(); break;
      }
      a = (/[def]/.test(m[7]) && m[2] && a > 0 ? '+' + a : a);
      c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
      x = m[5] - String(a).length;
      p = m[5] ? str_repeat(c, x) : '';
      o.push(m[4] ? a + p : p + a);
    }
    else throw ("Huh ?!");
    f = f.substring(m[0].length);
  }
  return o.join('');
}
/* site specific variables */

/**********/
/* GLOBAL */
/**********/

var global_siteid = "BBB";	// some files aren't processed by ruby so JS to the rescue

// Random Background Images
// number of images to cycle through, 0 means none
var global_num_random_background = 0;
var global_bg_format = "png";

/************/
/* CONSENT  */
/************/

var consent_first_pp_legalese = "You are attempting to access a website that contains graphic depictions of sexual activity. ";
var consent_click_no_url = "http://www.google.com";
var consent_enter_coords = 'shape="rect" coords="75,435,375,500"';
var consent_exit_coords = 'shape="rect" coords="500,435,550,500"';
var consent_site = "ADULT CONTENT";

/***********/
/* HEADER  */
/***********/

/* Nav Tabs Div Setup */
var header_navtab_setup = ' \
	<div id="tabAbout"><a href="about.html#page=offer"><img src="/BBB/images/header/tab1.png"></a></div> \
        <div id="tabBlog"><a href="about.html#page=blog"><img src="/BBB/images/header/tab2.png"></a></div> \
        <div id="tabJoin"><a href="join.html"><img src="/BBB/images/header/tab3.png"></a></div> \
        <div id="tabBrowse"><a href="browse.html"><img src="/BBB/images/header/tab_home.png"></a></div> \
        <div id="tabHow"></div> \
        <div id="tabAccount"><a href="myaccount.html"><img src="/BBB/images/header/tab_myaccount.png"></a></div> \
';

var header_tabBrowse_activated = '';
var header_tabAbout_activated = '';

/* Login Popup  */
var header_popup_heading_text = "Login!";

/***********/
/* SIDEBAR */
/***********/

/* if empty, do not display in sidebar */

/* section: provide html; styled text or image */
/* subhead: provide html */
/* choices: provide hash */
/* comment: provide text */

var sidebar_myaccount_section = "";


var sidebar_about_section = "";
var sidebar_about_choices = [
                { id: 'offer', desc: 'What\'s In This Site' },
              /*  { id: 'blog', desc: 'The Buzz' }, */
        ];

var sidebar_affiliate_section = "";
var sidebar_affiliate_choices = [
    { id: 'overview', desc: 'Affiliate Overview' },
    { id: 'faq', desc: 'Affiliate FAQ' },
    { id: 'get_started', desc: 'Get Started!' }
];
 
var sidebar_info_section = "";

var sidebar_how_section = "";
var sidebar_how_choices = [
            /*    { id: 'offer', desc: 'What\'s In This Site' },
                { id: 'blog', desc: 'Read the Breed' },*/
                { id: 'faq', desc: 'FAQ' },
                { id: 'uforgot', desc: 'Forgot Username' },
                { id: 'pforgot', desc: 'Forgot Password' },
                { id: 'support', desc: 'Contact Support' }
        ];

var sidebar_info_section = "";
var sidebar_info_choices = [
                { id: 'about', desc: 'The Company' },
                { id: 'terms', desc: 'Terms of Service' },
                { id: '2257', desc: '2257 Statement' },
                { id: 'contact', desc: 'Contact Us' },
                { id: 'privacy', desc: 'Privacy Policy' },
                { id: 'copyrights', desc: 'Copyrights' }
        ];

var sidebar_videos_section = "<h1><img src=\"/BBB/images/sideBar/sidebar_videos.png\" /></h1>";

var sidebar_videos_featured_subhead = "<h2 class=\"hide\">Featured<a href=\"#\" class=\"twistieOpen\"></a></h2>";
/* choices to choose from, used by sidebar.js 
		{ id: 'recent', desc: 'Recent Updates' },
                { id: 'popular', desc: 'Most Popular' },
                { id: 'all', desc: 'All Scenes' }
*/
var sidebar_videos_featured_choices = [
		{ id: 'recent', desc: 'Recent Updates' },
                { id: 'popular', desc: 'Most Popular' },
                { id: 'all', desc: 'All Scenes' }
              ];

var sidebar_quick_search_subhead = '<h2>QUICK SEARCH</h2>';
var sidebar_quick_search_hint = '<h3>Search for keywords:</h3>';

var sidebar_videos_tags_min = 5;	// num tags to show when collapsed
var sidebar_videos_tags_subhead = "<h2 class=\"hide\">Tags<a href=\"#\" class=\"twistieOpen\"></a></h2>";
var sidebar_videos_tags_minimized_override = "";
var sidebar_videos_tags_lightbox = "";
var sidebar_videos_tags_text_see_less = '&laquo; see less';
var sidebar_videos_tags_text_see_more = '&raquo; see more';

var sidebar_videos_studios_min = 5;        // num tags to show when collapsed
var sidebar_videos_studios_subhead = "<h2>Studios<a href=\"#\" class=\"twistieOpen\"></a></h2>";
var sidebar_videos_studios_minimized_override = "";
var sidebar_videos_studios_lightbox = "";
var sidebar_videos_studios_text_see_less = '&laquo; see less';
var sidebar_videos_studios_text_see_more = '&raquo; see more';

var sidebar_videos_actors_min = 5;	// num tags to show when collapsed
var sidebar_videos_actors_subhead = "<h2 class=\"hide\">Actors<a href=\"#\" class=\"twistieOpen\"></a></h2>";
var sidebar_videos_actors_minimized_override = "";
var sidebar_videos_actors_lightbox = "";
var sidebar_videos_actors_text_see_less = '&laquo; see less';
var sidebar_videos_actors_text_see_more = '&raquo; see more';

var sidebar_help_section = "<h1 class=\"hide\"></h1>";

var sidebar_help_choices = ' \
                 <li><a href="how.html">I need help!</a></li> \
		';


/* note: this sidebar extras has lots of HTML, so using a site-specific eiserne include 
var sidebar_extras_html = "<script type=\"text/javascript\">EiserneInclude(\'/BBB/inc/SITESPECIFIC_sidebar_stuff.inc\');</script>"; */
var sidebar_extras_html = "";

var sidebar_newsletter_section ="<h1 class=\"hide\"></h1>";
var sidebar_newsletter_comment = "Signup for free newsletter!";

var sidebar_vod_account_choices = [
        {logged: false, href: 'join.html', desc: 'Get VOD Account' },
        {logged: true, href: 'myaccount.html', id: 'memb', desc: 'My VOD Account' },
        {logged: false, href: 'javascript:header_login_click();', desc: 'Login' },
        {logged: true, href: 'myaccount.html', model: 'L', id: 'library', desc: 'My VOD Library'},
//        { logged: true, id: 'memb', desc: 'My Membership' },
        { logged: true, href: 'myaccount.html', id: 'pay', desc: 'My Payment Details' },
        { logged: true, href: 'myaccount.html', id: 'email', desc: 'My Email Address' },
        { logged: true, href: 'myaccount.html', id: 'pass', desc: 'My Password' },

        {logged: true, href: 'javascript:header_logout_click();', desc: 'Logout' }
];

/***************/
/* BROWSE PAGE */
/***************/

var browse_per_page = 5;    /* number of video items per page */

var browse_heading_recent = "Recent Updates";
var browse_heading_popular = "Most Popular";
var browse_heading_all = "All Titles";
var browse_heading_search = "Search Results";
var browse_heading_bycategory = "Search Results by Category";
var browse_heading_byactor = "Search Results by Actor";
var browse_heading_bystudio = "Search Results by Studio";
var browse_heading_bykeyword = "Search Results";

function generate_entries(videos, page) {

	var entries = '';

	for (var i in videos.videos) {
                var v = videos.videos[i];
                var stills = EiserneRequest('video_stills', { id: v.id, sortby: 'hotness' });

                entries += '<div class="' + ((i % 2) ? 'previewLt' : 'previewDk') + '">';
                entries += '<div class="previewText">';
                entries += '<a href="watch.html#video=' + v.id + '"><h3>' + v.title + '</h3></a>';
                // entries += '<p>' + v.description + '</p>';
                entries += '</div>';

                if (stills.stills.length < 2) { continue; }

                // entries += '<a href="watch.html#video=' + v.id + '">';

                /* if ( i == 0 && page == 1) { */

                if ( false ) { 
                // one large image
		//  entries += '<img class="photoBig" src="' + (stills.stills[0].large ? stills.stills[0].large : stills.stills[0].url) + '" />';

		// 4 images 



                entries += '<a href="watch.html#video=' + v.id + '">';
                entries += '<img class="photoLeft" src="' + (stills.stills[0].large ? stills.stills[0].large : stills.stills[0].url) + '" />';
                entries += '<img class="photoRight" src="' + (stills.stills[1].large ? stills.stills[1].large : stills.stills[1].url) + '" />';
		
                entries += '<img class="photoLeft" src="' + (stills.stills[2].large ? stills.stills[2].large : stills.stills[2].url) + '" />';
                entries += '<img class="photoRight" src="' + (stills.stills[3].large ? stills.stills[3].large : stills.stills[3].url) + '" />';
		
                entries += '</a>';

                entries += '<div class="clear"></div>';
                entries += '<div style="margin: 15px 12px 0 12px; font-size: 1em;">' + v.description + '</div>';

                } else
                {
                entries += '<div style="margin: -5px 12px 15px 12px; font-size: 1em;">' + v.description + '</div>';

                entries += '<div class="clear"></div>';

                entries += '<a href="watch.html#video=' + v.id + '">';
                entries += '<img class="photoLeft" src="' + (stills.stills[0].large ? stills.stills[0].large : stills.stills[0].url) + '" />';
                entries += '<img class="photoRight" src="' + (stills.stills[1].large ? stills.stills[1].large : stills.stills[1].url) + '" />';
                entries += '</a>';
                }


                entries += '<div class="clear"></div>';
                entries += '</div>';
        }
	return entries;
}

/*********/
/* WATCH */
/*********/

var watch_title = ' \
        <h3 id="watch_title"></h3> \
        <h4></h4><p class="studio" id="watch_studio" style="display: none;"></p><p class="pipe" style="margin-right:50px; display: none;"></p> \
        <p style="display: none;">Added: </p><p class="addedDate" id="watch_postdate" style="display: none;"></p> \
        ';


/********/
/* JOIN */
/********/

var join_step1_boxtitle = "<h2>Create Account</h2>";

var join_step1_offer = " \
		<div id=\"offerheading\"><b>What do you get with a membership?</b></div> \
		<p>This is a Membership site. For a low fee, you get unlimited access to many hours of exclusive hardcore action! \
		 Filmed in High Definition video and streamed to you with cutting-edge technology. Updated continuously.</p> \
		<div id=\"offerheading\"><b>How much does a membership cost?</b></div> \
		<div id=\"offer_plans\"></div> \
";

var join_step3_offer = "";
		
/* Note: offer_plans above is auto-populated with plans for site */


/********/
/* INFO */
/********/

/* info.html#page=about */

/* note: this page can either be custom designed and dropped into site folder,
or, simple styled text customizations allowed here.... */

var info_about_heading = "<h2>About The Company</h2>";
var info_about_text = "<p>This site is brought to you by PPVNetworks, a leading provider of the technology and infrastructure that powers hundreds of adult websites since 2001. PPVNetworks works with producers and webmasters to provide profitable solutions for video-on-demand, pay-per-view, pay-per-minute, membership and download-to-own sites. PPVNetworks is a first-to-market innovator of digtal rights management and serialized watermarkng of downloads.</p>";



/*********/
/* ABOUT */
/*********/

/* about.html#page=offer */

/* note: this page can either be custom designed and dropped into site folder,
or, simple styled text customizations allowed here.... */

var about_offer_heading = "<h2>What's In This Site</h2>";
var about_offer_text = "<p>This is Membership site. For a low fee, you get unlimited access to many hours of exclusive hardcore action! Filmed in High Definition video and streamed to you with cutting-edge technology. Updated continuously. Works on PC, Mac and all browsers without a hitch.</p><p>Powered by PPVNetworks 3.0, the revolutionary new web2.0 adult platform from VideoApp. Affiliate programs and marketing tools are available to webmasters.</p>";


/*************/
/* AFFILIATE */
/*************/

var affiliate_overview_heading = "<h2>Welcome to the Bareback Box Affiliate Program</h2>";
var affiliate_overview_text = "<p>We hope you're as excited about promoting Bareback Box as we are. BarebackBox.com is an all new site with a great concept for gay adult entertainment! Its pumped full of the absolute hottest bareback movies from your favorite studios, and from smaller edgy producers you can only find here. Always up-to-date with the latest releases, in many cases before other sites! BBB has been outperforming the competition in both revenue-per-click and conversions on other affiliate venues. We are looking forward to working with you to make BBB a success for you.</p>";


/**********/
/* FOOTER */
/**********/

var footer_copyright_text = "Content copyrighted by respective producers. Site powered by PPVNetworks. Hosted by VideoApp.";
var footer_affiliate_link = ''; 
//'<a href="mailto:affiliate@videoapp.net">affiliates</a>';
// '<a href="affiliate.html">affiliates</a>';


/**********/
/* PLAYER */
/**********/
var player_style_preview_height = '577px';
var player_style_preview_height_169 = '433px';
var player_style_preview_floater_top = '142px';
var player_style_preview_floater_top_169 = '62px';

var player_style_watch_height = '577px';
var player_style_watch_height_169 = '433px';

var player_style_scene_width_169 = 128;
var player_style_scene_width = 96;

/***********/
/* LIBRARY */
/***********/
var library_is_empty_html = 'Your VOD library is empty. Movies that you rent will appear here while you still have access to view them. Forever rentals will remain here indefinitely, for Premium members.';

/**********/
/* CUSTOM */
/**********/

/* don't forgot to create INC files for any custom pages setup in the sidebar menus */

/* site specific variables */

/**********/
/* GLOBAL */
/**********/

var global_siteid = "BBB";	// some files aren't processed by ruby so JS to the rescue

// Random Background Images
// number of images to cycle through, 0 means none
var global_num_random_background = 0;
var global_bg_format = "png";

/************/
/* CONSENT  */
/************/

var consent_first_pp_legalese = "You are attempting to access a website that contains graphic depictions of sexual activity. ";
var consent_click_no_url = "http://www.google.com";
var consent_enter_coords = 'shape="rect" coords="75,435,375,500"';
var consent_exit_coords = 'shape="rect" coords="500,435,550,500"';
var consent_site = "ADULT CONTENT";

/***********/
/* HEADER  */
/***********/

/* Nav Tabs Div Setup */
var header_navtab_setup = ' \
	<div id="tabAbout"><a href="about.html#page=offer"><img src="/BBB/images/header/tab1.png"></a></div> \
        <div id="tabBlog"><a href="about.html#page=blog"><img src="/BBB/images/header/tab2.png"></a></div> \
        <div id="tabJoin"><a href="join.html"><img src="/BBB/images/header/tab3.png"></a></div> \
        <div id="tabBrowse"><a href="browse.html"><img src="/BBB/images/header/tab_home.png"></a></div> \
        <div id="tabHow"></div> \
        <div id="tabAccount"><a href="myaccount.html"><img src="/BBB/images/header/tab_myaccount.png"></a></div> \
';

var header_tabBrowse_activated = '';
var header_tabAbout_activated = '';

/* Login Popup  */
var header_popup_heading_text = "Login!";

/***********/
/* SIDEBAR */
/***********/

/* if empty, do not display in sidebar */

/* section: provide html; styled text or image */
/* subhead: provide html */
/* choices: provide hash */
/* comment: provide text */

var sidebar_myaccount_section = "";


var sidebar_about_section = "";
var sidebar_about_choices = [
                { id: 'offer', desc: 'What\'s In This Site' },
              /*  { id: 'blog', desc: 'The Buzz' }, */
        ];

var sidebar_affiliate_section = "";
var sidebar_affiliate_choices = [
    { id: 'overview', desc: 'Affiliate Overview' },
    { id: 'faq', desc: 'Affiliate FAQ' },
    { id: 'get_started', desc: 'Get Started!' }
];
 
var sidebar_info_section = "";

var sidebar_how_section = "";
var sidebar_how_choices = [
            /*    { id: 'offer', desc: 'What\'s In This Site' },
                { id: 'blog', desc: 'Read the Breed' },*/
                { id: 'faq', desc: 'FAQ' },
                { id: 'uforgot', desc: 'Forgot Username' },
                { id: 'pforgot', desc: 'Forgot Password' },
                { id: 'support', desc: 'Contact Support' }
        ];

var sidebar_info_section = "";
var sidebar_info_choices = [
                { id: 'about', desc: 'The Company' },
                { id: 'terms', desc: 'Terms of Service' },
                { id: '2257', desc: '2257 Statement' },
                { id: 'contact', desc: 'Contact Us' },
                { id: 'privacy', desc: 'Privacy Policy' },
                { id: 'copyrights', desc: 'Copyrights' }
        ];

var sidebar_videos_section = "<h1><img src=\"/BBB/images/sideBar/sidebar_videos.png\" /></h1>";

var sidebar_videos_featured_subhead = "<h2 class=\"hide\">Featured<a href=\"#\" class=\"twistieOpen\"></a></h2>";
/* choices to choose from, used by sidebar.js 
		{ id: 'recent', desc: 'Recent Updates' },
                { id: 'popular', desc: 'Most Popular' },
                { id: 'all', desc: 'All Scenes' }
*/
var sidebar_videos_featured_choices = [
		{ id: 'recent', desc: 'Recent Updates' },
                { id: 'popular', desc: 'Most Popular' },
                { id: 'all', desc: 'All Scenes' }
              ];

var sidebar_quick_search_subhead = '<h2>QUICK SEARCH</h2>';
var sidebar_quick_search_hint = '<h3>Search for keywords:</h3>';

var sidebar_videos_tags_min = 5;	// num tags to show when collapsed
var sidebar_videos_tags_subhead = "<h2 class=\"hide\">Tags<a href=\"#\" class=\"twistieOpen\"></a></h2>";
var sidebar_videos_tags_minimized_override = "";
var sidebar_videos_tags_lightbox = "";
var sidebar_videos_tags_text_see_less = '&laquo; see less';
var sidebar_videos_tags_text_see_more = '&raquo; see more';

var sidebar_videos_studios_min = 5;        // num tags to show when collapsed
var sidebar_videos_studios_subhead = "<h2>Studios<a href=\"#\" class=\"twistieOpen\"></a></h2>";
var sidebar_videos_studios_minimized_override = "";
var sidebar_videos_studios_lightbox = "";
var sidebar_videos_studios_text_see_less = '&laquo; see less';
var sidebar_videos_studios_text_see_more = '&raquo; see more';

var sidebar_videos_actors_min = 5;	// num tags to show when collapsed
var sidebar_videos_actors_subhead = "<h2 class=\"hide\">Actors<a href=\"#\" class=\"twistieOpen\"></a></h2>";
var sidebar_videos_actors_minimized_override = "";
var sidebar_videos_actors_lightbox = "";
var sidebar_videos_actors_text_see_less = '&laquo; see less';
var sidebar_videos_actors_text_see_more = '&raquo; see more';

var sidebar_help_section = "<h1 class=\"hide\"></h1>";

var sidebar_help_choices = ' \
                 <li><a href="how.html">I need help!</a></li> \
		';


/* note: this sidebar extras has lots of HTML, so using a site-specific eiserne include 
var sidebar_extras_html = "<script type=\"text/javascript\">EiserneInclude(\'/BBB/inc/SITESPECIFIC_sidebar_stuff.inc\');</script>"; */
var sidebar_extras_html = "";

var sidebar_newsletter_section ="<h1 class=\"hide\"></h1>";
var sidebar_newsletter_comment = "Signup for free newsletter!";

var sidebar_vod_account_choices = [
        {logged: false, href: 'join.html', desc: 'Get VOD Account' },
        {logged: true, href: 'myaccount.html', id: 'memb', desc: 'My VOD Account' },
        {logged: false, href: 'javascript:header_login_click();', desc: 'Login' },
        {logged: true, href: 'myaccount.html', model: 'L', id: 'library', desc: 'My VOD Library'},
//        { logged: true, id: 'memb', desc: 'My Membership' },
        { logged: true, href: 'myaccount.html', id: 'pay', desc: 'My Payment Details' },
        { logged: true, href: 'myaccount.html', id: 'email', desc: 'My Email Address' },
        { logged: true, href: 'myaccount.html', id: 'pass', desc: 'My Password' },

        {logged: true, href: 'javascript:header_logout_click();', desc: 'Logout' }
];

/***************/
/* BROWSE PAGE */
/***************/

var browse_per_page = 5;    /* number of video items per page */

var browse_heading_recent = "Recent Updates";
var browse_heading_popular = "Most Popular";
var browse_heading_all = "All Titles";
var browse_heading_search = "Search Results";
var browse_heading_bycategory = "Search Results by Category";
var browse_heading_byactor = "Search Results by Actor";
var browse_heading_bystudio = "Search Results by Studio";
var browse_heading_bykeyword = "Search Results";

function generate_entries(videos, page) {

	var entries = '';

	for (var i in videos.videos) {
                var v = videos.videos[i];
                var stills = EiserneRequest('video_stills', { id: v.id, sortby: 'hotness' });

                entries += '<div class="' + ((i % 2) ? 'previewLt' : 'previewDk') + '">';
                entries += '<div class="previewText">';
                entries += '<a href="watch.html#video=' + v.id + '"><h3>' + v.title + '</h3></a>';
                // entries += '<p>' + v.description + '</p>';
                entries += '</div>';

                if (stills.stills.length < 2) { continue; }

                // entries += '<a href="watch.html#video=' + v.id + '">';

                /* if ( i == 0 && page == 1) { */

                if ( false ) { 
                // one large image
		//  entries += '<img class="photoBig" src="' + (stills.stills[0].large ? stills.stills[0].large : stills.stills[0].url) + '" />';

		// 4 images 



                entries += '<a href="watch.html#video=' + v.id + '">';
                entries += '<img class="photoLeft" src="' + (stills.stills[0].large ? stills.stills[0].large : stills.stills[0].url) + '" />';
                entries += '<img class="photoRight" src="' + (stills.stills[1].large ? stills.stills[1].large : stills.stills[1].url) + '" />';
		
                entries += '<img class="photoLeft" src="' + (stills.stills[2].large ? stills.stills[2].large : stills.stills[2].url) + '" />';
                entries += '<img class="photoRight" src="' + (stills.stills[3].large ? stills.stills[3].large : stills.stills[3].url) + '" />';
		
                entries += '</a>';

                entries += '<div class="clear"></div>';
                entries += '<div style="margin: 15px 12px 0 12px; font-size: 1em;">' + v.description + '</div>';

                } else
                {
                entries += '<div style="margin: -5px 12px 15px 12px; font-size: 1em;">' + v.description + '</div>';

                entries += '<div class="clear"></div>';

                entries += '<a href="watch.html#video=' + v.id + '">';
                entries += '<img class="photoLeft" src="' + (stills.stills[0].large ? stills.stills[0].large : stills.stills[0].url) + '" />';
                entries += '<img class="photoRight" src="' + (stills.stills[1].large ? stills.stills[1].large : stills.stills[1].url) + '" />';
                entries += '</a>';
                }


                entries += '<div class="clear"></div>';
                entries += '</div>';
        }
	return entries;
}

/*********/
/* WATCH */
/*********/

var watch_title = ' \
        <h3 id="watch_title"></h3> \
        <h4></h4><p class="studio" id="watch_studio" style="display: none;"></p><p class="pipe" style="margin-right:50px; display: none;"></p> \
        <p style="display: none;">Added: </p><p class="addedDate" id="watch_postdate" style="display: none;"></p> \
        ';


/********/
/* JOIN */
/********/

var join_step1_boxtitle = "<h2>Create Account</h2>";

var join_step1_offer = " \
		<div id=\"offerheading\"><b>What do you get with a membership?</b></div> \
		<p>This is a Membership site. For a low fee, you get unlimited access to many hours of exclusive hardcore action! \
		 Filmed in High Definition video and streamed to you with cutting-edge technology. Updated continuously.</p> \
		<div id=\"offerheading\"><b>How much does a membership cost?</b></div> \
		<div id=\"offer_plans\"></div> \
";

var join_step3_offer = "";
		
/* Note: offer_plans above is auto-populated with plans for site */


/********/
/* INFO */
/********/

/* info.html#page=about */

/* note: this page can either be custom designed and dropped into site folder,
or, simple styled text customizations allowed here.... */

var info_about_heading = "<h2>About The Company</h2>";
var info_about_text = "<p>This site is brought to you by PPVNetworks, a leading provider of the technology and infrastructure that powers hundreds of adult websites since 2001. PPVNetworks works with producers and webmasters to provide profitable solutions for video-on-demand, pay-per-view, pay-per-minute, membership and download-to-own sites. PPVNetworks is a first-to-market innovator of digtal rights management and serialized watermarkng of downloads.</p>";



/*********/
/* ABOUT */
/*********/

/* about.html#page=offer */

/* note: this page can either be custom designed and dropped into site folder,
or, simple styled text customizations allowed here.... */

var about_offer_heading = "<h2>What's In This Site</h2>";
var about_offer_text = "<p>This is Membership site. For a low fee, you get unlimited access to many hours of exclusive hardcore action! Filmed in High Definition video and streamed to you with cutting-edge technology. Updated continuously. Works on PC, Mac and all browsers without a hitch.</p><p>Powered by PPVNetworks 3.0, the revolutionary new web2.0 adult platform from VideoApp. Affiliate programs and marketing tools are available to webmasters.</p>";


/*************/
/* AFFILIATE */
/*************/

var affiliate_overview_heading = "<h2>Welcome to the Bareback Box Affiliate Program</h2>";
var affiliate_overview_text = "<p>We hope you're as excited about promoting Bareback Box as we are. BarebackBox.com is an all new site with a great concept for gay adult entertainment! Its pumped full of the absolute hottest bareback movies from your favorite studios, and from smaller edgy producers you can only find here. Always up-to-date with the latest releases, in many cases before other sites! BBB has been outperforming the competition in both revenue-per-click and conversions on other affiliate venues. We are looking forward to working with you to make BBB a success for you.</p>";


/**********/
/* FOOTER */
/**********/

var footer_copyright_text = "Content copyrighted by respective producers. Site powered by PPVNetworks. Hosted by VideoApp.";
var footer_affiliate_link = ''; 
//'<a href="mailto:affiliate@videoapp.net">affiliates</a>';
// '<a href="affiliate.html">affiliates</a>';


/**********/
/* PLAYER */
/**********/
var player_style_preview_height = '577px';
var player_style_preview_height_169 = '433px';
var player_style_preview_floater_top = '142px';
var player_style_preview_floater_top_169 = '62px';

var player_style_watch_height = '577px';
var player_style_watch_height_169 = '433px';

var player_style_scene_width_169 = 128;
var player_style_scene_width = 96;

/***********/
/* LIBRARY */
/***********/
var library_is_empty_html = 'Your VOD library is empty. Movies that you rent will appear here while you still have access to view them. Forever rentals will remain here indefinitely, for Premium members.';

/**********/
/* CUSTOM */
/**********/

/* don't forgot to create INC files for any custom pages setup in the sidebar menus */

/* edit.js variables site specific variables */

/**********/
/* GLOBAL */
/**********/
var global_num_random_background = 1;


/************/
/* CONSENT  */
/************/
var consent_site = "BAREBACK BOX";


/***********/
/* HEADER  */
/***********/

/* Nav Tabs Div Setup */
var header_navtab_setup = ' \
        <div id="tabAbout"><a href="about.html#page=offer"><img src="/BBB/images/header/tab-how.png"></a></div> \
        <div id="tabBlog"><a href="about.html#page=blog"></a></div> \
        <div id="tabJoin"><a href="join.html"><img src="/BBB/images/header/tab-join.png"></a></div> \
        <div id="tabBrowse"><a href="browse.html"><img src="/BBB/images/header/tab-videos.png"></a></div> \
        <div id="tabHow"></div> \
        <div id="tabAccount"><a href="myaccount.html"><img src="/BBB/images/header/tab-account.png"></a></div> \
';

var header_tabBrowse_activated = '<a href="browse.html"><img src="/BBB/images/header/tab-videos-activated.png"></a>';
var header_tabAbout_activated = '<a href="about.html"><img src="/BBB/images/header/tab-how-activated.png"></a>';


/***********/
/* SIDEBAR */
/***********/

var sidebar_videos_section = "<h1><img src=\"/BBB/images/sidebar/sidebar-videos.png\" /></h1>";

var sidebar_about_choices = [
                { id: 'offer', desc: 'Fresh and Raw' },
                { id: 'offer2', desc: 'Hi-Def Video' },
                { id: 'offer3', desc: 'Fun, Easy-to-Use' },
                { id: 'offer4', desc: 'Only $10/month!' },
              /*  { id: 'blog', desc: 'The Buzz' }, */
        ];
var sidebar_quick_search_subhead = '<h2><img src=\"/BBB/images/sidebar/sidebar-search.png\" /></h2>';
var sidebar_quick_search_hint = '';

var sidebar_videos_tags_min = 5;        // num tags to show when collapsed
var sidebar_videos_tags_subhead = "<h2><img src=\"/BBB/images/sidebar/sidebar-categories.png\"></h2>";
var sidebar_videos_tags_lightbox = true;

var sidebar_videos_studios_min = 5;        // num tags to show when collapsed
var sidebar_videos_studios_subhead = "<h2><img src=\"/BBB/images/sidebar/sidebar-studios.png\"></h2>";
var sidebar_videos_studios_minimized_override = "";
var sidebar_videos_studios_lightbox = true;

var sidebar_videos_actors_min = 5;      // num tags to show when collapsed
var sidebar_videos_actors_subhead = "<h2><img src=\"/BBB/images/sidebar/sidebar-actors.png\"></h2>";
var sidebar_videos_actors_minimized_override = "";
var sidebar_videos_actors_lightbox = true;

var sidebar_how_choices = [
                { id: 'faq_model_C', desc: 'FAQ' },
                { id: 'uforgot', desc: 'Forgot Username' },
                { id: 'pforgot', desc: 'Forgot Password' },
                { id: 'support', desc: 'Contact Support' }
        ];





/***************/
/* BROWSE PAGE */
/***************/


var browse_per_page = 16;    /* number of video items per page */

function generate_entries(videos, page) {

        var entries = '';

        for (var i in videos.videos) {
                var v = videos.videos[i];
                var stills = EiserneRequest('video_stills', { id: v.id, sortby: 'hotness' });

                entries += '<div class="browse_video_item">';
/*
                entries += '<div class="previewText">';
                entries += '<a href="watch.html#video=' + v.id + '"><h3>' + v.title + '</h3></a>';
                // entries += '<p>' + v.description + '</p>';
                entries += '</div>';
*/
                // entries += '<a href="watch.html#video=' + v.id + '">';


                // entries += '<div style="margin: 5px 12px 15px 12px; font-size: 1em;">' + v.description + '</div>';

                entries += '<a href="watch.html#video=' + v.id + '">';
                entries += '<img class="browse_boxcover" src="' + v.front + '" />';
                entries += '</a>';

                entries += '</div>';
        }
        return entries;
}




/*********/
/* WATCH */
/*********/

var watch_title = ' \
        <h3 id="watch_title"></h3> \
        <h4></h4><p class="studio" id="watch_studio" style="display: block;"></p><p class="pipe" style="margin-right:50px; display: block;"></p> \
        <p style="display: none;">Added: </p><p class="addedDate" id="watch_postdate" style="display: none;"></p> \
        ';


/********/
/* JOIN */
/********/

var join_step1_offer = " \
                <div id=\"offerheading\"><b>How do I pay for movies on this site?</b></div> \
                <p>This site offers pay-per-minute plans as low as $10 per month that are much more cost effective \
		than competitive sites.</p><p>Get unlimited access to 100s of the hottest bareback titles! \
                 Streamed to you with cutting-edge technology. Updated continuously.</p> \
                <div id=\"offerheading\"><b>How much does a plan cost?</b></div> \
                <div id=\"offer_plans\"></div> \
";

var join_step3_offer = ' \
		<ul> \
                    <li>- Hottest Exclusive Raw -</li> \
                    <li>- Unlimited Access -</li> \
                    <li>- No Hidden Charges -</li> \
                    <li>- Safe and Secure -</li> \
                    <li>- Frequent Updates -</li> \
                    <li>- No Popups or Spam -</li> \
                </ul> \
                ';


/********/
/* INFO */
/********/


/********/
/* ABOUT */
/*********/
var about_offer_heading = "";
var about_offer_text = "";



/**********/
/* FOOTER */
/**********/

/**********/
/* PLAYER */
/**********/
var player_style_preview_height = '577px';
var player_style_preview_height_169 = '433px';
var player_style_preview_floater_top = '142px';
var player_style_preview_floater_top_169 = '62px';

var player_style_watch_height = '577px';
var player_style_watch_height_169 = '433px';




/**********/
/* AFFILIATE */
/**********/

var footer_affiliate_link = '<a href="affiliate.html">webmasters</a>';
//'<a href="mailto:affiliate@videoapp.net">affiliates</a>';
// '<a href="affiliate.html">affiliates</a>';
/*
 * Controls login functions etc.
 */

var header_session_info = EiserneSessionInfo();
var header_site_info = EiserneRequest('site_info', {});
var header_user_info = null;
var header_path = location.href.split('/');
var header_path_last = header_path[header_path.length-1];
var header_path_page = header_path_last.split('.')[0];
var header_user_status_hook = new Array();
var header_anchor_hook = new Array();
var header_qs = new Querystring();
var header_hash = location.hash.substring(1, location.hash.length);


function header_init()
{
	var s = new String(location.href);
	if (s.indexOf('https://') == 0) {
		if ((header_path_last != 'join.html') && (header_path_last != 'myaccount.html')) {
			location.href = s.replace('https', 'http');
			throw 'turn off ssl';
		}
	
	}
	if (s.indexOf('http://') == 0) {
		if ((header_path_last == 'join.html') || (header_path_last == 'myaccount.html')) {
			location.href = s.replace('http', 'https');
			throw 'turn on ssl';
		}
	}
	
	/* if noconsent in querystring, set the consent attribute to avoid legal disclaimer */
	if (window.location.search.indexOf('noconsent=true') != -1) {
		EiserneSetSessionAttr('consent', 'Y');
	}

	if ((EiserneGetSessionAttr('consent') == null) && (window.location.search.indexOf('noconsent=true') == -1) ) {
		EiserneSetSessionAttr('wanted_url', window.location.href);
		location.href='consent.html';
		throw 'No Consent';		/* abort script */
	}

	header_check_user_status();
}

/*
 * Update diplay elements depending upon user's logged in/logged out status.
 * For users that are logged in, bounce them to appropriate pages if they
 * are not fully joined or their account is expired.
 */

function header_check_user_status()
{
	var div_joinNow = document.getElementById('joinNow');
	var div_tabJoin = document.getElementById('tabJoin');
	var div_account = document.getElementById('tabAccount');
	var div_login = document.getElementById('login');
	var div_logout = document.getElementById('logout');
	var div_nametag = document.getElementById('nametag');

	header_session_info = EiserneSessionInfo();	/* refresh */

	if (header_session_info.logged_in == 'N') {
		div_login.style.visibility = 'visible';
		div_account.style.visibility = 'hidden';
		div_joinNow.style.visibility = 'visible';
		div_tabJoin.style.visibility = 'visible';
		div_logout.style.visibility = 'hidden';
		div_nametag.style.visibility = 'hidden';
	} else {
		header_user_info = EiserneUserInfo();
	
		if (header_user_info.status == 'U') {
                        if (header_path_last != 'join.html') {
                                location.href = 'join.html';
                                throw 'Unconfirmed Member';
                        }
		}

		if (header_user_info.status == 'C') {
			if (header_path_last != 'cancelled.html') {
				location.href = 'cancelled.html';
				throw 'Cancelled Account';
			}
		}

		if (header_user_info.plan == null) {
			if (header_path_last != 'join.html') {
				location.href = 'join.html';
				throw 'Partial Member';
			}
		} else if (header_user_info.expired == 'Y') {
			if (header_path_last != 'myaccount.html') {
				location.href = 'myaccount.html';
				throw 'User Expired';
			}
		} 

		div_login.style.visibility = 'hidden';
		div_account.style.visibility = 'visible';
		div_joinNow.style.visibility = 'hidden';
		div_tabJoin.style.visibility = 'hidden';
		div_logout.style.visibility = 'visible';
		div_nametag.innerHTML = 'Welcome, ' + header_user_info.username + '!';
		div_nametag.style.visibility = 'visible';
	}
	
	for (var hook in header_user_status_hook) {
		(header_user_status_hook[hook])();
	}
}

// click login button to open login popup

function header_login_click()
{
	/* var loginDropDown = document.getElementById('login_popup');
	var div_username = document.getElementById('username');
	var div_password = document.getElementById('password');
	var div_login_error = document.getElementById('loginError');
	div_username.value = '';
	div_password.value = '';
	// div_password.type = 'text';
	div_login_error.style.visibility = 'hidden';
	loginDropDown.style.visibility = 'visible'; */

	document.getElementById('login_popup').style.display='block';
	document.getElementById('black_overlay').style.display='block';
	document.getElementById('login').style.visibility='hidden';

	document.forms[0].username.focus();
}

// click in a field in login popup

function header_login_field_focus(x)
{
	var div_username = document.getElementById('username');
	var div_password = document.getElementById('password');

/*	 
	if (x == div_username) {
		if (div_username.value == 'Username') {
			div_username.value = '';
		}
	} else {
		if (div_password.value == 'Password') {
			div_password.value = '';
			// initially set to text so we can detect and see it ;)
			// div_password.type = 'password';
		}
	}
*/
}

// close login popup

function header_login_close_click()
{

	document.getElementById('login_popup').style.display='none';
	document.getElementById('black_overlay').style.display='none';
	document.getElementById('login').style.visibility='visible';
	document.getElementById('loginError').style.visibility='hidden';

	var div_username = document.getElementById('username');
	var div_password = document.getElementById('password');
	div_username.value = '';
	div_password.value = '';
	//div_password.type = 'text';

}

// hit ENTER in login popup

function header_login_login_keypress(field,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13)
   	{
		header_login_login_click();
   		return false;
   	} else	return true;
}

// click login button on login_popup

function header_login_login_click()
{
	var div_loginDropDown = document.getElementById('login_popup');
	var div_username = document.getElementById('username');
	var div_password = document.getElementById('password');
	var div_login_error = document.getElementById('loginError');
	var response = EiserneRequest('login', { username: div_username.value, password: div_password.value });
	
	div_login_error.style.visibility = 'hidden';
	if (response.success == 'Y') {	
		// login successful! 
		// div_loginDropDown.style.visibility = 'hidden';
		header_login_close_click()
		header_session_info = EiserneSessionInfo();
		header_check_user_status();
	} else if (response.success == 'N') {
		if (response.errstatus != null) {
			var msg;

			switch (response.errstatus) {
				case 'INVALID': msg = 'Invalid user or password'; break;
				default: msg = 'Login error';
			}
			
			/* div_login_error.innerHTML = '<img src="/XXXXXXX/images/tri24.png" height=20 width=20 />' +  msg;  */
			div_login_error.innerHTML = msg; 
			
			div_login_error.style.visibility = 'visible';
		} else { alert(response.error); }
	} else {
		/* XXX - transient server error */
	}
}

// click logout (when logged in)

function header_logout_click()
{
	EiserneRequest('logout', { });
	if (header_path_last != 'browse.html') {
		window.location.href = 'index.html';
	} else {
		header_session_info = EiserneSessionInfo();
		header_user_info = null;
		header_check_user_status();
	}
}

function header_set_hash(x) { 
	window.location.hash = header_hash = x;
	header_qs = new Querystring();
	for (var hook in header_anchor_hook) {
		(header_anchor_hook[hook])();
	}
}

function random_background(div)
{
	if (global_num_random_background != 0) {
		var randomnumber=Math.ceil(Math.random() * global_num_random_background);
		document.getElementById(div).style.background = 'url(/' + global_siteid + '/images/backgrounds/' + randomnumber + '.' + global_bg_format+') no-repeat top right';
	}
}

/* 
 * Make back button work by polling periodically to see if the hash has changed.
 * There may be a race condition here ..
 */

var old_document_title = document.title;

setInterval(function() {
	if (busy == undefined){var busy=0; }
	if ( busy == 0 ) {
	var x = window.location.hash;
	x = x.substring(1, x.length);

	document.title = old_document_title;

    	if (x != header_hash) { window.location.reload(); }
}}, 250);

/**
 * A standardized messaging popup that can be used on the sites like an alert box.
 * It would automatically resize its height based on length of text message.
 * 
 *  Usage: MessageBox("Processing your Upgrade","Please wait a moment while your upgrade processes.",process_whatever() );
 */
function MessageBox(title, text, button_text, callbackfunction) {
    var message_box = document.getElementById('message_box');
    
    if (!message_box) {
        var newChild = document.createElement('div');
        document.body.appendChild(newChild);
        newChild.innerHTML = EiserneLoad('/BBB/inc/message_box.inc');
    }
    
    message_box = document.getElementById('message_box');
    if (!message_box) {
        return;
    }
    
    var div_title = document.getElementById('message_box_title');
    if (div_title) {
        div_title.innerHTML = title;
    }
    
    var div_text = document.getElementById('message_box_text');
    if (div_text) {
        div_text.innerHTML = text;
    }
    
    var div_button = document.getElementById('message_box_button');
    if (div_button) {
        if (button_text) {
            div_button.innerHTML = button_text;
            div_button.style.display = 'block';
        } else {
            div_button.style.display = 'none';
        }
    }
    
    if (typeof(callbackfunction) == 'function') {
        div_button.onclick = function() {
            callbackfunction();
            MessageBoxClose();
        };
    } else {
        div_button.onclick = MessageBoxClose;
    }
    
    message_box.style.margin = "-" + (message_box.clientHeight/2) + "px 0px 0px -" + (message_box.clientWidth / 2) + "px";
    
    document.getElementById('message_box_overlay').style.display = 'block';
    message_box.style.visibility = 'visible';
}

/**
 * Closes messaging popup.  
 */
function MessageBoxClose() {
    var message_box = document.getElementById('message_box');
    
    if (!message_box) {
        return;
    }
    
    message_box.style.visibility = 'hidden';
    document.getElementById('message_box_overlay').style.display = 'none';
} 
var sidebar_session_info;

/* minimized count of tags, defined in variables.js */
/* some variables will be defined in sidebar_init */
var sidebar_tags_min = sidebar_videos_tags_min; 
var sidebar_tags = {}; 
var sidebar_tags_more = false;
var sidebar_tag_select_hook = new Array();

/* minimized count of studios, defined in variables.js */
var sidebar_studios_min = sidebar_videos_studios_min; 
var sidebar_studios = {};
var sidebar_studios_more = false;
var sidebar_studios_select_hook = new Array();

/* minimized count of actors, defined in variables.js */
var sidebar_actors_min = sidebar_videos_actors_min; 
var sidebar_actors = {};
var sidebar_actors_more = false;
var sidebar_actor_select_hook = new Array();

var seemore_column_index = 0; /* current index of columns in seemore popup */
var seemore_column_count = 4;

// see more/less links text definition
var sidebar_text_default_see_less = '&laquo; see less';
var sidebar_text_default_see_more = '&raquo; see more';

if (typeof (sidebar_videos_tags_text_see_less) == 'undefined') {
    sidebar_videos_tags_text_see_less = sidebar_text_default_see_less;
}
if (typeof (sidebar_videos_studios_text_see_less) == 'undefined') {
    sidebar_videos_studios_text_see_less = sidebar_text_default_see_less;
}
if (typeof (sidebar_videos_actors_text_see_less) == 'undefined') {
    sidebar_videos_actors_text_see_less = sidebar_text_default_see_less;
}

if (typeof (sidebar_videos_tags_text_see_more) == 'undefined') {
    sidebar_videos_tags_text_see_more = sidebar_text_default_see_more;
}
if (typeof (sidebar_videos_studios_text_see_more) == 'undefined') {
    sidebar_videos_studios_text_see_more = sidebar_text_default_see_more;
}
if (typeof (sidebar_videos_actors_text_see_more) == 'undefined') {
    sidebar_videos_actors_text_see_more = sidebar_text_default_see_more;
}

/* NEWSLETTER */

// the field is clicked, clear it
function sidebar_newsletter_newsemail_click()
{
    var div_newsemail = document.getElementById('newsemail');
    div_newsemail.value = '';
}

function sidebar_newsletter_callback(response)
{
    var div_newsemail = document.getElementById('newsemail');
    var div_newsmsg = document.getElementById('newsmsg');
    var div_newssubmit = document.getElementById('newssubmit');

    if (response.success == 'Y') {
        div_newsmsg.innerHTML = 'Thanks!  Check your email for instructions to complete your subscription.';
        return;
    }

    div_newsemail.style.display = 'block';
    div_newssubmit.style.display = 'block';

    if (response.success == 'N') {
        div_newsmsg.innerHTML = response.error + '<br>Please try again.';
        return;
    }

    div_newsmsg.innerHTML = 'Server Error.  Please try again later.';
}

function sidebar_newsletter_submit_click()
{
    var div_newsemail = document.getElementById('newsemail');
    var div_newsmsg = document.getElementById('newsmsg');
    var div_newssubmit = document.getElementById('newssubmit');
    var div_newserr = document.getElementById('newserr');

    div_newsmsg.innerHTML = 'Processing...';
    div_newsemail.style.display = 'none';
    div_newssubmit.style.display = 'none';
    div_newserr.style.display = 'none';

    EiserneAsyncRequest('mailing_add', {
        email : div_newsemail.value
    }, sidebar_newsletter_callback);
}

function sidebar_tags_draw()
{
    var div_taglist = document.getElementById('taglist');
    var div_tag_seemore = document.getElementById('seemore_tags');
    var nodes = sidebar_tags_more ? sidebar_tags.length : sidebar_tags_min;
    var i;

    if (nodes > sidebar_tags.length)
        nodes = sidebar_tags.length;

    while (div_taglist.childNodes.length) {
        div_taglist.removeChild(div_taglist.childNodes[0]);
    }

    div_tag_seemore.innerHTML = sidebar_tags_more ? sidebar_videos_tags_text_see_less
            : sidebar_videos_tags_text_see_more;

    if (!sidebar_tags_more && sidebar_videos_tags_minimized_override) {
        if (typeof sidebar_videos_tags_minimized_override == 'string') {
            // overriden using plain text:
            div_taglist.innerHTML = sidebar_videos_tags_minimized_override;
            return;

        } else {
            // overriden using list of values:
            for (i = 0; i < sidebar_videos_tags_minimized_override.length; i++) {
                var new_li = sidebar_create_list_item('tags',
                        sidebar_videos_tags_minimized_override[i]);
                div_taglist.appendChild(new_li);
            }
            return;
        }
    }

    for (i = 0; i < nodes; i++) {
        var new_li = sidebar_create_list_item('tags', sidebar_tags[i]);

        div_taglist.appendChild(new_li);
    }
}

function sidebar_studios_draw()
{
    var div_studiolist = document.getElementById('studiolist');
    var div_studio_seemore = document.getElementById('seemore_studios');
    var nodes = sidebar_studios_more ? sidebar_studios.length
            : sidebar_studios_min;
    var i;

    if (nodes > sidebar_studios.length)
        nodes = sidebar_studios.length;

    while (div_studiolist.childNodes.length) {
        div_studiolist.removeChild(div_studiolist.childNodes[0]);
    }

    div_studio_seemore.innerHTML = sidebar_studios_more ? sidebar_videos_studios_text_see_less
            : sidebar_videos_studios_text_see_more;

    if (!sidebar_studios_more && sidebar_videos_studios_minimized_override) {
        if (typeof sidebar_videos_studios_minimized_override == 'string') {
            // overriden using plain text:
            div_studiolist.innerHTML = sidebar_videos_studios_minimized_override;
            return;

        } else {
            // overriden using list of values:
            for (i = 0; i < sidebar_videos_studios_minimized_override.length; i++) {
                var new_li = sidebar_create_list_item('studios',
                        sidebar_videos_studios_minimized_override[i]);
                div_taglist.appendChild(new_li);
            }
            return;
        }
    }

    for (i = 0; i < nodes; i++) {
        var new_li = sidebar_create_list_item('studios', sidebar_studios[i]);
        
        div_studiolist.appendChild(new_li);
    }
}

function sidebar_actors_draw()
{
    var div_actorlist = document.getElementById('actorlist');
    var div_actor_seemore = document.getElementById('seemore_actors');
    var nodes = sidebar_actors_more ? sidebar_actors.length
            : sidebar_actors_min;
    var i;

    if (nodes > sidebar_actors.length)
        nodes = sidebar_actors.length;

    while (div_actorlist.childNodes.length) {
        div_actorlist.removeChild(div_actorlist.childNodes[0]);
    }

    div_actor_seemore.innerHTML = sidebar_actors_more ? sidebar_videos_actors_text_see_less
            : sidebar_videos_actors_text_see_more;

    if (!sidebar_actors_more && sidebar_videos_actors_minimized_override) {
        if (typeof sidebar_videos_actors_minimized_override == 'string') {
            // overriden using plain text:
            div_actorlist.innerHTML = sidebar_videos_actors_minimized_override;
            return;

        } else {
            // overriden using list of values:
            for (i = 0; i < sidebar_videos_actors_minimized_override.length; i++) {
                var new_li = sidebar_create_list_item('actors',
                        sidebar_videos_actors_minimized_override[i]);
                div_taglist.appendChild(new_li);
            }
            return;
        }
    }

    for (i = 0; i < nodes; i++) {
        var item = '';
        
        var new_li = sidebar_create_list_item('actors', sidebar_actors[i]);

        div_actorlist.appendChild(new_li);
    }
}

function sidebar_featured_draw()
{
    var div_sidebar_featured = document.getElementById('sidebar_featured');

    var choices = sidebar_videos_featured_choices; // defined in variables.js

    /*
     * var choices = [ { id: 'recent', desc: 'Freshly Breeded' } { id:
     * 'popular', desc: 'Most Breeded' } ];
     */

    while (div_sidebar_featured.childNodes.length) {
        div_sidebar_featured.removeChild(div_sidebar_featured.childNodes[0]);
    }
    for ( var i = 0; i < choices.length; i++) {
        var new_li = document.createElement('li');
        var selected = (header_qs.get(choices[i].id) != null);
        var href = '';

        href += '<a href="';
        if (header_path_page == 'browse') {
            href += 'javascript:sidebar_featured_click(' + "'" + choices[i].id
                    + "'" + ')';
        } else {
            href += 'browse.html#' + choices[i].id + '=yes';
        }

        href += '">';
        if (selected) {
            href += '<b>';
        }
        href += choices[i].desc;
        if (selected) {
            href += '</b>';
        }
        href += '</a>';

        new_li.innerHTML = href;
        div_sidebar_featured.appendChild(new_li);
    }
}

function sidebar_tags_click(t)
{
    sidebar_seemore_close_click();
    header_set_hash('bytag=' + t);
}

function sidebar_tags_seemore_click()
{
    // lightbox view:
    if (typeof sidebar_videos_tags_lightbox != 'undefined'
            && sidebar_videos_tags_lightbox) {
        sidebar_seemore_click('tags');
        return;
    }

    // default view:
    sidebar_tags_more = !sidebar_tags_more;
    EiserneSetSessionAttr('sidebar_tags_more', sidebar_tags_more ? 'T' : 'F');
    sidebar_tags_draw();
}

function sidebar_studios_click(t)
{
    sidebar_seemore_close_click();
    header_set_hash('bystudio=' + t);
}

function sidebar_studios_seemore_click()
{
    // lightbox view:
    if (typeof sidebar_videos_studios_lightbox != 'undefined'
            && sidebar_videos_studios_lightbox) {
        sidebar_seemore_click('studios');
        return;
    }

    // default view:
    sidebar_studios_more = !sidebar_studios_more;
    EiserneSetSessionAttr('sidebar_studios_more', sidebar_studios_more ? 'T'
            : 'F');
    sidebar_studios_draw();
}

function sidebar_actors_click(t)
{
    sidebar_seemore_close_click();
    header_set_hash('byactor=' + t);
}

function sidebar_actors_seemore_click()
{
    // lightbox view:
    if (typeof sidebar_videos_actors_lightbox != 'undefined'
            && sidebar_videos_actors_lightbox) {
        sidebar_seemore_click('actors');
        return;
    }

    // default view:
    sidebar_actors_more = !sidebar_actors_more;
    EiserneSetSessionAttr('sidebar_actors_more', sidebar_actors_more ? 'T'
            : 'F');
    sidebar_actors_draw();
}

function sidebar_user_status_change()
{
    var div_newsletter = document.getElementById('newsletter');

    sidebar_session_info = EiserneSessionInfo();
    if (sidebar_session_info.logged_in == 'Y') {
        div_newsletter.style.visibility = 'hidden';
    } else {
        div_newsletter.style.visibility = 'visible';
    }
}

function sidebar_featured_click(s)
{
    header_set_hash(s + '=yes');
}

function sidebar_quick_search_press(event)
{
    if (event.keyCode == 13) {
        sidebar_quick_search_submit();
    }
}

function sidebar_quick_search_submit()
{
    var keyword = document.getElementById('sidebar_quick_search_text').value;
    
    if (header_path_page == 'browse') {
        header_set_hash('bykeyword=' + keyword);
    } else {
        location.href = 'browse.html#bykeyword=' + keyword;
    }
}

function sidebar_vod_account_draw()
{
    header_session_info = EiserneSessionInfo(); /* refresh */

    var div = document.getElementById('sidebar_vod_account');
    var header_site_info = EiserneRequest('site_info', {});
    var model = header_site_info.model;

    if (!div)
        return;

    var choices = sidebar_vod_account_choices; // defined in variables.js

    while (div.childNodes.length) {
        div.removeChild(div.childNodes[0]);
    }
    for ( var i = 0; i < choices.length; i++) {
        //model support
        if (typeof (choices[i].model) != 'undefined' && choices[i].model != model) {
            continue;
        }
        
        if ((choices[i].logged && header_session_info.logged_in == 'N')
                || (!choices[i].logged && header_session_info.logged_in == 'Y')) {
            continue;
        }
        var new_li = document.createElement('li');
        var selected = (header_qs.get(choices[i].id) != null);
        var href = '';
        var attrs = '';

        if (typeof (choices[i].attrs) != 'undefined') {
            attrs = choices[i].attrs;
        }

        if (typeof (choices[i].href) != 'undefined') {
            var t = choices[i].href;
            
            if (choices[i].href == (header_path_page + '.html')) {
                
                if (typeof (choices[i].id) != 'undefined') {
                    
                    href = '<a';
                    href += ' href="javascript:header_set_hash(' + "'page=" + choices[i].id + "'); " + '"';
                    href += attrs + '>';
                    href += choices[i].desc;
                    href += '</a>';

                } else {
                    href += '<a href="' + t + '" ' + attrs + '>';
                    href += choices[i].desc;
                    href += '</a>';
                }                
                
            } else {
                if (typeof (choices[i].id) != 'undefined') {
                    t += '#page=' + choices[i].id;
                }
                
                href += '<a href="' + t + '" ' + attrs + '>';
                href += choices[i].desc;
                href += '</a>';
                
            }         
        }

        if (typeof (choices[i].before) != 'undefined') {
            href = choices[i].before + href;
        }
        if (typeof (choices[i].after) != 'undefined') {
            href = href + choices[i].after;
        }

        new_li.innerHTML = href;
        div.appendChild(new_li);
    }
}

function sidebar_seemore_click(type)
{
    var ul_div = document.getElementById('seemore_popup_links');
    while (ul_div.childNodes.length) {
        ul_div.removeChild(ul_div.childNodes[0]);
    }

    var nodes = '';
    var header = '';

    switch (type) {
        case 'actors':
            nodes = EiserneRequest('actors', {}).actors;
            header = 'Actors';
            break;
        case 'tags':
            nodes = EiserneRequest('categories', {}).categories;
            header = 'Categories';
            break;
        case 'studios':
            nodes = EiserneRequest('studios', {}).studios;
            header = 'Studios';
            break;
        default:
            return;
    }
    document.getElementById('seemore_header').innerHTML = header;

    var ul = '';
    var column_index = 1;

    for (var i = 0; i < nodes.length; i++) {
        if (i % 20 == 0) {
            ul = document.createElement('ul');
            ul.className = 'seemore_column_' + column_index;
            column_index++;
            ul_div.appendChild(ul);
        }
        var new_li = sidebar_create_list_item(type, nodes[i]);

        ul.appendChild(new_li);
    }

    // if (column_index > 4) {
    var nav_links = document.createElement('div');
    nav_links.className = 'seemore_nav_links';
    nav_links.innerHTML = '<a href="javascript:seemore_nav_next()" id="seemore_nav_next">Next &raquo;</a>' + '<a href="javascript:seemore_nav_prev()" id="seemore_nav_prev">&laquo; Prev</a>';
    ul_div.appendChild(nav_links);
    // }
    seemore_nav_setcolumn(0);

    document.getElementById('black_overlay_seemore').style.display = 'block';
    document.getElementById('seemore_popup').style.display = 'block';
}

function seemore_nav_setcolumn(index)
{
    seemore_column_index = index;
    var ul_div = document.getElementById('seemore_popup_links');
    var total = ul_div.childNodes.length - 1; // last one is nav block
    for ( var i = 0; i < total; i++) {
        if (i >= index && i < index + seemore_column_count) {
            ul_div.childNodes[i].style.display = 'block';
        } else {
            ul_div.childNodes[i].style.display = 'none';
        }
    }
    if (index == 0) {
        document.getElementById("seemore_nav_prev").style.display = "none";
    } else {
        document.getElementById("seemore_nav_prev").style.display = "block";
    }

    if (index + seemore_column_count + 1> total) {
        document.getElementById("seemore_nav_next").style.display = "none";
    } else {
        document.getElementById("seemore_nav_next").style.display = "block";
    }
}

function seemore_nav_next()
{
    seemore_nav_setcolumn(seemore_column_index + seemore_column_count);
}

function seemore_nav_prev()
{
    seemore_nav_setcolumn(seemore_column_index - seemore_column_count);
}

function sidebar_create_list_item(type, element)
{
    var url = '';
    var search_by = '';

    switch (type) {
        case 'actors':
            url = 'browse.html#byactor=';
            search_by = header_qs.get('byactor');
            break;
        case 'tags':
            url = 'browse.html#bytag=';
            search_by = header_qs.get('bytag');
            break;
        case 'studios':
            url = 'browse.html#bystudio=';
            search_by = header_qs.get('bystudio');
            break;
    }

    var new_li = document.createElement('li');
    var href = '';
    var selected = (element.id == search_by);

    href = '<a';
    if (header_path_page == 'browse') {
        // NB: dynamic function name:
        href += ' onclick="javascript:sidebar_' + type + '_click(' + element.id
                + ');"';
    } else {
        href += ' href="' + url + element.id + '"';
    }
    href += '>';
    if (selected) {
        href += '<b>';
    }
    href += element.name;
    if (selected) {
        href += '</b>';
    }
    href += '</a>';

    new_li.innerHTML = href;
    return new_li;
}

//used for drop-down side lists
function sidebar_create_option_item(option_value, option_caption) 
{
    var result = document.createElement('option');
    result.value = option_value;
    result.innerHTML = option_caption;
    
    return result;
}

function sidebar_seemore_close_click()
{
    var el = document.getElementById('black_overlay_seemore');
    if (el) {
        el.style.display = 'none';
    }
    el = document.getElementById('seemore_popup');
    if (el) {
        el.style.display = 'none';
    }
}

function sidebar_init()
{
    sidebar_tags = EiserneRequest('categories', {order: 'popularity'}).categories;
    sidebar_tags_more = (EiserneGetSessionAttr('sidebar_tags_more') == 'T');

    sidebar_studios = EiserneRequest('studios', {order: 'popularity'}).studios;
    sidebar_studios_more = (EiserneGetSessionAttr('sidebar_studios_more') == 'T');

    sidebar_actors = EiserneRequest('actors', {order: 'popularity'}).actors;
    sidebar_actors_more = (EiserneGetSessionAttr('sidebar_actors_more') == 'T');
    
    header_user_status_hook.push(sidebar_user_status_change);
    header_anchor_hook.push(sidebar_tags_draw);
    header_anchor_hook.push(sidebar_studios_draw);
    header_anchor_hook.push(sidebar_actors_draw);
    header_anchor_hook.push(sidebar_featured_draw);
    sidebar_featured_draw();
    sidebar_tags_draw();
    sidebar_studios_draw();
    sidebar_actors_draw();
    sidebar_user_status_change();
    sidebar_vod_account_draw();
}


