/////////////////////////////////////////////////////////////////////////////////
// Play and Update all info into the page
////////////////////////////////////////////////////////////////////////////////
function refreshAndPlayVideoPage (guid)
{
if (guid.indexOf("{")==-1)
guid = "{"+guid+"}";
//alert("refresh1");
try {
stopPlayer();
} catch(e) { alert("no pude hacer stop");}
try {
getVideoInfo(guid);
} catch(e) {}
//alert("refresh2");
try {
// reloadAdsAndPlayVideo(guid);
} catch(e) {}
//alert("refresh3");
try {
showRelatedVideos(guid);//myartistname);
} catch(e) {}
//alert("refresh4");
try {
showBrowseVideos(guid);
} catch(e) {}
//alert("refresh5");
try {
getEntityComments(guid,1);
} catch(e) {}
//alert("refresh6");
}
function getUserId() {
var userId;
userId = getCookie("batangauserid");
var batangakey;
batangakey = getCookie("batangakey");
if ((userId == null)||(batangakey == null)) {
userId = getCookie("fakeId");
}
if (userId == null) {
userId = "-1"+Math.random().toString().substr(2,8);
setCookieD("fakeId",escape(userId),365,"batanga.com");
}
return userId;
}
function isUserLoged()
{
var batangaU=getCookie("batangauserid");
var batangaK=getCookie("batangakey");
if ((batangaU=='' || batangaU == null)||(batangaK=='' || batangaK == null))
return false;
else
return true;
}
function checkFavoriteVideo(strGuid)
{
tagNameFavorites = "myFavoriteVideo"
if (!isUserLoged()){
changeInnerHTML(tagNameFavorites,'
Login to Add to my Favorites');
}
else{
checkFavorite(getUserId(),strGuid,'Video');
}
}
/**********************************************************************************/
var errorMessage = "Error retrieving AJAX data";
/**********************************************************************************/
var xmlHttp1;
function getPopularTagsForEntity(eGuid,eTitle)
{
nTags="8";
try {
var url="/video/ajax/getPopularTagsForEntity.asp?sid=" + Math.random()+"&guid=" + eGuid + "&nTags=" + nTags +"&idioma="+getCookie("idioma")+"&titlePres="+eTitle;
xmlHttp1=GetXmlHttpObject(getPopularTagsForEntityResult);
xmlHttp1.open("GET", url , true);
xmlHttp1.send(null);
} catch (e) {}
}
function getPopularTagsForEntityResult()
{
if ((xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete") && xmlHttp1.status==200)
{
changeInnerHTML("pTags",xmlHttp1.responseText);
}
}
/**********************************************************************************/
var xmlHttpAdd;
function adCount(B)
{
nTags="8";
// try {
// var url="/adserver/adCount.asp?sid=" + Math.random()+"&B=" + B;
// xmlHttpAdd=GetXmlHttpObject(adCountResult);
// xmlHttpAdd.open("GET", url , true);
// xmlHttpAdd.send(null);
// } catch (e) {}
var img = document.createElement('img');
img.id = "playvideopixel";
img.src = "http://adserver.planetatv.com/admentor/adserve.asp?B="+B+"&nocache="+Math.random();
document.body.appendChild(img);
}
function adCountResult()
{
if ((xmlHttpAdd.readyState==4 || xmlHttpAdd.readyState=="complete") && xmlHttpAdd.status==200)
{
//changeInnerHTML("pTags",xmlHttpAdd.responseText);
}
}
/**********************************************************************************/
var xmlHttpSearch;
function searchVideo(q,iPage)
{
changeInnerHTML("serchEntities","
");
try {
var url="/video/ajax/searchVideo.asp?cacherefresh_=true&sid=" + Math.random()+"&q=" + q+"&iPage="+iPage;
xmlHttpSearch=GetXmlHttpObject(searchVideoResult);
xmlHttpSearch.open("GET", url , true);
xmlHttpSearch.send(null);
} catch (e) {}
}
function searchVideoResult()
{
if ((xmlHttpSearch.readyState==4 || xmlHttpSearch.readyState=="complete") && xmlHttpSearch.status==200)
{
changeInnerHTML("serchEntities",xmlHttpSearch.responseText);
checkSearchVideos();
//alert("searchVideoResult");
ProcessFavorites();
}
}
/**********************************************************************************/
var xmlHttpVisits;
function getEntityVisits(guid)
{
return false;
try {
var url="/video/ajax/getEntityVisits.asp?&sid=" + Math.random()+"&guid=" + guid;
xmlHttpVisits=GetXmlHttpObject(getEntityVisitsResult);
xmlHttpVisits.open("GET", url , true);
xmlHttpVisits.send(null);
} catch (e) {}
}
function getEntityVisitsResult()
{
if ((xmlHttpVisits.readyState==4 || xmlHttpVisits.readyState=="complete") && xmlHttpVisits.status==200)
{
changeInnerHTML("entityVisits",xmlHttpVisits.responseText);
}
}
/**********************************************************************************/
var xmlHttpRating;
function getEntityRatings(guid)
{
try {
var url="/video/ajax/getEntityRatings.asp?&sid=" + Math.random()+"&guid=" + guid + "&batangauser=" + getUserId();
xmlHttpRating=GetXmlHttpObject(getEntityRatingsResult);
xmlHttpRating.open("GET", url , true);
xmlHttpRating.send(null);
} catch (e) {}
}
function getEntityRatingsResult()
{
if ((xmlHttpRating.readyState==4 || xmlHttpRating.readyState=="complete") && xmlHttpRating.status==200)
{
changeInnerHTML("entityRatings",xmlHttpRating.responseText);
}
}
/**********************************************************************************/
var xmlHttpFavorited;
function getEntityFavorited(guid)
{
try {
var url="/video/ajax/getEntityFavorited.asp?&sid=" + Math.random()+"&guid=" + guid;
xmlHttpFavorited=GetXmlHttpObject(getEntityFavoritedResult);
xmlHttpFavorited.open("GET", url , true);
xmlHttpFavorited.send(null);
} catch (e) {}
}
function getEntityFavoritedResult()
{
if ((xmlHttpFavorited.readyState==4 || xmlHttpFavorited.readyState=="complete") && xmlHttpFavorited.status==200)
{
changeInnerHTML("entityFavorited",xmlHttpFavorited.responseText);
}
}
/**********************************************************************************/
var xmlHttpVideoInfo;
function getVideoInfo(guid)
{
strGuid=guid;
try {
var url="/video/ajax/getVideoInfo.asp?cacherefresh=true&sid=" + Math.random()+"&guid=" + guid;
xmlHttpVideoInfo=GetXmlHttpObject(getVideoInfoResult);
xmlHttpVideoInfo.open("GET", url , true);
xmlHttpVideoInfo.send(null);
} catch (e) {}
}
function getVideoInfoResult()
{
if ((xmlHttpVideoInfo.readyState==4 || xmlHttpVideoInfo.readyState=="complete") && xmlHttpVideoInfo.status==200)
{
myTitle=getObj("entityTitle1").innerHTML;
changeInnerHTML("videoInfo",xmlHttpVideoInfo.responseText);
//changeInnerHTML("entityTitle2",myTitle);
document.title=myTitle;
launchJavascript(xmlHttpVideoInfo.responseText);
reloadAdsAndPlayVideo(strGuid);
}
}
function replaceAll(text, strA, strB)
{
while ( text.indexOf(strA) != -1)
{
text = text.replace(strA,strB);
}
return text;
}
/**********************************************************************************/
var xmlHttpComments;
function getEntityComments(guid,iPage)
{
//var url="/video/ajax/getEntityComments.asp?&sid=" + Math.random()+"&guid=" + guid+"&idioma="+getCookie("idioma")+"&iPage="+iPage;
try {
var url="/video/comments/getEntityComments.asp?&sid=" + Math.random()+"&guid=" + guid+"&idioma="+getCookie("idioma")+"&iPage="+iPage;
xmlHttpComments=GetXmlHttpObject(getEntityCommentsResult);
xmlHttpComments.open("GET", url , true);
xmlHttpComments.send(null);
} catch (e) {}
}
function getEntityCommentsResult()
{
if ((xmlHttpComments.readyState==4 || xmlHttpComments.readyState=="complete") && xmlHttpComments.status==200)
{
changeInnerHTML("comments",xmlHttpComments.responseText);
}
}
var xmlHttpComments2;
function postComment(guid,comment)
{
//alert(guid);
if (comment.length > 500)
{
alert("Comment must be 500 characters or less");
return false;
}
changeInnerHTML("postCommentText","
");
try {
var url="/video/ajax/addEntityComment.asp?&sid=" + Math.random()+"&guid=" + guid + "&userId=" + getUserId() + "&comment="+comment + "&batangauser="+getCookie("batangausername") + "&screenname="+getCookie("DJScreenName")+ "&email="+getCookie("batangacom")
xmlHttpComments2=GetXmlHttpObject(postCommentResult);
xmlHttpComments2.open("GET", url , true);
xmlHttpComments2.send(null);
} catch (e) {}
return false;
}
function postCommentResult()
{
if ((xmlHttpComments2.readyState==4 || xmlHttpComments2.readyState=="complete") && xmlHttpComments2.status==200)
{
getEntityComments(strGuid,1);
}
}
/**********************************************************************************/
var xmlHttpVote;
var vScore;
function voteForEntity(score)
{
changeInnerHTML('entityRatings','
');
vScore=score;
try {
var url="/video/ajax/scorePresentation.asp?sid=" + Math.random()+"&guid=" + strGuid + "&score=" + score + "§ion=" + section + "&userid=" + getUserId() + "&username="+getCookie("batangausername")+ "&screenname="+getCookie("DJScreenName") + "&email="+getCookie("batangacom");
xmlHttpVote=GetXmlHttpObject(voteForEntityResult);
xmlHttpVote.open("GET", url , true);
xmlHttpVote.send(null);
} catch (e) {}
}
function voteForEntityResult()
{
if ((xmlHttpVote.readyState==4 || xmlHttpVote.readyState=="complete") && xmlHttpVote.status==200)
{
if (xmlHttpVote.responseText!=0)
{
alert("ERROR: \n\n"+xmlHttpVote.responseText);
return false;
}
getEntityRatings(strGuid);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Related Videos
//////////////////////////////////////////////////////////////////////////////////////////////////////
var xmlHttpRelVideo;
function showRelatedVideos(guid)
{
//if (artistname.length==0)
//{ document.getElementById("RelatedVideos").innerHTML=""
// return
//}
xmlHttpRelVideo=GetXmlHttpObjectX()
if (xmlHttpRelVideo==null)
{alert ("Browser does not support HTTP Request")
return
}
try {
var url="/video/relatedVideos/getRelatedVideos.asp"
url=url+"?guid="+guid+'&sid='+Math.random()
xmlHttpRelVideo.onreadystatechange=stateChanged
xmlHttpRelVideo.open("GET",url,true)
xmlHttpRelVideo.send(null)
} catch (e) {}
}
function stateChanged()
{ if (xmlHttpRelVideo.readyState==4 || xmlHttpRelVideo.readyState=="complete")
{
document.getElementById("RelatedVideos").innerHTML=xmlHttpRelVideo.responseText;
launchJavascript(xmlHttpRelVideo.responseText);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Browse Videos
//////////////////////////////////////////////////////////////////////////////////////////////////////
var xmlHttpBrowseVideo;
function showBrowseVideos(guid,section)
{
//if (artistname.length==0)
//{ document.getElementById("RelatedVideos").innerHTML=""
// return
//}
xmlHttpBrowseVideo=GetXmlHttpObjectX()
if (xmlHttpBrowseVideo==null)
{alert ("Browser does not support HTTP Request")
return
}
try {
var url="/video/browse/getBrowseVideos.asp"
url=url+"?guid="+guid;
if (section != null)
url = url+'&bsection='+section;
url = url+'&sid='+Math.random()
xmlHttpBrowseVideo.onreadystatechange=browseStateChanged
xmlHttpBrowseVideo.open("GET",url,true)
xmlHttpBrowseVideo.send(null)
} catch (e) {}
}
function browseStateChanged()
{ if (xmlHttpBrowseVideo.readyState==4 || xmlHttpBrowseVideo.readyState=="complete")
{
if (xmlHttpBrowseVideo.status==200) {
document.getElementById("BrowseVideos").innerHTML=xmlHttpBrowseVideo.responseText;
launchJavascript(xmlHttpBrowseVideo.responseText);
} else {
document.getElementById("BrowseVideos").innerHTML=errorMessage;
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Playlist Update
//////////////////////////////////////////////////////////////////////////////////////////////////////
var xmlHttpPlaylistVideo;
function reloadPlaylist(guid,ignoreFirstVideoInTheCookie)
{
//if (artistname.length==0)
//{ document.getElementById("RelatedVideos").innerHTML=""
// return
//}
xmlHttpPlaylistVideo=GetXmlHttpObjectX()
if (xmlHttpPlaylistVideo==null)
{alert ("Browser does not support HTTP Request")
return
}
try {
var url="/video/ajax/getPlaylist.asp"
url=url+'?guid='+guid;
if (ignoreFirstVideoInTheCookie)
url = url + "&ignorefirstvideo=true";
url = url +'&sid='+Math.random()
xmlHttpPlaylistVideo.onreadystatechange=showUpdatedPlaylist
xmlHttpPlaylistVideo.open("GET",url,true)
xmlHttpPlaylistVideo.send(null)
} catch (e) {}
}
function showUpdatedPlaylist()
{ if (xmlHttpPlaylistVideo.readyState==4 || xmlHttpPlaylistVideo.readyState=="complete")
{
document.getElementById("playlistInPage").innerHTML=xmlHttpPlaylistVideo.responseText;
launchJavascript(xmlHttpPlaylistVideo.responseText);
//alert("showUpdatedPlaylist");
ProcessFavorites();
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
// My Favorites Videos
//////////////////////////////////////////////////////////////////////////////////////////////////////
var xmlHttpMyFavVideo;
function showMyFavVideos(cacherefresh)
{
var key = getCookie('batangakey');
var userid = getCookie('batangauserid');
if(key!='' && userid!=''&& key!=null && userid!=null)
{
xmlHttpMyFavVideo=GetXmlHttpObjectX()
if (xmlHttpMyFavVideo==null)
{alert ("Browser does not support HTTP Request")
return
}
var url="/video/myfavorites/myfavorites.asp"
url=url+'?batangauserid='+userid;
url = url +'&sid='+Math.random()
if (cacherefresh)
url = url +'&cacherefresh=true';
xmlHttpMyFavVideo.onreadystatechange=stateChangedMyFav
xmlHttpMyFavVideo.open("GET",url,true)
xmlHttpMyFavVideo.send(null)
}
else
{
document.getElementById("favorites").innerHTML='Login My Batanga'
}
}
function stateChangedMyFav()
{ if (xmlHttpMyFavVideo.readyState==4 || xmlHttpMyFavVideo.readyState=="complete")
{ document.getElementById("favorites").innerHTML=xmlHttpMyFavVideo.responseText;
//launchJavascript(xmlHttpMyFavVideo.responseText);
checkMyFavorites();
//alert("stateChangedMyFav");
ProcessFavorites();
}
}
function GetXmlHttpObjectX()
{var objXMLHttp=null
if (window.XMLHttpRequest)
{objXMLHttp=new XMLHttpRequest();}
else if (window.ActiveXObject)
{objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");}
return objXMLHttp
}
/////////////////////////////////////////////////////////////////////////////////
// Send video
////////////////////////////////////////////////////////////////////////////////
function enviarVideo(guid) {
popUpWindow2('/player/new/enviar_new.asp?guid='+guid+'&idioma=ES','enviar',300,437);
}
function popUpWindow2(url, name, width, height) {
var left;
var top;
left = getCenteredLeft('789') - 5;
top = getCenteredTop('545') - 12;
// Build the param string.
var params = "toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=0";
params += ",width=" + width;
params += ",height=" + height;
params += ",left=" + left;
params += ",top=" + top;
params += ",screenX=" + left; // for Netscape.
params += ",screenY=" + top;
// Open the window. Set the opener property if it's missing. And return the window handle.
var wh = window.open(url, name, params);
return wh;
//if (wh.opener == null) wh.opener = window;
}
function getCenteredLeft(width) {
var sw = screen.availWidth;
if (sw > 0) return (Math.floor((sw - width) / 2));
else return (0);
}
function getCenteredTop(height) {
var sh = screen.availHeight;
if (sh > 0) return (Math.floor((sh - height) / 2));
else return (0);
}
function selectMenuOption(mysection)
{
try{
getObj("menu_1").className="";
getObj("menu_2").className="";
getObj("menu_6").className="";
getObj("menu_7").className="";
getObj("menu_9").className="";
ocultarCapa("submenu_chicas");
ocultarCapa("submenu_movies");
ocultarCapa("submenu_music");
ocultarCapa("submenu_estilo");
ocultarCapa("submenu_home");
if (mysection=="chicas"){
mostrarCapa("submenu_chicas");
getObj("menu_9").className="select";
showSubmenuPixeles(submenuChicasOpt);
}
else if (mysection=="movies"){
mostrarCapa("submenu_movies");
getObj("menu_6").className="select";
showSubmenuPixeles(submenuMoviesOpt);
}
else if (mysection=="music"){
mostrarCapa("submenu_music");
getObj("menu_2").className="select";
showSubmenuPixeles(submenuMusicOpt);
}
else if (mysection=="style"){
mostrarCapa("submenu_estilo");
getObj("menu_7").className="select";
showSubmenuPixeles(submenuStyleOpt);
}
else{
mostrarCapa("submenu_home");
getObj("menu_1").className="select";
showSubmenuPixeles(submenuHomeOpt);
}
}
catch(e){}
}