function startVideo(){if(window.opera||Browser.Engine.trident4){$$("a.js-video-btn").each(function(a){a.addEvent("click",function(b){Event(b).stop();if(window.opera){alert("Sorry Opera users, we're not ready for you.")}else{alert("Sorry IE6 users, you're time has passed.")}return false})});return false}if(VINES_USER_BAN_WIKID==true){$$("a.js-video-btn").each(function(a){a.remove()});return false}if(VINES_USER_NAME==false){$$("a.js-video-btn").each(function(a){a.addEvent("click",function(c){var b=vinesLoginRequired();if(!b){return}})});return false}}window.addEvent("domready",startVideo);VideoForm=new Class({Extends:LaunchPad.Base,options:{url:"/video/ajax_post/",video_found:false,video_id:false,content_type_id:false,object_id:false,form_mode:"flv_url"},initialize:function(a){this.setOptions(a);this.parent(this.options);if(this.options.video_id){var b={method:"video_form",content_type_id:this.options.content_type_id,object_id:this.options.object_id,video_id:this.options.video_id}}else{var b={method:"video_form",content_type_id:this.options.content_type_id,object_id:this.options.object_id}}this.addEvent("openComplete",function(){this.manageForm()}.bind(this));this.open("post",b)},manageForm:function(){if(this.options.form_mode=="embed"){if(this.options.video_id){this.show_fields()}else{var c=this.options.stage.getElement("#id_embed");var b=this.options.stage.getElement(".jsFind");b.addEvent("click",function(){this.get_video_details_from_embed(c.value)}.bind(this));b.removeClass("dn")}}else{var a=this.options.stage.getElement(".jsAdd");a.removeClass("dn")}var a=this.options.stage.getElement(".jsAdd");a.addEvent("click",function(){this.submit()}.bind(this))},get_video_details_from_embed:function(a){this.toggleLoading(true,this);this.options.stage.getElement(".jsEmbedError").setHTML("");var b={method:"embed_details",embed:a};new VinesAjax(this.options.url,{method:"post",data:b,onFailure:function(){this.options.stage.getElement(".jsEmbedError").setHTML("Sorry, I cannot compute that emebed code.");this.toggleLoading(false,this)}.bind(this),onComplete:function(e){var e=JSON.decode(e);this.options.video_found=true;this.show_fields();var f=this.options.stage.getElement("#id_name");var d=this.options.stage.getElement("#id_deck");var i=this.options.stage.getElement("#id_embed");var c=this.options.stage.getElement("#jsSingleImageSrc");var g=this.options.stage.getElement("#thumbnail_input");if(f.value.trim()==""){f.value=e.name}if(d.innerHTML.trim()==""){d.setHTML(e.deck)}c.src=e.thumbnail_url;c.setProperties({width:"100px",height:"100px"});g.value=e.thumbnail_url;var h=this.options.stage.getElement(".jsEmbed");h.setHTML(i.value);this.toggleLoading(false,this)}.bind(this)}).request()},submit:function(){var f="";var d=this.options.stage.getElement("#id_name");var b=this.options.stage.getElement("#id_deck");var h=this.options.stage.getElement("#id_embed");var c=this.options.stage.getElement("#id_url");var a=this.options.stage.getElement("#id_video_type");if(this.options.form_mode=="embed"){if(h.value==""){f+="You need to embed some flash code\n"}if(!this.options.video_found&&h.value!==""){f+="The video embed code was not recognized."}}else{if(c.value==""){f+="You need a link to an FLV file\n"}}if(d.value==""){f+="You need to fill in a name\n"}if(b.value==""){f+="You need to fill in a summary\n"}if(a.selectedIndex==0){f+="You need to select a type\n"}if(f!==""){f="Sorry "+VINES_USER_NAME+":\n"+f;alert(f);return false}this.toggleLoading(true,this.options.stage);var g={method:"video_save",content_type_id:this.options.content_type_id,object_id:this.options.object_id};if(this.options.stage.getElement("#jsForm")){g=this.options.stage.getElement("#jsForm")}var e;new VinesAjax(this.options.url,{method:"post",update:this.options.stage,evalScripts:true,data:g,onFailure:function(){alert("Sorry, there was an error");this.toggleLoading(false,this.options.stage)}.bind(this),onComplete:function(i){this.toggleLoading(false,this.options.stage)}.bind(this)}).request()}});VideoForm.implement(new Options);function editVideosJs(a){a.titleTextStr="Edit Video";new VideoForm(a)}function addVideosJs(a){a.titleTextStr="Add Video";new VideoForm(a)}function toggleVidAssoc(){toggleDiv("js-content-obj-assoc");toggleDiv("js-topic-assoc");if($("js-content-obj-assoc").hasClass("dn")){}};