﻿document.domain = 'fulltono.com';
var m_idv; var m_artv; var m_titv;
/************** left menu pager ****************/
function pMenu(l){
  if(l=='A'){
    $('dListA').style.display='block';
    $('dListB').style.display='none';
    $('dListC').style.display='none';
    $('dLMheader').style.background='url(/images/lm-music.jpg) left no-repeat';            
  }
  if(l=='B'){
    $('dListA').style.display='none';
    $('dListB').style.display='block';
    $('dListC').style.display='none';
    $('dLMheader').style.background='url(/images/lm-video.jpg) left no-repeat';            
  }
  if(l=='C'){
    $('dListA').style.display='none';
    $('dListB').style.display='none';
    $('dListC').style.display='block';
    $('dLMheader').style.background='url(/images/lm-photo.jpg) left no-repeat';            
  }
}

var m_lmCurPage = 1;
function fnLmGoPriorPg(){fnLmGoPg(m_lmCurPage-1);}
function fnLmGoNextPg(){fnLmGoPg(m_lmCurPage+1);}
function fnLmGoPg(pag){
  if(m_lmCurPage == pag) return;
  if(!m_lmCurPage) m_lmCurPage = 1;
  if($('dListA' + pag)){
    $('dListA' + m_lmCurPage).style.display = 'none';
    $('dListB' + m_lmCurPage).style.display = 'none';
    $('dListC' + m_lmCurPage).style.display = 'none';
    $('lmPgLnk' + m_lmCurPage).className = 'divPC_a';
    m_lmCurPage = pag;
    $('dListA' + m_lmCurPage).style.display = 'block';
    $('dListB' + m_lmCurPage).style.display = 'block';
    $('dListC' + m_lmCurPage).style.display = 'block';
    $('lmPgLnk' + m_lmCurPage).className = 'divPC_selected';
  }
}
function fnLmGoPgByLi(_id){
  var _li = document.getElementById('li' + _id);
  if(_li){
    _li.className = 'liActive';
    fnLmGoPg(_li.parentNode.parentNode.id.replace('dListA', ''));
  }
}
/************ end left menu pager **************/
/************* player and favorites ***************/
var m_currentSongIdx = 0;
var m_arrIdx = null;var m_arrTitles = null;
var m_isLyricsShown = new Boolean();
function toggleFav(){
  var op=0;
  if($('dFavLinks').style.display=='block' || $('dFavLinks').style.display==''){$('dFavLinks').style.display='none';op=1;$('favlIco').src='/images/favl-ico-b.gif';}
  if($('dFavLinks').style.display=='none' && op==0){$('dFavLinks').style.display='block';$('favlIco').src='/images/favl-ico.gif';}
}
function closeFavPP(){
  var ob=document.getElementById('dFavPopup');
  if(ob)ob.style.display='none';
}
function openFavPP(idx){
  var ob=$('dFavPopup');
  if(ob){
    ob.style.display='block';
    $('hdnIdG').value = m_arrIdx[idx];
    $('dFavMsg').innerHTML = 'Haz click en la lista donde quieres añadir "' + m_arrTitles[idx] + '"';
  }else{
    alert('Tiene que iniciar sesión para agregar a favoritos');
  }
}
function addToFavorites(id){
var hdn = $('hdnIdG');
var url = '/ajax/addToFavorites?idm=' + hdn.value + '&f=' + id;
var log = $('dFavMsg');
var ajax = new Ajax(url, { 
  update: log,
  method: 'get',
  onComplete: function(results) {
    alert(results);
    closeFavPP();
  }
}).request();
}
m_isLyricsShown = false;
function callChangeSong(idx, idm){
  getVideoList(idm, m_artv, m_arrTitles[idx]);
  changeSong(idx, true)
  showLyrics(idx, idm);
}
function changeSong(idx,noplay){
  if(!m_currentSongIdx)m_currentSongIdx = 0;
  var item = $('songItem' + m_currentSongIdx);
  if(item){
    item.className = 'cSongsListItem';
    m_currentSongIdx = idx;
    $('songItem' + m_currentSongIdx).className = 'cSongsListItemSelected';
    if(!noplay){playerChangeSong(idx)}
    //setPlayerTitle(idx);
   showRingTone(idx); //se aumento para showringtone
  }
}
function setPlayerTitle(idx){
  if(m_arrTitles != null){thisMovie("myplayer").setTitle("   " + (idx+1) + ". " + m_arrTitles[idx]);}
}
function hlSongItem(item){item.className='cSongsListItemMouseOver';}
function clsSongItem(item){item.className='cSongsListItem';$('songItem' + m_currentSongIdx).className = 'cSongsListItemSelected';}
function playerChangeSong(idx) {thisMovie("myplayer").playSong(idx);}
function thisMovie(movieName) {
  if (navigator.appName.indexOf("Microsoft") != -1) {
    return window[movieName]
  }
  else {
    return document[movieName]
  }
}
var m_curIdx;
var m_curIdm;
var m_lastLyricsLoaded;
function showLyrics(idx,idm){
  m_curIdx = idx; m_curIdm = idm;
  if(m_pageLoaded &&  m_isLyricsShown){
    if(!m_artv) m_artv = '';
    var url = "/myLyrics.lrXx?artist=" + escape(m_artv) + "&title=" + escape(m_arrTitles[idx]) + "&idm=" + idm;
    var ajaxUR = new Ajax(url, {method: 'get', update:$('dSongLyrics')}).request();
    m_lastLyricsLoaded = idx;
  }
}
function toggleLyrics(ctrl){
  if(m_isLyricsShown==undefined)m_isLyricsShown = false;
  if(!m_isLyricsShown){
    m_isLyricsShown = true;
    if(m_lastLyricsLoaded != m_curIdx) showLyrics(m_curIdx, m_curIdm);
    $('dSongsList').style.display = 'none';
    $('dSongLyrics').style.display = 'block';
    ctrl.innerHTML = 'Ocultar Lyrics';
  } else {
    m_isLyricsShown = false;
    $('dSongLyrics').style.display = 'none';
    $('dSongsList').style.display = 'block';
    ctrl.innerHTML = 'Mostrar Lyrics';
  }
}
/*********** end player *************/
/************* COMMENTS **************/
function askLogin(qs){
  if(confirm('Ud. no ha iniciado sesi\u00f3n.\nDesea iniciar ahora?')){
    top.location.href='/login.aspx?'+qs;
  }
}
function saveCom(txt) {var ajaxUR = new Ajax('/ajax/addComment?c=' + escape(txt), {method: 'get', update:$('dnewComment')}).request();}
/*********** END COMMENTS ************/

var m_pageLoaded = new Boolean();
m_pageLoaded = false;
/*********** Videos *******/
function getVideoList(id,art,tit){
  if(m_pageLoaded && id && tit){
    if(!art)art ='';
    var url = 'http://vaj.fulltono.com/search-video?id=' + id + '&q=' + escape(art + ' ' + tit);
    $('frmV').src = url;
  }
  else{m_idv = id;m_artv=art;m_titv=tit;}
}
/*********** FIN Videos *******/
function setLoaded(){
  m_pageLoaded = true;
  getVideoList(m_idv,m_artv,m_titv);
  var ajaxUR = new Ajax("/ajax/getLastPlayedList", { method: 'get', update: $('ur') }).request();
}
//function sss(h){$('frmV').height=h;}
window.addEvent('load', function() {
  var status = {
		'true': 'Ocultar Categorías',
		'false': 'Mostrar Categorías'
	};
  var ob=document.getElementById('toggle_cathor_text');
  ob.innerHTML='Ocultar Categorias';
  var slider5 = new Fx.Slide('dToggler',{onComplete:function(){if(slider5.open)ob.innerHTML='Mostrar Categorias';else ob.innerHTML='Ocultar Categorias';}});
  $('toggle_cathor_text').addEvent('click', 
    function (ev){
      new Event(ev).stop();
      slider5.toggle();
    }
  );
});
/******************* Details **************/
var divD='';
function _aopDet(div){
  _cdato(div);
  _dopDet(divD);
  var ob=document.getElementById('copdm'+div);
  var obop=document.getElementById('opdm'+div);
  
  if(obop){obop.style.background='#2b1100';if(ob){ob.style.display='block'}}
  divD=div;
}
function _dopDet(div){
  var ob=document.getElementById('copdm'+div);
  var obop=document.getElementById('opdm'+div);
  var obmsg=document.getElementById('msgd');

  if(obop)obop.style.background='black';
  if(ob)ob.style.display='none';
  if(obmsg)obmsg.style.display='none';
}

var txtnombre=null;
var txtcorreo=null;
var txtclave=null;
var txttunombre=null;
var txtsunombre=null;
var txttucorreo=null;
var txtsucorreo=null;
var txtmensaje2=null;
function _cdato(div){
  var nombre="name";
  var correo="e@hot.com";
  
  if(div==2){
    if(txttunombre.value==nombre)txttunombre.value="";
    if(txtsunombre.value==nombre)txtsunombre.value="";       
    if(txttucorreo.value==correo)txttucorreo.value="";
    if(txtsucorreo.value==correo)txtsucorreo.value="";

    if(txtnombre.value=='')txtnombre.value=nombre;
    if(txtcorreo.value=='')txtcorreo.value=correo;
  }
  if(div==3){
    if(txttunombre.value=="")txttunombre.value=nombre;
    if(txtsunombre.value=="")txtsunombre.value=nombre;   
    if(txttucorreo.value=="")txttucorreo.value=correo;
    if(txtsucorreo.value=="")txtsucorreo.value=correo;

    if(txtnombre.value==nombre)txtnombre.value="";
    if(txtcorreo.value==correo)txtcorreo.value="";
  }
}

var m_nom = '';
var m_email = '';
function todlc(){
  var chk=document.form1.chkcon;
  if(chk){
    if(chk.length){
      for(var i=0;i<chk.length;i++){
        chk[i].checked=document.form1.todoscontactos.checked;
      }
    }else{chk.checked=document.form1.todoscontactos.checked;}
  }
}
function enviar(){
  var _cntr = 0;
  var ems = '';
  var chk=document.form1.chkcon;
  if(chk){
    if(chk.length){
      for(var i=0;i<chk.length;i++){
        if(chk[i].checked){
          ems += chk[i].value + (i<(chk.length-1)?',':'');
          _cntr++;
        }
      }
    }else{
      if(chk.checked){
        ems = chk.value;
        _cntr++;
      }
    }
  }
  if(_cntr == 0){
    alert('Tiene que seleccionar por lo menos un contacto');
  } else {
    //alert(ems);
    var frm = document.frmCon;
    frm.ems.value = ems;
    frm.nom.value = m_nom;
    frm.org.value = m_email;
    frm.msg.value = $('txtMensaje').value;
    
    frm.submit();
  }
}
function send1(){
  m_nom = txttunombre.value;
  m_email = txttucorreo.value;
  ems = txtsucorreo.value;
  msg = txtmensaje2.value;
  
  if(m_nom==''){alert('Ingrese Nombre'); $('txtTuNombre').focus(); return;}
  if(m_email==''){alert('Ingrese e-mail'); $('txtTuCorreo').focus(); return;}
  if(ems==''){alert('Ingrese el e-mail a donde enviar');$('txtSuCorreo').focus(); return;}
  
  var frm = document.frmCon;
  frm.ems.value = ems;
  frm.nom.value = m_nom;
  frm.org.value = m_email;
  frm.msg.value = msg;
  
  frm.submit();
}

function getCon(btn){
  try{
    if(txtcorreo.value==''){alert('Ingrese Correo válido');txtcorreo.focus();return false;}
    if(txtclave.value==''){alert('Ingrese Contraseña');txtclave.focus();return false;}
    btn.disabled = true; btn.value = 'importando contactos ...';
    m_nom = txtnombre.value.replace(/&/g, "%26");
    m_email = txtcorreo.value.replace(/&/g, "%26");
    //alert(m_email + ' ' + m_nom);
    var params = "email=" + m_email;
    params += "&pwd=" + txtclave.value.replace(/&/g, "%26");
    params += "&noms=" + m_nom;
    
    var url = "/ajax/getJasonContacts";
    var msgerror = "Usuario o contraseña incorrecto";
    var emails = null;
    var ajaxC = new Ajax(url,{
      method: 'post',data:params,
      onComplete: function(request){
        if(request==1){
          alert(msgerror);
        }else{
          emails = eval(request);
          //alert(emails);
          tmpStr = "";
          for(i=0;i<emails.length;i++){
            tmpStr += "<div><input type='checkbox' name='chkcon'  checked='checked' value='" + emails[i] + "'>" + emails[i] + "</div>";
          }
          $('dconcon').innerHTML = tmpStr;
        }
        btn.value = 'Generar Contactos';
        btn.disabled = false;
      }
    });ajaxC.request();
  }catch(ex){alert(ex);}
  return false;
}
/***************** END Details ************/

/************** inicio de dialog ***********/
function msg() {
    if (document.body) {
        var ancho = (document.body.clientWidth);
    }
    else {
        var ancho = (window.innerWidth);
    }
    var container = document.documentElement;
    var alto;
    if (container.innerWidth) {
        alto = container.innerHeight;
    }
    else {
        alto = container.clientHeight;
    }
    var posx = (ancho / 2) - 355
    var posy = (alto / 2) - 184
    $('layout-cloud').setStyle('top', posy);
    $('layout-cloud').setStyle('left', posx);
    $('mask2').setStyle('display', 'block');
    $('mask1').setStyle('height', '100%');
}
function msg_salir() {
    $('mask1').setStyle('display', 'none');
    $('mask2').setStyle('display', 'none');
}
function msg_si(lnk) {
    fnHP(lnk);
	msg_no();
  return false;          
}

function msg_no() {
    msg_salir();
    return false;
}
function activafl() {
    if (document.body) {
        var ancho = (document.body.clientWidth);
    }
    else {
        var ancho = (window.innerWidth);
    }
    var container = document.documentElement;
    var alto;
    if (container.innerWidth) {
        alto = container.innerHeight;
    }
    else {
        alto = container.clientHeight;
    }
    $('fifl').setStyle('display', 'block');
    $('fdfl').setStyle('display', 'block');
}

/************** fin de fialog *************/

//inicio - showringtone
function showRingTone(idx) {
    m_curIdx = idx;
    var xtrart = '';
    var xtrsong = '';
    if (m_artv) {
        var xtrart = m_artv;
        var xtrsong = m_arrTitles[idx];
    }
    else {
        xtrsong = m_arrTitles[idx];
        var xtrpos = xtrsong.indexOf(' - ');
        //alert(xtrpos);
        if (xtrpos > 0) {
            xtrart = xtrsong.substring(0, xtrpos);
            xtrsong = xtrsong.substring(xtrpos + 3);
        }
    }
    if (xtrart != '' || xtrsong != '') {
        var txt = '<center><table border="0"><tr>';
        txt += '<td><a href="http://www.ringtonematcher.com/co/ringtonematcher/02/noc.asp?sid=FUTOros&artist=' + escape(xtrart.replace(/ /g, '+')) + '&song=' + escape(xtrsong.replace(/ /g, '+')) + '" target="_blank"><img src="/images/phone_icon_blue_small_trans_left.gif" border="0"/></a></td> ';
        txt += '<td align="center"><a href="http://www.ringtonematcher.com/co/ringtonematcher/02/noc.asp?sid=FUTOros&artist=' + escape(xtrart.replace(/ /g, '+')) + '&song=' + escape(xtrsong.replace(/ /g, '+')) + '" target="_blank" class="linkRingtone">Descarga el tono de "' + xtrsong + '" a tu movil</a></td> ';
        txt += '<td><a href="http://www.ringtonematcher.com/co/ringtonematcher/02/noc.asp?sid=FUTOros&artist=' + escape(xtrart.replace(/ /g, '+')) + '&song=' + escape(xtrsong.replace(/ /g, '+')) + '" target="_blank"><img src="/images/phone_icon_blue_small_trans_right.gif" border="0"/></a></td> ';
        txt += '</tr></table></center>'
        $('divRingtone').setHTML(txt);
    }
}
//fin - showringtone

/*************** Barra FaceBook ******************/
function s_lbl(ob, msg) {
    if ($('lnk-op' + ob.id.replace('c-lnk-op', '')).className != 'lnk-op-h') {
        $('msg_lbl_tb').innerHTML = msg;
        $('label-tb').style.display = 'block';
        ob.appendChild($('label-tb'));
    }
}
function h_lbl() { $('label-tb').style.display = 'none'; }
var lnk_op = 1;
function op_tb(id) {
    if ($('lnk-op' + id).className == 'lnk-op') {
        switch (id) {
            case 2:
                if ($('toolbar-conte2').innerHTML == '') $('toolbar-conte2').innerHTML = '<iframe src="http://www.facebook.com/widgets/activity.php?site=http://www.fulltono.com&header=false&width=280&height=480" width="280" height="480" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>';
                break;
            case 4:
                if ($('toolbar-conte4').innerHTML == '') $('toolbar-conte4').innerHTML = '<iframe src="http://toolbar2.wibiya.com/fanpage2/fanpage.php?toolbarAppId=1688044&appId=27&toolbarId=540929&fpid=141069075925809" width="772" height="430" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>';
                break;
            case 5:
                if ($('toolbar-conte5').innerHTML == '') $('toolbar-conte5').innerHTML = '<iframe src="http://www.facebook.com/widgets/livefeed.php?api_key=4c947599c79c5139cd641e624cd197b9&xid=YOUR_EVENT_XID&width=425&height=580&hide_friends_tab=0&always_post_to_friends=0&locale=es_LA" width="425" height="580" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>';
                break;
        }
        if ($('c-det-tb' + lnk_op)) { $('c-det-tb' + lnk_op).style.display = 'none'; }
        if ($('lnk-op' + lnk_op)) { $('lnk-op' + lnk_op).className = 'lnk-op'; }
        $('lnk-op' + id).className = 'lnk-op-h';
        $('c-det-tb' + id).style.display = 'block';
        h_lbl();
        lnk_op = id;
    } else { $('lnk-op' + id).className = 'lnk-op'; h_det_tb(id) }
}
function h_det_tb(id) { $('c-det-tb' + id).style.display = 'none'; }
/*************** Fin Barra FaceBook ******************/
