var clock=new Date();var milisegundos=0;var yoxviewPath=$.KumbiaPHP.publicPath+"javascript/yoxview/";function CTRequest(d,c,a,b,e){jQuery.ajax({url:$.KumbiaPHP.publicPath+d,type:c,async:true,data:a,dataType:b,success:e,error:e})}jQuery(document).ready(function(){jQuery(document).everyTime(30000,"announcement",ChangeAnnouncements);jQuery(".ann_playpause").css({background:"url('"+$.KumbiaPHP.publicPath+"img/ann_pause.png')"});jQuery(".comments").prettyComments();jQuery(".scrollable").scrollable({keyboard:false});jQuery(".yoxview").yoxview({lang:"es",playDelay:5000});jQuery("#BannerSuperior").ekko({minTimeout:20000,method:"post",multiplier:2,sendData:null,type:"json",url:$.KumbiaPHP.publicPath+"banners/actualizar"},function(a){jQuery.each(a,function(b,c){file="";if(c.file.match(".swf")){file="<object type='application/x-shockwave-flash' data='"+$.KumbiaPHP.publicPath+"img/upload/banners/"+c.file+"' width="+c.width+"' height='"+c.height+"'><param name='movie' value='"+$.KumbiaPHP.publicPath+"img/upload/banners/"+c.file+"' /><param name='wmode' value='transparent' /></object>"}else{file="<img src='"+$.KumbiaPHP.publicPath+"img/upload/banners/"+c.file+"' width='"+c.width+"' height='"+c.height+"' alt='"+c.title+"' title='"+c.file+"' />";if(c.url!=""){file="<a href='"+c.url+"' target='_blank'>"+file+"</a>"}}if(c.type=="1"){if(c.pos=="U"){jQuery("#BannerSuperior").html(file)}else{jQuery("#BannerMedio").html(file)}}if(c.type=="3"){if(c.pos=="L"){jQuery("#BannerLeft").html(file)}else{jQuery("#BannerRight").html(file)}}})});jQuery("#messages").ekko({minTimeout:20000,method:"post",multiplier:2,sendData:null,type:"html",url:$.KumbiaPHP.publicPath+"mensajes/actualizar"},function(a){jQuery("#messages").html(a)});jQuery("#clock").ekko({minTimeout:60000,method:"post",multiplier:1,sendData:null,type:"text",url:$.KumbiaPHP.publicPath+"actualizaciones/reloj"},function(a){jQuery("#clock").html(a)})});var arrayPlaylist=new Array();var backcolor="";var contPlaylist=0;var currentItem=-1;var currentItemID=0;var currentItemType="";var currentPosition=0;var currentState="";var player=null;var playlistLoaded=false;var playlistNews=0;var playlistOn=false;var previousItem=-1;var previousItemID=0;var previousState="";var songListened=false;var tabSelected="Artists";function AddFavorite(b,a){if(navigator.appName=="Netscape"){window.sidebar.addPanel(b,a,"")}if(navigator.appName=="Microsoft Internet Explorer"){window.external.AddFavorite(a,b)}}function AddListeners(){if(player){player.addControllerListener("ITEM","ItemListener");player.addModelListener("STATE","StateListener");player.addModelListener("TIME","PositionListener")}else{setTimeout("AddListeners()",100)}}function ChangeAnnouncements(c){c=c||1;var b=parseInt(jQuery("#ann_curr").html());var a=parseInt(jQuery("#ann_total").html());if(c==1){jQuery("#announcement"+b).hide();if(b>=a){b=1}else{b++}jQuery("#announcement"+b).show()}else{jQuery("#announcement"+b).hide();if(b<=1){b=a}else{b--}jQuery("#announcement"+b).show()}jQuery("#ann_curr").html(b);jQuery(document).everyTime(30000,"announcement",ChangeAnnouncements)}function ChangeColorWeb(c,b,a){backcolor=b;jQuery(".ColorWeb").css({background:"url('"+$.KumbiaPHP.publicPath+"img/page_bg.png') "+b});jQuery(".FontWeb").css({color:a});CTRequest("colores/cambiar/"+c,"POST",null,"html",null)}function ChangeImageNews(c){var a=parseInt(jQuery("#noticias_actual").val());var b=parseInt(jQuery("#noticias_total").val());if(c==1){jQuery("#news_image"+a).hide("slow");if(a>=b){a=1}else{a++}jQuery("#news_image"+a).show("slow")}else{jQuery("#news_image"+a).hide("slow");if(a<=1){a=b}else{a--}jQuery("#news_image"+a).show("slow")}jQuery("#noticias_actual").val(a)}function ConfirmAddToMyPlaylist(b,e,d,a){if(b=="S"){msg="Deseas agregar esta canci\u00F3n a tus favoritas"}else{msg="Deseas agregar este video a tus favoritos"}var g=confirm("\u00BF"+msg+"\u003F");if(g){var c=false;for(var f in arrayPlaylist){if(arrayPlaylist[f].description==b+":"+e){c=true}}if(c){alert("Este archivo ya está en tus favoritos.")}else{jQuery("#PlaylistMSG").css({background:"url('img/spinner.gif') center no-repeat"});jQuery("#PlaylistMSG").show();if(b=="S"){img="<img src='img/music_delete.gif' alt='' height='16' title='Eliminar de tus favoritos' width='16' onclick=\"DeleteFromMyPlaylist('"+contPlaylist+"');\" />";action="music";type_str="sound"}else{img="<img src='img/video_delete.gif' alt='' height='16' title='Eliminar de tus favoritos' width='16' onclick=\"DeleteFromMyPlaylist('"+contPlaylist+"');\" />";action="video";type_str="video"}CTRequest("modules/public.php","POST","op=GetFile&type="+b+"&id="+e+"&playlist=S","json",function(h){arrayPlaylist[contPlaylist]={author:d,description:b+":"+e,file:stripslashes(h.file),image:stripslashes(h.image),link:stripslashes(h.url),title:a,type:type_str};contPlaylist++;jQuery("#MyPlaylist").append("<li class='new'>"+img+" "+stripslashes(d)+" - "+stripslashes(a)+"</li>");playlistNews++;jQuery("#SaveFavorites").show();jQuery("#PlaylistMSG").css({background:""});jQuery("#PlaylistMSG").hide()})}}}function DeleteFromMyPlaylist(a){arrayPlaylist[a]={author:"",description:"",file:"",image:"",link:"",title:"",type:""};playlistNews--;if(playlistNews>0){jQuery("#SaveFavorites").show()}else{jQuery("#SaveFavorites").hide()}player.sendEvent("LOAD",arrayPlaylist);arrayPlaylist=player.getPlaylist();currentLength=arrayPlaylist.length;alert("currentItem: "+currentItem+", currentLength: "+currentLength);if(playlistOn){if(currentItem==currentLength-1){player.sendEvent("NEXT")}else{player.sendEvent("PLAY")}}PrintPlaylistPlayer()}function FixPNG(){jQuery(document).ready(function(){jQuery("img[src$=.png]").ifixpng()})}function InitPlayer(b){backcolor=b||"CCCCCC";var a={backcolor:backcolor,skin:"./lib/overlay.swf",controlbar:"over"};var d={allowfullscreen:"true",allowscriptaccess:"always",wmode:"transparent"};var c={id:"player",name:"player"};swfobject.embedSWF("lib/mediaplayer.swf","player","300","292","8",false,a,d,c)}function IsAlphaNum(b){if(b+""=="undefined"||b+""=="null"||b+""==""){return false}var a=true;b+="";for(i=0;i<b.length;i++){if(!(((b.charAt(i)>="0")&&(b.charAt(i)<="9"))||((b.charAt(i)>="a")&&(b.charAt(i)<="z"))||((b.charAt(i)>="A")&&(b.charAt(i)<="Z"))||(b.charAt(i)=="@"))){a=false;break}}return a}function IsEmailAddress(b){var a=/^[A-Za-z][A-Za-z0-9_]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;if(b.length==0){return true}if(a.test(b)){return true}return false}function LoadFile(b,c,a){jQuery("#PlaylistMSG").css({background:"url('img/spinner.gif') center no-repeat"});jQuery("#PlaylistMSG").show();currentItemID=c;currentItemType=b;songListened=false;CTRequest("modules/public.php","POST","op=GetFile&type="+b+"&id="+c,"json",function(d){LoadPlayer(d.file,d.image,d.url,a);jQuery("#PlaylistMSG").css({background:""});jQuery("#PlaylistMSG").hide()})}function LoadPlayer(g,b,e,a){backcolor=backcolor||"FFFFFF";a=a||false;g=stripslashes(g);b=stripslashes(b);e=stripslashes(e);var c={autostart:a,backcolor:backcolor,controlbar:"over",file:g,image:b,link:e,skin:"./lib/overlay.swf"};var f={allowfullscreen:"true",allowscriptaccess:"always",wmode:"transparent"};var d={id:"player",name:"player"};swfobject.embedSWF("lib/mediaplayer.swf","player","300","292","8",false,c,f,d);if(playlistOn){player.sendEvent("STOP");PlayerStopped();playlistLoaded=false}}function LoadScript(a){CTRequest("js/modules/"+a+".min.js","POST","","script",null)}function LoadScriptAdmin(a){CTRequest("js/admin/"+a+".min.js","POST","","script",null)}function LogonUser(){nick=jQuery("#nick").val();pass=jQuery("#pass").val();remember="N";if(nick==""&&pass==""){alert("Debe ingresar el nick y la clave.");jQuery("#nick").focus()}else{if(nick==""){alert("Debe ingresar el nick.");jQuery("#nick").focus()}else{if(pass==""){alert("Debe ingresar la clave.");jQuery("#pass").focus()}else{if($("#remember").attr("checked")==true){remember="S"}jQuery("#btnLogon").attr("disabled","disabled");jQuery("#LogonUserMSG").css({background:"url('img/spinner.gif') center no-repeat"});jQuery("#LogonUserMSG").show();CTRequest("modules/users.php","POST","op=LogonUser&nick="+nick+"&pass="+pass+"&remember="+remember,"json",LogonUserFN)}}}}function LogonUserFN(a){if(a.msg=="ok"){alert("Hola "+a.nick+", Bienvenid@ a Chattagena -  Tu Ciudad en Internet.");jQuery(".ColorWeb").css({background:"url('img/page_bg.png') #"+a.bgcolor});jQuery("#UserNick").html(a.nick);jQuery("#nick").val("");jQuery("#pass").val("");jQuery("#LogonOption").hide();jQuery("#LogoffOption").show();jQuery("#form_login").hide()}else{if(a.msg=="user_banned"){alert("Este usuario ha sido banneado.")}else{alert("Datos incorrectos.")}}jQuery("#btnLogon").attr("disabled","");jQuery("#LogonUserMSG").css({background:""});jQuery("#LogonUserMSG").hide()}function LogoffUser(){CTRequest("modules/users.php","POST","op=LogoffUser&secure=S","json",LogoffUserFN)}function LogoffUserFN(a){if(a.msg!="ok"){alert("Error al Desconectar.")}else{alert(a.nick+" vuelve pronto a Chattagena - Tu Ciudad en Internet.");jQuery("#UserNick").html("Turista");jQuery("#LogonOption").show();jQuery("#LogoffOption").hide()}}function NeedLogin(){alert("Chattagena.com te invita a iniciar sesión para poder hacer uso de esta opción.")}function NstroChat(){window.open("nstrochat/","NstroChat","width=800,height=650,toolbar=no,location=no,status=no,menubar=no,resizable=no,scrollbars=no")}function NstraMusik(){window.open("http://canciones.chattagena.com","NstraMusik","width=500,height=220,toolbar=no,location=no,status=no,menubar=no,resizable=no,scrollbars=no")}function NstrosVideos(){window.open("http://videos.chattagena.com","NstrosVideos","width=600,height=300,toolbar=no,location=no,status=no,menubar=no,resizable=no,scrollbars=no")}function PlayerPlaying(){playlistOn=true;jQuery("#PlayFavorites").hide();jQuery("#StopFavorites").show()}function playerReady(a){}function PlayerStopped(){playlistOn=false;jQuery("#PlayFavorites").show();jQuery("#StopFavorites").hide()}function PlayFavorites(){if(!playlistLoaded){playlistLoaded=true}if(playlistOn){PlayerStopped();player.sendEvent("STOP")}else{player.sendEvent("LOAD",arrayPlaylist);player.sendEvent("PLAY");jQuery("#SaveFavorites").hide();PrintPlaylistPlayer()}}function PlayStopChangeAnnouncements(){img=jQuery(".ann_playpause").css("background");if(img.match("pause")){jQuery(document).stopTime("announcement");jQuery(".ann_playpause").css({background:"url('img/ann_play.png')"})}else{jQuery(document).everyTime(30000,"announcement",ChangeAnnouncements);jQuery(".ann_playpause").css({background:"url('img/ann_pause.png')"})}}function PositionListener(a){currentPosition=a.position}function PrintPlaylist(a){jQuery("#MyPlaylist").html("");for(var b in arrayPlaylist){if(arrayPlaylist[b].author!=""&&arrayPlaylist[b].title!=""){if(arrayPlaylist[b].type=="sound"){img="<img src='img/music_delete.gif' alt='' height='16' title='Eliminar de tus favoritos' width='16' onclick=\"DeleteFromMyPlaylist('"+b+"');\" />"}else{img="<img src='img/video_delete.gif' alt='' height='16' title='Eliminar de tus favoritos' width='16' onclick=\"DeleteFromMyPlaylist('"+b+"');\" />"}if(b==a){jQuery("#MyPlaylist").append("<li class='listen'>"+img+" "+arrayPlaylist[b].author+" - "+arrayPlaylist[b].title+"</li>")}else{jQuery("#MyPlaylist").append("<li>"+img+" "+arrayPlaylist[b].author+" - "+arrayPlaylist[b].title+"</li>")}}}}function PrintPlaylistPlayer(c){var b=null;b=player.getPlaylist();if(b){var a="";jQuery("#MyPlaylist").html("");for(var d in b){if(b[d].type=="sound"){img="<img src='img/music_delete.gif' alt='' height='16' title='Eliminar de tus favoritos' width='16' onclick=\"DeleteFromMyPlaylist('"+d+"');\" />"}else{img="<img src='img/video_delete.gif' alt='' height='16' title='Eliminar de tus favoritos' width='16' onclick=\"DeleteFromMyPlaylist('"+d+"');\" />"}if(d==c){jQuery("#MyPlaylist").append("<li class='listen'>"+img+" "+b[d].author+" - "+b[d].title+"</li>")}else{jQuery("#MyPlaylist").append("<li>"+img+" "+b[d].author+" - "+b[d].title+"</li>")}}}}function SaveFavorites(){jQuery("#SaveFavorites").hide();player.sendEvent("LOAD",arrayPlaylist);playlistNews=0;playlistLoaded=true;PrintPlaylistPlayer();songListened=false}function ScrollToMain(){jQuery.scrollTo("#main",800)}function SendPass(){email=$("#email").val();if(email==""){alert("Debe ingresar el email.");jQuery("#email").focus()}else{if(!email.match("@")){alert("Ingrese un email v\u00E1lido.");jQuery("#email").focus()}else{jQuery("#btnForgotPass").attr("disabled","disabled");jQuery("#ForgotPassMSG").css({background:"url('img/spinner.gif') center no-repeat"});jQuery("#ForgotPassMSG").show();CTRequest("modules/users.php","POST","op=SendPass&email="+email,"html",SendPassFN)}}}function SendPassFN(a){jQuery("#btnForgotPass").attr("disabled","");jQuery("#ForgotPassMSG").css({background:""});jQuery("#ForgotPassMSG").hide()}function ItemListener(b){if(currentState=="PLAYING"){if(playlistLoaded){PlayerPlaying();if(b.index!=currentItem){previousItem=currentItem;currentItem=b.index;PrintPlaylistPlayer(currentItem);var a=null;a=player.getPlaylist();desc=a[currentItem].description;temp=desc.split(":");currentItemType=temp[0];currentItemID=parseInt(temp[1]);alert("playlistLoaded, currentItemID: "+currentItemID+", currentItemType: "+currentItemType);if(currentItemID>0&&currentItemType!=""){songListened=true;op="SongListened";if(currentItemType=="V"){op="VideoViewed"}CTRequest("modules/public.php","POST","op="+op+"&id="+currentItemID,null)}}}else{alert("!playlistLoaded currentItemID: "+currentItemID+", currentItemType: "+currentItemType);if(currentItemID>0&&currentItemType!=""){songListened=true;op="SongListened";if(currentItemType=="V"){op="VideoViewed"}CTRequest("modules/public.php","POST","op="+op+"&id="+currentItemID,null)}}}}function StateListener(a){currentState=a.newstate;previousState=a.oldstate;if((currentState=="COMPLETED")&&(previousState=="PLAYING")){currentItem=a.index;currentLength=player.getPlaylist().length;songListened=false;if(currentItem<currentLength-1||playlistOn){player.sendEvent("LOAD",arrayPlaylist);player.sendEvent("NEXT");jQuery("#SaveFavorites").hide()}}}function stripslashes(a){a=a.replace(/\\/g,"");return a}function ToggleDiv(a){jQuery("#"+a).toggle()}function TogglePlaylist(){jQuery("#PlaylistContent").slideToggle()}function ToggleOptions(b){var c="";var a="";if(b==1){c="form_login";a="nick_nav";jQuery("#form_forgot_pass").hide()}else{if(b==2){c="form_forgot_pass";a="email_nav";jQuery("#form_login").hide()}}jQuery("#"+c).toggle();jQuery("#options_text").toggle();jQuery("#"+a).focus()}function Trim(b){var a="";a=TrimLeft(b);a=TrimRight(a);return a}function TrimLeft(c){var b="";var a=len=0;if(c+""=="undefined"||c==null){return""}c+="";if(c.length==0){b=""}else{len=c.length;while((a<=len)&&(c.charAt(a)==" ")){a++}b=c.substring(a,len)}return b}function TrimRight(c){var b="";var a=0;if(c+""=="undefined"||c==null){return""}c+="";if(c.length==0){b=""}else{a=c.length-1;while((a>=0)&&(c.charAt(a)==" ")){a--}b=c.substring(0,a+1)}return b}function ValidarRegistro(){if(!IsAlphaNum(Trim($("#usuario_nick").val()))){alert("El nick solo puede tener números y letras, no se aceptan caracteres especiales ni tildes");jQuery("#usuario_nick").focus();return false}if(!IsEmailAddress(Trim($("#usuario_email").val()))){alert("Ingrese un E-Mail válido");jQuery("#usuario_email").focus();return false}return true}function ViewSection(a,b){jQuery("#DivLoading").show();CTRequest("modules/"+a+".php","POST","op="+b,"html",ViewSectionFN);LoadScript(a)}function ViewSectionFN(a){if(a!=""){jQuery("#Main").html(a)}else{Boxy.ask("<font class='error'>Tenemos un Error, intenta de nuevo.</font>",null,null,{title:"<img src='img/error.png' alt='' />&nbsp;Error",closeable:true,closeText:"[Cerrar]"})}FixPNG();jQuery("#DivLoading").hide()}function ViewSectionAdmin(a,b){jQuery("#DivLoading").show();CTRequest("admin/"+a+".php","POST","op="+b,"html",ViewSectionAdminFN);LoadScriptAdmin(a)}function ViewSectionAdminFN(a){if(a!=""){jQuery("#Main").html(a)}else{Boxy.ask("<font class='error'>Tenemos un Error, intenta de nuevo.</font>",null,null,{title:"<img src='img/error.png' alt='' />&nbsp;Error",closeable:true,closeText:"[Cerrar]"})}FixPNG();jQuery("#DivLoading").hide()}function ViewTab(a){jQuery("#"+tabSelected+"Updates").slideUp("slow");jQuery("#"+a+"Updates").slideDown("slow");jQuery("#Tab"+a).css({background:"#CCC"});jQuery("#Tab"+tabSelected).css({background:""});tabSelected=a};
