// used with the famecast player in /flash/fcp/ function famecastCallBack(e) { //console.log('javascript from jw:'); //console.log(e); //console.log('----------'); } function newsUpdate () { var last_id = $('news_id').value; new Ajax.Request('/ajax/newsfeed.php?last_id='+last_id, { method: 'get', asynchronous: true, onSuccess: function(transport) { Effect.Fade('newsticker',{duration:0.5, afterFinish:function(){ $('newsticker').innerHTML = transport.responseText; Effect.Appear('newsticker',{duration:0.5}); } }); } }); } function submitForgottenPassword() { var email = document.getElementById('login_email').value; if(email=="" || email.length<6 || email.indexOf('@')==-1 || email.indexOf('@')!=email.lastIndexOf('@')) { alert("You must supply a valid email address to recover a forgotten password."); } else { location.href = '/forgot_password.php?login_email='+email; } return false; } function getLoginBox() { var mypg = 0; // if an argument is given, it is the name of the calling script (PHP_SELF) if (arguments.length > 0) mypg = arguments[0]; new Ajax.Request('/ajax/loginbox.php', { method: 'get', asynchronous: true, parameters: {my_page: mypg}, onComplete: function(transport) { var data = transport.responseText.evalJSON(); fc_user_type = data['fc_user_type']; $('login_box').innerHTML = data['output']; $('admin_login_box').innerHTML = data['admin_output']; if(data['admin_output'] != "") $('admin_login_box').style.height = "auto"; $('label_login_box').innerHTML = data['label_output']; if(data['label_output'] != "") $('label_login_box').style.height = "auto"; if(data['pollchat'] && data['pollchat']==1) pollChat(); if(userTypeLoaded) userTypeLoaded(); } }); } function getCartLinkBox() { new Ajax.Request('/ajax/cart.php', { method: 'get', asynchronous: true, onComplete: function(transport) { var data = transport.responseText.evalJSON(); $('cart_link').innerHTML = data['output']; } }); } var windowsArray = new Array(); var pe; function pollChat() { pe = new PeriodicalExecuter(checkChat,20); } var insertArray = []; function checkChat() { new Ajax.Request('/chat/', { method: 'post', asynchronous: true, postBody: 'action=check', onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1) { pe.stop(); var items = data['sessions']; items.each(function(item) { var session_id = item['session_id']; var p_id = item['p_id']; var friend = item['friend']; if (windowsArray[p_id] && windowsArray[p_id].open && !windowsArray[p_id].closed) { // popup already there, don't refresh } else { //let's spawn a new popup if (friend != 1 && friend != 0) { var req_check = true; } else { if( insertArray.indexOf(p_id) == -1 ) { insertArray.push(p_id); new Ajax.Request('/chat/', { method: 'post', asynchronous: true, postBody: 'action=req&p_id='+p_id+'&session_id='+session_id, onSuccess: function(transport){ Sound.play('/sounds/beep.mp3',{track:'fctrack'}); var data = transport.responseText.evalJSON(); var win = new Window({id: 'req_'+p_id, className: "famecast", width:302, height:122, zIndex: 1000, resizable: false, title: "Chat Request", showEffect:Effect.Appear, showEffectOptions: {duration:0.3}, hideEffect: Effect.Fade, hideEffectOptions: {duration:0.3}, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false, onClose: function(){ ignoreChat(session_id,p_id);} }) ; win.getContent().innerHTML = data['msg']; win.showCenter(true); } }); } } if(req_check == true) { acceptChat(session_id,p_id); } else { //nada } } }); //alert(insertArray.join(", ")); } } }); } function acceptChat(session_id,p_id) { if($('req_'+p_id)) { Windows.close('req_'+p_id); } windowsArray[p_id] = window.open ("/chat/?session_id="+session_id,p_id,"location=0, status=0, scrollbars=0, resizable=0,menubar=0, toolbar=0, directories=0, width=360, height=360"); windowsArray[p_id].focus(); insertArray = removeItems(insertArray, p_id); pollChat(); } function declineChat(session_id,p_id) { if($('req_'+p_id)) { Windows.close('req_'+p_id); } new Ajax.Request('/chat/', { method: 'post', asynchronous: true, postBody: 'action=decline&session_id='+session_id }); insertArray = removeItems(insertArray, p_id); pollChat(); } function ignoreChat(session_id,p_id) { if($('req_'+p_id)) { Windows.close('req_'+p_id); } new Ajax.Request('/chat/', { method: 'post', asynchronous: true, postBody: 'action=ignore&session_id='+session_id }); insertArray = removeItems(insertArray, p_id); pollChat(); } function blockChat(session_id,p_id) { if($('req_'+p_id)) { Windows.close('req_'+p_id); } new Ajax.Request('/chat/', { method: 'post', asynchronous: true, postBody: 'action=block&session_id='+session_id }); insertArray = removeItems(insertArray, p_id); pollChat(); } function startPollers() { //new PeriodicalExecuter(newsUpdate,10); } function cartNotLoggedIn() { alert("You must be signed in to add items to your cart. Please sign in now to continue."); return false; } function iWantThisMedia(artist_id, media_type, media_id, sub_status, fan_id) { new Ajax.Request('/ajax/iwantit.php', { asynchronous: true, parameters: {action:'addmedia', artist_id:artist_id, media_type:media_type, media_id:media_id, sub_status:sub_status, fan_id:fan_id }, onSuccess: function(transport) { var content = ""; if(transport.responseText.isJSON()) { var data = transport.responseText.evalJSON(); if(data['status']==1) { var media_id = data['media_id']; var media_type = data['media_type']; var sub_status = data['sub_status']; var artist_id = data['artist_id']; var fan_id = data['fan_id']; content = "
"+data['content']+"
"; } else { content = "
We're sorry, there was a system error. Please try again later.
"; } } else { content = "
Failed to submit media request. Please try again later.
"; } var window_id = 'iwantit_window'; var window_title = "Thank you. We've sent your request."; var win = Windows.getWindow(window_id); if(win && win.close) { win.close(); } win = new Window({id: window_id, className: "famecast", width:322, height:72, zIndex: 1001, resizable: false, title: window_title, showEffect: Element.show, hideEffect: Element.hide, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false, onClose: function(){ } }); win.getContent().innerHTML = content; win.showCenter(true); } }); } function launchChat(fan_id) { var openChat = 0; if(fan_id > 0) { if (windowsArray[fan_id] && windowsArray[fan_id].open && !windowsArray[fan_id].closed) { // popup already there, don't refresh windowsArray[fan_id].focus(); } else { // Check if partner is online new Ajax.Request('/chat/', { method: 'post', asynchronous: false, postBody: 'action=partner_status&partner_id='+fan_id, onSuccess: function(transport){ var data = transport.responseText.evalJSON(); // check if user is logged in if(data['is_logged_in'] == 0) { var ctext = ""; if(data['status'] == 0) { ctext = "You need to be logged in to leave a message"; } else { ctext = "You need to be logged in to use the chat"; } var rtl = confirm(ctext); if(rtl) { location.href='/login.php'; } } else if(data['is_logged_in'] == 1) { // check if partner is logged in // status: 1 iff the partner is logged in. f: 1 iff the partner is a friend of the current user if(data['status'] == 0) { if(data['f'] == 1) { var win = new Window({id: 'lau_'+fan_id, className: "famecast", width:302, height:180, zIndex: 1000, resizable: false, title: "Leave Offline Message", showEffect:Effect.Appear, showEffectOptions: {duration:0.3}, hideEffect: Effect.Fade, hideEffectOptions: {duration:0.3}, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false}); win.getContent().innerHTML = data['msg']; win.showCenter(true); } else { if(data['is_artist'] == 1) { // trying to chat w. offline artist if(data['fan_of_them'] == 1) { var win = new Window({id: 'lau_'+fan_id, className: "famecast", width:302, height:180, zIndex: 1000, resizable: false, title: "Leave Offline Message", showEffect:Effect.Appear, showEffectOptions: {duration:0.3}, hideEffect: Effect.Fade, hideEffectOptions: {duration:0.3}, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false}); win.getContent().innerHTML = data['msg']; win.showCenter(true); } else { var fr = confirm("You must be a fan of this artist in order to leave an offline message. Do you want to join their fan club?"); if(fr) { top.ether.location.href='/backstage/artist.php?artist_id='+data['artist_id']+'&action=joinfanclub'; } } } else if(0 == 1) { // I'm an artist trying to chat w. offline fan if(data['fan_of_me'] == 1) { var win = new Window({id: 'lau_'+fan_id, className: "famecast", width:302, height:180, zIndex: 1000, resizable: false, title: "Leave Offline Message", showEffect:Effect.Appear, showEffectOptions: {duration:0.3}, hideEffect: Effect.Fade, hideEffectOptions: {duration:0.3}, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false}); win.getContent().innerHTML = data['msg']; win.showCenter(true); } else { // I can't add them to my fan club, so we can't chat alert("This user is not a member of your fan club. You cannot chat with them."); } } else { var fr = confirm("You must be a friend in order to leave an offline message. Do you want to send a friend request?"); if(fr) { top.ether.location.href='/fans/profile.php?action=friendrequest&fanforce=1&fan_id='+fan_id; } } } } else if(data['status'] == 1) { if(data['f'] == 1) { openChat = 1; } else { if(data['is_artist'] == 1) { // trying to chat w. online artist if(data['fan_of_them'] == 1) { var win = new Window({id: 'lau_'+fan_id, className: "famecast", width:302, height:180, zIndex: 1000, resizable: false, title: "Leave Offline Message", showEffect:Effect.Appear, showEffectOptions: {duration:0.3}, hideEffect: Effect.Fade, hideEffectOptions: {duration:0.3}, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false}); win.getContent().innerHTML = data['msg']; win.showCenter(true); } else { var fr = confirm("You must be a fan of this artist in order to chat. Do you want to join their fan club?"); if(fr) { top.ether.location.href='/backstage/artist.php?artist_id='+data['artist_id']+'&action=joinfanclub'; } } } else if(0 == 1) { // I'm an artist trying to chat w. online fan if(data['fan_of_me'] == 1) { var win = new Window({id: 'lau_'+fan_id, className: "famecast", width:302, height:180, zIndex: 1000, resizable: false, title: "Leave Offline Message", showEffect:Effect.Appear, showEffectOptions: {duration:0.3}, hideEffect: Effect.Fade, hideEffectOptions: {duration:0.3}, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false}); win.getContent().innerHTML = data['msg']; win.showCenter(true); } else { // I can't add them to my fan club, so we can't chat alert("This user is not a member of your fan club. You cannot chat with them."); } } else { var fr = confirm("You must be a friend in order to chat with this person. Do you want to send a friend request?"); if(fr) { top.ether.location.href='/fans/profile.php?action=friendrequest&fanforce=1&fan_id='+fan_id; } } } } } } }); } } if(openChat == 1) { windowsArray[fan_id] = window.open ("/chat/?action=init&partner_id="+fan_id,fan_id,"location=0, status=0, scrollbars=0, resizable=1,menubar=0, toolbar=0, directories=0, width=360, height=360"); windowsArray[fan_id].focus(); } } function chatInfo() { var rtl = confirm("You need to be logged in to use the chat"); if(rtl) { location.href='/login.php'; } } function offlineMessage(request, fan_id) { new Ajax.Request('/chat/?action=offline&partner_id='+fan_id,{ method: 'post', asynchronous: true, parameters:$(request).serialize(true), onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1) { $('txt_'+fan_id).value = ''; Windows.close('lau_'+fan_id); } } }); } function deleteOffline(message_id) { var delcheck = confirm("Are you sure you want to delete this message?"); if(delcheck) { new Ajax.Request('/chat/?action=delete&message_id='+message_id,{ method: 'post', asynchronous: true, onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1) { new Effect.Fade('m_'+message_id, {duration: 0.5, afterFinish: function(){ $('m_'+message_id).remove(); } }); } } }); updateInboxCount(); } } function updateInboxCount() { new Ajax.Updater({ success: 'inboxcount' }, '/ajax/messages.php', { asynchronous: true }); } function expandInbox(message_id){ $('longmsg_'+message_id).show(); $('shortmsg_'+message_id).hide(); } function minimizeInbox(message_id){ $('longmsg_'+message_id).hide(); $('shortmsg_'+message_id).show(); } function removeItems(array, item) { var i = 0; while (i < array.length) { if (array[i] == item) { array.splice(i, 1); } else { i++; } } return array; } function loadPaging(artist_id, fan_id, type, offset) { new Ajax.Request('/ajax/pagination.php?artist_id='+artist_id+'&fan_id='+fan_id+'&type='+type+'&offset='+offset, { asynchronous: true, onCreate: function() { Element.setOpacity(type, 0.4); new Insertion.Before(type, '
Loading
'); }, onSuccess: function(transport) { var data = transport.responseText.evalJSON(); if(data['status'] == 1) { $(type+'_content').innerHTML = data['content']; new Effect.Opacity(type, { duration:0.3, from:0.4, to:1.0, queue:'end' }); $('loadingbar').remove(); $(type+'_actions').innerHTML = data['actions']; } } }); } function loadPaging2(artist_id, fan_id, type, offset) { new Ajax.Request('/ajax/pagination.php?artist_id='+artist_id+'&fan_id='+fan_id+'&type='+type+'2&offset='+offset, { asynchronous: true, onCreate: function() { Element.setOpacity(type, 0.4); new Insertion.Before(type, '
Loading
'); }, onSuccess: function(transport) { var data = transport.responseText.evalJSON(); if(data['status'] == 1) { $(type+'_content').innerHTML = data['content']; new Effect.Opacity(type, { duration:0.3, from:0.4, to:1.0, queue:'end' }); $('loadingbar').remove(); $(type+'_actions').innerHTML = data['actions']; } } }); } // see http://www.geocities.com/Athens/Academy/4038/graph/fontset.htm for Unicode reference function replaceWeirdCharacters(s) { var es = encodeURI(s); // replace 'smart quote' characters: es = es.replace(/%E2%80%98/g, "'"); es = es.replace(/%E2%80%99/g, "'"); es = es.replace(/%E2%80%9A/g, "'"); es = es.replace(/%E2%80%9B/g, "'"); es = es.replace(/%E2%80%B2/g, "'"); es = es.replace(/%E2%80%9C/g, "\""); es = es.replace(/%E2%80%9D/g, "\""); es = es.replace(/%E2%80%9E/g, "\""); es = es.replace(/%E2%80%B3/g, "\""); // replace long-dash character es = es.replace(/%E2%80%93/g, "--"); es = es.replace(/%E2%80%94/g, "--"); es = es.replace(/%E2%80%95/g, "--"); //alert('comments='+es); es = es.replace(/%E2%80%A6/g, "..."); es = es.replace(/%E2%80%97/g, "="); var ds = decodeURI(es); return ds; } function getColleges(element, state_id, labelclass) { if(labelclass == undefined){ labelclass = ''; } new Ajax.Updater(element, '/ajax/colleges.php?state_id='+state_id+'&labelclass='+labelclass); } // IMPORTANT // function toggleLayer(name){ if($('outer_min_layer_'+name)){ closeMinLayer(name); } if(name == 'audio' && $('outer_layer_bookmark')){ closeLayer('bookmark', 1); } else if (name == 'bookmark' && $('outer_layer_audio')) { closeLayer('audio', 1); } if(!$('outer_layer_'+name)) { var markup = '
'; //new Insertion.Before('bodywrap', markup); new Insertion.After('login_box', markup); new Ajax.Updater('inner_layer_'+name, '/layers/'+name+'.php', { evalScripts: true, onComplete: function(){ Effect.toggle('layer_'+name, 'slide', { duration: 0.5, //hack to deal with overflow issue when using Effect.Slide afterFinish: function(){ if($('tracks')){ $('tracks').setStyle({overflowY: 'scroll', overflowX: 'hidden'}); } if($('bookmarks')){ $('bookmarks').setStyle({overflowY: 'scroll', overflowX: 'hidden'}); } if($('playlists')){ $('playlists').setStyle({overflowY: 'auto', overflowX: 'hidden'}); } if($('folders')){ $('folders').setStyle({overflowY: 'auto', overflowX: 'hidden'}); } if($('playinfo')){ $('playinfo').setStyle({overflowY: 'hidden', overflowX: 'hidden'}); } // highlight current playlist track if there is one if(pl_current_item > 0 && $('track_'+pl_current_item)){ selectTrack(pl_current_item); location.hash='#anchor_track_'+pl_current_item; location.hash='#top'; } if(bm_current_item > 0 && $('track_'+bm_current_item)){ location.hash='#anchor_track_'+bm_current_item; location.hash='#top'; } } }); } }); if(name == 'audio'){ var bname = 'playlist'; } else { var bname = name; } var img_src = '/img/greg/nav5/nav_'+bname+'_on.png'; if(name == 'bookmark'){ img_src = '/img/35/fc35_icon_bookmark_on.gif'; } else if(name == 'playlist' || name == 'audio') { img_src = '/img/35/fc35_icon_playlist_on.gif'; } $(name+'button').src = img_src; $(name+'button').addClassName('active'); } else { closeLayer(name, 1); } } function closeLayer(name, cb){ if($('layer_'+name).visible()) { Effect.toggle('layer_'+name, 'slide', { duration: 0.5, //hack to deal with overflow issue when using Effect.Slide beforeStart: function(){ if(name == 'audio'){ if($('tracks')){ $('tracks').setStyle({overflowY: 'hidden'}); } if($('playlists')){ $('playlists').setStyle({overflowY: 'hidden'}); } if($('playinfo')){ $('playinfo').setStyle({overflowY: 'hidden'}); } } if(name == 'bookmark'){ if($('bookmarks')){ $('bookmarks').setStyle({overflowY: 'hidden'}); } if($('folders')){ $('folders').setStyle({overflowY: 'hidden'}); } } }, afterFinish: function() { $('outer_layer_'+name).remove(); } }); } else { $('outer_layer_'+name).remove(); } if(cb == 1){ new Ajax.Request('/ajax/'+name+'.php?action=toggle_layer', { parameters: {status: 0} }); if(name == 'audio'){ var bname = 'playlist'; } else { var bname = name; } var img_src = '/img/greg/nav5/nav_'+bname+'_off.png'; if(name == 'bookmark'){ img_src = '/img/35/fc35_icon_bookmark_orange.gif'; } else if(name == 'playlist' || name == 'audio') { img_src = '/img/35/fc35_icon_playlist_orange.gif'; } $(name+'button').src = img_src; $(name+'button').removeClassName('active'); } } function closeMinLayer(name, cb){ if($('min_layer_'+name).visible()) { Effect.toggle('min_layer_'+name, 'slide', { duration: 0.5, afterFinish: function() { $('outer_min_layer_'+name).remove(); } }); } else { $('outer_min_layer_'+name).remove(); } if(cb == 1){ new Ajax.Request('/ajax/'+name+'.php?action=toggle_layer', { parameters: {status: 0} }); if(name == 'audio'){ var bname = 'playlist'; } else { var bname = name; } var img_src = '/img/greg/nav5/nav_'+bname+'_off.png'; if(name == 'bookmark'){ img_src = '/img/35/fc35_icon_bookmark_orange.gif'; } else if(name == 'playlist' || name == 'audio') { img_src = '/img/35/fc35_icon_playlist_orange.gif'; } $(name+'button').src = img_src; $(name+'button').removeClassName('active'); } } function toggleMinimizedLayer(name){ if($('outer_layer_'+name)){ closeLayer(name); } if(!$('outer_min_layer_'+name)){ var markup = '
'; //alert('close minlayer'); //new Insertion.Before('bodywrap', markup); new Insertion.After('login_box', markup); new Ajax.Updater('inner_min_layer_'+name, '/layers/min_'+name+'.php', { evalScripts: true, onSuccess: function(){ Effect.toggle('min_layer_'+name, 'slide', { duration: 0.5 }); new Ajax.Request('/ajax/'+name+'.php?action=toggle_layer', { parameters: {status: 2} }); } }); if(name == 'audio'){ var bname = 'playlist'; } else { var bname = name; } var img_src = '/img/greg/nav5/nav_'+bname+'_off.png'; if(name == 'bookmark'){ img_src = '/img/35/fc35_icon_bookmark_orange.gif'; } else if(name == 'playlist' || name == 'audio') { img_src = '/img/35/fc35_icon_playlist_orange.gif'; } $(name+'button').src = img_src; $(name+'button').removeClassName('active'); } else { closeMinLayer(name, 1); } } var playlistUpdated = false; function playlistSelect(el,pl_type) { var pl_prefix = (pl_type==1?'f_':(pl_type==2?'c_':'')); if($(pl_prefix+'pl_'+el).hasClassName('selected') && playlistUpdated == false && $(pl_prefix+'pl_'+el).descendantOf('playlist_b')){ var editor = new Ajax.InPlaceEditor(pl_prefix+'pl_'+el,'/ajax/audio.php?action=update_playlist&id='+el,{ okButton: false, cancelLink:false, submitOnBlur:true, formClassName:'playlist_ipe', savingText:'', onComplete: function(){ editor.dispose(); renderPlaylist(current_playlist); } }); editor.enterEditMode('click'); } else { if(playlistUpdated == false){ $$('ul.playlist li').invoke('removeClassName', 'selected'); //check if there are any unprocessed InPlaceEditors and take care of them var openItems = $$('input.editor_field'); if(openItems.size() > 0){ openItems.invoke('blur'); } else { $(pl_prefix+'pl_'+el).addClassName('selected'); renderTracks(el); current_playlist = el; if($('playpreview').visible()){ $('playpreview').hide(); $('tracks').setStyle({height:'324px'}); } } } else { playlistUpdated = false; } } } function renderPlaylist(playlist_id){ if(playlist_id == undefined){ playlist_id = ''; } new Ajax.Updater('playlists', '/layers/audio_playlist.php?playlist='+playlist_id, { evalScripts: true, onComplete: function(){ Sortable.create('playlist_b', { dropOnEmpty:true, constraint:false, onUpdate: function(){ playlistUpdated = true; new Ajax.Request('/ajax/audio.php?action=reorder_playlist', { postBody: Sortable.serialize('playlist_b') }); } }); } }); } function renderTracks(playlist_id){ if(playlist_id == undefined){ playlist_id = ''; } new Ajax.Updater('tracks', '/layers/audio_tracks.php?playlist='+playlist_id+'¤t_item_id='+pl_current_item, { evalScripts: true, onCreate: function(){ $('tracks').update('
Loading
'); $('trackhead').update(); } }); new Ajax.Updater('trackhead', '/layers/audio_trackhead.php?playlist='+playlist_id, { evalScripts: true }); } function renderInfo(item_id){ if(item_id == undefined){ item_id = ''; } new Ajax.Updater('playinfo', '/layers/audio_info.php?item_id='+item_id, { evalScripts: true }); } function renderPreview(item_id){ if(item_id == undefined){ item_id = ''; } $('playpreview').update(); new Ajax.Updater('playpreview', '/layers/audio_preview.php?item_id='+item_id, { evalScripts: true }); } function createPlaylist(){ var markup = '
  • '; new Insertion.Bottom('playlist_b', markup); var editor = new Ajax.InPlaceEditor('newPl','/ajax/audio.php?action=create_playlist',{ okButton: false, cancelLink:false, submitOnBlur:true, formClassName:'playlist_ipe', savingText:'', onComplete: function(){ editor.dispose(); renderPlaylist(current_playlist); } }); editor.enterEditMode('click'); } function togglePlGroups(el, el2){ if(el.firstDescendant().hasClassName('expanded')){ el.firstDescendant().removeClassName('expanded'); el.firstDescendant().addClassName('collapsed'); el2.each(function(s){ $('playlist_'+s).hide(); }) var type = 1; } else { el.firstDescendant().removeClassName('collapsed'); el.firstDescendant().addClassName('expanded'); el2.each(function(s){ $('playlist_'+s).show(); }) var type = 0; } new Ajax.Request('/ajax/audio.php?action=toggle_groups', { parameters: {group_id: el2[0], type: type} }); } function playTrack(item_id){ $$('#playlistracks tr').invoke('removeClassName', 'selected'); $('track_'+item_id).addClassName('selected'); window.location = '/layers/play_item.php?item_id='+item_id; } function goBackTrack(){ new Ajax.Request('/ajax/audio.php',{ asynchronous: true, parameters: {action: 'get_next_track', item_id: pl_current_item, playlist_id: active_playlist, request: 'back'}, onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1 && data['item_id'] > 0) { window.location = '/layers/play_item.php?item_id='+data['item_id']; } } }); } function goFwdTrack(){ if(nextTrack > 0) { window.location = '/layers/play_item.php?item_id='+nextTrack; } } function getNextTrack(){ new Ajax.Request('/ajax/audio.php',{ asynchronous: false, parameters: {action: 'get_next_track', item_id: pl_current_item, playlist_id: active_playlist, request: 'fwd'}, onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1) { nextTrack = data['item_id']; } } }); } function selectTrack(item_id){ $$('#playlistracks tr').invoke('removeClassName', 'selected'); $('track_'+item_id).addClassName('selected'); renderInfo(item_id); renderPreview(item_id); if(!$('playpreview').visible()){ $('tracks').setStyle({height:'227px'}); Effect.Appear('playpreview', { duration: 0.3 }); //location.hash='#anchor_track_'+item_id; //location.hash='#top'; } } function renderMiniTracks(){ new Ajax.Updater('mini_tracks', '/layers/audio_mini_tracks.php?', { evalScripts: true, parameters: {item_id: nextTrack} }); } function toggleShuffle(){ if(playlist_shuffle == 1){ playlist_shuffle = 0; if($('mini_shuffle_ind')){ $('mini_shuffle_ind').update('Off'); } } else { playlist_shuffle = 1; if($('mini_shuffle_ind')){ $('mini_shuffle_ind').update('On'); } } new Ajax.Request('/ajax/audio.php?action=toggle_shuffle', { parameters: {status: playlist_shuffle} }); getNextTrack(); renderMiniTracks(); } function searchAndPlay(){ $$('#playlistracks tr.selected').each(function(s) { var sel_id = s.id.split('_'); playTrack(sel_id[1]); }); } function togglePlaylistStatus(req){ if(req == undefined){ req = ''; } else { playliststatus = req; } if(playliststatus==1){ playliststatus = 0; if($('mini_play_link')){ $('mini_play_link').update(''); } } else { playliststatus = 1; $('mini_play_link').update(''); if(vidFinito == 1){ goFwdTrack(); } } } function sharePlaylist(){ new Ajax.Request('/ajax/audio.php?action=share_playlist', { parameters: $('plshareform').serialize(true) }); } function featurePlaylist(){ new Ajax.Request('/ajax/audio.php?action=feature_playlist', { parameters: $('plshareform').serialize(true) }); } function copyPlaylistPrompt(playlist_id) { new Ajax.Request('/ajax/audio.php', { asynchronous: true, parameters: {action: 'copy_playlist_prompt', playlist_id: playlist_id}, onSuccess: function(transport) { var data = transport.responseText.evalJSON(); var window_title = "Copy Playlist"; var contents = '
    You have chosen to copy the Playlist "'+data['playlist_title']+'".

    Please enter a new name for the Playlist:

    '; if(!$('copy_'+playlist_id)){ var win = new Window({id: 'copy_'+playlist_id, className: "famecast", width:302, height:122, zIndex: 1001, resizable: false, title: window_title, showEffect:Effect.Appear, showEffectOptions: {duration:0.3}, hideEffect: Effect.Fade, hideEffectOptions: {duration:0.3}, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false, onClose: function(){ } }) ; win.getContent().innerHTML = contents; win.showCenter(true); } } }); } function copyPlaylist(playlist_id){ new Ajax.Request('/ajax/audio.php?action=copy_playlist&playlist_id='+playlist_id, { parameters: $('plp_'+playlist_id).serialize(true), onSuccess: function(transport) { var data = transport.responseText.evalJSON(); if(data['status'] == 1){ var window_id = 'copy_'+playlist_id; var win = Windows.getWindow(window_id); win.close(); } } }); } function deleteTrack(el){ var delCheck = confirm("Are you sure you want to delete this track?"); if(delCheck){ new Ajax.Request('/ajax/audio.php',{ asynchronous: true, parameters: {action: 'delete_track', item_id: el}, onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1) { renderTracks(current_playlist); if($('playpreview').visible()){ $('playpreview').hide(); $('tracks').setStyle({height:'100%'}); } } } }); } } function deletePlaylist(el){ var delCheck = confirm("Are you sure you want to delete this playlist?"); if(delCheck){ new Ajax.Request('/ajax/audio.php',{ asynchronous: true, parameters: {action: 'delete_playlist', playlist_id: el}, onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1) { renderPlaylist(0); renderTracks(0); } } }); } } //Bookmark Stuff function renderFolders(folder_id){ if(folder_id == undefined){ folder_id = ''; } new Ajax.Updater('folders', '/layers/bookmark_folders.php?bookmarkfolder='+folder_id, { evalScripts: true, onComplete: function(){ Sortable.create('playlist_b', { dropOnEmpty:true, constraint:false, onUpdate: function(){ folderUpdated = true; new Ajax.Request('/ajax/bookmark.php?action=reorder_folders', { postBody: Sortable.serialize('playlist_b') }); } }); } }); } function createFolder(){ var markup = '
  • '; new Insertion.Bottom('playlist_b', markup); var editor = new Ajax.InPlaceEditor('newPl','/ajax/bookmark.php?action=create_folder',{ okButton: false, cancelLink:false, submitOnBlur:true, formClassName:'playlist_ipe', savingText:'', onComplete: function(){ editor.dispose(); renderFolders(current_playlist); } }); editor.enterEditMode('click'); } var folderUpdated = false; function folderSelect(el){ if($('fo_'+el).hasClassName('selected') && folderUpdated == false && $('fo_'+el).descendantOf('playlist_b')){ var editor = new Ajax.InPlaceEditor('fo_'+el,'/ajax/bookmark.php?action=update_folder&id='+el,{ okButton: false, cancelLink:false, submitOnBlur:true, formClassName:'playlist_ipe', savingText:'', onComplete: function(){ editor.dispose(); renderFolders(current_playlist); } }); editor.enterEditMode('click'); } else { if(folderUpdated == false){ $$('ul.folder li').invoke('removeClassName', 'selected'); //check if there are any unprocessed InPlaceEditors and take care of them var openItems = $$('input.editor_field'); if(openItems.size() > 0){ openItems.invoke('blur'); } else { $('fo_'+el).addClassName('selected'); renderBookmarks(el); current_folder = el; } } else { folderUpdated = false; } } } function renderBookmarks(folder_id){ if(folder_id == undefined){ folder_id = ''; } new Ajax.Updater('bookmarks', '/layers/bookmarks.php?folder='+folder_id+'¤t_item_id='+pl_current_item, { evalScripts: true }); new Ajax.Updater('bookmarkhead', '/layers/bookmarkhead.php?folder='+folder_id, { evalScripts: true }); } function toggleBGroups(el, el2){ if(el.firstDescendant().hasClassName('expanded')){ el.firstDescendant().removeClassName('expanded'); el.firstDescendant().addClassName('collapsed'); el2.each(function(s){ $('playlist_'+s).hide(); }) var type = 1; } else { el.firstDescendant().removeClassName('collapsed'); el.firstDescendant().addClassName('expanded'); el2.each(function(s){ $('playlist_'+s).show(); }) var type = 0; } new Ajax.Request('/ajax/bookmark.php?action=toggle_groups', { parameters: {group_id: el2[0], type: type} }); } function deleteFolder(el){ var delCheck = confirm("Are you sure you want to delete this bookmark folder?"); if(delCheck){ new Ajax.Request('/ajax/bookmark.php',{ asynchronous: true, parameters: {action: 'delete_folder', folder_id: el}, onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1) { renderFolders(0); renderBookmarks(0); } } }); } } function deleteBookmark(el){ var delCheck = confirm("Are you sure you want to delete this bookmark?"); if(delCheck){ new Ajax.Request('/ajax/bookmark.php',{ asynchronous: true, parameters: {action: 'delete_bookmark', item_id: el}, onSuccess: function(transport){ var data = transport.responseText.evalJSON(); if(data['status'] == 1) { renderBookmarks(current_playlist); } } }); } } function addToBookmarkPrompt(page_url, page_title) { if(!$('bm_'+page_url)){ new Ajax.Request('/ajax/bookmark.php?action=get_folderlist', { asynchronous: true, onSuccess: function(transport) { var data = transport.responseText.evalJSON(); var folders = data['folders']; var window_title = "Add To Bookmarks"; var contents = "
    You have chosen to add this page to your bookmarks.

    Please select a bookmark folder to add this page to:

    "; var win = new Window({id: 'bm_'+page_url,className: "famecast", width:302, height:152, zIndex: 1001, resizable: false, title: window_title, showEffect:Effect.Appear, showEffectOptions: {duration:0.3}, hideEffect: Effect.Fade, hideEffectOptions: {duration:0.3}, draggable:true, wiredDrag: false, minimizable: false, maximizable: false, destroyOnClose: true, recenterAuto: false, onClose: function(){ } }); win.getContent().innerHTML = contents; win.showCenter(true); var options_obj = document.getElementById('folder_id').options; options_obj.length = 0; for(var i=0; i < folders.length; i++) { options_obj[i] = new Option(folders[i][1],folders[i][0]); } } }); } } function addToBookmarks(folder_id, page_url, page_title) { new Ajax.Request('/ajax/bookmark.php', { asynchronous: true, parameters: {action: 'add_to_bookmarks', folder_id: folder_id, page_url: page_url, page_title: page_title, video_id: bookmark_video_id, audio_id: bookmark_audio_id}, onSuccess: function(transport) { var data = transport.responseText.evalJSON(); var window_id = 'bm_'+page_url; var win = Windows.getWindow(window_id); if(data['status'] == 1) { var item_id = data['item_id']; win.close(); } else { win.getContent().innerHTML = "
    There was a problem adding this page to your bookmarks.
    "; win.showCenter(true); } } }); } function goToBookmark(bookmark_id) { new Ajax.Request('/ajax/bookmark.php', { asynchronous: true, parameters: {action: 'get_bookmark', bookmark_id: bookmark_id}, onSuccess: function(transport) { var data = transport.responseText.evalJSON(); if(data['status'] == 1) { var url_string1 = ""; var url_string2 = ""; if(data['video_id'] > 0){ url_string1 = "&video_id="+data['video_id']+"&artist_id="+data['artist_id']; } if(data['audio_id'] > 0){ url_string2 = "&audio_id="+data['audio_id']; } window.location = data['target_url']+url_string1+url_string2; } } }); } function editBookmark(el){ $('ebm_'+el).addClassName('ip'); $('ebm_'+el).hide(); var editor = new Ajax.InPlaceEditor('bmc_'+el,'/ajax/bookmark.php?action=update_bookmark&id='+el,{ okButton: false, cancelLink:false, submitOnBlur:true, formClassName:'bookmark_ipe', savingText:'', onComplete: function(){ editor.dispose(); $('ebm_'+el).show(); $('ebm_'+el).removeClassName('ip'); renderBookmarks(current_folder); } }); editor.enterEditMode('click'); } String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } function previewMedia(el, type, id, title, artist, show_preview_text) { if(show_preview_text == undefined) show_preview_text = 1; if($(el).next('.preview_media_box_video')) { $(el).next('.preview_media_box_video').remove(); if(show_preview_text==1) $(el).update('Preview'); } else if ($(el).next('.preview_media_box_audio')) { $(el).next('.preview_media_box_audio').remove(); if(show_preview_text==1) $(el).update('Preview'); } else { $$('.preview_media_box_video').invoke('remove'); $$('.preview_media_box_audio').invoke('remove'); if(show_preview_text==1) $$('.preview_media').invoke('update','Preview'); if(show_preview_text==1) $(el).update('Previewing'); var media_tag = ''; if(type == 2) { media_tag = 'video_id'; } else if(type == 1) { media_tag = 'audio_id'; } var foo = new Date; var unixtime_ms = foo.getTime(); var previewClass = 'audio'; if(type == 2) { previewClass = 'video'; } var pm = '
    '+title+'
    '+artist+'
    '; $(el).insert({after: pm}); var flashvars = { "config":"/xml/player_conf_int.php", "autostart":"true", "controlbar":"bottom", "logo.file":"http://www.getroadworn.com/img/px.gif", "logo.hide":"false", "famecast.position":"top", "famecast.size":"0", "playlistfile":"/xml/getplaylist.php?"+media_tag+"="+id+"%26site_id=16" }; var params = {"allowscriptaccess":"true", "allowfullscreen":"true", "wmode":"transparent", "bgcolor":"#FFF"}; var attributes = {"id": "mpl"}; if(false && !$('contest_player1')) { //alert('removeswf'); swfobject.removeSWF('mpl'); if(typeof(pageTracker)!='undefined') pageTracker._trackPageview(); // re-create it var div = document.createElement("div"); var el = document.getElementById('contest_player_container'); el.appendChild(div); div.setAttribute("id", 'contest_player1'); } swfobject.embedSWF("/flash/fcp/player-licensed.swf?"+(Math.round(1000 * Math.random())), "pl"+unixtime_ms, 200, 169, "10.0.0", "", flashvars, params, attributes); } } function chatStatus(){ var userString = ""; $$('.chat_status').each(function(s){ var mySplitResult = $(s).id.split("_"); userString = userString + mySplitResult[1] + ','; }); new Ajax.Request('/ajax/onlinestatus.php', { parameters: {action: 'check', users: userString}, onComplete: function(transport) { var data = transport.responseText.evalJSON(); if(data['status'] == 1){ data['online'].each(function(uid){ $$('.ci_'+uid).invoke('update', ''); }); } } }); } function URLEncode (clearString) { var output = ''; var x = 0; clearString = clearString.toString(); var regex = /(^[a-zA-Z0-9_.]*)/; while (x < clearString.length) { var match = regex.exec(clearString.substr(x)); if (match != null && match.length > 1 && match[1] != '') { output += match[1]; x += match[1].length; } else { if (clearString[x] == ' ') output += '+'; else { var charCode = clearString.charCodeAt(x); var hexVal = charCode.toString(16); output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase(); } x++; } } return output; } function URLDecode (encoded) { // Replace + with ' ', %xx with equivalent character, and "" if %xx is invalid var HEXCHARS = "0123456789ABCDEFabcdef"; var plaintext = ""; var i = 0; while (i < encoded.length) { var ch = encoded.charAt(i); if (ch == "+") { plaintext += " "; i++; } else if (ch == "%") { if (i < (encoded.length-2) && HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 && HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) { plaintext += unescape( encoded.substr(i,3) ); i += 3; } else { plaintext += ""; i++; } } else { plaintext += ch; i++; } } return plaintext; }