function woome_show_friendshare_popup(continuation){var username=woome.loggedin.username;if(username==''){return woome_signin();}
new Ajax("/iha/share_item/",{method:"get",update:$('iha_container'),onComplete:function(){woome_load_sharelist_contacts();try{var video_swf=window.document.vid_player;}
catch(e){if(navigator.appName.indexOf("Microsoft")!=-1){var video_swf=window.vid_player;}}
if(video_swf){video_swf.pauseVideo();}
if(continuation){continuation();}},evalScripts:true}).request();}
function woome_show_profile_friendshare(user_id,firstname,thumb){$('friendshare').addClass("userProfileShareItem");$$("#friendshare_popup_content .firstname").setText(firstname);$('favorite_person').setProperty("value",user_id);$$("#friendshare_popup_content .thumbnail").setProperty("src",thumb);}
function woome_show_specific_friendshare_popup(id){$('video_share_id').setText(id);woome_show_friendshare_popup();}
function woome_show_endofsession_friendshare_popup(userid,sessionid,matchPage){woome_video_autopublish(userid,sessionid)
$('endofsession_video_share_id').setText(sessionid);woome_show_friendshare_popup(function(){woome_update_endofsession_friendshare_popup(sessionid,matchPage)});}
function woome_update_endofsession_friendshare_popup(sessionid,matchPage){$E('h3.title').setText("your video is on WooMe TV, share it with friends!");if(matchPage=="redirect"){$$("#btnCloseSharePopup").setProperty("href","/session/"+sessionid+"/match/");$$(".cancelItemShare").setProperty("href","/session/"+sessionid+"/match/");}}
var woome_update_sharelist_checked_counter=function(node,decr){try{if(node.checked){$('shareListSelectedCounter').setText(parseInt($('shareListSelectedCounter').getText())+1);}
else if(decr===true){$('shareListSelectedCounter').setText(parseInt($('shareListSelectedCounter').getText())-1);}}
catch(e){}}
function woome_load_sharelist_contacts(){var username=woome.loggedin.username;$('shareListUL').addEvent('click',function(event){var target=event.target;if($(target).getTag()=='input'&&target.getAttribute('type')=='checkbox'){woome_update_sharelist_checked_counter(target,true);event.stopPropagation();}}.bindWithEvent())
woome__get_sharelist_fragment('/'+username+'/friendshare/popular/?limit=30',function(xml){$('shareListLoading').addClass('hidden');if(xml.getElementsByTagName('li').length===0){$E('.friendFinder').removeClass('hidden');$('video_friendshare_form').addClass('hidden');return false;}
else{$E('.friendFinder').addClass('hidden');$('friendFinderLogin').removeClass('hidden');$('friendFinderLoading').addClass('hidden');$('video_friendshare_form').removeClass('hidden');}
$('shareListNotEmpty').removeClass('hidden');});}
function woome_load_all_sharelist(username){$('loadAllContacts').setText("please wait - loading all contacts...").removeProperty("onclick").setStyle("text-decoration","none");$('shareListUL').empty();$('shareListSelectedCounter').setText("0");$('shareListCounter').setText("0");woome__get_sharelist_fragment('/'+username+'/friendshare/?limit=50',function(){},function(){},function(){$('loadAllContacts').remove();$('shareList').addClass("full");});}
function woome__get_sharelist_fragment(url,success_callback,failure_callback,completed_callback){var get_input_from_li=function(li){try{return li.getElementsByTagName('input')[0];}
catch(e){}}
var chain_callback=function(txt,xml){if(document.importNode){var lis=xml.getElementsByTagName('li');$('shareListCounter').setText(parseInt($('shareListCounter').getText())+lis.length);for(var i=0;i<lis.length;i++){var node=document.importNode(lis[i],true);woome_update_sharelist_checked_counter(get_input_from_li(node));$('shareListUL').appendChild(node);}
var next=xml.getElementById('next_fragment');}else{var x=document.createElement('div');x.innerHTML=txt;var lis=x.getElementsByTagName('li');$('shareListCounter').setText(parseInt($('shareListCounter').getText())+lis.length);while(lis.length)
{var node=document.getElementById('shareListUL').appendChild(lis[0]);woome_update_sharelist_checked_counter(get_input_from_li(node));}
top._x=x;var next=null;var links=x.getElementsByTagName('a');for(var i=links.length-1;i>=0;i--){if(links[i].id=='next_fragment'){next=links[i];break;}}}
if(next){var url=next.getAttribute('href');completed_callback!==undefined?completed_callback:function(){};woome__get_sharelist_fragment(url,null,null,completed_callback);}
else{if(completed_callback){completed_callback();}}}
new Ajax(url,{'method':'get','onComplete':function(responseText,responseXML){if(success_callback){if(success_callback(responseXML)===false){return false;}}chain_callback(responseText,responseXML);},'onFailure':failure_callback!==undefined?failure_callback:function(){}}).request();}
function woome_friendshare_import(){$E('.friendFinder').removeClass('hidden');$('video_friendshare_form').addClass('hidden');}
function woome_friendshare_get_contacts(){var username=woome.loggedin.username;$('friendFinderLogin').addClass('hidden');$('friendFinderLoading').removeClass('hidden');new Ajax('/'+username+'/friendshare/import_from_email_account/',{'method':'post','data':$('AddressBookImportForm'),'update':$('contactBlock'),'onSuccess':function(){woome_load_sharelist_contacts();},'onFailure':function(){},'isSuccess':function(code){return(code>=200&&code<300||code==401)}}).request();}
function woome_friendshare_delete_contact(divid,emailaddress){var get_input_from_li=function(li){try{return li.getElementsByTagName('input')[0];}
catch(e){}}
var username=woome.loggedin.username;var li=$('contact_'+divid);li&&li.addClass('hidden');new Ajax('/'+username+'/friendshare/',{'method':'post','data':{'delete':'delete','emailaddress':emailaddress},'isSuccess':function(code){return code==204||code==1223;},'onSuccess':function(){if(li){var inp=get_input_from_li(li);if(inp.checked){inp.checked=false;woome_update_sharelist_checked_counter(inp,true);}
li.remove();}
$('shareListCounter').setText(parseInt($('shareListCounter').getText())-1);},'onFailure':function(){li&&li.removeClass('hidden');}}).request();}
function woome_toggle_additionalemails(){$("emailBlock").toggleClass("minimised");}
function woome_friendfinder_hidepopup(e){if(e.checked){Cookie.set('hide_friendfinder','yes',{domain:'woome.com',path:'/',duration:'14'});}
else{Cookie.remove('hide_friendfinder',{domain:'woome.com',path:'/'});}}
function woome_friendshare_submit_video(){$E(".buttonShareNow").addClass("greyedOut").setProperty("href","javascript;:");var username=woome.loggedin.username;var video_id='';var session_id='';var session_match_page=false;try{video_id=$('video_share_id').getText();}
catch(e){try{session_id=$('endofsession_video_share_id').getText();session_match_page=true;}
catch(e){}}
path='/'+username+'/friendshare/video/';if(video_id!=''){path+=video_id+'/';}else if(session_id!=''){path+='session/'+session_id+'/';}else{path+=(/\/video\/([0-9]+)\//.exec(document.location.pathname)[1])+'/';}
new Ajax(path,{'method':'post','data':$('video_friendshare_form'),'onSuccess':function(txt,xml){var spans=xml.getElementsByTagName('span');var count=null;for(var i=0;i<spans.length;i++){if(spans[i].getAttribute('id')=='count'){count=spans[i].textContent!==undefined?spans[i].textContent:spans[i].text;}}
if(count!==null&&count>0){$('friendshare').addClass('hidden');var message="<h3>great news!</h3><p>video sent successfully to friends</p>";woome_generic_alert_OK(message,function(){$('generic_alert_container').addClass('hidden');},true);if($('fav_video')!=undefined&&$('fav_video').getProperty("checked")){woome_favourite_video();}
if(session_match_page){window.location='/session/'+session_id+'/match/';}}
else{woome_import_asset('friendshare_nocontacts',function(){woome_render_popup('#friendshare_alert_container');});}},'onFailure':function(){$('friendshare').addClass('hidden');var message="<h3>uh-oh</h3><p>something went wrong with your submission - please try again</p>";woome_generic_alert_OK(message,function(){document.location.reload();});}}).request();}
function woome_favoriteshare_submit(){$E(".buttonSendNow").addClass("greyedOut").setProperty("href","javascript;:");var username=woome.loggedin.username;path='/'+username+'/friendshare/favorite/';new Ajax(path,{'method':'post','data':$('video_friendshare_form'),'onSuccess':function(txt,xml){var spans=xml.getElementsByTagName('span');var count=null;for(var i=0;i<spans.length;i++){if(spans[i].getAttribute('id')=='count'){count=spans[i].textContent!==undefined?spans[i].textContent:spans[i].text;}}
if(count!==null&&count>0){var message="<h3>great news!</h3><p>profile sent successfully to friends</p>";woome_generic_alert_OK(message,function(){$('generic_alert_container').addClass('hidden');},true);}
else{woome_import_asset('profileshare_nocontacts');}},'onFailure':function(){var message="<h3>uh-oh</h3><p>something went wrong with your submission - please try again</p>";woome_generic_alert_OK(message,function(){document.location.reload();});}}).request();}
function woome_favourite_video(video_id){woome_disable_link_item('favouriteVideoLink');if(!video_id){var video_id=$('meeting_id').getText();}
var req=new Ajax("/video/"+video_id+"/favourite/",{method:"post",data:"switch=yes",onSuccess:function(){if($("favouriteVideo").hasClass("favouriteVideoOn")){$("favouriteVideo").removeClass("favouriteVideoOn");$("favouriteVideo").addClass("favouriteVideo");$("favouriteVideoLink").setHTML("add to favorites");$("favouriteVideoLink").setProperty('href','javascript:woome_favourite_video('+video_id+')');$("favouriteVideoLink").removeClass('greyedOut');}
else{$("favouriteVideo").removeClass("favouriteVideo");$("favouriteVideo").addClass("favouriteVideoOn");$("favouriteVideoLink").setHTML("video is a fave!");$("favouriteVideoLink").setProperty('href','javascript:woome_favourite_video('+video_id+')');$("favouriteVideoLink").removeClass('greyedOut');}},onFailure:function(){}}).request();}
function woome_clear_share_inputs(){if($E('#emailBlock input').hasClass('greyedOut')){$$('#emailBlock input').setProperty('value','');$$('#emailBlock input').removeClass('greyedOut');}}
var is_select=true;function woome_toggle_share_checkboxes(){if(is_select===true){var t=document.getElementById('shareListUL').getElementsByTagName('input');for(var i=0;i<t.length;i++){t[i].setAttribute('checked','checked');t[i].checked=true;}
$('shareListSelectedCounter').setText(t.length);$E('#checkboxToggle span').setText('deselect');is_select=false;}
else{var s=document.getElementById('shareListUL').getElementsByTagName('input');for(var i=0;i<s.length;i++){s[i].removeAttribute('checked');s[i].checked=false;}
$('shareListSelectedCounter').setText(0);$E('#checkboxToggle span').setText('select');is_select=true;}}