// 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("Debes proveer un correo electronico valido para solicitar una contrasena olvidada. ");
}
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: "Solicitud de Chat", 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 = "
Disculpa hubo un error del sistema. Por favor intenta mas tarde.
";
}
}
else
{
content = "
No se pudo enviar la solicitud. Por favor intenta mas tarde.
";
}
var window_id = 'iwantit_window';
var window_title = "Gracias. Hemos enviado tu solicitud.";
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 = "Tienes que iniciar sesión para dejar un mensaje.";
} else {
ctext = "Tienes que estar conectado para usar 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: "Dejar mensaje offline", 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: "Dejar mensaje offline", 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: "Dejar mensaje offline", 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("Tienes que ser un amigo para dejar un mensaje offline. Quieres mandar un solicitud de amigo?");
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: "Dejar mensaje offline", 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: "Dejar mensaje offline", 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("Tienes que ser un amigo para chatear con esta persona. Quieres mandar un solicitud de amigo?");
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("Tienes que estar conectado para usar 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("Estás seguro que quieres borrar este mensaje?");
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, '
Cargando
');
},
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, '
Cargando
');
},
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 = '