tagged.namespace("util.lightbox");tagged.util.lightbox={maskId:"lbMask",lightboxId:"lbContent",elIDs:["ad_unit_0_div","ad_unit_1_div","ad_unit_2_div","comment_rte"],show:function(d,h){for(var g=0;g<this.elIDs.length;g++){if(D.get(this.elIDs[g])){D.get(this.elIDs[g]).style.visibility="hidden"}}if(!document.getElementById(this.maskId)){var l=document.createElement("div");l.id=this.maskId;l.style.width=parseInt(D.getViewportWidth())+"px";l.style.height=YAHOO.util.Dom.getDocumentHeight()+"px";document.body.appendChild(l)}if(D.get(this.lightboxId)){document.body.removeChild(D.get(this.lightboxId))}else{if(D.get("captcha_div")){document.body.removeChild(D.get("captcha_div"))}}var a=document.createElement("div");a.id=this.lightboxId;var j=this.getScroll();a.style.top=(j+75)+"px";a.style.left=(parseInt(D.getViewportWidth())-500)/2+"px";var k=document.createElement("div");k.innerHTML='<img src="'+TAGGED.static_uri+'/images/loading_grey32.gif"/>';k.id="lbLoader";a.appendChild(k);document.body.appendChild(a);if(d.constructor==String){var c=document.createElement("div");c.innerHTML=d;c.style.visibility="hidden";c.style.position="absolute"}else{var c=d;c.style.visibility="hidden";c.style.position="absolute"}a.appendChild(c);var f=function(){var i=c.offsetWidth+1;var m=c.offsetHeight;if((i>50)||(m>50)){e(c,i,m)}else{setTimeout(f,250)}};var e=function(p,m,v){k.style.display="none";var q=parseInt(D.getStyle(p,"paddingLeft"));var o=parseInt(D.getStyle(p,"paddingRight"));var x=parseInt(D.getStyle(p,"paddingTop"));var n=parseInt(D.getStyle(p,"paddingBottom"));var u=parseInt(D.getViewportWidth());var t=((u-100)-(m+q+o))/2;var i=(v+n);if(YAHOO.util.Anim){var r={left:{to:t},width:{to:m},height:{to:i}};var w=new YAHOO.util.Anim("lbContent",r,0.4);var s=function(){p.style.position="";p.style.visibility="";p.style.display="block";window.setTimeout(function(){tagged.util.domMethods.set_bg_iframe(a)},0);if(h){var y=D.get(h);if(y){y.select()}}};w.onComplete.subscribe(s);w.animate()}else{p.style.left=t+"px";p.style.width=m+"px";p.style.height=v+"px";d.style.position="";d.style.visibility="";d.style.display="block";window.setTimeout(function(){tagged.util.domMethods.set_bg_iframe(a)},0)}};f();var b=new YAHOO.util.KeyListener(document,{keys:27},tagged.util.lightbox.hide);b.enable()},hide:function(){if(!this.maskId){this.maskId="lbMask"}if(!this.lightboxId){this.lightboxId="lbContent"}document.body.removeChild(D.get(this.maskId));document.body.removeChild(D.get(this.lightboxId));for(var a=0;a<this.elIDs.length;a++){if(D.get(this.elIDs[a])){D.get(this.elIDs[a]).style.visibility="visible"}}},getScroll:function(){var a;if(self.pageYOffset){a=self.pageYOffset}else{if(document.documentElement&&document.documentElement.scrollTop){a=document.documentElement.scrollTop}else{if(document.body){a=document.body.scrollTop}}}return a},setScroll:function(){window.scrollTo(0,this.getScroll())}};tagged.namespace("util.captcha");tagged.util.captcha={successCallback:null,cbArgs:null,cbScope:null,verify:function(b){TUC.successCallback=b;var a={method:"tagged.util.verifyCaptcha",callback:"tagged.util.captcha._processRequest"};TAGGED.api.call(a);return false},submit:function(b){var a={method:"tagged.util.verifyCaptcha",callback:"tagged.util.captcha._processRequest",response:b};TAGGED.api.call(a);return false},_processRequest:function(a){if(a.stat=="ok"&&a.result){if(a.result.captchaPassed){if(D.get("lbContent")){tagged.util.lightbox.hide()}if(TUC.successCallback&&TUC.cbArgs){TUC.successCallback.call(TUC.cbScope?TUC.cbScope:TUC,TUC.cbArgs)}else{if(TUC.successCallback){TUC.successCallback.call(TUC.cbScope?TUC.cbScope:TUC)}}return true}else{if(a.result.captchaHTML){tagged.util.lightbox.show(a.result.captchaHTML,"captcha_code");return true}}}alert("An error has occured. Please refresh the page and try again.");return false}};var TUC=tagged.util.captcha;TAGGED.namespace("util.hintinput");TAGGED.util.hintinput={attach:function(b,e,d){var c=(typeof b=="object")?b:D.get(b);var a=(typeof e=="object")?e:D.get(e);if(c!=null){YAHOO.lang.augmentObject(c,TAGGED.util.hintinput.methods,true);E.addListener(c,"blur",c._insertDefaultText);E.addListener(c,"focus",c._removeDefaultText);E.addListener(a,"submit",c._onFormSubmit,c);c.setAttribute("defaultText",d);c.setAttribute("prevColor",YAHOO.util.Dom.getStyle(c,"color"));if(typeof(document.activeElement)=="object"){if(document.activeElement!=c){c._insertDefaultText()}}else{c._insertDefaultText()}}},methods:function(){return{getValue:function(){this._removeDefaultText();var a=this.value;this._insertDefaultText();return a},setValue:function(a){this._removeDefaultText();this.value=a;this._insertDefaultText()},hasValue:function(){return !D.hasClass(this,"showdefault")&&this.value!=""},clearValue:function(){this.setValue("")},_insertDefaultText:function(){if(!this.disabled&&!D.hasClass("showdefault")&&this.value==""){D.addClass(this,"showdefault");D.setStyle(this,"color","#999");this.value=this.getAttribute("defaultText")}},_removeDefaultText:function(){if(D.hasClass(this,"showdefault")){D.removeClass(this,"showdefault");D.setStyle(this,"color","#000");this.value=""}},_onFormSubmit:function(b,a){a._removeDefaultText()}}}()};TAGGED.namespace("videos");TAGGED.videos={setupPageEvents:function(){switch(pageType){case"player":var d=document.forms.search_video;TAGGED.util.hintinput.attach(d.search_term,d,"Search Videos...");d.onsubmit=function(){window.location=video_uri+"/video_search.html#s="+encodeURIComponent(this.search_term.getValue());return false};var f=document.getElementById("vid").value;var h=[{method:"tagged.ytvideos.getVideoMetadataExtended",video_id:f,use_cache:1,callback:"TAGGED.videos.setVideoPlayerInfo"},{method:"tagged.ytvideos.getRelatedVideos",video_id:f,offset:1,num_videos:10,use_cache:1,callback:"TAGGED.videos.setRelatedVideos"}];var n=[{method:"tagged.ytvideos.getComments",video_id:f,offset:1,num_comments:10,callback:"TAGGED.videos.setComments"}];var g=document.getElementById("ownerId").value;if(g!=0){n.push({method:"tagged.profile.getCustomBoxesList",id:g,callback:"TAGGED.videos.createCopyDropdown"})}TAGGED.api.call(n);TAGGED.api.call(h);document.forms.copy_video.submit_btn.onclick=function(){TAGGED.videos.copyVideo();return false};var b=document.getElementById("video_meta").getElementsByTagName("input");for(var e in b){b[e].onclick=function(){this.select();TAGGED.util.copytoclipboard.copyInput(this.id,this.alt)}}break;case"add_video":var j=document.getElementById("vertical_tabs").getElementsByTagName("li");var d=document.forms.search_video;var l=document.forms.search_video_results;for(var e in j){j[e].onclick=function(){TAGGED.videos.showTab(this.id,true);return false}}d.onsubmit=function(){TAGGED.videos.doSearch({searchKey:d.search_key.value});return false};l.onsubmit=function(){d.search_key.value=l.search_key.value;TAGGED.videos.doSearch({searchKey:d.search_key.value});return false};l.search_key.onclick=function(){this.select()};document.forms.add_video.onsubmit=function(){TAGGED.videos.addVideo();return false};break;case"gallery":case"primary_gallery":TAGGED.videos.getGalleryResults();break;case"search":var c=searchKeyInitialState;var d=document.forms.search_video;d.search_key.value=c;d.onsubmit=function(){c=d.search_key.value;YAHOO.util.History.multiNavigate({s:c,pageNum:"1",o:"relevance"});return false};d.order_by.onchange=function(){YAHOO.util.History.multiNavigate({s:c,pageNum:"1",o:this.value})};d.search_key.onclick=function(){this.select()};break;case"video_index":TAGGED.videos.setCategoryStyle();var m=document.forms.video_feeds;m.feed_name.onchange=function(){if(this.value=="recently_featured_url"){m.time.value="";m.time.disabled="disabled"}else{m.time.disabled=""}YAHOO.util.History.multiNavigate({f:String(this.value),pageNum:"1",c:YAHOO.util.History.getCurrentState("c")})};m.time.onchange=function(){YAHOO.util.History.multiNavigate({t:String(this.value),pageNum:"1",c:YAHOO.util.History.getCurrentState("c")})};var d=document.forms.search_video;d.onsubmit=function(){window.location=video_uri+"/video_search.html#s="+encodeURIComponent(d.search_key.value);return false};d.search_key.onclick=function(){this.select()};var k=document.getElementById("vid_categories").getElementsByTagName("a");for(e in k){k[e].onclick=function(){YAHOO.util.History.multiNavigate({c:this.title,pageNum:"1"});(this.title=="All")?m.time.style.visibility="visible":m.time.style.visibility="hidden";return false}}break}},createPreviewBox:function(c){var b=c.video_id;var e=c.title;var d=TAGGED.videos.convertTime(c.duration,"toMinutes");var a=document.getElementById("video_gallery");var f=document.createElement("div");f.id=b;f.title=e;if(e.length>26){var e=e.substr(0,26)+"..."}e=tagged.util.string.breakString(e,16);(c.is_primary)?f.className="box primary":f.className="box";TAGGED.videos.attachPreviewBoxEvents(f);previewHTML='<img src="http://i.ytimg.com/vi/'+b+'/default.jpg" alt="" class="preview"/>';previewHTML+='<p class="title">'+e+'</p><p class="duration">'+d+"</p>";if(pageType!="add_video"&&pageType!="player"){previewHTML+='<img src="'+TAGGED.static_uri+'/im/icons/icon_play_video.png" alt="" width="20" height="20" class="play" />'}if(pageType=="primary_gallery"){previewHTML+='<img src="'+TAGGED.static_uri+'/im/icons/icon_set_primary.png" alt="" width="20" height="20" class="set_primary" title="Set this video as my Primary Video" onclick="TAGGED.videos.setPrimaryVideo(\''+b+"', event); return false;\" />";previewHTML+='<img src="'+TAGGED.static_uri+'/im/icons/icon_delete.png" alt="" width="20" height="20" class="delete" title="Delete this video" onclick="TAGGED.videos.deleteVideo(\''+b+"', event);\" />"}f.innerHTML=previewHTML;return f},attachPreviewBoxEvents:function(a){YAHOO.util.Event.addListener(a,"click",function(){if(pageType=="add_video"){TAGGED.videos.selectVideoPreview(a.id)}else{window.location=video_uri+"/?v="+a.id}});YAHOO.util.Event.addListener(a,"mouseover",function(){(a.className=="box primary")?a.className="box primary hover":a.className="box hover"});YAHOO.util.Event.addListener(a,"mouseout",function(){(a.className=="box primary hover")?a.className="box primary":a.className="box"})},doSearch:function(e){if(!e){return}TAGGED.videos.toggleLoader("show");var c=document.forms.search_video;var f=document.getElementById("video_gallery");var d,g;(e.searchKey)?d=e.searchKey:d=c.search_key.value;(e.pageNum)?g=e.pageNum:g=1;var h=c.search_type.value;if((d.match("tagged.com")||d.match("youtube.com"))&&(d.match("v="))){var j=d.split("v=");var a=j[1];if(a.match("&")){var j=a.split("&");var a=j[0]}if(h!="url"){var h="url";if(pageType=="add_video"){TAGGED.videos.showTab("tab_url")}}}else{if(d.match("youtube.com/v/")){var j=d.split("/v/");var a=j[1];if(a.match("&")){var j=a.split("&");var a=j[0]}if(h!="url"){var h="url";if(pageType=="add_video"){TAGGED.videos.showTab("tab_url")}}}}if(h=="url"){if(d.match("http")==null){var h="search";if(pageType=="add_video"){TAGGED.videos.showTab("tab_search")}}}else{var a=d}switch(pageType){case"add_video":results_form=document.forms.search_video_results;results_form.search_key.value=d;results_form.search_type.value=h;f.innerHTML="Loading...";switch(h){case"search":var k=[{method:"tagged.ytvideos.searchYouTubeByString",search_string:a,offset:1,num_videos:resultsPerPage,callback:"TAGGED.videos.showSearchResultsAddVideo"}];break;case"url":var k=[{method:"tagged.ytvideos.searchYouTubeById",video_id:a,callback:"TAGGED.videos.showSearchResultsAddVideo"}];break;case"username":var k=[{method:"tagged.ytvideos.searchYouTubeByUsername",username:a,offset:1,num_videos:resultsPerPage,callback:"TAGGED.videos.showSearchResultsAddVideo"}];break}break;case"search":if(h=="url"){var k=[{method:"tagged.ytvideos.searchYouTubeById",video_id:a,callback:"TAGGED.videos.showSearchResults"}]}else{var k=[{method:"tagged.ytvideos.searchYouTubeByString",search_string:a,offset:(e.pageNum*resultsPerPage-resultsPerPage+1),num_videos:resultsPerPage+1,order_by:e.orderBy,callback:"TAGGED.videos.showSearchResults"}]}break;case"video_index":if(e.category=="All"){var k=[{method:"tagged.ytvideos.searchStandardFeed",offset:(e.pageNum*resultsPerPage-resultsPerPage+1),num_videos:resultsPerPage+1,category:e.category,feed_name:e.feedName,time:e.time,use_cache:1,callback:"TAGGED.videos.showSearchResults"}]}else{var b="viewCount";switch(e.feedName){case"top_rated_url":b="rating";break;case"top_favorites_url":b="updated";break;case"most_linked_url":b="relevance";break}var k=[{method:"tagged.ytvideos.searchYouTubeByString",offset:(e.pageNum*resultsPerPage-resultsPerPage+1),num_videos:resultsPerPage+1,category:e.category,order_by:b,use_cache:1,callback:"TAGGED.videos.showSearchResults"}]}break}TAGGED.api.call(k)},convertTime:function(e,d){if(d=="toMinutes"){var b=Math.floor(e/60);var a=Math.round(60*((e/60)-b))+"";if(a.length==1){a=a+"0"}return(b+":"+a)}else{if(d=="toSeconds"){var c=e.split(":");return(parseInt(c[0]*60))+parseInt(c[1])}}},toggleLoader:function(b){var a=document.getElementById("loading_mask");var c=document.getElementById("loading_img");if(b){a.style.display="";c.style.display=""}else{a.style.display="none";c.style.display="none"}},showTab:function(b,k){var h=document.getElementById("vertical_tabs").getElementsByTagName("li");var c=b.substr(4,b.length);var a=document.forms.search_video;a.search_type.value=c;if(k){TAGGED.videos.toggleLoader();a.search_key.value="";document.getElementById("video_gallery").innerHTML="";document.getElementById("search_panel").style.display="";document.getElementById("video_player").innerHTML="";document.forms.add_video.submit_btn.style.display="none";document.getElementById("video_added").style.display="none";document.getElementById("search_results").style.display="none"}var f=a.submit_btn;var e=document.forms.search_video_results.submit_btn;var g=document.getElementById("example");var j=document.getElementById("lbl_search_key");for(var d in h){if(h[d].id==b){h[d].className="tab_active";if(c=="search"){j.innerHTML="";g.innerHTML="(like <a href=\"#\" onclick=\"TAGGED.videos.doSearch({'searchKey': 'American Idol'}); return false;\">American Idol</a>)";f.value="Get Videos";e.value="Get Videos"}else{if(c=="url"){j.innerHTML="Video URL:";g.innerHTML="(like <a href=\"#\" onclick=\"TAGGED.videos.doSearch({'searchKey': 'http://www.youtube.com/watch?v=Ar_JH1ycrPc'}); return false;\">http://www.youtube.com/watch?v=Ar_JH1ycrPc</a>)";f.value="Get Video";e.value="Get Video"}else{if(c=="username"){j.innerHTML="YouTube Username:";g.innerHTML="(like <a href=\"#\" onclick=\"TAGGED.videos.doSearch({'searchKey': 'Lonelygirl15'}); return false;\">Lonelygirl15</a>)";f.value="Get Videos";e.value="Get Videos"}}}}else{h[d].className="tab_inactive"}}},showSearchResultsAddVideo:function(e){var c=document.getElementById("video_gallery");c.innerHTML="";var b=document.forms.add_video;if(e.stat!=null&&e.stat=="ok"){if(e.results==null||e.results.length<1){if(document.forms.search_video_results.search_type.value=="url"){c.innerHTML='<p class="no_results">Username not found</p>'}else{c.innerHTML='<p class="no_results">No results were found</p>'}b.submit_btn.style.display="none";document.getElementById("video_player").innerHTML=""}else{for(var a in e.results){if(e.results[a]&&e.results[a].video_id&&e.results[a].title&&e.results[a].duration){var d=TAGGED.videos.createPreviewBox(e.results[a]);if(a==0){b.video_id.value=e.results[a].video_id;b.title.value=e.results[a].title;b.duration.value=TAGGED.videos.convertTime(e.results[a].duration,"toMinutes");TAGGED.videos.showVideoPlayer(e.results[a].video_id);d.className="box primary"}c.appendChild(d)}}b.submit_btn.style.display=""}}else{if(e.error.code==100){c.innerHTML='<p class="no_results">No results were found</p>'}else{c.innerHTML='<p class="error">An error occured.</p><p class="error">Please try again in a few minutes.</p>'}b.submit_btn.style.display="none"}TAGGED.videos.toggleLoader();document.getElementById("search_panel").style.display="none";document.getElementById("video_added").style.display="none";document.getElementById("search_results").style.display=""},selectVideoPreview:function(a){var e=document.getElementById("video_gallery").getElementsByTagName("div");for(var c=0;c<e.length;c++){if(e[c].id==a){var b=e[c];e[c].className="box primary hover"}else{e[c].className="box"}}var d=document.forms.add_video;d.video_id.value=a;var f=b.getElementsByTagName("p");for(c in f){if(f[c].className=="title"){d.title.value=f[c].innerHTML}else{if(f[c].className=="duration"){d.duration.value=f[c].innerHTML}}}TAGGED.videos.showVideoPlayer(a)},showVideoPlayer:function(a){var b=document.getElementById("video_player");b.innerHTML="";var c=document.createElement("embed");c.setAttribute("src","http://www.youtube.com/v/"+a+"&rel=1");c.setAttribute("type","application/x-shockwave-flash");c.setAttribute("wmode","transparent");c.setAttribute("width","300");c.setAttribute("height","248");b.appendChild(c);document.forms.add_video.submit_btn.style.display="";document.getElementById("video_added").style.display="none"},addVideo:function(){var c=document.forms.add_video;var a=c.video_id.value;var e=c.title.value;var d=TAGGED.videos.convertTime(c.duration.value,"toSeconds");if((!a)||(!e)||(!d)){return}else{var b=[{method:"tagged.ytvideos.addProfileVideo",video_id:a,title:e,duration:d,callback:"TAGGED.videos.responseAddVideo"}];TAGGED.api.call(b)}},responseAddVideo:function(a){if(a.stat=="ok"&&a.result&&a.result.success==1){document.forms.add_video.submit_btn.style.display="none";document.getElementById("video_added").style.display=""}else{if(a.error&&a.error.code==500){alert("You can't add the same video twice!")}else{alert("Connection failed. Your video has not yet been added. Please try again")}}},setVideoPlayerInfo:function(c){if(c.results&&c.results.length){document.getElementById("video_title").innerHTML=c.results[0].title||"";var b=c.results[0].description||"";b=b.replace(/\n/g,"<br/>");document.getElementById("video_description").innerHTML=b;document.getElementById("video_views").innerHTML=c.results[0].views;var a=document.forms.copy_video;a.duration.value=c.results[0].duration;if(!a.submit_btn.getAttribute("loggedout")){a.submit_btn.className="greyBtnBig";a.submit_btn.disabled=""}}else{if(c.error){if(c.error.code==100){document.getElementById("column1").innerHTML='<h1>This video could not be found.</h1><p><a href="'+video_uri+'">Go to the Video Gallery &gt;</a></p><p>&nbsp;</p>';document.getElementById("column2").style.display="none"}}}},setRelatedVideos:function(e){if(e.results){var b=e.results;document.getElementById("preview_loader").style.display="none";var c=document.getElementById("video_gallery");c.innerHTML="";for(var a in b){if(b[a]&&b[a].video_id&&b[a].title&&b[a].duration){var d=TAGGED.videos.createPreviewBox(b[a]);c.appendChild(d)}}}},getComments:function(b){if(!b){var b=1}var a={method:"tagged.ytvideos.getComments",video_id:vid,offset:b,num_comments:10,callback:"TAGGED.videos.setComments"};TAGGED.api.call(a)},setComments:function(d){if(d.stat=="ok"&&d.results.contents&&document.getElementById("video_comments")){var c=document.getElementById("video_comments");c.innerHTML=d.results.contents}var a=YAHOO.util.Dom.getElementsByClassName("comment_txt","div","video_comments");for(var b=0;b<a.length;b++){if(a[b].innerHTML.length>32){a[b].innerHTML=tagged.util.string.breakString(a[b].innerHTML,32)}}},addComment:function(){var a=document.forms.post_comment;if(a.comment_text.value==""){return false}else{a.submit_btn.value="Posted!";a.submit_btn.disabled="disabled";a.submit_btn.className="btnDisabled";tagged.util.captcha.verify(TAGGED.videos.completeAddComment)}},completeAddComment:function(){var c=document.forms.post_comment;var a=c.comment_text.value;var b=[{method:"tagged.ytvideos.addComment",video_id:vid,text:a,callback:"TAGGED.videos.commentsUpdated"}];TAGGED.api.call(b);c.comment_text.value="";c.comment_text.focus()},activateCommentBtn:function(){var a=document.forms.post_comment;a.submit_btn.value="Post!";a.submit_btn.disabled="";a.submit_btn.className="greyBtn"},deleteComment:function(b){if(!document.getElementById("vid_comment_"+b)){return false}else{if(confirm("Are you sure you want to delete your comment?")){var a={method:"tagged.ytvideos.removeComment",video_id:vid,comment_id:b,callback:"TAGGED.videos.commentsUpdated"};TAGGED.api.call(a);var c=document.getElementById("video_comments");var d=document.getElementById("vid_comment_"+b);c.removeChild(d)}}},commentsUpdated:function(c){if(c.error){if(c.error.code==203){alert("Your comment includes HTML or banned content. Please fix and try again.")}}else{if(c.stat=="fail"||(c.results&&c.results.success!=1)){alert("Connection failed. Please try again")}else{var a=document.forms.post_comment;a.comment_text.value="";a.comment_text.focus();TAGGED.videos.getComments()}}var b=window.setTimeout(TAGGED.videos.activateCommentBtn,5000)},reportCommentSpam:function(d,c,b){d.parentNode.innerHTML="Reported!";var a={method:"tagged.usermgmt.reportSpam",uid_to_report:c,content_type:"comment_video",content_id:b,content_body:document.getElementById("cmt_txt_"+b).innerHTML,callback:"TAGGED.videos.spamReported"};TAGGED.api.call(a)},spamReported:function(a){if(a.results&&a.results.ERROR_FLAG!=0){alert("An error occured. Unable to report this comment as spam.")}},createCopyDropdown:function(f){if(f.result&&document.forms.copy_video){var d=document.forms.copy_video;var e=d.box_list;var a=f.result.custom_boxes||[];for(var b=0;b<a.length;b++){if(a[b].title&&a[b].id){var c=document.createElement("option");c.value=a[b].id;c.innerHTML="Copy to "+a[b].title;e.appendChild(c)}}}},copyVideo:function(){var d=document.forms.copy_video;var a=document.getElementById("embed_code").value;var c=d.box_list.value;d.submit_btn.className="greyBtnBig btn_disabled";d.submit_btn.disabled="disabled";switch(c){case"primary_video":var b=[{method:"tagged.ytvideos.addProfileVideo",video_id:d.vid.value,title:document.getElementById("video_title").innerHTML,duration:d.duration.value,is_primary:1,callback:"TAGGED.videos.copyVideoCallback"}];TAGGED.api.call(b);break;case"my_videos":var b=[{method:"tagged.ytvideos.addProfileVideo",video_id:d.vid.value,title:document.getElementById("video_title").innerHTML,duration:d.duration.value,callback:"TAGGED.videos.copyVideoCallback"}];TAGGED.api.call(b);break;case"messages":case"give_props":case"edit_journal":case"add_a_box":var d=document.forms[c];d.embedContents.value=a;d.submit();break;default:var b=[{method:"tagged.widget.addWidgetToBox",app_id:"YouTube",content:a,box_id:c,callback:"TAGGED.videos.copyVideoCallback"}];TAGGED.api.call(b);break}},copyVideoCallback:function(c){var a=document.forms.copy_video;a.submit_btn.className="greyBtnBig";a.submit_btn.disabled="";if(c.stat=="ok"&&c.result&&c.result.success==1){var b=document.getElementById("copied");b.innerHTML="Copied!";b.style.visibility="visible";setTimeout("document.getElementById('copied').style.visibility='hidden'",5000)}else{if(c.stat=="fail"&&c.error&&c.error.code==100&&c.error.message){var b=document.getElementById("copied");b.innerHTML=c.error.message;b.style.visibility="visible";setTimeout("document.getElementById('copied').style.visibility='hidden'",5000)}else{if(c.stat=="fail"&&c.error&&c.error.code==300){window.location=base_uri}else{if(c.stat=="fail"&&c.error&&c.error.message){alert(c.error.message)}else{alert("Connection failed. Your video was not copied, please refresh the page and try again.")}}}}},getGalleryResults:function(b){if(!b||b<1){var b=1}var a=[{method:"tagged.ytvideos.getProfileVideos",user_id:uid,offset:((b-1)*resultsPerPage)+1,num_videos:resultsPerPage,callback:"TAGGED.videos.setGalleryResults"}];TAGGED.api.call(a)},setGalleryResults:function(e){if(e.results){var c=e.results.videosSet||[];var a=document.getElementById("video_gallery");a.innerHTML="";if(c.length>0){for(var b in c){if(c[b]&&c[b].video_id&&c[b].title&&c[b].duration&&c[b].is_deleted=="N"){var d=TAGGED.videos.createPreviewBox(c[b]);a.appendChild(d)}}TAGGED.videos.setGalleryNav(c.length,e.results.totalCount)}else{if(e.results.totalCount>0){TAGGED.videos.navigatePage("1")}else{if(pageType=="primary_gallery"){a.innerHTML='<p class="novideos">No Videos. <a href="'+url_base+'/add_videos.html">Add Videos!</a></p>'}else{a.innerHTML='<p class="novideos">No Videos. <a href="'+video_uri+'">Check Out Tagged Video!</a></p>'}}}TAGGED.videos.toggleLoader()}},setGalleryNav:function(b,g){var a=document.getElementById("video_count");var c=parseInt(YAHOO.util.History.getCurrentState("pageNum"));var d=Math.ceil(g/resultsPerPage);var f=c*resultsPerPage-resultsPerPage+1;a.innerHTML="Videos "+(f)+" - "+(f+(b-1))+" of "+g;var e="";if(c>1){e+='<span class="smaller_font"><a href="#" onclick="TAGGED.videos.navigatePage(\'1\'); return false;">&lt;&lt; First</a></span>';e+='<span><a href="#" onclick="TAGGED.videos.navigatePage(\''+(c-1)+"'); return false;\">&lt; Previous</a></span>"}else{e+='<span class="smaller_font">&lt;&lt; First</span>';e+="<span>&lt; Previous</span>"}e+='<span class="devider">|</span>';if(c<d){e+='<span><a href="#" onclick="TAGGED.videos.navigatePage(\''+(c+1)+"'); return false;\">Next &gt;</span>";e+='<span class="smaller_font"><a href="#" onclick="TAGGED.videos.navigatePage(\''+d+"'); return false;\">Last &gt;&gt;</span>"}else{e+="<span>Next &gt;</span>";e+='<span class="smaller_font">Last &gt;&gt;</span>'}if((c>1)||(c<d)){document.getElementById("nav_top").innerHTML=e;document.getElementById("nav_btm").innerHTML=e}},navigatePage:function(a){YAHOO.util.History.navigate("pageNum",String(a))},setPrimaryVideo:function(d,h){YAHOO.util.Event.stopEvent(h);var f=[{method:"tagged.ytvideos.setPrimaryVideo",video_id:d,autoplay:"N",callback:"TAGGED.videos.setPrimaryVideoCallback"}];TAGGED.api.call(f);var g=parseInt(YAHOO.util.History.getCurrentState("pageNum"));if(g!=1){TAGGED.videos.toggleLoader("show")}else{var c=document.getElementById("video_gallery");var b=document.getElementById(d);var a=b.cloneNode(true);a.className="box primary";var c=document.getElementById("video_gallery");c.firstChild.className="box";TAGGED.videos.attachPreviewBoxEvents(c.firstChild);c.insertBefore(a,c.firstChild);TAGGED.videos.attachPreviewBoxEvents(a);c.removeChild(b);window.scrollTo(0,0)}},setPrimaryVideoCallback:function(a){if(a.stat=="ok"&&a.results&&a.results.success==1){TAGGED.videos.navigatePage("1")}else{alert("An error occured. Please try again.");window.location=window.location}},deleteVideo:function(a,c){YAHOO.util.Event.stopEvent(c);var b=[{method:"tagged.ytvideos.deleteProfileVideo",video_id:a,callback:"TAGGED.videos.deleteVideoCallback"}];TAGGED.api.call(b);TAGGED.videos.toggleLoader("show")},deleteVideoCallback:function(d){if(d.stat=="ok"&&d.results&&d.results.success==1){var b=YAHOO.util.History.getCurrentState("pageNum");var a=document.getElementById("video_gallery");var c=a.childNodes;if(c.length==1){b=b-1}TAGGED.videos.getGalleryResults(b)}else{alert("An error occured. Please try again.");window.location=window.location}},showSearchResults:function(g){TAGGED.videos.toggleLoader();if(pageType=="video_index"){TAGGED.videos.setCategoryStyle()}var a=document.getElementById("video_gallery");if(g.results&&g.results.length>0){var c=g.results;a.innerHTML="";if(c.length>resultsPerPage){var e=resultsPerPage;var h=true}else{var e=c.length}for(var b=0;b<e;b++){if(c[b]&&c[b].video_id&&c[b].title&&c[b].duration){var f=TAGGED.videos.createPreviewBox(c[b]);a.appendChild(f)}}var d=parseInt(YAHOO.util.History.getCurrentState("pageNum"));TAGGED.videos.setSearchNav(d,h)}else{a.innerHTML='<p class="novideos">No results were found</p>'}},setSearchNav:function(c,e){var d="";if(c>1){d+='<span><a href="#" onclick="TAGGED.videos.navigatePage(\''+(c-1)+"'); return false;\">&lt; Previous</a></span>"}else{d+="<span>&lt; Previous</span>"}d+='<span class="devider">|</span>';if(e){d+='<span><a href="#" onclick="TAGGED.videos.navigatePage(\''+(c+1)+"'); return false;\">Next &gt;</span>"}else{d+="<span>Next &gt;</span>"}var b=document.getElementById("nav_top");var a=document.getElementById("nav_btm");if(c>1||e){b.innerHTML=d;a.innerHTML=d}else{b.innerHTML="";a.innerHTML=""}},setCategoryStyle:function(){var b=document.getElementById("vid_categories").getElementsByTagName("a");for(i in b){(YAHOO.util.History.getCurrentState("c")==b[i].title)?b[i].className="selectedFeed":b[i].className=""}}};