var cookie_domain='youtube.com';
var cookie_prefix='';
bind=function(fn,self,var_args){
var boundArgs=fn.boundArgs_;
if(arguments.length>2){
var args=Array.prototype.slice.call(arguments,2);
if(boundArgs){
args.unshift.apply(args,boundArgs);
}
boundArgs=args;
}
self=fn.boundSelf_||self;
fn=fn.boundFn_||fn;
var newfn;
if(boundArgs){
newfn=function(){
var args=Array.prototype.slice.call(arguments);
args.unshift.apply(args,boundArgs);
return fn.apply(self,args);
}
}else{
newfn=function(){
return fn.apply(self,arguments);
}
}
newfn.boundArgs_=boundArgs;
newfn.boundSelf_=self;
newfn.boundFn_=fn;
return newfn;
};
Function.prototype.bind=function(self,var_args){
if(arguments.length>1){
var args=Array.prototype.slice.call(arguments,1);
args.unshift(this,self);
return bind.apply(null,args);
}else{
return bind(this,self);
}
};
Function.prototype.inherits=function(parentCtor){
inherits(this,parentCtor);
};
inherits=function(childCtor,parentCtor){
function tempCtor(){};
tempCtor.prototype=parentCtor.prototype;
childCtor.superClass_=parentCtor.prototype;
childCtor.prototype=new tempCtor();
childCtor.prototype.constructor=childCtor;
};
var goog=window.goog?window.goog:{};
window.goog=goog;
goog.typeOf=function(value){
var s=typeof value;
if(s=='object'){
if(value){
if(typeof value.length=='number'&&
typeof value.splice=='function'&&
typeof value.propertyIsEnumerable=='function'&&
!value.propertyIsEnumerable('length')){
return 'array';
}
}else{
return 'null';
}
}
return s;
};
function addclass(obj,cl){
if(obj){
if(!checkclass(obj,cl)){
obj.className+=obj.className?' '+cl:cl;
}
}
}
function checkclass(obj,cl){
return obj&&new RegExp('\\b'+cl+'\\b').test(obj.className);
}
function removeclass(obj,cl){
if(obj&&obj.className){
var rep=obj.className.match(' '+cl)?' '+cl:cl;
obj.className=obj.className.replace(rep,'');
}
}
(function(){
var ANIMATION_SLICE_MS=10;
var animations=[];
var timerId;
function animationSorter(a,b){
if(a.startTime==b.startTime){
return a.property?0:1;
}
return(a.startTime-b.startTime);
}
function defragmentAnimations(){
var old=animations;
animations=[];
for(var i=0;i<old.length;++i){
if(old[i]!=null){
animations.push(old[i]);
}
}
}
function animate(){
animations.sort(animationSorter);
if(timerId){
window.clearTimeout(timerId);
timerId=null;
}
timerId=window.setTimeout(animationLoop,0);
}
function animateNow(){
if(timerId){
window.clearTimeout(timerId);
timerId=null;
}
animationLoop();
}
function animationLoop(){
var now=(new Date()).valueOf();
var active=false;
var defrag=false;
for(var i=0;i<animations.length;++i){
var ani=animations[i];
if(ani.startTime>now){
break;
}
if(ani.endTime<=now){
if(ani.property){
ani.object[ani.property]=ani.interpolator?ani.interpolator(
ani.startValue,
ani.targetValue,
1,
ani.timeline
):ani.targetValue;
}else if(typeof(ani.targetValue)=='function'){
ani.targetValue(ani.object);
}
animations[i]=null;
defrag=true;
continue;
}
var duration=ani.endTime-ani.startTime;
try{
if(ani.property){
ani.object[ani.property]=ani.interpolator(
ani.startValue,
ani.targetValue,
(now-ani.startTime)/ duration,
ani.timeline
);
active=true;
}
}catch(e){
animations[i]=null;
defrag=true;
}
}
if(defrag){
defragmentAnimations();
}
if(active){
timerId=window.setTimeout(animationLoop,ANIMATION_SLICE_MS);
}else if(animations.length>0){
timerId=window.setTimeout(animationLoop,animations[0].startTime-now);
}
}
function animateProperty(
element,object,property,startValue,targetValue,delay,duration,
interpolator,timeline,opt_restore,opt_hold){
var startTime=(new Date()).valueOf()+delay*1000;
var endTime=startTime+duration*1000;
var animationProperties={
element:element,
object:object,
property:property,
startValue:startValue,
targetValue:targetValue,
startTime:startTime,
endTime:endTime,
interpolator:((typeof interpolator=='function')?
interpolator:interpolators[interpolator]),
timeline:timelines[timeline]
};
animations.push(animationProperties);
if(opt_restore){
opt_hold=opt_hold||0;
animations.push({
element:element,
object:object,
property:property,
startValue:null,
targetValue:object[property],
startTime:opt_hold*1000+endTime+1,
endTime:opt_hold*1000+endTime+1,
restorer:true
});
}
animate();
return animationProperties;
};
function animatePropertyDiscrete(
element,object,property,values,delay,duration,opt_restore,opt_hold){
function interpolator(start,end,position,timeline){
var pos=timeline(start,end,position);
return values[Math.round(pos*(values.length-1))];
}
animateProperty(element,object,property,0,1,delay,duration,
interpolator,'linear',opt_restore,opt_hold);
}
function delaySetProperty(element,object,property,targetValue,delay,opt_restore,opt_hold){
animateProperty(element,object,property,targetValue,
targetValue,delay,0,null,null,opt_restore,opt_hold);
}
function pad2(str){
if(str.length<2){
return '0'+str;
}
return str;
}
function scheduleAction(element,object,callback,delay,opt_callback_cleanup,opt_hold){
animateProperty(element,object,null,null,callback,delay,0);
if(opt_hold){
var runTime=(new Date()).valueOf()+delay*1000;
var cleanupTime=runTime+opt_hold*1000;
animations.push({
element:element,
object:object,
targetValue:opt_callback_cleanup,
startTime:cleanupTime,
endTime:cleanupTime,
restorer:true
});
}
animate();
}
function endAllAnimations(){
animateNow();
var now=(new Date()).valueOf();
for(var i=0;i<animations.length;++i){
var cur=animations[i];
cur.startTime=now;
cur.endTime=now;
}
animateNow();
}
function isAncestorOrSelf(old,young){
var cur=young;
do{
if(cur==old){
return true;
}
}while(cur=cur.parentNode);
return false;
}
function endAnimations(element){
animateNow();
var now=(new Date()).valueOf();
for(var i=0;i<animations.length;++i){
var cur=animations[i];
if(isAncestorOrSelf(element,cur.element)){
cur.startTime=now;
cur.endTime=now;
}
}
animateNow();
}
function parseRgb(rgb){
if(rgb.indexOf('rgb')==0){
segs=rgb.split(/[^0-9]+/);
return '#'+
pad2(parseInt(segs[1]).toString(16))+
pad2(parseInt(segs[2]).toString(16))+
pad2(parseInt(segs[3]).toString(16));
}else if(rgb.length==4){
return '#'+
rgb.charAt(1)+'0'+rgb.charAt(2)+'0'+rgb.charAt(3)+'0';
}else{
return rgb;
}
}
function parsePx(px){
if(!px)return 0;
if(typeof(px)=='number')return px;
return parseInt(px.replace('px',''));
}
var timelines={
linear:function(v0,v1,pos){
return v0*(1-pos)+v1*pos;
},
decelerate:function(v0,v1,pos){
pos=1-(pos-1)*(pos-1);
return v0*(1-pos)+v1*pos;
},
sine:function(v0,v1,pos){
var rads=Math.PI/2;
var scomp=Math.sin(pos*rads);
var ccomp=1-Math.sin(rads+pos*rads);
var pos=ccomp*(1-pos)+scomp*pos;
return v0*(1-pos)+v1*pos;
}
};
var interpolators={
rgb3:function(color0,color1,position,timeline){
var i,result='',digit0,digit1,newvalue,newdigit;
for(i=1;i<4;++i){
digit0=parseInt(color0.charAt(i),16);
digit1=parseInt(color1.charAt(i),16);
newvalue=Math.round(timeline(digit0*16,digit1*16,position));
result+=pad2(newvalue.toString(16));
}
return '#'+result;
},
rgb6:function(color0,color1,position,timeline){
var i,result='',digit0,digit1,newvalue,newdigit;
for(i=0;i<3;++i){
digit0=parseInt(color0.substr(i*2+1,2),16);
digit1=parseInt(color1.substr(i*2+1,2),16);
newvalue=Math.round(timeline(digit0,digit1,position));
result+=pad2(newvalue.toString(16));
}
return '#'+result;
},
number:function(num0,num1,position,timeline){
return timeline(num0,num1,position);
},
integer:function(num0,num1,position,timeline){
return Math.round(timeline(num0,num1,position));
},
px:function(px0,px1,position,timeline){
return Math.round(timeline(parsePx(px0),parsePx(px1),position))+'px';
},
filter:function(num0,num1,position,timeline){
return 'alpha(opacity='+timeline(num0*100,num1*100,position)+')';
}
};
window.scheduleAction=scheduleAction;
window.animateProperty=animateProperty;
window.animatePropertyDiscrete=animatePropertyDiscrete;
window.endAnimations=endAnimations;
window.endAllAnimations=endAllAnimations;
window.delaySetProperty=delaySetProperty;
window.parseRgb=parseRgb;
window.parsePx=parsePx;
window.animateProperty.interpolators=interpolators;
window.animateProperty.timelines=timelines;
})();
function ani(){}
ani.DEFAULT_MESSAGE_DELAY=10;
ani.DEFAULT_MESSAGE_FADEOUT=2;
ani.DEFAULT_MESSAGE_SLIDE=0.5;
ani.USE_OPACITY=0;
ani.USE_FILTER=1;
ani.TRANSPARENCY_METHOD=null;
function poller(interval,limit,callback){
if(limit>0){
setTimeout(function(){
try{
callback();
}catch(e){
poller(interval,limit-interval,callback);
}
},interval);
}
}
(function(){
var f=function(){
if(/MSIE/.test(navigator.userAgent)&&typeof document.body.style.filter=='string'){
ani.TRANSPARENCY_METHOD=ani.USE_FILTER;
}else if(typeof document.body.style.opacity=='string'){
ani.TRANSPARENCY_METHOD=ani.USE_OPACITY;
}
};
if(window.onLoadFunctionList){
window.onLoadFunctionList.push(f);
}else{
poller(1000,20000,f);
}
})();
ani.fade=function(el,start,end,delay,duration,opt_restore,opt_restore_delay){
if(ani.TRANSPARENCY_METHOD==ani.USE_OPACITY){
animateProperty(el,el.style,'opacity',start,end,delay,duration,
'number','linear',opt_restore,opt_restore_delay);
}else if(ani.TRANSPARENCY_METHOD==ani.USE_FILTER){
animateProperty(el,el.style,'filter',start,end,delay,duration,
'filter','linear',opt_restore,opt_restore_delay);
}
}
ani.fadeDuringSlideUp=function(el,delay,duration){
ani.wrap(el,function(wrapper){
endAnimations(wrapper);
animateProperty(wrapper,wrapper.style,'height',wrapper.offsetHeight+'px',
'1px',delay,duration,'px','sine',true);
animateProperty(wrapper,wrapper.style,'opacity','1.0','0.0',delay,duration,
'number','sine',true);
animateProperty(wrapper,wrapper.style,'filter','1.0','0.0',delay,duration,
'filter','sine',true);
delaySetProperty(el,el.style,'display','none',delay+duration);
},delay,duration);
};
ani.fadeAndSlideUp=function(el,delay,fadeDuration,slideDuration){
var wrapper=ani.insertWrapper(el);
wrapper.style.height=wrapper.offsetHeight+10+'px';
wrapper.style.overflow='hidden';
wrapper.style.position='relative';
animateProperty(wrapper,wrapper.style,'height',wrapper.offsetHeight+'px',
wrapper.offsetHeight+'px',delay,fadeDuration,'px','linear');
ani.fade(wrapper,'1.0','0.0',delay,fadeDuration);
animateProperty(wrapper,wrapper.style,'height',wrapper.offsetHeight+'px',
'1px',delay+fadeDuration,slideDuration,'px','sine');
delaySetProperty(el,el.style,'display','none',delay+fadeDuration+
slideDuration);
scheduleAction(wrapper,wrapper,ani.removeWrapper,delay+fadeDuration+
slideDuration+1);
};
ani.slideDownAndFadeIn=function(el,delay,fadeDuration,slideDuration){
ani.wrap(el,function(wrapper){
wrapper.style.visibility="hidden";
var height=ani.getDimensions(wrapper).height;
animateProperty(wrapper,wrapper.style,'height','1px',height+'px',
delay,slideDuration,'px','sine');
animateProperty(wrapper,wrapper.style,'height',height+'px',
height+'px',delay+slideDuration,fadeDuration,'px','linear');
ani.fade(wrapper,0,1,delay+slideDuration,fadeDuration);
wrapper.style.height="1px";
delaySetProperty(wrapper,wrapper.style,'visibility','visible',delay+slideDuration);
scheduleAction(wrapper,wrapper,ani.exciseNode,delay+fadeDuration+slideDuration);
},delay,-1,10);
};
ani.ajaxSlideOpen=function(el,delay,duration,opt_start_height,opt_end_height){
var height=ani.getDimensions(el).height;
if(!opt_end_height){
opt_end_height=height;
}
if(!opt_start_height){
opt_start_height=1;
}
if(el.animation_property_margin){
var prop=el.animation_property_margin;
prop.startTime=(new Date()).valueOf();
prop.endTime=(new Date()).valueOf()+duration*1000;
prop.startValue=el.wrapper.style.marginTop;
prop.targetValue=(opt_end_height-height)+'px';
prop.timeline=window.animateProperty.timelines.decelerate;
var prop_h=el.animation_property_height;
prop_h.startTime=(new Date()).valueOf();
prop_h.endTime=(new Date()).valueOf()+duration*1000;
prop_h.startValue=el.style.height;
prop_h.targetValue=opt_end_height+'px';
prop_h.timeline=window.animateProperty.timelines.decelerate;
}else{
ani.wrap(el,function(wrapper){
wrapper.style.height=opt_start_height+'px';
el.wrapper=wrapper;
el.animation_property_margin=animateProperty(el,el.style,
'marginTop',(opt_start_height-height)+'px',(opt_end_height-height)+'px',delay,
duration,'px','sine');
el.animation_property_height=animateProperty(wrapper,wrapper.style,
'height',opt_start_height+'px',opt_end_height+'px',delay,
duration,'px','sine');
delaySetProperty(el,el,'animation_property_margin',null,delay+duration);
delaySetProperty(el,el.style,'marginTop','0',delay+duration);
delaySetProperty(el,el.style,'display','block',delay);
},delay,duration,0);
}
};
ani.ajaxSlideSideways=function(el,delay,duration,opt_only_reveal,opt_start_width,opt_end_width){
var width=ani.getDimensions(el).width;
if(!opt_end_width){
opt_end_width=width;
}
if(!opt_start_width){
opt_start_width=1;
}
if(el.animation_property_margin){
var prop=el.animation_property_margin;
prop.startTime=(new Date()).valueOf();
prop.endTime=(new Date()).valueOf()+duration*1000;
prop.startValue=el.wrapper.style.marginTop;
prop.targetValue=(opt_end_width-width)+'px';
prop.timeline=window.animateProperty.timelines.decelerate;
var prop_h=el.animation_property_width;
prop_h.startTime=(new Date()).valueOf();
prop_h.endTime=(new Date()).valueOf()+duration*1000;
prop_h.startValue=el.style.width;
prop_h.targetValue=opt_end_width+'px';
prop_h.timeline=window.animateProperty.timelines.decelerate;
}else{
ani.wrap(el,function(wrapper){
wrapper.style.width=opt_start_width+'px';
el.wrapper=wrapper;
if(!opt_only_reveal){
el.animation_property_margin=animateProperty(el,el.style,
'marginLeft',(opt_start_width-width)+'px',(opt_end_width-width)+'px',delay,duration,'px','sine');
}
el.animation_property_width=animateProperty(wrapper,wrapper.style,
'width',opt_start_width+'px',opt_end_width+'px',delay,duration,'px','sine');
delaySetProperty(el,el,'animation_property_margin',null,delay+duration);
delaySetProperty(el,el.style,'marginLeft','0',delay+duration);
delaySetProperty(el,el.style,'display','block',delay);
},delay,duration,0);
}
};
ani.slideClosedBySpeed=function(el,pxPerSecond,callback){
var duration=el.offsetHeight/ pxPerSecond;
ani.wrap(el,function(wrapper){
var start_height=wrapper.offsetHeight;
animateProperty(el,el.style,
'marginTop','0px',(1-start_height)+'px',0,
duration,'px','linear',true,0);
animateProperty(wrapper,wrapper.style,'height',start_height+'px','1px',
0,duration,'px','linear');
},0,duration);
scheduleAction(el,el,callback,duration);
};
ani.measureHeight=function(el){
var oldPosition=el.style.position;
el.style.position='absolute';
el.style.visibility='hidden';
el.style.display='block';
var height=el.offsetHeight;
el.style.display='none';
el.style.visibility='visible';
el.style.position=oldPosition;
return height;
}
ani.slideOpenBySpeed=function(el,pxPerSecond,callback){
var end_height=ani.measureHeight(el);
var duration=end_height/ pxPerSecond;
ani.wrap(el,function(wrapper){
wrapper.style.height='0px';
el.style.display='block';
animateProperty(el,el.style,
'marginTop',-end_height+'px','0px',0,duration,
'px','linear',true,0);
animateProperty(wrapper,wrapper.style,
'height','0px',end_height+'px',0,duration,
'px','linear');
},0,duration);
if(callback)scheduleAction(el,el,callback,duration);
};
ani.slideClosed=function(el,delay,duration){
ani.wrap(el,function(wrapper){
var start_height=wrapper.offsetHeight;
animateProperty(el,el.style,
'marginTop','0px',(1-start_height)+'px',delay,
duration,'px','sine',true);
animateProperty(wrapper,wrapper.style,'height',start_height+'px','1px',
delay,duration,'px','sine');
delaySetProperty(el,el.style,'display','none',delay+duration,true);
scheduleAction(wrapper,wrapper,function(div){
div.parentNode.removeChild(div);},delay+duration);
},delay,-1,0);
};
ani.wrap=function(el,callback,delay,duration,opt_extra_height){
var wrapper=ani.insertWrapper(el);
opt_extra_height=opt_extra_height||0;
wrapper.style.height=wrapper.offsetHeight+opt_extra_height+'px';
wrapper.style.overflow='hidden';
wrapper.style.position='relative';
callback(wrapper);
function teardown(el){
ani.removeWrapper(wrapper);
}
if(duration>0){
scheduleAction(el,el,null,delay,teardown,duration);
}
};
ani.insertWrapper=function(el){
var wrapper=document.createElement('div');
wrapper.style.margin='0px';
wrapper.style.padding='0px';
el.parentNode.insertBefore(wrapper,el);
el.parentNode.removeChild(el);
wrapper.appendChild(el);
return wrapper;
};
ani.removeWrapper=function(wrapper){
var el=wrapper.firstChild;
wrapper.removeChild(el);
wrapper.parentNode.insertBefore(el,wrapper);
wrapper.parentNode.removeChild(wrapper);
};
ani.exciseNode=function(el){
var par=el.parentNode;
var node=el.firstChild;
while(node=el.firstChild){
el.removeChild(node);
par.insertBefore(node,el);
}
par.removeChild(el);
}
ani.getPosition=function(target){
var left=0;
var top=0;
do{
left+=target.offsetLeft;
top+=target.offsetTop;
}while(target=target.offsetParent);
return{x:left,y:top};
}
ani.getDimensions=function(el){
var dimensions={};
ani.wrap(el,function(wrapper){
dimensions.width=wrapper.offsetWidth;
dimensions.height=wrapper.offsetHeight;
dimensions.top=wrapper.offsetTop;
dimensions.left=wrapper.offsetLeft;
ani.exciseNode(wrapper);
});
return dimensions;
};
ani.hideAndFloatClone=function(el,opt_duration){
var clone;
ani.wrap(el,function(wrapper){
clone=wrapper.cloneNode(true);
clone.style.left=wrapper.offsetLeft+"px";
clone.style.top=wrapper.offsetTop+"px";
clone.style.width=wrapper.offsetWidth+'px';
clone.style.height=wrapper.offsetHeight+'px';
ani.exciseNode(wrapper);
});
clone.firstChild.id=el.id+"-clone";
clone.style.position="absolute";
el.style.visibility="hidden";
el.offsetParent.insertBefore(clone,el.offsetParent.firstChild);
clone.style.zIndex=el.style.zIndex?el.style.zIndex+1:"100";
clone.style.clear="both";
if(opt_duration){
function teardown(el){
el.style.visibility="visible";
setTimeout(function(){removeNode(clone);},0);
}
scheduleAction(el,el,null,0,teardown,opt_duration);
}
return clone;
};
ani.slideTo=function(el,start_top,start_left,end_top,end_left,duration,opt_use_clone){
var ani_obj=opt_use_clone?ani.hideAndFloatClone(el,duration):el;
ani_obj.style.visibility="visible";
animateProperty(ani_obj,ani_obj.style,'top',start_top,end_top,0,duration,
'px','decelerate');
animateProperty(ani_obj,ani_obj.style,'left',start_left,end_left,0,duration,
'px','decelerate');
};
ani.swapDivs=function(a,b,duration){
var a_clone=ani.hideAndFloatClone(a,duration+0.25);
var b_clone=ani.hideAndFloatClone(b,duration+0.25);
ani.fade(a_clone,1,0.5,0,duration/ 4);
ani.fade(b_clone,1,0.5,0,duration/ 4);
ani.fade(a_clone,0.5,1,3*duration/ 4,duration/ 4);
ani.fade(b_clone,0.5,1,3*duration/ 4,duration/ 4);
var b_next=b.nextSibling;
a.parentNode.insertBefore(b,a.nextSibling);
b.parentNode.insertBefore(a,b_next);
var a_dim=ani.getDimensions(a);
var b_dim=ani.getDimensions(b);
if(a.offsetTop!=b.offsetTop){
animateProperty(a_clone,a_clone.style,'top',a_clone.style.top,a_dim.top+'px',0,duration,'px','sine');
animateProperty(b_clone,b_clone.style,'top',b_clone.style.top,b_dim.top+'px',0,duration,'px','sine');
}
if(a.offsetLeft!=b.offsetLeft){
animateProperty(a_clone,a_clone.style,'left',a_clone.style.left,a_dim.left+'px',0,duration,'px','sine');
animateProperty(b_clone,b_clone.style,'left',b_clone.style.left,b_dim.left+'px',0,duration,'px','sine');
}
};
ani.crossfadeReveal=function(hide,show,reveal,speed,opt_height,opt_oncompleteCallback){
var w=hide.offsetWidth;
var h=hide.offsetHeight;
hide.style.position='absolute';
hide.style.width=w+'px';
hide.style.height=h+'px';
var origHeight=h;
hide._origHeight=origHeight;
var duration;
var targetHeight;
function animateWrapper(wrapper){
reveal.style.display='block';
targetHeight=opt_height?opt_height:ani.getDimensions(reveal).height;
duration=Math.min((Math.abs(targetHeight-origHeight))/ speed,2.0);
ani.fade(hide,'1.0','0.0',0,duration);
if(show){
ani.fade(show,'0.0','1.0',0,duration);
}
wrapper.style.overflow='hidden';
wrapper.style.height=origHeight;
animateProperty(wrapper,wrapper.style,'height',origHeight+'px',targetHeight+'px',0,duration,'px','decelerate');
scheduleAction(wrapper,wrapper,ani.exciseNode,duration);
if(opt_oncompleteCallback){
scheduleAction(reveal,reveal,opt_oncompleteCallback,duration);
}
}
ani.wrap(reveal,animateWrapper,0,-1);
return{height:targetHeight,duration:duration};
};
ani.crossfadeRevealUndo=function(hide,show,reveal,speed,opt_height,opt_oncompleteCallback){
var duration;
var origHeight;
var targetHeight;
function animateWrapper(wrapper){
origHeight=hide._origHeight;
targetHeight=opt_height?opt_height:ani.getDimensions(reveal).height;
wrapper.style.overflow='hidden';
wrapper.style.height=targetHeight;
duration=Math.min((Math.abs(targetHeight-origHeight))/ speed,2.0);
ani.fade(hide,'0.0','1.0',0,duration);
if(show){
ani.fade(show,'1.0','0.0',0,duration);
}
delaySetProperty(reveal,reveal.style,'display','none',duration-0.1);
delaySetProperty(hide,hide.style,'position','static',duration);
animateProperty(wrapper,wrapper.style,'height',targetHeight+'px',origHeight+'px',0,duration,'px','decelerate');
scheduleAction(wrapper,wrapper,ani.exciseNode,duration);
if(opt_oncompleteCallback){
scheduleAction(reveal,reveal,opt_oncompleteCallback,duration);
}
}
ani.wrap(reveal,animateWrapper,0,-1);
return{height:targetHeight,duration:duration};
};
function removeNode(el){
el.parentNode.removeChild(el);
}
ani.fadeAndMakeUnclickable=function(el,opt_opacity,opt_background){
var opacity=opt_opacity||0.3;
var background=opt_background||'white';
var pos=ani.getPosition(el);
var curtain=document.createElement('iframe');
curtain.frameBorder="0";
curtain.scrolling="no";
curtain.style.position="absolute";
var border_size=el.clientLeft||0;
curtain.style.top=(pos.y-border_size)+"px";
curtain.style.left=(pos.x-border_size)+"px";
curtain.style.width=(el.offsetWidth+border_size*2)+"px";
curtain.style.height=(el.offsetHeight+border_size*2)+"px";
curtain.style.background=background;
curtain.style.opacity=opacity;
curtain.style.filter="alpha(opacity="+Math.round(opacity*100)+")";
curtain.style.zIndex=el.style.zIndex?el.style.zIndex+1:101;
curtain.style.border="0";
curtain.style.margin="0";
curtain.style.overflow="hidden";
return curtain;
};
ani.scrollUntilVisible=function(el,opt_duration){
if(!opt_duration){
opt_duration=0.75;
}
var top=ani.getPosition(el).y;
var bottom=top+ani.getDimensions(el).height;
var docEl=document.body.scrollTop>=document.documentElement.scrollTop?
document.body:document.documentElement;
var browserHeight=window.innerHeight?window.innerHeight:docEl.clientHeight;
if(self.pageYOffset){
var scrollTop=Math.max(self.pageYOffset,docEl.scrollTop);
}else{
var scrollTop=docEl.scrollTop;
}
var scrollBottom=scrollTop+browserHeight;
var targetTop=-1;
var FRIENDLY_PADDING=10;
if(top<scrollTop){
targetTop=top-FRIENDLY_PADDING;
}else if(bottom>scrollBottom){
targetTop=bottom-browserHeight+FRIENDLY_PADDING;
}
if(targetTop>0){
animateProperty(docEl,docEl,'scrollTop',scrollTop,targetTop,0,opt_duration,'number','decelerate');
return true;
}
return false;
};
var ZIPPY_ANIMATION_DURATION=0.05;
var ZIPPY_ANIMATION_OFFSETS=[
'0 0','-13px 0','-26px 0','-39px 0','-52px 0','-65px 0','-78px 0'
];
var ZIPPY_ANIMATION_OFFSETS_REVERSED=
ZIPPY_ANIMATION_OFFSETS.slice().reverse();
function animateZippyOpen(element){
animatePropertyDiscrete(
element,element.style,'backgroundPosition',ZIPPY_ANIMATION_OFFSETS,0,
ZIPPY_ANIMATION_DURATION);
}
function animateZippyClosed(element){
animatePropertyDiscrete(
element,element.style,'backgroundPosition',
ZIPPY_ANIMATION_OFFSETS_REVERSED,0,ZIPPY_ANIMATION_DURATION);
}
window.YT_stats_zippy=function(id,ajaxUrl,loginUrl,opt_cookie_flag,opt_onexpand,opt_onminimize){
this.id_=id;
this.url_=ajaxUrl;
this.loginUrl_=loginUrl;
this.div_content_=_gel(id+"-content");
this.div_contentClosed_=_gel(id+"-content-closed");
this.div_bottomCapOpen_=_gel(id+"-bcap-open");
this.div_bottomCapClosed_=_gel(id+"-bcap-closed");
this.div_arrowRight_=_gel(id+"-arrowRight");
this.div_arrowDown_=_gel(id+"-arrowDown");
this.div_titleBtmClose_=_gel(id+"-titleBtmClose");
this.div_titleBtmOpen_=_gel(id+"-titleBtmOpen");
this.div_title_=_gel(id+"-title");
this.div_titleText_=_gel(id+"-titleText");
this.div_arrowRight_.onmousedown=function(){this.expand();}.bind(this);
this.div_arrowDown_.onmousedown=function(){this.minimize();}.bind(this);
this.div_titleText_.onmousedown=function(){this.toggleState();}.bind(this);
this.onexpand_=opt_onexpand;
this.onminimize_=opt_onminimize;
this.cookie_flag_=opt_cookie_flag;
if(this.cookie_flag_){
try{
var collapsed=yt.UserPrefs.getFlag(this.get_state_cookie_name());
if(collapsed){
this.minimize();
}else{
this.expand();
}
}catch(e){
}
}
};
YT_stats_zippy.prototype.minimizeForeignZippies=function(zippyList){
for(var i=0;i<zippyList.length;++i){
var cz=zippyList[i];
if(cz&&cz!=this&&cz.isExpanded()){
cz.minimize();
}
}
};
YT_stats_zippy.prototype.get_state_cookie_name=function(){
return yt.UserPrefs.Flags[this.cookie_flag_];
};
YT_stats_zippy.prototype.save_state=function(state){
if(this.cookie_flag_){
try{
yt.UserPrefs.setFlag(this.get_state_cookie_name(),state);
yt.UserPrefs.save();
}catch(e){
}
}
};
YT_stats_zippy.prototype.isExpanded=function(){
return(this.div_arrowRight_.style.display=="none");
};
YT_stats_zippy.prototype.toggleState=function(){
if(this.isExpanded()){
this.minimize();
}else{
this.expand();
}
};
YT_stats_zippy.prototype.expandUI=function(){
this.div_arrowRight_.style.display="none";
this.div_arrowDown_.style.display="inline";
this.div_content_.style.display="block";
if(this.div_contentClosed_){
this.div_contentClosed_.style.display="none";
}
if(this.div_titleBtmClose_&&this.div_titleBtmOpen_){
this.div_titleBtmClose_.style.display="none";
this.div_titleBtmOpen_.style.display="block";
}
if(this.div_bottomCapOpen_&&this.div_bottomCapClosed_){
this.div_bottomCapClosed_.style.display="none";
this.div_bottomCapOpen_.style.display="block";
}
}
YT_stats_zippy.prototype.expand=function(){
this.save_state(false);
this.expandUI();
if(this.div_content_.innerHTML.match(/^\s*$/)&&this.url_){
this.ajax_fetch();
}
if(typeof this.onexpand_=='function'){
this.onexpand_(this);
}
};
YT_stats_zippy.prototype.ajax_fetch=function(){
this.div_content_.innerHTML='<div style="text-align: center; margin: 35px;"><img src="http://s.ytimg.com/yt/img/icn_loading_animated-vfl24663.gif"></div>';
var handleResponse=function(xhr){
this.handleAjaxResponse(
xhr,
this.div_content_,
this.loginUrl_
);
}.bind(this);
var fetchContent=function(){
getUrl(this.url_,true,handleResponse);
}.bind(this);
setTimeout(fetchContent,0);
};
YT_stats_zippy.prototype.minimizeUI=function(){
this.div_arrowRight_.style.display="inline";
this.div_arrowDown_.style.display="none";
this.div_content_.style.display="none";
if(this.div_contentClosed_){
this.div_contentClosed_.style.display="";
}
if(this.div_titleBtmClose_&&this.div_titleBtmOpen_){
this.div_titleBtmClose_.style.display="block";
this.div_titleBtmOpen_.style.display="none";
}
if(this.div_bottomCapOpen_&&this.div_bottomCapClosed_){
this.div_bottomCapClosed_.style.display="block";
this.div_bottomCapOpen_.style.display="none";
}
}
YT_stats_zippy.prototype.minimize=function(){
this.save_state(true);
this.minimizeUI();
if(typeof this.onminimize_=='function'){
this.onminimize_(this);
}
};
YT_stats_zippy.prototype.flashUI=function(){
if(this.isExpanded()){
this.minimizeUI();
this.expandUI();
}else{
this.expandUI();
this.minimizeUI();
}
}
YT_stats_zippy.prototype.handleAjaxResponse=function(xmlHttpRequest,content,loginUrl){
if(xmlHttpRequest.readyState==4){
if(xmlHttpRequest.status==200){
content.innerHTML=xmlHttpRequest.responseText;
}else if(xmlHttpRequest.status==401){
window.location.pathname=loginUrl;
}else{
if(this.error_page_){
var error_page=_gel(this.error_page_);
content.innerHTML=error_page.innerHTML;
}
}
}
};
var feed_module_index=[];
function next_feed_module_item(tab_id,module_id,num_items){
if(feed_module_index[module_id]==undefined){
feed_module_index[module_id]=0;
}
addClass(_gel('feed-module-'+tab_id+'-'+module_id+'-item-'+feed_module_index[module_id]),'hide');
feed_module_index[module_id]+=1;
feed_module_index[module_id]=feed_module_index[module_id]%num_items;
removeClass(_gel('feed-module-'+tab_id+'-'+module_id+'-item-'+feed_module_index[module_id]),'hide');
}
function previous_feed_module_item(tab_id,module_id,num_items){
if(feed_module_index[module_id]==undefined){
feed_module_index[module_id]=0;
}
addClass(_gel('feed-module-'+tab_id+'-'+module_id+'-item-'+feed_module_index[module_id]),'hide');
feed_module_index[module_id]+=num_items-1;
feed_module_index[module_id]=feed_module_index[module_id]%num_items;
removeClass(_gel('feed-module-'+tab_id+'-'+module_id+'-item-'+feed_module_index[module_id]),'hide');
}
function select_feed_module_item(tab_id,module_id,new_index,num_items){
if(feed_module_index[module_id]==undefined){
feed_module_index[module_id]=0;
}
addClass(_gel('feed-module-'+tab_id+'-'+module_id+'-item-'+feed_module_index[module_id]),'hide');
feed_module_index[module_id]=new_index%num_items;
removeClass(_gel('feed-module-'+tab_id+'-'+module_id+'-item-'+feed_module_index[module_id]),'hide');
}
var Insight={
encode_data:function(data,max){
var simpleEncoding='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var d="";
for(var i=0;i<data.length;i++){
d=d+simpleEncoding.charAt(Math.round((simpleEncoding.length-1)*data[i]/ max));
}
return d;
},
get_max:function(data){
var max=10;
for(var i=0;i<data.length;i++){
if(data[i]>max){
max=data[i];
}
}
return max;
},
update_topcountry:function(data,top_country_id){
var ordering=[];
for(var i=0;i<data.value.length;i++){
ordering[i]=i;
}
ordering.sort(function(a,b){return data.value[b]-data.value[a];});
var top_countries=_gel(top_country_id);
var countries=[];
for(var i=0;i<5;i++){
if(data.value[ordering[i]]>0){
countries.push(data.display_label[ordering[i]]);
}
}
top_countries.innerHTML=countries.join(", ");
},
get_videos:function(data,max){
var videos=[];
if(data.label){
var len=data.label.length;
if(len>max)len=max;
for(var i=0;i<len;i++){
videos.push(data.label[i]);
}
}
return videos;
},
map_callback:function(responses){
if(!responses.found){
_gel("insight_map_error").style.display='block';
_gel("feed_insight_map-content").style.display='none';
return;
}
Insight.update_map(responses.response[0],responses.response[1]);
var data=responses.response[2];
var videos=Insight.get_videos(data,2);
if(videos.length>0){
Insight.map_movers=data;
Insight.request_titles(videos);
}
},
update_map:function(popmap_data,views_data){
Insight.update_topcountry(popmap_data,"insight_map_top_country");
var map_url="http://chart.apis.google.com/chart?cht=t&chs=350x175&chco=f5f5f5,edf0d4,c9dba3,a6c27d,6c9642,365e24,13390a&chls=1,4,0&chxt=x&chxl=0:|world&chf=bg,s,EAF7FE";
var chd="&chd=s:"+Insight.encode_data(popmap_data.value,100);
var chld="&chld="+popmap_data.label.join("");
var img=_gel("insight_map_image");
img.src=map_url+chd+chld;
var timeseries=[];
for(var i=0;i<views_data.timeseries.length;i++){
timeseries.push(views_data.timeseries[i].value);
}
var max=Math.round(Insight.get_max(timeseries)*1.3);
var line_chart="http://chart.apis.google.com/chart?cht=lc&chs=210x35&chco=4f8742&chls=1.5,4,0&chm=B,c4d4b4aa,0,0,0&chg=0,-1,1,0&chxt=y&chxs=0,444444,10&chxr=0,0,"+max;
var chd="&chd=s:"+Insight.encode_data(timeseries,max);
var img=_gel("insight_map_chart");
img.src=line_chart+chd;
},
chart_callback:function(responses){
if(!responses.found){
_gel("insight_chart_error").style.display='block';
_gel("feed_insight_chart-content").style.display='none';
return;
}
Insight.update_chart(responses.response[0],responses.response[1]);
var data=responses.response[2];
var videos=Insight.get_videos(data,3);
if(videos.length>0){
Insight.chart_topvideos=data.label;
}
var data=responses.response[3];
var videos_movers=Insight.get_videos(data,2);
if(videos_movers.length>0){
Insight.chart_movers=data;
}
Insight.request_titles(videos.concat(videos_movers));
},
update_chart:function(viewsmap_data,views_data){
Insight.update_topcountry(viewsmap_data,"insight_chart_top_country");
var timeseries=[];
for(var i=0;i<views_data.timeseries.length;i++){
timeseries.push(views_data.timeseries[i].value);
}
var max=Math.round(Insight.get_max(timeseries)*1.3);
var line_chart="http://chart.apis.google.com/chart?cht=lc&chs=350x175&chco=3d7930&chls=2,4,0&chm=B,c5d4b5bb,0,0,0&chg=14.3,-1,1,1&chxt=y&chxr=0,0,"+max;
var chd="&chd=s:"+Insight.encode_data(timeseries,max);
var img=_gel("insight_chart_image");
img.src=line_chart+chd;
},
combined_callback:function(responses){
if(!responses.found){
_gel("insight_map_error").style.display='block';
_gel("feed_insight_map-content").style.display='none';
_gel("insight_chart_error").style.display='block';
_gel("feed_insight_chart-content").style.display='none';
return;
}
Insight.update_map(responses.response[0],responses.response[1]);
Insight.update_chart(responses.response[3],responses.response[1]);
var data=responses.response[4];
var videos=Insight.get_videos(data,3);
if(videos.length>0){
Insight.chart_topvideos=data.label;
}
var data=responses.response[2];
var videos_movers=Insight.get_videos(data,2);
if(videos_movers.length>0){
Insight.chart_movers=data;
Insight.map_movers=data;
}
Insight.request_titles(videos.concat(videos_movers));
},
set_titles:function(videos,elem){
var html=[];
var len=videos.length;
if(len>3)len=3;
for(var i=0;i<len;i++){
html.push("<div style='white-space:nowrap;'>"+(i+1)+" <a href='/my_videos_insight?v=");
html.push(videos[i]);
html.push("'>");
html.push(Insight.video_titles[videos[i]]);
html.push("</a></div>");
}
elem.innerHTML=html.join("");
},
set_movers:function(movers,elem){
var html=[];
var len=movers.label.length;
if(len>2)len=2;
html.push("<table cellspacing='0' cellpadding='0'>");
for(var i=0;i<len;i++){
html.push("<tr><td><div class='insight_mover'><a href='/my_videos_insight?v=");
html.push(movers.label[i]);
html.push("'>");
html.push(Insight.video_titles[movers.label[i]]);
html.push("</a></div></td>");
var v=Math.round(movers.value[i]/ 100);
if(v<0){
html.push("<td class='insight_down'>");
}else if(v<100){
html.push("<td class='insight_up'>+");
}else{
html.push("<td class='insight_up'>&gt;");
v=100;
}
html.push(v+"%</td></tr>");
}
html.push("</table>");
elem.innerHTML=html.join("");
},
titles_callback:function(response){
for(var i=0;i<response.id.length;i++){
Insight.video_titles[response.id[i]]=response.title[i];
}
if(Insight.map_movers){
Insight.set_movers(Insight.map_movers,_gel("insight_map_changes"));
}
if(Insight.chart_topvideos){
Insight.set_titles(Insight.chart_topvideos,_gel("insight_chart_most_watched"));
}
if(Insight.chart_movers){
Insight.set_movers(Insight.chart_movers,_gel("insight_chart_changes"));
}
},
request_data:function(url){
var sn=document.createElement('script');
sn.type='text/javascript';
sn.src=url;
document.getElementsByTagName('head')[0].appendChild(sn);
},
request_titles:function(videos){
if(videos.length>0){
Insight.request_data('http://www.youtube.com/insight_data?callback=Insight.titles_callback&video_ids='+encodeURIComponent(videos.join(',')));
}
},
video_titles:[]
}
window.Insight=Insight;
(function(){
var isIE=document.all&&navigator.userAgent.toLowerCase().indexOf('msie')!=-1;
var AGGREGATE_FORM="AGG";
var AGGREGATE_FORM_VID_WIDTH=4;
YT_php_undo_object=function(){
this.module_="";
this.undo_function_=null;
};
YT_php_support=function(xsrf_token,site_read_only_mode,logged_out_mode){
this.default_ordering_=[];
this.ordering_=[];
this.xsrf_token_=xsrf_token;
this.site_read_only_mode=site_read_only_mode;
this.logged_out_mode=logged_out_mode;
this.waiting_on_order_ajax_=false;
this.delayed_ordering_requests_=[];
this.undo_object_=new YT_php_undo_object();
this.ANIMATE_MODULE_SWAP_TIME=0.4;
this.ANIMATE_SLIDE_TIME=0.25;
this.ANIMATE_SLIDE_RIGHT_TIME=0.25;
this.ANIMATE_MODULE_FADE_TIME=0.75;
};
window.YT_php_support=YT_php_support;
YT_php_support.prototype.add_module=function(mod){
this.default_ordering_.push(mod);
};
YT_php_support.prototype.init=function(){
this.update_ordering();
this.reset_updown_buttons();
if(!this.logged_out_mode){
_gel("feed_undo_delete_link").href="javascript:php_support.undo();";
}
};
YT_php_support.prototype.init_drag_drop=function(){
if(!this.logged_out_mode&&!this.site_read_only_mode){
this.ddr=new DragDropRearranger(_gel("dragdrop"));
for(var i in this.ordering_){
var module_name=this.ordering_[i];
this.ddr.add_child(_gel("feedmodule-"+module_name),_gel(module_name+"-titlebar"));
}
this.ddr.add_rearrange_handler(this.handle_drag_drop_new_order.bind(this));
}
};
YT_php_support.prototype.handle_drag_drop_new_order=function(module_ids,moved_module_id){
this.ordering_=[];
for(var i in module_ids){
var id_components=module_ids[i].split('-');
if(id_components[0]!="UNDO"){
this.ordering_.push(id_components[1]);
}
}
this.reset_updown_buttons();
var moved_module=moved_module_id.substr(moved_module_id.length-3,3);
var new_pos=this.indexOf(this.ordering_,moved_module);
var module_after_moved_module=moved_module;
if(new_pos!=this.ordering_.length-1){
module_after_moved_module=this.ordering_[new_pos+1];
}
this.adjust_module_order(moved_module,module_after_moved_module,"dragdrop");
};
YT_php_support.prototype.adjust_module_order=function(module_to_move,module_to_insert_before,opt_logging_param){
if(this.waiting_on_order_ajax_){
this.delayed_ordering_requests_.push({'module_to_move':module_to_move,'module_to_insert_before':module_to_insert_before,'logging':opt_logging_param})
return;
}
var url="/index";
if(opt_logging_param){
url+="?"+opt_logging_param;
}
var data="module="+module_to_move+"&dir=dragdrop&next_module="+module_to_insert_before+"&session_token="+this.xsrf_token_;
postUrl(url,data,true,function(xmlHttpRequest){
if(xmlHttpRequest.readyState==4){
if(xmlHttpRequest.status==200){
}
this.waiting_on_order_ajax_=false;
if(this.delayed_ordering_requests_.length>0){
var delayed_request=this.delayed_ordering_requests_.shift();
this.adjust_module_order(delayed_request.module_to_move,delayed_request.module_to_insert_before,delayed_request.logging);
}
}
}.bind(this));
this.waiting_on_order_ajax_=true;
};
YT_php_support.prototype.undo=function(){
if(this.undo_object_.undo_function_){
this.undo_object_.undo_function_();
}
};
YT_php_support.prototype.adjust_module=function(cmd,dir){
var url="/index";
var data="module="+cmd+"&dir="+dir+"&session_token="+this.xsrf_token_;
postUrl(url,data,true,function(xmlHttpRequest){
if(xmlHttpRequest.readyState==4){
if(xmlHttpRequest.status==200){
}
}
});
};
YT_php_support.prototype.animate_length_preference=function(cmd,selector,form_type){
showDiv(cmd+'-loading-icn');
this.open_loading_pane(cmd+'-loading-msg');
this.set_length_preference(cmd,selector,form_type);
};
YT_php_support.prototype.set_length_preference=function(module,selector,form_type){
select=_gel(selector);
var idx=select.options.selectedIndex;
var selected=select.options[idx];
var num=selected.value;
if(form_type==AGGREGATE_FORM){
num=num*AGGREGATE_FORM_VID_WIDTH;
}
var url="/index";
var data="alter=true&module="+module+"&num="+num+"&session_token="+this.xsrf_token_;
postUrl(url,data,true,execOnSuccess(function(xmlHttpRequest){
var module_anchor=_gel("feedmodule-"+module);
module_anchor.innerHTML=xmlHttpRequest.responseText;
this.reset_updown_buttons();
this.ddr.lookup_dragger_by_id("feedmodule-"+module).set_drag_handle(_gel(module+"-titlebar"));
showDiv(module+'-options');
hideDiv(module+'-loading-icn');
hideDiv(module+'-loading-msg');
}.bind(this))
);
};
YT_php_support.prototype.set_form_preference=function(module,form_type){
var url="/index";
var data="alter=true&module="+module+"&ftype="+form_type+"&session_token="+this.xsrf_token_;
postUrl(url,data,true,execOnSuccess(function(xmlHttpRequest){
var module_anchor=_gel("feedmodule-"+module);
module_anchor.innerHTML=xmlHttpRequest.responseText;
this.reset_updown_buttons();
this.ddr.lookup_dragger_by_id("feedmodule-"+module).set_drag_handle(_gel(module+"-titlebar"));
showDiv(module+'-options');
hideDiv(module+'-loading-icn');
hideDiv(module+'-loading-msg');
}.bind(this))
);
};
YT_php_support.prototype.set_hometown=function(module,loc_element){
var url="/index";
var loc=_gel(loc_element).value;
var data="alter=true&module="+module+"&loc="+loc+"&session_token="+this.xsrf_token_;
postUrl(url,data,true,execOnSuccess(function(xmlHttpRequest){
var module_anchor=_gel("feedmodule-"+module);
module_anchor.innerHTML=xmlHttpRequest.responseText;
this.reset_updown_buttons();
this.ddr.lookup_dragger_by_id("feedmodule-"+module).set_drag_handle(_gel(module+"-titlebar"));
showDiv(module+'-options');
hideDiv(module+'-loading-icn');
hideDiv(module+'-loading-msg');
}.bind(this))
);
};
YT_php_support.prototype.update_ordering=function(){
this.ordering_=[];
for(o in this.default_ordering_){
var order=this.default_ordering_[o];
var module_anchor=_gel("feedmodule-"+order);
if(module_anchor){
this.ordering_.push(order);
}
}
};
YT_php_support.prototype.scan_active_modules=function(){
var modules=getElementsByTagNameAndClass('div','feedmodule-anchor');
this.ordering_=[];
for(i in modules){
var module=modules[i];
if(module.id.substring(0,5)!="UNDO-"&&module.id.substring(module.id.length-6,module.id.length)!="-clone"){
var id_components=module.id.split("-");
var order=id_components[1];
this.ordering_.push(order);
}
}
};
YT_php_support.prototype.indexOf=function(arr,obj){
var arr_length=arr.length;
for(var i=0;i<arr_length;i++){
if(arr[i]==obj){
return i;
}
}
return-1;
};
YT_php_support.prototype.reset_updown_buttons=function(){
var order_len=this.ordering_.length;
for(var i in this.ordering_){
var order=this.ordering_[i];
var up_btn=_gel("mup-"+order);
var disabled_up_btn=_gel("mup-disabled-"+order);
var down_btn=_gel("mdown-"+order);
var disabled_down_btn=_gel("mdown-disabled-"+order);
if(!this.site_read_only_mode&&!this.logged_out_mode){
var close_btn=_gel("mclose-"+order);
var disabled_close_btn=_gel("mclose-disabled-"+order);
close_btn.style.display="inline";
disabled_close_btn.style.display="none";
}
if(i==0||this.site_read_only_mode||this.logged_out_mode){
up_btn.style.display="none";
disabled_up_btn.style.display="inline";
}else{
up_btn.style.display="inline";
disabled_up_btn.style.display="none";
}
if(i==(order_len-1)||this.site_read_only_mode||this.logged_out_mode){
down_btn.style.display="none";
disabled_down_btn.style.display="inline";
}else{
down_btn.style.display="inline";
disabled_down_btn.style.display="none";
}
}
};
YT_php_support.prototype.move_module=function(type,dir){
var cur_pos=this.indexOf(this.ordering_,type);
var next=cur_pos+1;
if(dir=='up'){
next=cur_pos-1;
}
var anchor=_gel("feedmodule-"+type);
var next_anchor=_gel("feedmodule-"+this.ordering_[next]);
if(!anchor)return;
if(!next_anchor)return;
var swap=this.ordering_[cur_pos];
this.ordering_[cur_pos]=this.ordering_[next];
this.ordering_[next]=swap;
if(next==this.ordering_.length-1){
this.adjust_module_order(type,type,'arrow');
}else{
this.adjust_module_order(type,this.ordering_[next+1],'arrow');
}
this.reset_updown_buttons();
ani.swapDivs(anchor,next_anchor,this.ANIMATE_MODULE_SWAP_TIME);
};
YT_php_support.prototype.change_form_type=function(module,type){
if(type==AGGREGATE_FORM){
showDiv(module+'-options-grid');
hideDiv(module+'-options-list');
}else{
showDiv(module+'-options-list');
hideDiv(module+'-options-grid');
}
showDiv(module+'-loading-icn');
this.open_loading_pane(module+'-loading-msg');
this.set_form_preference(module,type);
};
YT_php_support.prototype.process_disabled_button=function(pane){
if(this.logged_out_mode||this.site_read_only_mode){
this.open_options_pane(pane);
}
};
YT_php_support.prototype.open_options_pane=function(pane){
var el=_gel(pane);
if(el.style.display=='block'){
return this.close_options_pane(pane);
}
el.style.display='block';
if(isIE){
showDiv(pane);
}else{
ani.ajaxSlideOpen(el,0.0,this.ANIMATE_SLIDE_TIME);
}
};
YT_php_support.prototype.close_options_pane=function(pane){
if(isIE){
hideDiv(pane);
}else{
ani.fadeDuringSlideUp(_gel(pane),0.0,this.ANIMATE_SLIDE_TIME)
}
};
YT_php_support.prototype.open_loading_pane=function(pane){
showDiv(pane);
};
YT_php_support.prototype.show_undo_remove_msg=function(){
var status_msg=_gel("mundo-remove");
status_msg.style.opacity='0.0';
status_msg.style.filter='alpha(opacity=100)';
status_msg.style.display='block';
if(isIE){
window.setTimeout("hideDiv('mundo-remove')",30000);
}else{
ani.fade(status_msg,'0.0','1.0',0,this.ANIMATE_MODULE_FADE_TIME);
ani.fadeDuringSlideUp(status_msg,30.0,this.ANIMATE_SLIDE_TIME)
}
};
YT_php_support.prototype.hide_undo_remove_msg=function(){
var status_msg=_gel("mundo-remove");
ani.fadeDuringSlideUp(status_msg,0,this.ANIMATE_MODULE_FADE_TIME);
if(isIE){
status_msg.style.display='none';
}else{
delaySetProperty(status_msg,status_msg.style,'display','none',this.ANIMATE_MODULE_FADE_TIME);
}
};
YT_php_support.prototype.remove_module=function(cmd){
var url="/index";
var data="remove=true&module="+cmd+"&session_token="+this.xsrf_token_;
postUrl(url,data,true,execOnSuccess(function(xmlHttpRequest){
}.bind(this))
);
this.animate_module_destruction(cmd);
this.undo_object_.undo_function_=function(){this.undo_remove_module(cmd);}.bind(this);
};
YT_php_support.prototype.animate_module_destruction=function(type){
var id="feedmodule-"+type;
var anchor=_gel(id);
if(isIE){
hideDiv(id);
}else{
ani.fadeDuringSlideUp(anchor,0,this.ANIMATE_MODULE_FADE_TIME);
}
var undo_id="UNDO-"+id;
anchor.id=undo_id;
this.scan_active_modules();
this.reset_updown_buttons();
this.show_undo_remove_msg();
};
YT_php_support.prototype.undo_remove_module=function(cmd){
var url="/index";
var data="remove=true&undo=true&module="+cmd+"&session_token="+this.xsrf_token_;
postUrl(url,data,true,execOnSuccess(function(xmlHttpRequest){
}.bind(this))
);
this.animate_module_recreation(cmd);
this.undo_object_.undo_function_=null;
};
YT_php_support.prototype.animate_module_recreation=function(type){
var id="feedmodule-"+type;
var undo_id="UNDO-"+id;
var anchor=_gel(undo_id);
anchor.style.display="block";
if(isIE){
showDiv(undo_id);
}else{
ani.ajaxSlideOpen(anchor,0.0,this.ANIMATE_MODULE_FADE_TIME);
}
anchor.id=id;
this.scan_active_modules();
this.reset_updown_buttons();
this.hide_undo_remove_msg();
};
YT_php_support.prototype.change_already_watched_videos_exclusion=function(module,checkbox_value){
var url="/index";
var data="alter=true&setfilter=True&module="+module+"&session_token="+this.xsrf_token_;
if(checkbox_value==1){
data+="&filter=True"
}
postUrl(url,data,true,execOnSuccess(function(xmlHttpRequest){
}.bind(this))
);
};
YT_php_support.prototype.change_friend_activity_options=function(activity_type,checkbox_value){
var response_div=_gel("temp-reflect")
if(checkbox_value==1){
response_div.innerHTML="This activity type turned on (temp message): "+activity_type
}
else{
response_div.innerHTML="This activity type turned off (temp message): "+activity_type
}
showDiv("temp-reflect")
};
})();
(function(){
function getMouseOffset(target,event){
event=event||window.event;
var mouse_pos=mouseCoords(event);
return{x:mouse_pos.x-target.offsetLeft,y:mouse_pos.y-target.offsetTop};
}
function mouseCoords(event){
if(event.pageY){
return{x:event.pageX,y:event.pageY};
}
var scroll_top=Math.max(document.body.scrollTop,document.documentElement.scrollTop);
var scroll_left=Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);
return{
x:event.clientX+scroll_left-document.body.clientLeft,
y:event.clientY+scroll_top-document.body.clientTop
};
}
function drag_mouse_move(event){
if(Dragger.current_target){
event=event||window.event;
var mouse_pos=mouseCoords(event);
var dragger=Dragger.current_target;
if(!Dragger.current_drag_helper){
Dragger.current_drag_helper=dragger.get_drag_helper();
}
var height=Dragger.current_drag_helper.offsetHeight;
var width=Dragger.current_drag_helper.offsetWidth;
var top=mouse_pos.y-dragger.mouse_offset.y;
var left=mouse_pos.x-dragger.mouse_offset.x;
if(dragger.get_bounds()){
var bounds=dragger.get_bounds();
if(top<0){
top=0;
mouse_pos.y=dragger.mouse_offset.y;
}
if(mouse_pos.y>bounds.startBottom){
mouse_pos.y=bounds.startBottom-1;
}
if(top+height>bounds.startHeight){
top=bounds.startHeight-height;
}
if(left<0)left=0;
if(left+width>bounds.startWidth){
left=bounds.startWidth-width;
}
}
if(false&&dragger.get_element().offsetParent){
top+=dragger.get_element().offsetParent.offsetTop;
left+=dragger.get_element().offsetParent.offsetLeft;
}
Dragger.current_drag_helper.style.top=top+"px";
Dragger.current_drag_helper.style.left=left+"px";
Dragger.top=top;
Dragger.left=left;
if(DropTarget.drop_targets){
check_if_over_and_notify(DropTarget.drop_targets,dragger,dragger.mouse_offset.x,mouse_pos.y);
}
maybe_scroll_page(mouse_pos);
event.cancelBubble=true;
if(event.stopPropagation)event.stopPropagation();
return false;
}
}
var scroll_timeout=null;
function maybe_scroll_page(mouse_pos,opt_timeout){
if(!opt_timeout&&scroll_timeout){
window.clearTimeout(scroll_timeout);
scroll_timeout=null;
}
var window_height=window.innerHeight||document.body.clientHeight||document.documentElement.clientHeight;
var scroll_top=Math.max(document.body.scrollTop,document.documentElement.scrollTop);
var distance_from_bottom=window_height-mouse_pos.y+scroll_top;
var scroll_delta=0;
if(distance_from_bottom<25){
scroll_delta=(25-distance_from_bottom)/ 2;
}
var distance_from_top=mouse_pos.y-scroll_top;
if(distance_from_top<25){
scroll_delta=(distance_from_top-25)/ 2;
}
if(scroll_delta!=0){
document.body.scrollTop+=scroll_delta;
document.documentElement.scrollTop+=scroll_delta;
mouse_pos.y+=scroll_delta;
scroll_timeout=window.setTimeout(function(){
maybe_scroll_page(mouse_pos,true);
},100);
}
}
function check_if_over_and_notify(drop_targets,dragger,x,y){
var drop_target=null;
for(var i in drop_targets){
var drop_el=drop_targets[i].get_element();
if(drop_el.startLeft<x&&drop_el.startRight>x&&
drop_el.startTop<y&&drop_el.startBottom>y){
drop_target=drop_targets[i];
}
}
if(DropTarget.current_target!=drop_target){
if(DropTarget.current_target&&DropTarget.current_target.ondragout){
DropTarget.current_target.ondragout(dragger,x,y);
}
if(drop_target&&drop_target.ondragover){
drop_target.ondragover(dragger,x,y);
}
}
if(drop_target&&drop_target.ondragmove){
drop_target.ondragmove(dragger,x,y);
}
DropTarget.current_target=drop_target;
}
function drag_mouse_up(event){
if(Dragger.current_target){
if(Dragger.current_target.mouse_up){
Dragger.current_target.mouse_up();
}
if(DropTarget.current_target&&DropTarget.current_target.ondrop){
DropTarget.current_target.ondrop(Dragger.current_target);
}
Dragger.current_target=null;
Dragger.current_drag_helper=null;
DropTarget.current_target=null;
return false;
}
}
function add_helper_attributes(el){
var pos=ani.getPosition(el);
el.startWidth=parseInt(el.offsetWidth);
el.startHeight=parseInt(el.offsetHeight);
el.startLeft=pos.x;
el.startTop=pos.y;
el.startRight=pos.x+el.startWidth;
el.startBottom=pos.y+el.startHeight;
el.startMiddleX=(el.startLeft+el.startRight)/ 2;
el.startMiddleY=(el.startTop+el.startBottom)/ 2;
}
var Dragger=function(el,opt_drag_handle,opt_use_clone){
if(!el){
return;
}
this.element_=el;
addClass(this.element_,"draggable");
this.bounds_=null;
this.use_clone_=opt_use_clone;
if(opt_drag_handle){
this.set_drag_handle(opt_drag_handle);
}else{
this.set_drag_handle(el);
}
};
window.Dragger=Dragger;
Dragger.current_target=null;
Dragger.prototype.set_drag_handle=function(el){
el.style.cursor="move";
if(!this.handler_func_){
var dd=this;
this.handler_func_=function(event){dd.mouse_down(event)};
}
if(this.drag_handle_){
removeListener(this.drag_handle_,'mousedown',this.handler_func_);
this.drag_handle_.onmousedown=this.drag_handle_.oldonmousedown;
}
this.drag_handle_=el;
addListener(el,'mousedown',this.handler_func_);
el.oldonmousedown=el.onmousedown;
el.onmousedown=function(){return false;};
return this;
};
Dragger.prototype.set_drag_bound_element=function(el){
this.bounds_=el;
};
Dragger.prototype.create_drag_helper=function(){
if(this.use_clone_){
this.drag_helper_=ani.hideAndFloatClone(this.element_);
this.element_.style.display="none";
}else{
this.drag_helper_=this.element_;
this.orig_position_=this.element_.style.position?this.element_.style.position:"static";
}
this.drag_helper_.style.position="absolute";
addClass(this.drag_helper_,"drag_helper");
var position=ani.getPosition(this.element_);
this.drag_helper_.style.top=position.y+"px";
this.drag_helper_.style.left=position.x+"px";
};
Dragger.prototype.setup_global_handlers=function(event){
this.orig_mousemove=document.onmousemove;
document.onmousemove=function(){return false;};
addListener(document,'mousemove',drag_mouse_move);
this.orig_mouseup=document.onmouseup;
document.onmouseup=function(){return false;};
addListener(document,'mouseup',drag_mouse_up);
return drag_mouse_move(event);
};
function is_clickable(element){
if(!element){
return false;
}
if(element.onclick||element.href){
return true;
}
return is_clickable(element.parentNode);
}
function target_is_clickable(event){
if(!event){
event=window.event;
}
var target=event.target;
if(!target){
target=event.srcElement;
}
return is_clickable(target);
}
Dragger.prototype.mouse_down=function(event){
if(Dragger.current_target){
return;
}
if(target_is_clickable(event)){
if(this.element_.oldonmousedown){
return this.element_.oldonmousedown(event);
}
return;
}
Dragger.current_target=this;
add_helper_attributes(this.element_);
this.mouse_offset=getMouseOffset(this.element_,event);
if(this.start_drag){
this.start_drag();
}
this.create_drag_helper();
return this.setup_global_handlers(event);
};
Dragger.prototype.mouse_up=function(event){
if(this.end_drag){
this.end_drag();
}
if(this.orig_position_){
this.element_.style.position=this.orig_position_;
}
if(this.use_clone_){
removeNode(this.drag_helper_);
this.element_.style.display="";
}
var orig_mouseup=this.orig_mouseup;
var orig_mousemove=this.orig_mousemove;
removeClass(this.drag_helper_,"drag_helper");
window.setTimeout(function(){
document.onmouseup=orig_mouseup?orig_mouseup:null;
document.onmousemove=orig_mousemove?orig_mousemove:null;
},1);
};
Dragger.prototype.get_bounds=function(){
return this.bounds_;
};
Dragger.prototype.get_element=function(){
return this.element_;
};
Dragger.prototype.get_drag_helper=function(){
return this.drag_helper_;
};
var DropTarget=function(el){
this.element_=el;
add_helper_attributes(el);
DropTarget.drop_targets.push(this);
};
window.DropTarget=DropTarget;
DropTarget.drop_targets=[];
DropTarget.prototype.ondragover=function(dragger,x,y){
addClass(this.element_,"draghover");
};
DropTarget.prototype.ondragout=function(dragger,x,y){
removeClass(this.element_,"draghover");
};
DropTarget.prototype.ondrop=function(dragger,x,y){
removeClass(this.element_,"draghover");
if(this.handle_drop){
this.handle_drop(dragger);
}
};
DropTarget.prototype.get_element=function(){
return this.element_;
};
var RearrangeableDragger=function(el,drag_drop_rearranger,opt_drop_targets,opt_drag_handle){
Dragger.apply(this,[el,opt_drag_handle,true]);
this.drop_targets_=[drag_drop_rearranger];
if(opt_drop_targets){
this.drop_targets_=opt_drop_targets;
}
this.drag_drop_rearranger_=drag_drop_rearranger;
};
inherits(RearrangeableDragger,Dragger);
RearrangeableDragger.prototype.start_drag=function(){
if(this.drag_drop_rearranger_.ondrag){
this.drag_drop_rearranger_.ondrag(this);
}
};
RearrangeableDragger.prototype.end_drag=function(){
this.element_.style.visibility="hidden";
};
var DragDropRearranger=function(container,opt_orientation){
this.drop_target_=new DropTarget(container);
var ddr=this;
this.drop_target_.handle_drop=function(dragger){ddr.ondrop(dragger)};
this.drop_target_.ondragmove=function(dragger,x,y){ddr.ondragmove(dragger,x,y)};
this.drop_target_.ondragover=function(dragger,x,y){ddr.ondragover(dragger,x,y)};
this.drop_target_.ondragout=function(dragger,x,y){ddr.ondragout(dragger,x,y)};
this.orientation_=(opt_orientation?opt_orientation:"vertical");
this.draggers_=[];
this.dragger_lookup_={};
this.animate_drop_=false;
};
window.DragDropRearranger=DragDropRearranger;
DragDropRearranger.prototype.add_child=function(el,opt_el_drag_handle){
if(!el){
return;
}
var dragger=new RearrangeableDragger(el,this,null,opt_el_drag_handle);
this.draggers_.push(dragger);
this.dragger_lookup_[el.id]=dragger;
dragger.set_drag_bound_element(this.drop_target_.get_element());
};
DragDropRearranger.prototype.lookup_dragger_by_id=function(id){
return this.dragger_lookup_[id];
};
DragDropRearranger.prototype.index_of=function(dragger){
for(var i in this.draggers_){
if(this.draggers_[i]==dragger){
return i;
}
}
return-1;
};
DragDropRearranger.prototype.has_dragger=function(dragger){
return this.index_of(dragger)!=-1;
};
DragDropRearranger.prototype.ondrag=function(dragger,x,y){
if(!this.has_dragger(dragger)){
return;
}
add_helper_attributes(this.drop_target_.get_element());
this.placeholder_=document.createElement('div');
addClass(this.placeholder_,"drag_placeholder");
this.drop_target_.get_element().insertBefore(this.placeholder_,dragger.get_element());
var border_size=(this.placeholder_.clientLeft||2)*2;
this.placeholder_.style.width=(dragger.get_element().startWidth-border_size)+"px";
this.placeholder_.style.height=(dragger.get_element().startHeight-border_size)+"px";
this.just_moved_=true;
};
DragDropRearranger.prototype.ondragover=function(dragger,x,y){
return;
if(!this.has_dragger(dragger)){
return;
}
if(this.last_placeholder_sibling_){
this.drop_target_.get_element().insertBefore(this.placeholder_,this.last_placeholder_sibling_);
}
};
DragDropRearranger.prototype.ondragout=function(dragger,x,y){
return;
this.has_left_the_building_=true;
if(!this.has_dragger(dragger)){
return;
}
try{
this.last_placeholder_sibling_=this.placeholder_.nextSibling;
this.drop_target_.get_element().removeChild(this.placeholder_);
}catch(e){
}
};
DragDropRearranger.prototype.ondrop=function(dragger){
if(!this.has_dragger(dragger)){
return false;
}
var drag_el=dragger.get_element();
if(this.animate_drop_){
drag_el.style.visibility="hidden";
window.setTimeout(function(){
var new_pos=ani.getPosition(drag_el);
ani.slideTo(drag_el,drag_el.offsetTop,drag_el.offsetLeft,new_pos.y,new_pos.x,
1.0,true);
},1);
}else{
dragger.get_element().style.visibility="visible";
}
this.drop_target_.get_element().insertBefore(dragger.get_element(),this.placeholder_);
this.drop_target_.get_element().removeChild(this.placeholder_);
this.placeholder_=null;
if(this.rearrange_handler_){
var ids=[];
var container=this.drop_target_.get_element();
for(var i in container.childNodes){
var el=container.childNodes[i];
if(hasClass(el,"draggable")){
ids.push(el.id);
}
}
this.rearrange_handler_(ids,dragger.get_element().id);
}
return true;
};
function is_before_in_parent(el1,el2){
var parent_node=el1.parentNode;
var child_nodes=parent_node.childNodes;
for(var i=0;i<child_nodes.length;i++){
if(child_nodes[i]==el1){
return true;
}else if(child_nodes[i]==el2){
return false;
}
}
return true;
}
DragDropRearranger.prototype.ondragmove=function(dragger,x,y){
if(!this.has_dragger(dragger)){
return;
}
if(this.just_moved_){
for(var i in this.draggers_){
var d=this.draggers_[i];
add_helper_attributes(d.get_element());
}
add_helper_attributes(this.placeholder_);
this.just_moved_=false;
return;
}
if(this.placeholder_.startLeft<x&&this.placeholder_.startRight>x&&
this.placeholder_.startTop<y&&this.placeholder_.startBottom>y){
this.last_y=y;
return false;
}
var drag_over=null;
for(var i in this.draggers_){
var d=this.draggers_[i];
var el=d.get_element();
if(el.startLeft<x&&el.startRight>x&&
el.startTop<y&&el.startBottom>y){
drag_over=d;
break;
}
}
if(drag_over&&dragger!=drag_over){
var over_el=drag_over.get_element();
if(this.has_left_the_building_){
insert_before=y<this.last_y;
if(insert_before){
over_el.parentNode.insertBefore(this.placeholder_,over_el);
}else{
over_el.parentNode.insertBefore(this.placeholder_,over_el.nextSibling);
}
this.just_moved_=true;
this.has_left_the_building_=false;
}else{
var insert_before=false;
if(this.orientation_=="horizontal"){
insert_before=x<this.placeholder_.startMiddleX;
}else{
if(y==this.last_y){
return;
}
insert_before=y<this.last_y;
}
if(insert_before!=is_before_in_parent(this.placeholder_,over_el)){
ani.swapDivs(over_el,this.placeholder_,0.25);
this.just_moved_=true;
}
}
}
this.last_y=y;
};
DragDropRearranger.prototype.add_rearrange_handler=function(handler){
this.rearrange_handler_=handler;
};
})();
(function(){
YT_ads_masthead=function(tile,expanded_iframe_src,collapsed_iframe_src){
this.tile_=tile;
this.expanded_iframe_src_=expanded_iframe_src;
this.collapsed_iframe_src_=collapsed_iframe_src;
this.masthead_id_='ad_creative_'+tile;
this.expand_btn_='ad_creative_expand_btn_'+tile;
this.collapse_btn_='ad_creative_collapse_btn_'+tile;
this.iframe_id_='ad_creative_iframe_'+tile;
this.cflag_=yt.UserPrefs.Flags['FLAG2_HIDE_MASTHEAD'];
}
YT_ads_masthead.prototype.collapse_masthead=function(){
hideDiv(this.masthead_id_);
showDiv(this.expand_btn_)
hideDiv(this.collapse_btn_)
yt.UserPrefs.setFlag2(this.cflag_,true);
yt.UserPrefs.save();
getUrl("/gen_204?a=homepage_collapse_masthead_ad",true,null);
}
YT_ads_masthead.prototype.expand_masthead=function(){
showDiv(this.masthead_id_);
hideDiv(this.expand_btn_)
showDiv(this.collapse_btn_)
var src=_gel(this.iframe_id_).src;
if(src==this.collapsed_iframe_src_){
_gel(this.iframe_id_).src=this.expanded_iframe_src_;
}
yt.UserPrefs.setFlag2(this.cflag_,false);
yt.UserPrefs.save();
getUrl("/gen_204?a=homepage_expand_masthead_ad",true,null);
}
})();
(function(){
var Survey={};
Survey.open=function(survey_id,user_token,return_page){
Survey.add_page_mask();
var survey_url="http://youtube-survey.appspot.com/answer?s="+survey_id+"&session_id="+user_token+"&next="+return_page;
Survey.create_survey_frame(survey_url);
window.scroll(0,0);
};
var mask_frame=null;
Survey.add_page_mask=function(){
mask_frame=document.createElement('iframe');
mask_frame.setAttribute('id','mask_frame');
mask_frame.setAttribute('name','mask_frame');
mask_frame.frameBorder='0';
mask_frame.allowTransparency=true;
mask_frame.style.border='0px';
mask_frame.style.width='100%';
var height=document.body.clientHeight||document.documentElement.scrollHeight;
height++;
mask_frame.style.height=height?height+"px":'100%';
mask_frame.style.zIndex='1000';
mask_frame.style.background='#333';
mask_frame.style.opacity='0.4';
mask_frame.style.filter='alpha(opacity=40)';
mask_frame.style.position='absolute';
mask_frame.style.top='0';
mask_frame.style.left='0';
document.body.appendChild(mask_frame);
mask_frame.contentWindow.document.write('<body style="background:transparent"></body>');
mask_frame.contentWindow.document.close();
};
var survey_frame=null;
Survey.create_survey_frame=function(url){
survey_frame=document.createElement('iframe');
survey_frame.src=url;
survey_frame.frameBorder='0';
survey_frame.allowTransparency=true;
survey_frame.style.border='0';
survey_frame.style.zIndex='1001';
survey_frame.style.position='absolute';
survey_frame.style.left=(document.body.clientWidth-620)/ 2+'px';
survey_frame.style.top='100px';
survey_frame.style.width='621px';
survey_frame.style.backgroundColor='transparent';
survey_frame.style.height='800px';
document.body.appendChild(survey_frame);
};
Survey.close_survey=function(){
mask_frame.style.display="none";
survey_frame.style.display="none";
if(_gel('survey_link')){
_gel('survey_link').style.display='none';
}
};
window.Survey=Survey;
})();
