//#############################################
// Source: standard.js
// Size: 15070
// Hash: -1886238206
//#############################################

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

var KimiCore = {};
KimiCore.createElement = function(tagName, styles)  // static utility method to create a mootools-extended Element with the specified styles
{
  var elem = $(document.createElement(tagName));
  if (typeof styles == 'string') elem.addClass(styles);
  else elem.setStyles(styles);

  return elem;
};

function is_defined(variable)
    {
    return (typeof(window[variable]) == "undefined") ? false : true;
    };

function console_log(str)
    {
    if (is_defined("console") && console)
        console.log(str);
    else if (is_defined("opera"))
        opera.postError(str);
//    else (ignore)
//        alert(str)
    };

function include(file)
    {
    var script  = document.createElement('script');
    script.src  = file;
    script.type = 'text/javascript';
    script.defer = true;
    document.getElementsByTagName('head').item(0).appendChild(script);
    };

function getTag(TagID)
    {
    return  document.getElementById(TagID)
    };

//*****************************
// AJaxVars
//*****************************
//below are the "ajax_vars". This page is loaded dynamically via ajax html requests. Unfortunately that means
//All javascript in a page that is ajax-loaded won't be executed. In order to have
//vars that update when the page is ajax-refreshed, use these get/setAjaxVar functions below for reading and writing these vars.
//You must declar the vars in HTML. The vars' id should start with "ajax_var_" and should have its value set in the "title" field of the tag.
//
//Example:
//
//<a style="display:none;">  <!--Hidden element since we don't want to user to see any evidence ot this-->
//    <a id="ajax_var_my_var" title="abcd1234"> <!-- my_var is set to an initial value of abcd1234
//</a>
//
//In javascript:
//
//my_var=getAjaxVar("my_var")    //returns "abcd1234" (if still set to the initial value)
//setAjaxVar("my_var","val")     //the "title" attribute of the "ajax_var_my_var" tag will be set to "val"

//General get/set functions (assume the value is just a string)
function getAjaxVar(id)         {return $("ajax_var_"+id).title};
function setAjaxVar(id,value)   {$("ajax_var_"+id).title=value};

//Boolean specific get/set functions (does the necessary string<->bool conversions. Bool strings are "t" for true and "f" for false)
function getAjaxBoolVar(id)         {return $("ajax_var_"+id).title=="t"};
function setAjaxBoolVar(id,value)   {$("ajax_var_"+id).title=value ? "t" : "f"};

//Easy way to convert a string to a number, multiply the string by "*1":
//num=getAjaxVar("my_int")*1



function condSetField(ID,matchstr,setstr)    {if ($(ID).value==matchstr) $(ID).value=setstr;};

function changeInputType(ID, oType)
    {
    var oldObject = $(ID);
    try {
        //non-IE style
        oldObject.type=oType;
        return oldObject;
        }
    catch(x)
        {}
    var newObject = document.createElement('input');
    newObject.type = oType;
    if(oldObject.size) newObject.size = oldObject.size;
    if(oldObject.value) newObject.value = oldObject.value;
    if(oldObject.name) newObject.name = oldObject.name;
    if(oldObject.id) newObject.id = oldObject.id;
    if(oldObject.onblur) newObject.onblur = oldObject.onblur;
    if(oldObject.onfocus) newObject.onfocus = oldObject.onfocus;
    if(oldObject.className) newObject.className = oldObject.className;
    oldObject.parentNode.replaceChild(newObject,oldObject);
    return newObject;
    }

function focusUserName()
    {
    obj=$("user_username");
    if (obj.value=="username")
        {
        obj.value="";
        }
    obj.select();
    };

function enablePasswordBox()
    {
    obj=$("user_password");
    if (obj.value=="password")
        {
        obj=changeInputType("user_password","password");
        obj.value="";
        }
    };

function focusPassword(ID)
    {
    obj=$(ID);
    if (obj.value=="password")
        {
        a=obj.onfocus;
        obj=changeInputType(ID,"password");
        obj.focus();
        obj.focus(); //IE requires a second focus for it to take (for unknown reasons)

        obj.value="";
        }
    obj.select();
    };

function blurPassword(ID)
    {
    obj=$(ID);
    if (obj.value=="")
        {
        obj=changeInputType(ID,"text");
        obj.value="password";
        }
    };

//*****************************
// AJax
//*****************************
function getAjaxObject()
    {
    var xmlHttp;
    try
        {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();;
        }
    catch (e)
        {
        // Internet Explorer
        try
            {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            }
        catch (e)
            {
            try
                {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
                }
            catch (e)
                {
                alert("Your browser does not support AJAX!");
                return false;
                }
            }
        }
    return xmlHttp;
    };

function ajaxRewriteInnerHTML(TagID,URL)
    {
    var xmlHttp=getAjaxObject();
    xmlHttp.onreadystatechange=function()
        {
        if(xmlHttp.readyState==4)
            {
            $(TagID).innerHTML=xmlHttp.responseText;
            }
        };
    xmlHttp.open("GET",URL,true);
    xmlHttp.send(null);
    };

function ajaxExecFunction(URL,func) //func should take three args: URL,Response
    {
    var xmlHttp=getAjaxObject();
    xmlHttp.onreadystatechange=function()
        {
        if(xmlHttp.readyState==4)
            {
            //alert("ajax success");
            func(URL,xmlHttp.responseText);
            }
        };
    xmlHttp.open("GET",URL,true);
    xmlHttp.send(null);
    };

function ajaxSwap(URL,TagID1,TagID2,swap_before)
    //swaps the visiblility of id1 and id2
    //if swap_before, swaps before the request as well as when done
    {
    if (swap_before) swapVisibility(TagID1,TagID2);
    var xmlHttp=getAjaxObject();
    xmlHttp.onreadystatechange=function()
        {
        if (xmlHttp.readyState==4)
            {
            swapVisibility(TagID1,TagID2);
            }
        };
    xmlHttp.open("GET",URL,true);
    xmlHttp.send(null);
    };

function toggleVisibility(TagID)
    {
    var el=$(TagID);
    if (el.style.display=="block" || el.style.display=="")
        {
        el.style.display="none";
        }
    else
        {
        el.style.display="block";
        }
    };

function showDiv(TagID) {$(TagID).style.display="block"};
function hideDiv(TagID) {$(TagID).style.display="none"};

function swapDisplay1(BaseTag)  {swapVisibility(BaseTag+"1",BaseTag+"2")};
function swapDisplay2(T1,T2)    {swapVisibility(T1,T2)};

function setCSSClass(ID,CSSClass)
    {
    var obj=$(ID);
    obj.setAttribute("class", CSSClass);
    obj.setAttribute("className", CSSClass);
    };

function setBackground(ID,background)
    {
    var obj=$(ID);
    obj.style.backgroundImage="url("+background+")";
    };

function swapVisibility(TagID1,TagID2)
    {
    var el1=$(TagID1);
    var el2=$(TagID2);
    if (el1 && el2)
        {
        var temp=el1.style.display;
        el1.style.display=el2.style.display;
        el2.style.display=temp;
        }
    };

function swapOnVisibility(OnTagID,OffTagID)
    {
    var el1=$(OnTagID);
    var el2=$(OffTagID);
    if (el2.style.display!="none")
        {
        var temp=el1.style.display;
        el1.style.display=el2.style.display;
        el2.style.display=temp;
        }
    };
function swapOffVisibility(OffTagID,OnTagID)
    {
    var el1=$(OffTagID);
    var el2=$(OnTagID);
    if (el1.style.display!="none")
        {
        var temp=el1.style.display;
        el1.style.display=el2.style.display;
        el2.style.display=temp;
        }
    };

function swap_tags_innerHTML(TagID1,TagID2)
    {
    var Tag1=$(TagID1);
    var Tag2=$(TagID2);

    var SwapTemp = Tag1.innerHTML;
    Tag1.innerHTML=Tag2.innerHTML;
    Tag2.innerHTML=SwapTemp;
    };

function set_select_value(select_tag, Value)
  {
  for(i = 0; i < select_tag.length; i++)
    {
    if(select_tag[i].value == Value)
      select_tag.selectedIndex = i;
    }
  }

//#############################################
// Source: browser_detect.js
// Size: 3298
// Hash: -991363374
//#############################################
//***********************************
// Browser Detect
//***********************************
BrowserDetectLog="";
var BrowserDetect =
    {
    init: function ()
        {
        this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
        this.imikimi_plugin = this.imikimi_plugin_temp;
        this.version = this.searchVersion(navigator.userAgent)
            || this.searchVersion(navigator.appVersion)
            || "an unknown version";
        this.OS = this.searchString(this.dataOS) || "an unknown OS";
        },

    searchString: function (data)
        {
        this.imikimi_plugin_temp="NO";
        for (var i=0;i<data.length;i++)
            {
            var dataString = data[i].string;
            var dataProp = data[i].prop;
            this.versionSearchString = data[i].versionSearch || data[i].identity;
            if (dataString)
                {
                if (dataString.indexOf(data[i].subString) != -1)
                    {
                    BrowserDetectLog+="dataString="+dataString+"\n";
                    this.imikimi_plugin_temp=data[i].p;
                    return data[i].identity;
                    }
                }
            else if (dataProp)
                {
                this.imikimi_plugin_temp=data[i].p;
                return data[i].identity;
                }
            }
        },

    searchVersion: function (dataString)
        {
//        alert("this.versionSearchString="+this.versionSearchString+"\ndataString="+dataString);
        var index = dataString.indexOf(this.versionSearchString);
        if (index == -1) return;
        return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
        },

    dataBrowser:
        [
        {prop: window.opera,                                p: "NPAPI", identity: "Opera"},
        {string: navigator.vendor,   subString: "Apple",    p: "NO",    identity: "Safari"},
        {string: navigator.vendor,   subString: "iCab",     p: "NO",    identity: "iCab"},
        {string: navigator.vendor,   subString: "KDE",      p: "NO",    identity: "Konqueror"},
        {string: navigator.vendor,   subString: "Camino",   p: "NO",    identity: "Camino"},
        {string: navigator.userAgent,subString: "OmniWeb",  p: "NO",    identity: "OmniWeb",    versionSearch: "OmniWeb/"},
        {string: navigator.userAgent,subString: "MSIE",     p: "IE",    identity: "Explorer",   versionSearch: "MSIE"},
        {string: navigator.userAgent,subString: "Firefox",  p: "NPAPI", identity: "Firefox"},
        {string: navigator.userAgent,subString: "Netscape", p: "NPAPI", identity: "Netscape"},                              // for newer Netscapes (6+)
        {string: navigator.userAgent,subString: "Gecko",    p: "NPAPI", identity: "Mozilla",    versionSearch: "rv"},
        {string: navigator.userAgent,subString: "Mozilla",  p: "NPAPI", identity: "Netscape",   versionSearch: "Mozilla"}  // for older Netscapes (4-)
        ],

    dataOS :
        [
        {string: navigator.platform, subString: "Win",      identity: "Windows"},
        {string: navigator.platform, subString: "Mac",      identity: "Mac"},
        {string: navigator.platform, subString: "Linux",    identity: "Linux"}
        ]
    };
BrowserDetect.init();

//#############################################
// Source: help_videos.js
// Size: 676
// Hash: 2131804950
//#############################################
function SelectVideo(youtube)
    {
    var d = document.getElementById("videoEmbed");
    d.innerHTML="&nbsp;<object width='425' height='350' "+
        " classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'"+
        " codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0'>"+
        "<param name='movie' value='http://www.youtube.com/v/"+youtube+"'/>"+
        "<param name='wmode' value='transparent'/>"+
        "<param name='autoStart' value=''/>"+
        "<embed src='http://www.youtube.com/v/"+youtube+"' type='application/x-shockwave-flash' wmode='transparent' width='425' height='350'></embed>"+
        "</object>";
    };

//#############################################
// Source: inline_field_edit.js
// Size: 4604
// Hash: -1615170247
//#############################################
var InlineFieldEditInfo=null;
var PreviousInlineEditValue=null;


function inline_field_edit(edit_tag,submit_url,options)
    {
    edit_tag=$(edit_tag);    //make sure mootools hooks the edit tag
    if (!options) options={};
    //Options:
    //  options.value       intitial value for text box - otherwise taken from edit_tag.innerHTML
    //  options.max_length  sets MAXLENGTH on the input field
    //read the current value and unescape HTML stuff
    v=options.value ? options.value : edit_tag.innerHTML;
    v=v.replace(/&lt;/gi,"<");
    v=v.replace(/&gt;/gi,">");

    //info
    var edit_tag_size=edit_tag.getSize().size;

    //create single-field edit div    var edit_window_tag = document.createElement('div');
    //Create edit_window_tag
    var edit_window_tag=$(document.createElement('div'));
    edit_window_tag.className="edit_field_div";
    edit_window_tag.id="edit_window_tag_id";
    border_size=2;
    edit_window_tag.style.top=(edit_tag.getPosition().y-border_size)+"px";
    edit_window_tag.style.left=(edit_tag.getPosition().x-border_size)+"px";
    edit_window_tag.style.width=edit_tag.getSize().size.x+"px";
    edit_window_tag.style.height=edit_tag.getSize().size.y+"px";

    //Create form_tag
    var form_tag=$(document.createElement("form"));
    var input_tag=$(document.createElement("input"));
    form_tag.setAttribute("action",submit_url);
    form_tag.setAttribute("method","post");
    form_tag.addEvent('submit',function(e)
        {
        //prevent the submit event
        new Event(e).stop();

        //ajax submit
        form_tag.commit_inline_edit();
        });
    form_tag.edit_window_tag=edit_window_tag;
    form_tag.edit_tag=edit_tag;
    form_tag.cancel_inline_field_edit=function()
        {
        edit_window_tag.parentNode.removeChild(edit_window_tag);
        };
    form_tag.previousValue=edit_tag.innerHTML;
    form_tag.committed=false;
    form_tag.commit_inline_edit=function()
        {
        if (!form_tag.committed && form_tag.previousValue!=input_tag.value)
            {
            form_tag.committed=true;
            this.send
                ({
                onComplete: function(response)
                    {
                    json_response=eval('(' + response + ')');
                    if (json_response.success)
                        {
                        v=json_response.value;
                        v=v.replace(/</g,"&lt;");
                        v=v.replace(/>/g,"&gt;");
                        edit_tag.innerHTML=v;
                        form_tag.cancel_inline_field_edit();
                        }
                    else if (json_response.validation_error)
                        {
                        options.value=input_tag.value;
                        form_tag.cancel_inline_field_edit();
                        if (confirm(json_response.validation_error+"\n\nContinue Editing?"))
                            {
                            inline_field_edit(edit_tag,submit_url,options);
                            }
                        }
                    else
                        {
                        alert("Error: "+json_response.error);
                        form_tag.cancel_inline_field_edit();
                        }
                    }
                });
            }
        else
            form_tag.cancel_inline_field_edit();
        };

    //Create input_tag
    input_tag.className="edit_field_input";
    input_tag.setAttribute("type","text");
    input_tag.setAttribute("value",v);
    input_tag.setAttribute("name","value");
    input_tag.setAttribute("bob","!@#$%");
    input_tag.setStyle("border","0px none");
    input_tag.addEvent("blur",function(){this.parentNode.commit_inline_edit();});
    input_tag.setStyle("font-size",edit_tag.getStyle("font-size"));
    input_tag.setStyle("font-face",edit_tag.getStyle("font-face"));
    input_tag.setStyle("font-style",edit_tag.getStyle("font-style"));
    input_tag.setAttribute("id","my_input");
    if (options.max_length) input_tag.setAttribute("maxlength",options.max_length);

    var h=edit_tag_size.y;
    if (window.ie) h-=1;
    input_tag.setStyle("width",edit_tag_size.x+"px");
    input_tag.setStyle("height",h+"px");

    //combine tags
    form_tag.appendChild(input_tag);
    edit_window_tag.appendChild(form_tag);
    document.body.appendChild(edit_window_tag);

    input_tag.focus();
    input_tag.select();


    //note tags
    InlineFieldEditInfo={submit_url:submit_url,edit_window_tag:edit_window_tag,edit_tag:edit_tag,form_tag:form_tag,input_tag:input_tag};
    };

//#############################################
// Source: kimi_bag.js
// Size: 4318
// Hash: 129017704
//#############################################
function load_kimi_bag_string()              {var ret=Cookie.get("kimi_bag",{path:"/"});if (!ret) ret=""; return ret;};
function save_kimi_bag_string(bag_string)
    {
    Cookie.set("kimi_bag", bag_string, {duration:30,path:"/"});
    console_log("save_kimi_bag_string: "+bag_string);
    };

function load_kimi_bag_array()
    {
    var bagCookie = load_kimi_bag_string();
    if (!bagCookie || bagCookie=="") return [];
    var list=bagCookie.split(",");
    var new_list=[];
    for (i=0;i<list.length;i++) if (list[i]!=null) new_list.push(list[i]);
    return new_list;
    };

function save_kimi_bag_array(bag)  {save_kimi_bag_string(bag.join(","));};

function in_bag(kimi_msid) {return load_kimi_bag_string().indexOf(kimi_msid)>=0};

function kimi_bag_add(kimi_msid)
    {
    if (!in_bag(kimi_msid))
        {
        var bag=load_kimi_bag_array();
        bag.push(kimi_msid);
        save_kimi_bag_array(bag);
        }
    show_kimi_bag_bag_kimis();
    };

function kimi_bag_remove(kimi_msid)
    {
    if (in_bag(kimi_msid))
        {
        var bag=load_kimi_bag_array();
        var new_bag=[];
        for (i=0;i<bag.length;i++)
            if (bag[i]!=kimi_msid) new_bag.push(bag[i]);
        save_kimi_bag_array(new_bag);
        update_kimi_bag();
        }
    };

function clear_kimi_bag()
    {
    if (!confirm("Remove all Kimis from your Kimi-Bag?")) return;
    Cookie.remove("kimi_bag",{path:"/"});
    update_kimi_bag();
    };

var kimi_bag_watcher=null;
var last_kimi_bag_string=null;
var kimi_bag_mode="normal";
var kimi_bag_page=null;

function set_kimi_bag_page(page)
    {
    kimi_bag_page=page;
    show_kimi_bag();
    };

function kimi_bag_watcher_func()
    {
//    console_log("kimi_bag_watcher")
//    alert("watcher")
//    if (last_kimi_bag_string!="loading" && load_kimi_bag_string()!=last_kimi_bag_string && kimi_bag_showing()) console_log("kimi_bag_watcher update: "+load_kimi_bag_string())
    update_kimi_bag();
    };

function start_kimi_bag_watcher()
    {
    console_log("start_kimi_bag_watcher");
    last_kimi_bag_string=load_kimi_bag_string();
    if (!kimi_bag_watcher) kimi_bag_watcher=setInterval(function(){kimi_bag_watcher_func()},100);
    window.addEvent('domready', function(){console_log("call initKimiStrip");if (is_defined("KimiStrip")) KimiStrip.init()})
    };

function stop_kimi_bag_watcher()
    {
    if (kimi_bag_watcher) {clearInterval(kimi_bag_watcher);kimi_bag_watcher=null};
    };

function show_kimi_bag()
    {
    if (!$('kimi_bag')) return;
    last_kimi_bag_string="loading";
    url='/kimi_bag/kimi_bag?kimi_bag_mode='+kimi_bag_mode;
    if (kimi_bag_page) url+="&kimi_bag_page="+kimi_bag_page;
    ajaxExecFunction(url,function(URL,response)
        {
        last_kimi_bag_string=load_kimi_bag_string();
        $('kimi_bag').innerHTML=response;
        $('kimi_bag').style.display="block";
        Cookie.set("kimi_bag_shown", "true", {path:"/"});
        console_log("show_kimi_bag() "+load_kimi_bag_string());
        if (is_defined("KimiPage") && KimiPage) KimiPage.newKimisAddedToBag();
        if (is_defined("KimiStrip")) KimiStrip.init();
        window.fireEvent('resize'); // fire a handlResize to reposition things (like the bgkimi) that need to be repositioned

        //auto scroll-up
        if (window.getScrollTop() > $('kimi_bag').getPosition().y) new Fx.Scroll(window).toElement($('kimi_bag'));
        });
    };

function show_kimi_bag_bag_kimis()
    {
    Cookie.remove("users_kimis", {path:"/"});
    show_kimi_bag();
    };

function show_kimi_bag_users_kimis()
    {
    Cookie.set("users_kimis","true",{path:"/"});
    show_kimi_bag();
    };

function kimi_bag_showing()     {return $('kimi_bag') && $('kimi_bag').style.display=="block";}

function toggle_kimi_bag()
    {
    if (kimi_bag_showing()) hide_kimi_bag();
    else                    show_kimi_bag();
    };

function hide_kimi_bag()
    {
    $('kimi_bag').style.display="none";
    Cookie.remove("kimi_bag_shown", {path:"/"});
    window.fireEvent('resize'); // fire a handlResize to reposition things (like the bgkimi) that need to be repositioned
    };

function update_kimi_bag()  {if (last_kimi_bag_string!="loading" && load_kimi_bag_string()!=last_kimi_bag_string && kimi_bag_showing()) show_kimi_bag()};

start_kimi_bag_watcher();

//#############################################
// Source: kimi_plugin_helper.js
// Size: 4136
// Hash: -1864978077
//#############################################
function LoadKimiPlugin(cl,server,kimi_id)
    {
    var d = document.getElementById("kimi_plugin");
    d.innerHTML=""+
            "<OBJECT "+
            "    ID='Imikimi_activex_plugin' "+
            "    CLASSID='CLSID:D71F9A27-723E-4B8B-B428-B725E47CBA3E' "+
            "    WIDTH=950 "+
            "    HEIGHT=520 "+
            "    codebase='http://<%=@serverURL%>/download/imikimi_plugin.cab'"+
            "    >"+
            "    <PARAM NAME='commandline' VALUE='"+cl+"'>"+
            "    <embed type='application/imikimi-plugin' width=920 height=520"+
            "        commandline='"+cl+"'"+
            "        pluginspage='http://"+server+"/main/download_plugin/"+kimi_id+"'"+
            "        >"+
            "</OBJECT>";
    };


//alert(
//    "Browser name: "+BrowserDetect.browser+"\n"+
//    "Browser version: "+BrowserDetect.version+"\n"+
//    "OS name: "+BrowserDetect.OS+"\n"+
//    "Plugin: "+ BrowserDetect.imikimi_plugin
//    );

//*****************************
// AJax Instructions loader
//*****************************

function LoadPluginInstructions( URL)
    {
    ajaxRewriteInnerHTML("ImikimiPluginInstructions",URL);
    };
//*****************************

NPAPIPluginDetected = false;
IEPluginDetected = false;

function DetectNPAPIPlugin()
    {
    NPAPIPluginDetected = false;
    if (navigator.plugins == null)              {}  //alert("navigator.plugins == null")
    else if (navigator.plugins.length == 0)     {}  //alert("navigator.plugins.length == 0")
    else
        {
        var I=0;
        for(I=0;I<navigator.plugins.length;I++)
            {
            if (navigator.plugins[I].name.indexOf("Imikimi")>=0)
                NPAPIPluginDetected=true;
            }
        }
    };

function ShowNotSupportedInstructions()
    {
    ImikimiPluginInstructions.innerHTML="Sorry, but your computer ("+BrowserDetect.OS+
    ") or browser ("+BrowserDetect.browser+
    ") is not supported. Please try FireFox, Opera or Internet Explorer on a Windows 2000, XP or Vista machine.";
    };

function ShowIEPluginInstructions()
    {
    //ImikimiPluginInstructions.innerHTML="Here's how you setup your plugin in IE...";
    if (BrowserDetect.version==7)
        LoadPluginInstructions("/download/help/winxp_ie7_help.html");
    else
        LoadPluginInstructions("/download/help/winxp_ie6_help.html");
    };

function ShowNPAPIPluginInstructions()
    {
    //ImikimiPluginInstructions.innerHTML="Here's how you setup your plugin in "+BrowserDetect.browser+"...";
    LoadPluginInstructions("/download/help/npapi_plugin_help.html");
    //LoadPluginInstructions("/download/help/winxp_ie7_help.html");
    };

function ShowPluginInstructions()
    {
    if (NPAPIPluginDetected || IEPluginDetected)
        {}  //plugin detected
    else
        LoadPluginInstructions(edit_kimi_install_instructions);
    return;

    DebugString=
        "<ul><li>NPAPIPluginDetected="+NPAPIPluginDetected+
        "<li>IEPluginDetected="+IEPluginDetected +
        "<li>Browser name: "+BrowserDetect.browser+"\n"+
        "<li>Browser version: "+BrowserDetect.version+"\n"+
        "<li>OS name: "+BrowserDetect.OS+"\n"+
        "<li>Plugin: "+ BrowserDetect.imikimi_plugin+
        "<li>BrowserDetectLog: "+ BrowserDetectLog+
        "</ul>";
//    BrowserDetectInfo.innerHTML=DebugString;

    ;
    if (NPAPIPluginDetected || IEPluginDetected)
        {
//        alert("Plugin Detected");
//        ImikimiPluginInstructions.innerHTML="";
        }
    else
        {
        if (BrowserDetect.OS!="Windows" || BrowserDetect.imikimi_plugin=="NO")   ShowNotSupportedInstructions();
        else
        if (BrowserDetect.imikimi_plugin=="IE") ShowIEPluginInstructions();
        else
        if (BrowserDetect.imikimi_plugin=="NPAPI") ShowNPAPIPluginInstructions();

//        setTimeout(ShowPluginInstructions, 2000);
        }
    };

function ShowPlugin()
    {
    DetectNPAPIPlugin();
    if (TestForIEPlugin) DetectIEPlugin();

    DoShowPlugin=true;
    if (BrowserDetect.imikimi_plugin=="NPAPI" && !NPAPIPluginDetected) DoShowPlugin=false;
    ShowPluginInstructions();
    };

//#############################################
// Source: KimiStripImage.js
// Size: 2444
// Hash: 584407651
//#############################################
var KimiStripImage = new Class({

  options: {
    scaleDuration: 250, // ms
    inactiveOpacity: 1,
    activeOpacity: 1
  },

  initialize: function(strip, options)
  {
    this.strip = strip;
    $extend(this.options, options);
    
    this.img = KimiCore.createElement('img', 'KimiStripImage');
    this.img.setStyle('margin-left', this.options.kimiSpacing);
    this.img.onload = this.onLoad.bind(this);
    this.img.addEvent('mouseover', this.onMouseOver.bind(this));
    //this.img.addEvent('mouseleave', this.onMouseLeave.bind(this));
    
    this.marginTop = parseInt((this.options.activeHeight - this.options.inactiveHeight) / 2) - 1;
    this.img.setStyles({ width: this.options.inactiveWidth, height: this.options.inactiveHeight, marginTop: this.marginTop, visibility: 'hidden' });
    
    this.a = KimiCore.createElement('a', 'KimiStripImageLink');
    this.a.appendChild(this.img);
        
    this.fxSize = new Fx.Styles(this.img, { duration: this.options.scaleDuration, transition: Fx.Transitions.Sine.easeOut });
    this.isActive = false;
  },
  
  inject: function(container)
  {
    container.appendChild(this.a);
  },
  
  load: function(data)
  {
    this.img.style.visibility = 'hidden';
    this.img.setAttribute('src', data.src);
    this.img.setAttribute('kp_animated', data.kp_animated);
    this.img.setAttribute('kp_img_url', data.kp_img_url);
    this.img.addClass(data.className);
    this.img.setStyle('cursor', data.cursor);
    
    this.a.setAttribute('href', data.href);
    this.a.setAttribute('title', data.title);
  },
  
  onLoad: function()
  {
    this.img.setStyle('visibility', 'visible');
    return true;
  },
  
  onMouseOver: function()
  {
    if (this.strip.dragIsActive) return;  // don't respond if a drag is active
  
    this.strip.shrinkActiveKimis();
    this.isActive = true;
    
    if (this.fxSize) this.fxSize.stop();
    this.fxSize.start({
      width: this.options.activeWidth,
      height: this.options.activeHeight,
      opacity: this.options.activeOpacity,
      top: 0 - this.marginTop
    });
  },
  
  onMouseLeave: function()
  {
    if (this.strip.dragIsActive) return;  // don't respond if a drag is active
  
    this.isActive = false;
  
    if (this.fxSize) this.fxSize.stop();
    this.fxSize.start({
      width: this.options.inactiveWidth,
      height: this.options.inactiveHeight,
      opacity: this.options.inactiveOpacity,
      top: 0
    });
  }
  
});
//#############################################
// Source: KimiStrip.js
// Size: 10203
// Hash: 172528860
//#############################################
// KimiStrip.js
// based on Posta.Strip.js, copyright 2007 Posta Inc.
// used with permission

var KimiStrip = new Class({

  options: {
    enlargeFromCenter: true,
    leftDisplacementDuration: 250, // ms
    activeWidth: 100,
    activeHeight: 75,
    inactiveWidth: 74,
    inactiveHeight: 56,
    kimiSpacing: 6  // don't set this in the stylesheet since we need to use the value in code (and parsing it doesn't work in all browsers)
  },

  initialize: function(container, options)
  {
    this.container = container;
    this.parseContainerContents();

    this.options = Object.extend(this.options, options || {});
    this.width = this.container.getSize().size.x;
    this.height = this.options.activeHeight;

    this.container.addClass('KimiStripContainer');
    this.container.setStyles({ height: this.height + 1, visibility: 'visible' });

    this.mouseIsOver = false;

    this.strip = KimiCore.createElement('div', 'KimiStrip');
    this.strip.setStyle('height', this.height + 2);
    this.strip.addEvent('mouseover', this.mouseOver.bindWithEvent(this));
    this.strip.addEvent('mouseleave', this.mouseLeave.bindWithEvent(this));
    this.strip.addEvent('mousemove', this.mouseMove.bindWithEvent(this));

    this.kimiWidth = this.getKimiWidth();
    this.zoomDisplacementLeft = 0 - ((this.options.activeWidth - this.options.inactiveWidth) / 2);

    //this.fxLeftDisplacement = new Fx.Styles(this.strip, { duration: this.options.leftDisplacementDuration, transition: Fx.Transitions.linear });
    this.fxLeftDisplacement = new Fx.Virtual({fps:80, duration: this.options.leftDisplacementDuration, transition: Fx.Transitions.Sine.easeOut, onSetStyle: this.updateLeftDisplacement.bind(this)});

    this.kimis = [];
    for (var i=0; i<this.kimiCount; i++)
    {
      var kimi = new KimiStripImage(this, this.options);
      kimi.inject(this.strip);
      this.kimis.push(kimi);
    }

    this.loadKimis();

    // nasty IE eternal loading glitch... we can't simply set this.container.innerHTML = '' here
    this.container.getChildren().each(function(child) {
        child.remove();
    });

    this.container.appendChild(this.strip);

    this.setLeft((KimiStrip.lastX > (this.scrollParams.viewPortWidth / 2)) ? this.scrollParams.stripScrollDistance : 0);
    if (typeof KimiPage != 'undefined') KimiPage.kimiThumbsMakeDraggable();
    
    window.addEvent('resize', this.handleResize.bind(this));
  },

  loadKimis: function()
  {
    for (var i=0; i<this.kimiCount; i++)
    {
      this.kimis[i].load(this.data[i]);
    }

    this.setScrollParams();
  },

  parseContainerContents: function()
  {
    // grab all kimi data from the container
    this.data = [];

    var aElements = this.container.getElements('a');
    aElements.each(function(a)
    {
      var img = a.getElement('img');
      var className = img.getAttribute('className') || img.getAttribute('class');
      this.data.push({ cursor: a.getStyle('cursor'), title: a.title, href: a.href, src: img.src, kp_animated: img.getAttribute('kp_animated') ? true : false, kp_img_url: img.getAttribute('kp_img_url'), className: className });
    }.bind(this));

    this.kimiCount = this.data.length;
  },

  getKimiWidth: function()
  {
    return this.options.inactiveWidth + this.options.kimiSpacing + 2 /* border-left + border-right */; // adjust these if settings in style.css#KimiStripImage change
  },

  handleResize: function(e)
  {
    try
    {
      this.setScrollParams();
    }
    catch(e)
    {
    
    }
  },

  setScrollParams: function(e)
  {
    var sw = this.kimiCount * this.kimiWidth;
    var containerSize = this.container.getSize();

    this.scrollParams = {
      stripWidth: sw,
      viewPortWidth: containerSize.size.x,
      scrollPortWidth: containerSize.size.x - this.kimiWidth,
      stripScrollDistance: (sw - containerSize.size.x) + this.options.kimiSpacing,
      containerPosX: this.container.getPosition().x
    };

    this.scrollParams.scrollPortX = this.scrollParams.containerPosX + (this.kimiWidth / 2);
    if (this.scrollParams.stripScrollDistance < 0) this.scrollParams.stripScrollDistance = 0;

    this.scrollParams.baseRate = this.scrollParams.stripScrollDistance / this.scrollParams.scrollPortWidth;
    this.scrollParams.enableLeftDisplacement = (this.scrollParams.stripWidth >= this.scrollParams.viewPortWidth);
    
    /*
    for (var i in this.scrollParams)
    {
      console.log(i + ':' + this.scrollParams[i]);
    }
    */
  },

  mouseMove: function(e)
  {
    if (this.dragIsActive) return;  // don't respond to mouse motions if a drag is active

    if (!this.mouseIsOver)
    {
      // IE7 handles a mouseMove event before the mouseOver event, so ignore this if it occurs
      this.mouseOver(e);
      return;
    }

    var x = this.calculateX(e);
    //console.log('x is ' + x);

    // if we're outside the scroll port to either side, jump to the terminal position
    if (x <= 0)
    {
      this.setLeft(0);
      this.fxLeftDisplacement.clearTimer();
      this.fxLeftDisplacement.set(0);
      return;
    }
    if (x >= this.scrollParams.scrollPortWidth)
    {
      this.setLeft(this.scrollParams.stripScrollDistance);
      if (!this.fxLeftDisplacement.isActive())
      {
        this.fxLeftDisplacement.clearTimer();
        this.fxLeftDisplacement.set(2 * this.zoomDisplacementLeft);
      }
      return;
    }

    var lx = KimiStrip.lastX;
    if (x == lx) return;

    var dx = x - lx;
    KimiStrip.lastX = x;

    var ssd = this.scrollParams.stripScrollDistance;
    var sl = this.stripLeft;

    // move the strip according to the (ratio of dx to total remaining x) over the total distance the strip has left to move
    var remainingScrollPortDistance;
    var remainingStripDistance;
    if (dx > 0)
    {
      remainingScrollPortDistance = (this.scrollParams.scrollPortWidth - lx);
      remainingStripDistance = (ssd - sl) + (-1 * this.zoomDisplacementLeft);
    }
    else if (dx < 0)
    {
      remainingScrollPortDistance = lx;
      remainingStripDistance = sl - this.zoomDisplacementLeft;
    }

    // if the ratio of remainingStripDistance to remainingScrollPortDistance is low, the strip will move slowly.  Limit this.
    var moveX;
    if (remainingStripDistance < remainingScrollPortDistance)
    {
      // move at the "base rate" of the PostaStrip
      moveX = dx * this.scrollParams.baseRate; // (dx * ssd) / this.scrollParams.scrollPortWidth;
    }
    else
    {
      moveX = (dx * remainingStripDistance) / remainingScrollPortDistance;
    }

    sl += moveX;
    this.setLeft(sl);
  },

  setLeft: function(left)
  {
    //console.log('setLeft: ' + left);
    if (!this.scrollParams.enableLeftDisplacement)
    {
      this.strip.style.left = '0px';
      return;
    }

    var ld = this.fxLeftDisplacement.get();

    // limit how far in each direction left can be set
    if (left < ld)
    {
      left = ld;
    }
    else
    {
      var rightLimit = this.scrollParams.stripScrollDistance;
      if (left > rightLimit)
      {
        left = rightLimit;
      }
    }

    this.stripLeft = left;
    this.strip.style.left = ((left * -1) + ld) + 'px';
  },

  calculateX: function(e)
  {
    var x = e.page.x - this.scrollParams.scrollPortX;
    var spw = this.scrollParams.scrollPortWidth;

    if (x < 0) x = 0;
    if (x > spw) x = spw;

    return x;
  },


  animateToLeftDisplacement: function()
  {
    if (this.options.enlargeFromCenter && this.scrollParams && (this.scrollParams.stripWidth > this.scrollParams.scrollPortWidth))
    {
      var targetLeft = 0;

      if (this.mouseIsOver)
      {
        targetLeft = this.zoomDisplacementLeft;
        if (this.kimis[0].isActive) targetLeft = 0;
        else if (this.kimis[this.kimiCount - 1].isActive)
        {
          targetLeft = (2 * this.zoomDisplacementLeft);
        }
      }

      this.fxLeftDisplacement.clearTimer();
      this.fxLeftDisplacement.custom(this.fxLeftDisplacement.get(), targetLeft);
    }
  },

  updateLeftDisplacement: function()
  {
    this.setLeft(this.stripLeft);
  },

  mouseOver: function(e)
  {
    if (this.dragIsActive) return;  // don't respond to mouseovers if a drag is active

    this.mouseIsOver = true;

    // set lastX to whatever X the event occurred at, to avoid a jump when mouseover happens
    KimiStrip.lastX = this.calculateX(e);

    this.animateToLeftDisplacement();
  },

  mouseLeave: function(e)
  {
    if (!this.dragIsActive)
    {
      this.mouseIsOver = false;
      this.shrinkActiveKimis();
      this.animateToLeftDisplacement();
    }
  },

  shrinkActiveKimis: function()
  {
    this.kimis.each(function(kimi)
    {
      if (kimi.isActive)
      {
        kimi.onMouseLeave();
      }
    });
  },

  notifyDragStarted: function()
  {
    // the page at large has notified us that a drag has started.  Suspend mouseLeave and mouseOut events
    this.dragIsActive = true;
  },

  notifyDragEnded: function()
  {
    // the page at large has notified us that a drag has ended.  Complete mouseLeave and mouseOut events
    this.dragIsActive = false;
    this.mouseLeave();

    this.kimis.each(function(kimi)
    {
      if (kimi.isActive)
      {
        kimi.onMouseLeave();
      }
    });
  }
});


// a moo.fx that is "Virtual" - that is, it doesn't move anything in the DOM, but provides current values and events to anyone who asks.
Fx.Virtual = Fx.Base.extend({

	initialize: function(options){
		this.element = {style: {virtual: 0}};
		this.setOptions(options);
		this.property = 'virtual';
	},

	increase: function(){
		this.setStyle(this.element, this.property, this.now);
	},

	setStyle: function(e, p, v){
		e.style[p] = v;
    if (this.options.onSetStyle) this.options.onSetStyle(v);
	},

  set: function(v){
    this.element.style.virtual = v;
  },

  doSetNow: function(v){
    this.setStyle(this.element, this.property, v);
  },

  get: function(){
    return this.element.style.virtual;
  },

  isActive: function() {
    return (this.now != this.to);
  }
});



// global init function
initKimiStrip = KimiStrip.init = function()
{
  // init the KimiStrip
  var elem = $$('.kimi_bag_area')[0];
  if (elem) KimiStrip.instance = new KimiStrip(elem);
};

//#############################################
// Source: kimi_thumb.js
// Size: 5113
// Hash: 385143137
//#############################################

//*******************************************
// Thumb Mouse-over
//*******************************************

function kimi_thumb_gif(tag)
    {
    if (!tag) return;
    src=tag.src;
    gifsrc=src.replace(/(.*)\.jpg/,"$1.gif");
    tag.src=gifsrc;
    };

function kimi_thumb_jpg(tag)
    {
    if (!tag) return;
    src=tag.src;
    gifsrc=src.replace(/(.*)\.gif/,"$1.jpg");
    tag.src=gifsrc;
    };

//*******************************************
// Animated Kimi-thumb cycling
//*******************************************

animated_thumbs=new Array;
last_animated_slice=0;
animated_slice_size=5;
function animate_kimi_thumbs()
    {
    for (i=0;i<animated_thumbs.length;i++)
        {
        tag=$(animated_thumbs[i]);
        kimi_thumb_jpg(tag);
        }

    last_animated_slice+=1;
    animated_thumbs=new Array;
    if (last_animated_slice>=animated_slice_size) last_animated_slice=0;
    for (i=last_animated_slice;i<kimi_thumb_list.length;i+=animated_slice_size)
        {
        tag=$(kimi_thumb_list[i]);
        kimi_thumb_gif(tag);
        animated_thumbs.push(kimi_thumb_list[i]);
        }
    setTimeout("animate_kimi_thumbs()",5000);
    };

function start_animating_kimi_thumbs()
    {
    setTimeout("animate_kimi_thumbs()",0);  //auto animate
    };

var kimi_thumb_list=new Array;
var f=null;
var t=true;
//sample:
//kthumb("abc-123","fankie","img_url","display_title",f,f,f,f,f,f,f)
function no_kthumb()
    {
    out="";
    out+="<td class=kimiIconsTable><table class=kimiHolder><tr><td>";
    out+="</td></tr></table></td>";
    };

//***********************************************
// Generate Kimi Thumb HTML
//***********************************************
function kthumb(options)
    {
    kimi_id=options.kimi;
    title=options.title;
    img_url=options.img;
    display_title=options.d_title;
    on_click=options.on_click;
    rating=options.stars;
    user_rating=options.my_stars;
    uses=options.uses;
    date_updated=options.updated;
    date_created=options.created;
    date_featured=options.featured;
    show_new=options["show_new"];
    mouseover_animate=options.mouse_ani;
    auto_animate=options.auto_ani;
    no_td=options.no_td;
    link_params=options.params;

    kp_img_url=options.kp_img_url;
    kp_animated=options.kp_animated;

    no_link=kp_img_url;

    add_td=(no_td!=t);

    out="";
    if (add_td) out+="<td class=kimiIconsTable>";
    out+="<table class=kimiHolder><tr><td>";

    click_url="/main/view_kimi/"+kimi_id;
    if (link_params)
        click_url+="?"+link_params;
    if (!on_click) on_click="window.location.href='#{click_url}'";

    out+="<div class=kimiHolderThumb on_click='"+on_click+"'>";

    if (!no_link) out+="<a href='"+click_url+"' on_click='return false'>";

    html_id="thumb_"+kimi_id;
    out+="<img id='"+html_id+"' class=kimi_thumb_image width=100 height=75 ";
    if (kp_animated) out+=" kp_animated=true ";
    if (kp_img_url) out+=" kp_img_url=\""+encodeURIComponent(kp_img_url)+"\" ";

    if (mouseover_animate) out+=" onmouseover='kimi_thumb_gif(this)' onmouseout='kimi_thumb_jpg(this)' ";

    out+=" title='"+title+"' alt='"+title+"' src='"+img_url+"'>";

    if (!no_link) out+="</a>";
    out+="</div></td>";
    out+="<td valign=bottom><img width=4 src='/images/image_icon_shadow_right.png'></td></tr>";
    out+="<tr><td colspan=2 align=right><img height=4 src='/images/image_icon_shadow_bottom.png'></td></tr>";

    out+="<tr><td align=center>";

/*
#if @bag_mode
#    %><div style="float:right;"><a href="." on_click="javascript:debag_kimi('<%=@kimi_thumb.kimi_msid%>');return false;" class=small>debag</a></div><%
#else
#    %><div style="float:right;"><a href="." on_click="javascript:bag_kimi('<%=@kimi_thumb.kimi_msid%>');return false;" class=small>bag</a></div><%
#end
*/
    if (auto_animate != f)
        kimi_thumb_list.push(html_id);

    if (display_title != f)
        {
        out+="<span class='kimiThumbTitle'><nobr>";
        out+=display_title;
        if (show_new) out+="<img width=20 height=12 src='http://imikimi.com/images/new.gif'>";
        out+="</nobr></span>";
        }
//************************************************
// Details
//************************************************

    out+="<span class=smallStatsText>";
    if (rating != f)
        {
        out+="<br><nobr>";
        var n;
        for (n=1;n<=5;n++)
            {
            starnum=0;
            if ((rating*2+0.5)==n*2-1) starnum=1;
            if ((rating*2+0.5)>=n*2) starnum=2;
            sel="";
            if (user_rating && user_rating>=n) sel="s";
            out+="<img width=15 height=15 src='/images/star"+starnum+sel+".gif'>";
            }
        out+="</nobr>";
        }

    if (uses != f)
        {
        out+="<br>"+uses+" use";
        if (uses!=1) out+="s";
        }

    if (date_updated != f)   out+="<br>"+date_updated+" ago";
    if (date_created != f)   out+="<br>"+date_created+" ago";
    if (date_featured != f)  out+="<br>"+date_featured+" ago";
    out+="</span></td></tr></table>";
    if (add_td) out+="</td>";
    document.write(out);
    };

//#############################################
// Source: mootools-cookie.js
// Size: 3487
// Hash: -1203353304
//#############################################
/*
Class: Cookie
    Class for creating, getting, and removing cookies.
*/

var Cookie = new Abstract({

    options: {
        domain: false,
        path: false,
        duration: false,
        secure: false
    },

    /*
    Property: set
        Sets a cookie in the browser.

    Arguments:
        key - the key (name) for the cookie
        value - the value to set, cannot contain semicolons
        options - an object representing the Cookie options. See Options below. Default values are stored in Cookie.options.

    Options:
        domain - the domain the Cookie belongs to. If you want to share the cookie with pages located on a different domain, you have to set this value. Defaults to the current domain.
        path - the path the Cookie belongs to. If you want to share the cookie with pages located in a different path, you have to set this value, for example to "/" to share the cookie with all pages on the domain. Defaults to the current path.
        duration - the duration of the Cookie before it expires, in days.
                    If set to false or 0, the cookie will be a session cookie that expires when the browser is closed. This is default.
        secure - Stored cookie information can be accessed only from a secure environment.

    Returns:
        An object with the options, the key and the value. You can give it as first parameter to Cookie.remove.

    Example:
        >Cookie.set('username', 'Harald'); // session cookie (duration is false), or ...
        >Cookie.set('username', 'JackBauer', {duration: 1}); // save this for 1 day

    */

    set: function(key, value, options){
        options = $merge(this.options, options);
        value = encodeURIComponent(value);
        if (options.domain) value += '; domain=' + options.domain;
        if (options.path) value += '; path=' + options.path;
        if (options.duration){
            var date = new Date();
            date.setTime(date.getTime() + options.duration * 24 * 60 * 60 * 1000);
            value += '; expires=' + date.toGMTString();
        }
        if (options.secure) value += '; secure';
        document.cookie = key + '=' + value;
        return $extend(options, {'key': key, 'value': value});
    },

    /*
    Property: get
        Gets the value of a cookie.

    Arguments:
        key - the name of the cookie you wish to retrieve.

    Returns:
        The cookie string value, or false if not found.

    Example:
        >Cookie.get("username") //returns JackBauer
    */

    get: function(key){
        var value = document.cookie.match('(?:^|;)\\s*' + key.escapeRegExp() + '=([^;]*)');
        return value ? decodeURIComponent(value[1]) : false;
    },

    /*
    Property: remove
        Removes a cookie from the browser.

    Arguments:
        cookie - the name of the cookie to remove or a previous cookie (for domains)
        options - optional. you can also pass the domain and path here. Same as options in <Cookie.set>

    Examples:
        >Cookie.remove('username') //bye-bye JackBauer, cya in 24 hours
        >
        >var myCookie = Cookie.set('username', 'Aaron', {domain: 'mootools.net'}); // Cookie.set returns an object with all values need to remove the cookie
        >Cookie.remove(myCookie);
    */

    remove: function(cookie, options){
        if ($type(cookie) == 'object') this.set(cookie.key, '', $merge(cookie, {duration: -1}));
        else this.set(cookie, '', $merge(options, {duration: -1}));
    }

});

//#############################################
// Source: view_kimi.js
// Size: 5123
// Hash: 1320425334
//#############################################

function validateInappropriateForm()
    {
    value=$("inappmulti").value;
    if (value=="")
        {
        alert("Please select your reason for flagging this Kimi as inappropriate.");
        return false;
        }
    else
        {
        return confirm("Please only flag Kimis that are truely inappropriate. We monitor abuse of the inappropriate flagging system.\n\nAre you sure this kimi is "+value+"?");
        }
    };

function affilateAjaxFunction( affil_url_id, kimi_msid )
    {
    $("affil_url_id").disabled = true;
    $("affil_status").innerHTML = '&nbsp;';
    url='/protected/set_affil_url?affil_url_id='+affil_url_id+'&kimi_msid='+kimi_msid;
    alert("url="+url);
    ajaxExecFunction
        (
        url,
        function(URL,response)
            {
            alert(URL);
            valuesArray = response.split("|");

            response = valuesArray[0];
            urlTitle = valuesArray[1];

            $("affil_status").innerHTML = '';
            $("affil_status").innerHTML = response;
            $("affil_url_id").disabled = false;

            if( urlTitle == '' )  {titleStr = '';}
            else                  {titleStr = 'title="'+urlTitle+'"';}

            }
        );
    };


function submitAndPublish() {document.kimiForm.publishToo.value='true';document.kimiForm.submit();};
function submitAndFeature(secs) {document.kimiForm.feature.value=secs;document.kimiForm.submit();};

function toggle_flag_content_ui()   {swapDisplay2("CenterContent","flagContentHTML")};
function toggle_stats_ui()          {swapDisplay1("stats")};
function toggle_tags_help_ui()      {swapDisplay1("tagsHelp")};
function toggle_categories()        {swapDisplay1("categories")};

//******************************
// Voting
//******************************

//When the user mouses over the stars, preview what their star-rating would look like if they clicked
function PreviewStars(n)
    {
    av_rating=getAjaxVar("av_rating")*1;
    user_rating=getAjaxVar("user_rating")*1;
    if (!getAjaxBoolVar("user_can_rate"))
        {
        if (!getAjaxBoolVar("supress_errors"))
            swapOnVisibility("rating_error","rating_count");
        return;
        }
    var i=0;
    for(i=1;i<=5;i++)
        {
        var d = $("star"+i);
        var num=0;
        if (i*2<=av_rating+1) num=1;
        if (i*2<=av_rating) num=2;

        var s="";
        if (i<=n) s="s";
        d.src="/images/star"+num+s+".gif";
        }
    };

//When the user moves their mouse away from the stars, restore the initial display of the stars
function LoginToRate()
  {
  swapOnVisibility("rating_error","rating_count");
  }

function RestoreStars()
    {
    av_rating=getAjaxVar("av_rating")*1;
    user_rating=getAjaxVar("user_rating")*1;
    swapOffVisibility("rating_error","rating_count");
    var i=0;
    for(i=1;i<=5;i++)
        {
        var d = $("star"+i);
        var num=0;
        if (i*2<=av_rating+1) num=1;
        if (i*2<=av_rating) num=2;

        var s="";
        if (i<=user_rating) s="s";
        d.src="/images/star"+num+s+".gif";
        }
    };

//When the users clicks on the stars, do an ajax update post to the database
function ClickStars(n,kimi_id)
    {
    if (getAjaxBoolVar("login_to_rate"))         {window.location="/main/new_user?redirect=/main/view_kimi/"+kimi_id;return;}
    if (!getAjaxBoolVar("user_can_rate"))         return;

    setAjaxVar("user_rating",n);
    ajaxSwap("/protected/rate/"+kimi_id+"?rating="+n,"rating_saving","rating_count",true);

    //setAjaxBoolVar("user_can_rate",false);

    //supress all further star error messages until a new _view_kimi_partial is loaded.
    //I would prefer to suppress the errors until the user moves the mouse away from the stars, a certain amount of time has passed, the ajax operation has completed, THEN re-enable the "already rated" error message.
    setAjaxBoolVar("supress_errors",true);
    };

function prompt_set_title(kimi_id,current_title,update_tag)
    {
    new_title=prompt("Edit Kimi Title", current_title);
    if (new_title==null) return;
    url="/protected/set_title/"+kimi_id+"?title="+escape(new_title);
    ajaxExecFunction
        (
        url,
        function(URL,response)
            {
            if (response=="success")
                update_tag.innerHTML=new_title;
            else
                {
                alert(response);
                prompt_set_title(kimi_id,new_title,update_tag);
                }
            }
        );
    };

function prompt_set_description(kimi_id,current_description,update_tag)
    {
    new_desc=prompt("Edit Kimi Description", current_description);
    if (new_desc==null) return;
    url="/protected/set_description/"+kimi_id+"?description="+escape(new_desc);
    ajaxExecFunction
        (
        url,
        function(URL,response)
            {
            if (response=="success")
                update_tag.innerHTML=new_desc;
            else
                {
                alert(response);
                prompt_set_description(kimi_id,new_desc,update_tag);
                }
            }
        );
    };


//#############################################
// Source: duplicatable.js
// Size: 4694
// Hash: 954766191
//#############################################
var Duplicatable = new Class({
  initialize: function(element) {
    this.element = element;
    this.add_link = element.getElement(".add");
    if(this.add_link) {
      this.add_link.addEvent("click", this.add.bind(this));
    }
    this.element.getElements(".duplicatable").each(function(duplicatable) {
      this.setup(duplicatable);
    }.bind(this));
  },
  
  add: function(duplicatable) {
    var clone = this.clone(duplicatable || this.element.getElements('.duplicatable').getLast());
    this.reset(clone);
    this.setup(clone);
    window.fireEvent("duplicatable:add", clone);
    clone.inject(this.element.getElements('.duplicatable').getLast(), 'after');
  },
  
  ensureOneEmptyInput: function(duplicatable) {
    // TODO: Consider inputs hidden from duplicatable?
    var emptyElements = this.element.getElements(".duplicatable").filter(function(element) {
      return element.getElement("select").value == "";
    });
    if(emptyElements.length == 0) { this.add(duplicatable); }

    var emptyOption = duplicatable.getElement("select option");
    if(emptyOption && emptyOption.getProperty("value") == "") { emptyOption.remove(); }
  
    // duplicatable.getElement(".remove").show();
    duplicatable.getElement(".remove").style.display = '';
  },
  
  clone: function(duplicatable) {
    var clone = duplicatable.clone();
    // This is required in IE, otherwise clicking the remove link removes all duplicatables.
    // TODO: We may want to remove events from all elements to make sure we don't get double binding going on.
    clone.getElement(".remove").removeEvents();
    var input = duplicatable.getElement("input[type=text]") || duplicatable.getElement("textarea") || duplicatable.getElement("select");
    var match = input.getProperty("id").match(/_(\d+)_/);
    
    if(match) {
      var duplicatable_id = match[1];
      var clone_id = parseInt(duplicatable_id) + 1;
    
      var inputs = duplicatable.getElements("input[type=text]") + duplicatable.getElements("textarea") + duplicatable.getElements("select");
      inputs.each(function(input) {
        input.setProperty("id", input.getProperty("id").gsub("_" + duplicatable_id + "_", "_" + clone_id + "_"));
        input.setProperty("name", input.getProperty("name").gsub(/\[\d+\]/, "[" + clone_id + "]"));
      });
    
      clone.getElements('label').each(function(label) {
        var duplicatable_for = label.getProperty("for");
        if(duplicatable_for) {
          label.setProperty("for", duplicatable_for.gsub("_" + duplicatable_id + "_", "_" + clone_id + "_"));
        }
      });
    }
    
    var delete_field = clone.getElement(".delete");
    if(delete_field) { delete_field.remove(); }
    // clone.show();
    clone.style.display = '';
    
    return clone;
  },
  
  reset: function(duplicatable) {
    duplicatable.getElements('input[type=text]').each(function(input) { input.value = input.getProperty("default") || ""; });
    duplicatable.getElements('textarea').each(function(input) { input.value = ''; });
    duplicatable.getElements('select').each(function(input) { input.selectedIndex = 0; });
  },
  
  setup: function(duplicatable) {
    duplicatable.getElement(".remove").addEvent("click", this.remove.bind(this, duplicatable));
    if(!this.add_link) {
      duplicatable.getElement("select").addEvent("change", this.ensureOneEmptyInput.bind(this, duplicatable));
      if(duplicatable.getElement("select").getProperty("value") == "") {
        // duplicatable.getElement(".remove").hide();
        duplicatable.getElement(".remove").style.display = "none";
      } else {
        // TODO: This can cause the first item to be selected if the actual selected item is no longer available
        var emptyOption = duplicatable.getElement("select option");
        if(emptyOption && emptyOption.getProperty("value") == "") { emptyOption.remove(); }
      }
    }
  },

  remove: function(duplicatable) {
    var visible_duplicatables = this.element.getElements('.duplicatable').filter(function(d) { 
      // return d.visible();
      return d.style.display != 'none';
    });
    
    var delete_field = duplicatable.getElement(".delete");
    if(delete_field) {
      delete_field.value = 1;
      // clone.hide();
      clone.style.display = "none";

      if(visible_duplicatables.length == 1) { this.add(); }
    } else {
      if(visible_duplicatables.length == 1) {
        this.reset(duplicatable);
      } else {
        duplicatable.remove();
      }
    }
    
    window.fireEvent("duplicatable:remove", duplicatable);
  }
});

window.addEvent("domready", function() {
  $$(".duplicatables").each(function(element) {
    new Duplicatable(element);
  }); 
});
//#############################################
// Source: ad_pool.js
// Size: 4473
// Hash: 1429614660
//#############################################
var AdPool = new Class({
  initialize: function(element) {
    this.element = element;
    this.ad_types = this.element.getElements(".ad select[name*=ad_id]").getLast().getElements("option");

    this.ad_type_select = this.element.getElement("select[name*=ad_type_ev]");
    this.ad_type_select.addEvent("change", this.updateAdSelections.bind(this));
    
    this.element.getElements(".ad").each(this.setup.bind(this));
    window.addEvent("duplicatable:add", this.setup.bind(this));
    window.addEvent("duplicatable:remove", this.updatePercentages.bind(this));
    
    this.updateAdSelections();
    this.updatePercentages();
  },
  
  setup: function(ad) {
    if(ad.hasClass("ad")) {
      ad.getElement("select").addEvent("change", this.updatePercentages.bind(this));
      ad.getElement("input").addEvent("change", this.updatePercentages.bind(this));
      ad.getElement(".plus").addEvent("click", this.changePercentage.bind(this, [ad, 1]));
      ad.getElement(".minus").addEvent("click", this.changePercentage.bind(this, [ad, -1]));
    }
  },
  
  changePercentage: function(ad, change) {
    var totalWeight = this.totalWeight();
    var currentWeight = parseFloat(ad.getElement("input").getProperty("value"));
    var currentPercentage = parseFloat(ad.getElement(".percentage .value").innerHTML);
    var othersWeight = totalWeight - currentWeight;
    var newPercentage = (currentPercentage + change) / 100;
    if(newPercentage >= 1) { newPercentage = .9999; }
    var newWeight = newPercentage * othersWeight / (1 - newPercentage);
    var newWeightRounded = newWeight.round() < newWeight ? newWeight.round() + 1 : newWeight.round();
    if(newPercentage <= 0) { newWeightRounded = 0; }
    ad.getElement("input").setProperty("value", newWeightRounded);
    this.updatePercentages();
  },

  totalWeight: function() {
    var totalWeight = 0;
    this.element.getElements(".ad").each(function(ad) {
      var ad_id = ad.getElement("select").getProperty("value");
      var weight = ad.getElement("input").getProperty("value");
      if(ad_id && weight) {
        totalWeight += parseFloat(weight);
      }
    }.bind(this));
    return totalWeight;
  },
  
  percentageFor: function(weight, totalWeight) {
    var percentage = totalWeight == 0 ? 0 : parseFloat(weight) / totalWeight * 100;
    return percentage.round();
  },
  
  // TODO: Consider inputs hidden from duplicatable?
  updatePercentages: function() {
    var totalWeight = this.totalWeight();
    this.element.getElements(".ad").each(function(ad) {
      var ad_id = ad.getElement("select").getProperty("value");
      var weight = ad.getElement("input").getProperty("value");
      if(ad_id && weight) {
        var percentage = this.percentageFor(weight, totalWeight);
        ad.getElement(".percentage .value").innerHTML = percentage + "%";
        ad.getElement(".percentage").style.display = "";
        if(percentage <= 0) {
          ad.getElement(".minus").addClass("disabled");
        } else {
          ad.getElement(".minus").removeClass("disabled");
        }
        if(percentage >= 100) {
          ad.getElement(".plus").addClass("disabled");
        } else {
          ad.getElement(".plus").removeClass("disabled");
        }
      } else {
        ad.getElement(".percentage").style.display = "none";
      }
    }.bind(this));
  },
  
  updateAdSelections: function() {
    this.ad_types.each(function(ad) {
      if(ad.getProperty("type") == null) {
        this.element.getElements(".ad select[name*=ad_id]").each(function(select) {
          if(select.getProperty("value") == "") {
            var option = select.getElement("option");
            if(!option || option.getProperty("value") != "") { ad.clone().inject(select); }
          }
        });
      } else if(ad.getProperty("type") == this.ad_type_select.getValue()) {
        this.element.getElements(".ad select[name*=ad_id]").each(function(select) {
          var option = select.getElement("option[value=" + ad.getProperty("value") + "]");
          if(!option) { ad.clone().inject(select); }
        });
      } else {
        this.element.getElements(".ad select[name*=ad_id]").each(function(select) {
          var option = select.getElement("option[value=" + ad.getProperty("value") + "]");
          if(option) { option.remove(); }
        });
      }
    }.bind(this));
  }
});

window.addEvent("domready", function() {
  $$(".ad_pool").each(function(element) {
    new AdPool(element);
  }); 
});
//#############################################
// Source: subscriptions.js
// Size: 7964
// Hash: -1451540392
//#############################################
var CvvDescription = new Class({
  initialize: function(element) {
    this.element = element;
    this.link = element.getElement("a");
    this.description = element.getElement("div")

    this.link.addEvent("mouseover", this.show.bind(this));
    this.link.addEvent("mouseout", this.hide.bind(this));
  },

  show: function() {
    if(!this.element.hasClass("disabled")) {
      this.description.style.display = '';
    }
  },

  hide: function() {
    this.description.style.display = 'none';
  }
});

var RegionInput = new Class({
  initialize: function(form) {
    this.form = form;
    this.country_select = form.getElement("select.country");
    this.country_select.addEvent("change", this.changeRegions.bind(this));

    this.state = this.form.getElement(".state");
    this.province = this.form.getElement(".province");
    this.region = this.form.getElement(".region");

    this.param_name = this.form.getElement(".region input").getProperty("name");
    this.changeRegions();
  },

  changeRegions: function() {
    var country_code = this.country_select.getProperty("value");
    if(country_code == "US") {
      this.show(this.state);
      this.hide(this.province);
      this.hide(this.region);
    } else if(country_code == "CA") {
      this.show(this.province);
      this.hide(this.state);
      this.hide(this.region);
    } else {
      this.show(this.region);
      this.hide(this.state);
      this.hide(this.province);
    }
  },

  show: function(container) {
    container.style.display = '';
    this.inputFor(container).setProperty("name", this.param_name);
  },

  hide: function(container) {
    container.style.display = 'none';
    this.inputFor(container).removeProperty("name");
  },

  inputFor: function(container) {
    return container.getElement("input[type=text]") || container.getElement("select");
  }
});

var PaymentMethod = new Class({
  initialize: function(form) {
    this.form = form;
    this.express = this.form.getElement(".payment_method .express");
    this.standard = this.form.getElement(".payment_method .standard");
    this.credit_card_information = this.form.getElement(".credit_card_information");
    this.billing_address = this.form.getElement(".billing_address");

    this.express.addEvent("click", this.enterExpressMode.bind(this));
    this.standard.addEvent("click", this.enterStandardMode.bind(this));

    if(this.standard.checked) {
      this.enterStandardMode();
    } else {
      this.enterExpressMode();
    }
  },

  enterExpressMode: function() {
    this.disable();
    this.form.setProperty("action", this.express.getProperty("href"));
  },

  enterStandardMode: function() {
    this.enable();
    this.form.setProperty("action", this.standard.getProperty("href"));
  },

  disable: function() {
    this.credit_card_information.addClass("disabled");
    this.credit_card_information.getElement(".cvv .description").addClass("disabled");
    this.credit_card_information.getElements("input").each(function(input) {
      input.setProperty("disabled", "disabled");
    });
    this.credit_card_information.getElements("textarea").each(function(input) {
      input.setProperty("disabled", "disabled");
    });
    this.credit_card_information.getElements("select").each(function(input) {
      input.setProperty("disabled", "disabled");
    });
    this.billing_address.addClass("disabled");
    this.billing_address.getElements("input").each(function(input) {
      input.setProperty("disabled", "disabled");
    });
    this.billing_address.getElements("textarea").each(function(input) {
      input.setProperty("disabled", "disabled");
    });
    this.billing_address.getElements("select").each(function(input) {
      input.setProperty("disabled", "disabled");
    });
  },

  enable: function() {
    this.credit_card_information.removeClass("disabled");
    this.credit_card_information.getElement(".cvv .description").removeClass("disabled");
    this.credit_card_information.getElements("input").each(function(input) {
      input.removeProperty("disabled");
    });
    this.credit_card_information.getElements("textarea").each(function(input) {
      input.removeProperty("disabled");
    });
    this.credit_card_information.getElements("select").each(function(input) {
      input.removeProperty("disabled");
    });
    this.billing_address.removeClass("disabled");
    this.billing_address.getElements("input").each(function(input) {
      input.removeProperty("disabled");
    });
    this.billing_address.getElements("textarea").each(function(input) {
      input.removeProperty("disabled");
    });
    this.billing_address.getElements("select").each(function(input) {
      input.removeProperty("disabled");
    });
  }
});

var PlanSelector = new Class({
  initialize: function(plan_selector) {
    this.plan_selector = plan_selector;

    this.plans = this.plan_selector.getElements(".plan");
    this.plans.each(function(plan) {
      plan.addEvent("click", this.select.bind(this, plan));
    }.bind(this));

    if (this.plan_selector.getElement(".current_plan"))
      {
      this.plan_selector.getElement(".current_plan").style.opacity=.5;
      }

    this.subscription_recurring_checkbox = $("subscription_recurring");
    this.subscription_recurring_checkbox.addEvent("click", this.updateInvoice.bind(this));
    this.invoice = $$(".subscriptions .invoice")[0];
    this.recurring_label = this.plan_selector.getNext().getElement("label");
    this.recurring_label_template = this.recurring_label.getProperty("template");

    this.updateRecurringLabel();
    this.updateInvoice();
  },

  select: function(selected) {
    this.plans.each(function(plan) {
      plan.removeClass("selected");
    }.bind(this));

    selected.addClass("selected");
    selected.getElement("input").setProperty("checked", "checked");

    this.updateRecurringLabel();
    this.updateInvoice();
  },

  selectedPlan: function() {
    return this.plan_selector.getElement(".selected");
  },

  subscriptionRecurring: function() {return this.subscription_recurring_checkbox.checked;},

  setInvoiceValueFromPropery: function(element_class_or_name,property) {
    var element=this.invoice.getElement(element_class_or_name);
    if (element) element.innerHTML=this.selectedPlan().getProperty(property);
  },

  updateInvoice: function() {
    var selected = this.selectedPlan();
    this.setInvoiceValueFromPropery(".plan_title","plan_title");
    this.setInvoiceValueFromPropery(".days_credit","days");
    this.setInvoiceValueFromPropery(".plan_title","plan_title");
    this.setInvoiceValueFromPropery(".today_bill","today_bill");
    this.setInvoiceValueFromPropery(".next_bill","next_bill");
    this.setInvoiceValueFromPropery(".period","period");
    this.setInvoiceValueFromPropery(".billing_date","date");
    this.setInvoiceValueFromPropery(".expiration_date","date");
    this.invoice.getElement(".active_subscription").style.display=this.subscriptionRecurring() ? "" : "none";
    this.invoice.getElement(".inactive_subscription").style.display=this.subscriptionRecurring() ? "none" : "";
  },

  updateRecurringLabel: function() {
    var selected = this.selectedPlan();
    this.recurring_label.innerHTML = this.recurring_label_template.replace('<period>', selected.getProperty("period")).replace('<days>', selected.getProperty("days")).replace('<date>', selected.getProperty("date"));
  }
});

window.addEvent("domready", function() {
  $$(".cvv .description").each(function(element) {
    new CvvDescription(element);
  });
  $$("form.address").each(function(form) {
    new RegionInput(form);
  });
  $$("form.payment").each(function(form) {
    new PaymentMethod(form);
  });
  $$(".plans").each(function(plan_selector) {
    new PlanSelector(plan_selector);
  });
  $$(".fieldWithErrors input, .fieldWithErrors textarea, .fieldWithErrors select").each(function(field) {
    field.addEvent("focus", function() {
      field.addClass("fixed");
    });
  });
});

//#############################################
// Source: history.js
// Size: 8509
// Hash: -15551864
//#############################################
var KimiHistory = new Class({
  initialize: function(element) {
    this.element                      = element;
    this.selected_revision_container  = $$(".selected_kimi_revision")[0];
    this.main_revision                = this.selected_revision_container.getElement(".main");
    this.image                        = this.main_revision.getElement("img");
    this.page                         = this.main_revision.getElement(".page #viewKimiPageContainer");
    this.version                      = this.main_revision.getElement(".version");
    this.created                      = this.main_revision.getElement(".created");
    this.author                       = this.main_revision.getElement(".author");
    this.revert_link                  = this.main_revision.getElement(".actions .revert");
    this.revert_link_revision         = this.revert_link.getElement(".revision");
    this.jump_link                    = this.main_revision.getElement(".actions .jump");
    this.jump_link_revision           = this.jump_link.getElement(".revision");
    this.compare_revision             = this.selected_revision_container.getElement(".compare");
    this.compare_image                = this.compare_revision.getElement("img");
    this.compare_page                 = this.compare_revision.getElement(".page #viewKimiPageContainer");
    this.compare_version              = this.compare_revision.getElement(".version");
    this.compare_created              = this.compare_revision.getElement(".created");
    this.compare_author               = this.compare_revision.getElement(".author");
    this.compare_revert_link          = this.compare_revision.getElement(".actions .revert");
    this.compare_revert_link_revision = this.compare_revert_link.getElement(".revision");
    this.compare_jump_link            = this.compare_revision.getElement(".actions .jump");
    this.compare_jump_link_revision   = this.compare_jump_link.getElement(".revision");

    var compare_method_control = $$(".compare_method input[checked]")[0];
    this.compare_method               = compare_method_control ? compare_method_control.getProperty("value") : null;
    this.selected_revision_container.addClass(this.compare_method);

    this.compare_effects = [];
    $$(".compare_method input").each(function(input) {
      input.addEvent("change", function() {
        this.selected_revision_container.removeClass(this.compare_method);
        this.compare_method = input.getProperty("value");
        this.selected_revision_container.addClass(this.compare_method);
        if(this.selected_revision_container.hasClass("compare")) {
          if(this.compare_method == "fade_in_out") {
            this.fadeToCompareRevision();
          } else {
            this.stopFadeInAndOutCompareMethod();
            this.compare_revision.setStyle("opacity", 1);
          }
        }
      }.bind(this));
    }.bind(this));
    
    this.revisions = this.element.getElements(".kimi_revision");
    this.revisions.each(function(revision) {
      revision.addEvent("click", this.setCurrentRevision.bind(this, revision));
      var compare_control = revision.getElement(".compare");
      if(compare_control) {
        compare_control.addEvent("click", function(event) {
          new Event(event).stopPropagation();
          this.setCompareRevision(revision);
        }.bind(this));
      }
    }.bind(this));
    
    [this.jump_link, this.compare_jump_link].each(function(jump_link) {
      jump_link.addEvent("click", function() {
        var selected_revision = this.revisions.filter(function(revision) { return revision.hasClass("selected"); })[0];
        var original_revision = this.revisions.filter(function(revision) { return revision.getProperty("data-revision") == selected_revision.getProperty("data-revert-revision"); })[0];
        this.setCurrentRevision(original_revision);
      }.bind(this));
    }.bind(this));

    this.setCurrentRevision(this.revisions[0], true);
  },
  
  setCurrentRevision: function(revision, skip_kimi_page_setup) {
    this.revisions.removeClass("selected");
    revision.addClass("selected");
    if(revision.getProperty("data-image")) {
      this.image.setProperty("src", revision.getProperty("data-image"));
    } else {
      this.page.setHTML(revision.getProperty("data-page"));
      if(!skip_kimi_page_setup) { setupKimiPage(); }
    }
    this.version.setHTML(revision.getElement(".version").innerHTML);
    this.created.setHTML(revision.getProperty("data-created"));
    this.author.setHTML(revision.getProperty("data-author"));
    this.revert_link.setProperty("href", revision.getProperty("data-revert-url"));
    this.revert_link_revision.setHTML(revision.getProperty("data-revision"));
    this.jump_link_revision.setHTML(revision.getProperty("data-revert-revision"));

    this.main_revision.removeClass("current");
    this.main_revision.removeClass("revert");
    if(revision.getProperty("data-current") == "true") {
      this.main_revision.addClass("current");
    } else if(revision.getProperty("data-revert-revision")) {
      this.main_revision.addClass("revert");
    }
    
    this.setCompareRevision(null);
  },
  
  setCompareRevision: function(revision) {
    if(!revision) {
      this.stopFadeInAndOutCompareMethod();
      this.selected_revision_container.removeClass("compare");
      this.revisions.each(function(r) {
        r.removeClass("compare");
        r.getElements("input[type=checkbox]").setProperty("checked", "");
      });
    } else if(revision.hasClass("compare")) {
      this.stopFadeInAndOutCompareMethod();
      this.selected_revision_container.removeClass("compare");
      revision.removeClass("compare");
      revision.getElements("input[type=checkbox]").setProperty("checked", "");
    } else {
      this.revisions.each(function(r) {
        r.removeClass("compare");
        r.getElements("input[type=checkbox]").setProperty("checked", "");
      });
      revision.addClass("compare");
      revision.getElements("input[type=checkbox]").setProperty("checked", "checked");
      if(revision.getProperty("data-image")) {
        this.compare_image.setProperty("src", revision.getProperty("data-image"));
      } else {
        this.compare_page.setHTML(revision.getProperty("data-page"));
        setupKimiPage();
      }
      this.compare_version.setHTML(revision.getElement(".version").innerHTML);
      this.compare_created.setHTML(revision.getProperty("data-created"));
      this.compare_author.setHTML(revision.getProperty("data-author"));
      this.compare_revert_link.setProperty("href", revision.getProperty("data-revert-url"));
      this.compare_revert_link_revision.setHTML(revision.getProperty("data-revision"));
      this.compare_jump_link_revision.setHTML(revision.getProperty("data-revert-revision"));
  
      this.compare_revision.removeClass("current");
      this.compare_revision.removeClass("revert");
      if(revision.getProperty("data-current") == "true") {
        this.compare_revision.addClass("current");
      } else if(revision.getProperty("data-revert-revision")) {
        this.compare_revision.addClass("revert");
      }

      this.selected_revision_container.addClass("compare");
      if(this.compare_method == "fade_in_out" && !this.compare_timeout) {
        this.compare_revision.setOpacity(0);
        this.fadeToCompareRevision();
      }
    }
  },

  fadeToCompareRevision: function() {
    this.compare_timeout = setTimeout(this.fadeToSelectedRevision.bind(this), 4000);
    this.compare_effects = [
      new Fx.Style(this.compare_revision, 'opacity', { duration: 2000 }).start(0, 1),
      new Fx.Style(this.main_revision, 'opacity', { duration: 2000 }).start(1, 0)
    ];
  },

  fadeToSelectedRevision: function() {
    this.compare_timeout = setTimeout(this.fadeToCompareRevision.bind(this), 4000);
    this.compare_effects = [
      new Fx.Style(this.compare_revision, 'opacity', { duration: 2000 }).start(1, 0),
      new Fx.Style(this.main_revision, 'opacity', { duration: 2000 }).start(0, 1)
    ];
  },

  stopFadeInAndOutCompareMethod: function() {
    clearTimeout(this.compare_timeout);
    this.compare_timeout = null;

    this.compare_effects.each(function(compare_effect) {
      compare_effect.stop();
    });
    this.compare_effects = [];

    this.main_revision.setOpacity(1);
    this.compare_revision.setOpacity(1);
  }
});

window.addEvent("domready", function() {
  $$(".kimi_revisions").each(function(element) {
    new KimiHistory(element);
  }); 
});
//#############################################
// Source: wiki_edit.js
// Size: 739
// Hash: -1226169101
//#############################################
var WikiEdit = new Class({
  initialize: function(element) {
    this.element        = element;
    this.edit_button    = this.element.getElement(".button");
    this.message        = this.element.getElement(".message");
    this.cancel_button  = this.message.getElement(".cancel");

    this.edit_button.addEvent("click", function(event) {
      this.element.addClass("confirm");
      new Event(event).preventDefault();
    }.bind(this));
    
    this.cancel_button.addEvent("click", function(event) {
      this.element.removeClass("confirm");
      new Event(event).preventDefault();
    }.bind(this));
  }
});

window.addEvent("domready", function() {
  $$(".wiki_edit").each(function(element) {
    new WikiEdit(element);
  }); 
});
//#############################################
// Source: voting.js
// Size: 1844
// Hash: 168096047
//#############################################

var VoteFloatingWidget = new Class({
  initialize: function(element) {
    this.element = element;
    this.vote_text = $("vote_text");
    this.description = element.getElement("div")

//    this.vote_text.addEvent("mouseover", this.show.bind(this));
//    this.description.addEvent("mouseout", this.hide.bind(this));
    $$(".vote_widget .close_button")[0].addEvent("click", this.hide.bind(this));
    $$(".show_vote_container .show_vote")[0].addEvent("click", this.toggle_show.bind(this));
  },

  show: function() {
    this.description.style.display = '';
  },

  toggle_show: function() {
    if (this.description.style.display == 'none')
      this.show();
    else
      this.hide();
  },

  hide: function() {
    this.description.style.display = 'none';
  }
});


function SubmitVote(vote_type,kimi_msid)
    {
    if (vote_type=="") return;
//    ajaxSwap(,"vote_saving","vote_display",true);
    url="/protected/vote/"+kimi_msid+"?vote_type="+vote_type;

    $('vote_saving').style.display="block";
    $('vote_display').style.display="none";
    ajaxExecFunction
      (
      url,
      function(URL,response)
        {
        res=eval('('+response+')');
        $('vote_saving').style.display="none";
//        if (res.result=="error" && res.retry)
          $('vote_display').style.display="block";
        if (res.info) alert(res.info);
        if (res.result=="success") document.location.reload();
        }
      );



    //setAjaxBoolVar("user_can_rate",false);

    //supress all further star error messages until a new _view_kimi_partial is loaded.
    //I would prefer to suppress the errors until the user moves the mouse away from the stars, a certain amount of time has passed, the ajax operation has completed, THEN re-enable the "already rated" error message.
    //setAjaxBoolVar("supress_errors",true);
    };

//#############################################
// Source: user_prefs.js
// Size: 1216
// Hash: -963755679
//#############################################
function update_user_pref(form_element,pref_name,original_value)
    {
    value=form_element.value
    if (form_element.type=="checkbox") value=form_element.checked ? "true" : "false"
    url="/protected/update_user_pref/"+pref_name+"?value="+value
//    alert("pref_name:"+pref_name+" original_value:"+original_value+"\n"+url);

    $(pref_name+"_saving").innerHTML="<span class='saving'>saving...</span>";

    ajaxExecFunction
      (
      url,
      function(URL,response)
        {
//        alert(response);


        //result
        res=eval('('+response+')');
        if (res.result=="success")
          {
          $(pref_name+"_saving").innerHTML="<span class='saved'>saved</span>";
          }
        else
          {
          $(pref_name+"_saving").innerHTML="<span class='error'>error: "+res.result+"</span>";
          if (original_value)
            {
            if (form_element.tagName=="SELECT")
              set_select_value(form_element,original_value);
            else
              form_element.value=original_value;
            }
          }
        if (res.info) alert(res.info);
        //setTimeout(function(){$(pref_name+"_saving").innerHTML="";},5000);
        }
      );
    };

//#############################################
// Source: realtime_bar.js
// Size: 3116
// Hash: 1195233790
//#############################################
var RealtimeBar = {
  'reloads' : 0,
  'updater': null,
  'reloadInterval': 5000,
  'playLength': 60*1000, // Defaults to 15 seconds
  'playUntil': null,

  'init': function(millis) {
    this.playLength = millis;

    this.play_button=$E(".realtime_bar .play_button");
    this.play_button.addEvent("click",this.play_button_click.bind(this));
    this.contents=[$E('.realtime_bar .contents_a'),$E('.realtime_bar .contents_b')]
    this.contents_fx = [
      new Fx.Styles(this.contents[0], {duration:500, wait:false}),
      new Fx.Styles(this.contents[1], {duration:500, wait:false})
      ];
    this.play_button_fx = new Fx.Styles(this.play_button, {duration:200, wait:false});

    if (window.ie)
      {
      this.contents[1].setStyle("display","none");
      }
    else
      {
      this.contents[1].setStyle("opacity","0");
      }

    this.play_button.setStyle("opacity","0");
    this.play();
    this.contents_front_buffer=0;
    this.contents_back_buffer=1;
  },

  play_button_click: function() {
    this.play();
    this.fetchBar();
  },

  'play': function() {
    // Hide the play button
    //this.play_button.setStyle('display','none');
    this.play_button_fx.start({'opacity': '0'});

    // Set the playUntil (in the form of milliseconds from epoch)
    this.playUntil = new Date().getTime() + this.playLength;

    // Start the timer
    this.updater = this.reload.periodical(this.reloadInterval, RealtimeBar);
//    this.fetchBar();
  },

  pause: function() {
    // Clear the updater
    $clear(this.updater);

    // Show the play button
    //this.play_button.setStyle('display','block');
    this.play_button_fx.start({'opacity': '1'});
  },

  reload: function() {
    if (new Date().getTime() < this.playUntil) {
      this.fetchBar();
    }
    else {
      this.pause();
    }
  },

  fetchBar: function() {
    new Ajax('/protected/realtime_bar', {
      data: {
        reload_count: (++this.reloads),
        online_now_page: online_now_page,
        view_kimi: view_kimi_msid,
        page_owner: page_owner_user_id
      },
      onComplete: this.fetchBarComplete.bind(this)
    }).request();
  },

  swapBar: function() {
    var front=this.contents_front_buffer;
    var back=this.contents_back_buffer;
    if (window.ie)
      {
      this.contents[back].setStyle('display', 'block');
      this.contents[front].setStyle('display', 'none');
      }
    else
      {
      this.contents_fx[back].start({'opacity': '1'});
      this.contents_fx[front].start({'opacity': '0'});
      }
    this.contents_front_buffer=back;
    this.contents_back_buffer=front;
  },

  fetchBarComplete: function(response) {
    this.contents[this.contents_back_buffer].setHTML(response);
    images_to_load=0;
    imageLoaded=this.imageLoaded.bind(this);
    this.contents[this.contents_back_buffer].getElements("img").each(function(tag){
      images_to_load++;
      tag.addEvent("load",imageLoaded);
      });
    this.images_to_load=images_to_load;
  },

  imageLoaded: function() {
    this.images_to_load--;
    if (this.images_to_load==0)
      {
      this.swapBar();
      }
  }

};

//#############################################
// Source: tooltip.js
// Size: 956
// Hash: 1048815609
//#############################################
var ToolTipWidget = new Class({
  initialize: function(trigger_tag,tip_tag) {
    this.trigger_tag = trigger_tag;
    this.tip_tag = tip_tag;

    this.fx = new Fx.Styles(tip_tag, {duration:200, wait:false});
    this.trigger_tag.addEvent("mouseover", this.show.bind(this));
    this.trigger_tag.addEvent("mouseout", this.hide.bind(this));
  },

  show: function() {
    this.tip_tag.style.top = this.trigger_tag.offsetHeight+"px";
    this.tip_tag.style.opacity= 0;
    this.tip_tag.style.display = '';
    this.fx.start({'opacity': '1'});
  },

  hide: function() {
    /*this.tip_tag.fade(0);//style.display = 'none';*/
    this.fx.start({'opacity': '0'});
  }
});

window.addEvent("domready", function()
  {
  $$(".tooltip").each(
    function(info_tag)
      {
      trigger_tag=info_tag.getElement(".tooltip_trigger");
      tip_tag=info_tag.getElement(".tip");
      if (trigger_tag && tip_tag) new ToolTipWidget(trigger_tag,tip_tag);
      })
  })

//#############################################
// Source: gifts.js
// Size: 500
// Hash: 434128157
//#############################################

function download_wallpaper_gift(size_selector,wallpaper_name)
  {
  $E(".gift_form_"+wallpaper_name+" .gift_filename").value=wallpaper_name+"_"+$(size_selector).value;
  button=$E(".gift_form_"+wallpaper_name+" .gift_download");
  if (size_selector.value=="default") {button.disabled=true;} else {button.disabled=false;}
//  url="/subscriptions/gifts/"+wallpaper_name+"_"+$(size_selector).value+".jpg";
//  set_select_value(size_selector,"default");
//  alert(url);
//  document.location=url;
  };

