// Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// 
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/**
* SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
*   legal reasons.
*/

/*
 * QTObject embed
 * http://blog.deconcept.com/2005/01/26/web-standards-compliant-javascript-quicktime-detect-and-embed/
 *
 * by Geoff Stearns (geoff@deconcept.com, http://www.deconcept.com/)
 *
 * v1.0.2 - 02-16-2005
 *
 * Embeds a quicktime movie to the page, includes plugin detection
 *
 * Usage:
 *
 *	myQTObject = new QTObject("path/to/mov.mov", "movid", "width", "height");
 *	myQTObject.altTxt = "Upgrade your Quicktime Player!";    // optional
 
 *  myQTObject.addParam("controller", "false");              // optional
 *	myQTObject.write();
 *
 */
var Shortcut=Class.create();
Object.extend(Shortcut.prototype,Widget.prototype);
Object.extend(Shortcut.prototype,{initialize:function(){
this._manager=$('i151');
this._manager.addSortableBehavior();
this._isMoving=false;
Event.observe(this.getProperty('c311'),"click",this.onClick.bind(this),false);
Event.observe(this.getProperty('c95'),"click",this.onClickDelete.bind(this),false);
if(this.getProperty('c114')!=undefined){
Event.observe(this.getProperty('c114'),"click",this.onClickEdit.bind(this),false);
}
},isShortcut:true,startDrag:function(){
Marker.reportClick("shortcuts_drag");
this._isMoving=true;
},onClick:function(_1){
if(this._isMoving){
Event.stop(_1);
this._isMoving=false;
return;
}
if(!this.isEdited()&&this.isEmpty()){
this._manager.removeForm();
this._manager.displayFormForShortcut(this);
}
this.link=this.getProperty('c210');
if($('i191')&&this.link){
this.link.target="_blank";
}
Marker.reportClick("shortcuts_click");
},onClickDelete:function(_2){
Marker.reportClick("shortcuts_delete");
this.removeShortcut();
Event.stop(_2);
},onClickEdit:function(){
Marker.reportClick("shortcuts_edit");
if(!this.isEdited()){
this._manager.removeForm();
this._manager.displayFormForShortcut(this);
}
},getId:function(){
return this.id.substring(1);
},getTitle:function(){
return this.getProperty('c351').innerHTML;
},getPosition:function(){
return this.getProperty('c262').innerHTML;
},getType:function(){
return this.getProperty('c364').innerHTML;
},getThumbnailUrl:function(){
var _3=this.getProperty('c355').src;
return _3.substr(1+_3.indexOf("?"));
},getUrl:function(){
return decodeHref(this.getProperty('c210'));
},isEdited:function(){
return (this.getElementsByTagName("form").length!=0);
},isEmpty:function(){
return (Element.hasClassName(this.getProperty('c311'),'c116'));
},showControls:function(){
Element.show(this.getProperty('c113'));
},hideControls:function(){
Element.hidden(this.getProperty('c113'));
},save:function(){
if(!this.isEdited()){
return;
}
var _4="save.php";
_4+="?id="+this.getId();
_4+="&url="+encodeURIComponent($('i149').value);
_4+="&title="+encodeURIComponent($('i148').value);
this._manager.ajaxUpdate(_4);
},removeShortcut:function(){
this._manager.removeForm();
var _5="delete.php?id="+this.getId();
this._manager.moveToTrash(this);
this._manager.ajaxUpdate(_5);
}});
var ShortcutsManager=Class.create();
Object.extend(ShortcutsManager.prototype,Widget.prototype);
Object.extend(ShortcutsManager.prototype,{initialize:function(){
this.getShortcuts();
Event.observe(this.getProperty('c6'),"click",this.onClickAddMoreShortcuts.bind(this),false);
Event.observe(this.getProperty('c316'),"click",this.onClickShowEditButton.bind(this),false);
Event.observe(this.getProperty('c155'),"click",this.onClickHideEditButton.bind(this),false);
},observeForm:function(){
Event.observe(this.getForm(),"submit",this.onSubmit.bind(this),false);
Event.observe($('i149'),"keypress",this.onKeyPressed.bind(this),false);
Event.observe($('i148'),"keypress",this.onKeyPressed.bind(this),false);
Event.observe(document.getElementsByClassName('c56',$('i146'))[0],"click",this.onClickCancel.bind(this),false);
Event.observe(document.getElementsByClassName('c299',$('i146'))[0],"click",this.onClickSave.bind(this),false);
},onClickShowEditButton:function(_6){
Marker.reportClick("shortcuts_show_edit_buttons");
Element.show(this.getProperty('c155'));
Element.hide(this.getProperty('c316'));
Preferences.save({showEditShortcutButtons:"true"});
var _7=this.getProperties('c312');
for(var i=0;i<_7.length;i++){
_7[i].showControls();
}
Event.stop(_6);
},onClickHideEditButton:function(_9){
Marker.reportClick("shortcuts_hide_edit_buttons");
Element.show(this.getProperty('c316'));
Element.hide(this.getProperty('c155'));
Preferences.save({showEditShortcutButtons:"false"});
var _a=this.getProperties('c312');
for(var i=0;i<_a.length;i++){
_a[i].hideControls();
}
Event.stop(_9);
},onClickCancel:function(_c){
this.removeForm();
Event.stop(_c);
},onSubmit:function(_d){
Event.stop(_d);
return false;
},onClickSave:function(_e){
var _f=Event.element(_e).parentNode.parentNode.parentNode;
this.saveShortcut(_f);
Event.stop(_e);
},onClickAddMoreShortcuts:function(_10){
Marker.reportClick("shortcuts_add_more");
this.removeForm();
this.ajaxUpdate("moreShortcuts.php?x=x");
Event.stop(_10);
},onKeyPressed:function(_11){
if(_11.keyCode==Event.KEY_RETURN){
Event.stop(_11);
var _12=Event.element(_11).parentNode.parentNode.parentNode;
this.saveShortcut(_12);
return false;
}
if(_11.keyCode==Event.KEY_ESC){
Event.stop(_11);
this.removeForm();
}
},saveShortcut:function(_13){
var _14=$('i146');
var _15=$('i149').value;
if(_15&&_15.match(/[^\s]+/)){
_13.save();
this.removeForm();
}else{
if(!_14.isShaken){
new Effect.Shake(_14);
}
}
},getShortcuts:function(){
this.ajaxUpdate("get.php?x=x");
},ajaxUpdate:function(_16,_17){
var _18=new Date();
_16+="&ts="+encodeURIComponent(_18+_18.getMilliseconds());
Element.addClassName(this,'c332');
this._isSortable=false;
$('i145').success=$('i145');
new Ajax.Updater($('i145'),Minivc.href(_16,{controller:"shortcuts"}),{insertion:Insertion.Instead,asynchronous:true,method:"get",onFailure:this.onFailure.bind(this),timeout:25000,onComplete:_17,onSuccess:this.onSuccess.bind(this),evalScripts:true});
},onFailure:function(req){
Element.removeClassName(this,'c332');
var _1a=$String.parseArguments('An unexpected error occured. Please try to <a href=\"_0_\">reload this page</a>',[window.location]);
var _1b=$('i145');
var _1c=document.getElementsByClassName('c218',_1b);
if(_1c.length>0){
for(var i=0;i<_1c.length;i++){
_1c[i].innerHTML=_1a;
}
}else{
var _1e=document.createElement("div");
_1e.innerHTML=_1a;
Element.addClassName(_1e,'c218');
var _1f=$('i145').firstChild;
if(_1f){
$('i145').insertBefore(_1e,_1f);
}else{
$('i145').appendChild(_1e);
}
}
Element.scrollTo($('i145'));
},onSuccess:function(){
Element.removeClassName(this,'c332');
this.clearProperties('c312');
},displayFormForShortcut:function(_20){
_20.hideControls();
var _21=this.getForm();
if(_20.isEmpty()){
$('i149').value="";
$('i148').value="";
}else{
$('i149').value=_20.getUrl();
$('i148').value=_20.getTitle().unescapeHTML();
}
_21.parentNode.removeChild(_21);
_20.appendChild(_21);
Element.hide(_20.getProperty('c311'));
Element.show(_21);
Field.focus($('i149'));
},removeForm:function(){
var _22=this.getForm();
var _23=_22.parentNode;
if(_23.isShortcut){
if(_23.showControls&&Element.visible(this.getProperty('c155'))){
_23.showControls();
}
Element.show(_23.getProperty('c311'));
_23.removeChild(_22);
this.appendChild(_22);
}
Element.hide(_22);
},moveToTrash:function(_24){
_24.parentNode.removeChild(_24);
this.getProperty('c361').appendChild(_24);
},getShortcutById:function(_25){
return $("s"+_25);
},addSortableBehavior:function(){
var _26=this.getProperties('c312');
for(var i=0;i<_26.length;i++){
_26[i].style.position="relative";
}
if(!this._isSortable){
Sortable.create($('i145').id,{tag:"div",only:'c312',overlap:"vertical",constraint:false,format:/^s(.*)$/,onHover:this.onHover.bind(this),onUpdate:this.saveShortcutsOrder.bind(this,undefined),safeClickingMargin:5,draggingClass:'c229'});
this._isSortable=true;
Position.includeScrollOffsets=true;
}
},saveShortcutsOrder:function(_28){
var _29="modifyOrder.php?newOrder=";
var _2a=document.getElementsByClassName('c312',$('i145'));
for(var i=0;i<_2a.length;i++){
_29+=(i)+":"+_2a[i].getId()+"-";
}
this.removeForm();
this.ajaxUpdate(_29,_28);
},onHover:function(_2c,_2d,_2e){
if(Element.isParent(_2d,_2c)){
return;
}
var _2f=document.getElementsByClassName('c312',$('i145'));
var _30=_2f.indexOf(_2d);
var _31=_2f.indexOf(_2c);
if(_31>_30){
Sortable.mark(_2d,"before");
if(_2d.previousSibling!=_2c){
var _32=_2c.parentNode;
_2c.style.visibility="hidden";
_2d.parentNode.insertBefore(_2c,_2d);
if(_2d.parentNode!=_32){
Sortable.options(_32).onChange(_2c);
}
Sortable.options(_2d.parentNode).onChange(_2c);
}
}else{
Sortable.mark(_2d,"after");
var _33=_2d.nextSibling||null;
if(_33!=_2c){
var _32=_2c.parentNode;
_2c.style.visibility="hidden";
_2d.parentNode.insertBefore(_2c,_33);
if(_2d.parentNode!=_32){
Sortable.options(_32).onChange(_2c);
}
Sortable.options(_2d.parentNode).onChange(_2c);
}
}
},getForm:function(){
var _34=$('i146');
if(!_34){
_34=$('i147').cloneNode(true);
_34.id='i146';
var _35=_34.getElementsByTagName("input");
_35[0].id='i149';
_35[0].setAttribute("autocomplete","off");
_35[1].id='i148';
_35[1].setAttribute("autocomplete","off");
this.appendChild(_34);
this.observeForm();
}
return _34;
}});
var ShortcutsMessages=Class.create();
Object.extend(ShortcutsMessages.prototype,Widget.prototype);
Object.extend(ShortcutsMessages.prototype,{initialize:function(){
var _36=document.getElementsByClassName('c8',this);
if(_36[0]){
Event.observe(_36[0],"click",this.onClickAddShortcutLink.bind(this),false);
}
var _37=this.getProperty('c366');
if(_37){
Event.observe(_37,"click",this.onClickUndo.bind(this),false);
}
var _38=this.getElementsByTagName("li");
for(var i=0;i<_38.length;i++){
if(!Element.hasClassName(_38[i],'c242')){
this.registerBlink(_38[i]);
}
}
},registerBlink:function(_3a){
setTimeout(function(){
Effect.Pulsate(_3a);
}.bind(this),500);
},onClickAddShortcutLink:function(_3b){
Event.stop(_3b);
var _3c=document.getElementsByClassName('c312',$('i145'));
var _3d=undefined;
for(var i=0;i<_3c.length;i++){
if(_3c[i].isEmpty()){
_3d=_3c[i];
break;
}
}
if(_3d){
_3d.onClick(_3b);
}else{
$('i151').ajaxUpdate("addEmpty.php",function(){
setTimeout(function(){
var _3f=$('i151').getProperties('c312');
_3f[_3f.length-1].onClick(new Object());
},1000);
});
}
},onClickUndo:function(){
var _40=$('i151');
var _41=_40.getProperty('c361').lastChild;
var _42="undoDelete";
_42+="?id="+_41.getId();
_42+="&url="+encodeURIComponent(_41.getUrl());
_42+="&title="+encodeURIComponent(_41.getTitle());
_42+="&position="+_41.getPosition();
_42+="&thumbnailUrl="+encodeURIComponent(_41.getThumbnailUrl());
_42+="&type="+encodeURIComponent(_41.getType());
_40.ajaxUpdate(_42);
}});
var ShortcutsMessagesViewportControl=Class.create();
Object.extend(ShortcutsMessagesViewportControl.prototype,Widget.prototype);
Object.extend(ShortcutsMessagesViewportControl.prototype,{initialize:function(){
this.bodyHeight=Element.getHeight(document.body);
var _43=document.getElementsByClassName('c218',this);
var _44=false;
for(var i=0;i<_43.length;i++){
if(this.isMessageInViewPort(_43[i])){
if(_44){
Element.hide(_43[i]);
}else{
_44=true;
}
}
}
},isMessageInViewPort:function(_46){
var _47=Position.page(_46)[1];
return 0<=_47&&_47<this.bodyHeight;
}});
var ShortcutsUniverseItem=Class.create();
Object.extend(ShortcutsUniverseItem.prototype,Widget.prototype);
Object.extend(ShortcutsUniverseItem.prototype,{initialize:function(){
this.checkBox=this.getElementsByTagName("input")[0];
this.added=this.checkBox.checked;
Event.observe(this,"click",this.onClick.bind(this),false);
this.display();
},onClick:function(_48){
this.added=!this.added;
this.display();
},display:function(){
if(this.added){
Element.addClassName(this,'c5');
this.checkBox.checked=true;
}else{
Element.removeClassName(this,'c5');
this.checkBox.checked=false;
}
}});
var Bookmarklet=Class.create();
Object.extend(Bookmarklet.prototype,Widget.prototype);
Object.extend(Bookmarklet.prototype,{initialize:function(){
Event.observe($('i181'),"keypress",this.onKeypress.bind(this),false);
Event.observe($('i170'),"keypress",this.onKeypress.bind(this),false);
},onKeypress:function(_49){
if(_49.keyCode==Event.KEY_RETURN){
document.forms[0].submit();
Event.stop(_49);
}
}});

