///
// These are the main Ajax functions for the site. They will make a request and load the needed section
//
//global variable for the current video id.
var leftLogoutTxt='
';
var bottomLogoutTxt="
";
var detailsOn="images/Details_InfoTab_ON.jpg";
var detailsOff="images/Details_InfoTab.jpg";
function selectRange(what)
{
what.createTextRange();
}
var updateLoginInfo = function()
{
$cs('LoginFooter_DIV').innerHTML=bottomLogoutTxt;
$cs('UserLogin_DIV').innerHTML=leftLogoutTxt;
updateUserWelcome();
window.setTimeout("updateRatingHits(currentVideoID)",1000);
}
var updateUserWelcome=function()
{
var link="gallery.php";
var pars="username=1";
var myAjax = new Ajax.Updater(
'HelloUser',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars
});
}
var _loadVideo=function()
{
videoID=currentVideoID
var link="videoDetail.php";
var pars="videoID="+videoID+"&coments=1";
var myAjax = new Ajax.Updater(
'videoInfoComments_DIV',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars,
onComplete:_loadVideoCB
});
}
var _loadVideoCB=function()
{
showComments();
}
var updateLogin=function()
{
var link="login.php";
var pars="updateLogin=1"
var myAjax = new Ajax.Updater(
'UserLogin_DIV',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars
});
updateRatingHits(currentVideoID);
}
var updateRatingHits=function(videoID)
{
try{
var link="hitsvotes.php";
var pars="videoID="+videoID
var myAjax = new Ajax.Updater(
'VoteHits_DIV',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars
});
}
catch(e){alert(e)}
}
var loadVideo=function(videoID)
{
currentVideoID=videoID;
var link="videoDetail.php";
var pars="videoID="+videoID;
var myAjax = new Ajax.Updater(
'videoInfoComments_DIV',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars,
onComplete:completeLoadVideo
});
}
var completeLoadVideo=function()
{
updateRatingHits(currentVideoID);
loadVideoTitle(currentVideoID);
showVideoInfo();
loadVideoFile(currentVideoID);
}
var loadVideoFile=function(videoID)
{
var link="loadVideo.php";
var pars="videoID="+currentVideoID
var myAjax = new Ajax.Request(
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars,
onSuccess:function(req){
setFlvPath(req.responseText);
}
});
};
var loadVideoTitle=function()
{
var link="nowplaying.php";
var pars="videoID="+currentVideoID
var myAjax = new Ajax.Updater(
'NowPlaying',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars
});
}
var updateListingRow=function(page)
{
var sort=$cs('sortVideoList');
var sortBy=sort.options[sort.selectedIndex].value;
var link="videoListPaging.php";
var pars="page="+page+"&sort="+sortBy;
var myAjax = new Ajax.Updater(
'VideoListTitle_DIV',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars
});
updatePagingRow(link,pars);
}
function showPageResponse(req)
{
var newdiv = document.createElement("div");
newdiv.innerHTML = req.responseText;
var container = document.getElementById("VideoList_DIV");
container.innerHTML="";
container.appendChild(newdiv);
}
var updatePage=function(page)
{
updateListingRow(page);
var sort=$cs('sortVideoList');
var sortBy=sort.options[sort.selectedIndex].value;
var link="videoList.php";
$cs('VideoList_DIV').innerHTML="";
var pars="page="+page+"&sort="+sortBy;
var myAjax = new Ajax.Request(
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars,
onComplete:showPageResponse
});
}
var updateSort=function()
{
var sort=$cs('sortVideoList');
var sortBy=sort.options[sort.selectedIndex].value;
if(sortBy>0)
updatePage(0);
}
var doVote=function(vote,videoID)
{
var link="hitsvotes.php";
var pars="videoID="+videoID+"&voteScore="+vote+"&doVote=1";
var myAjax = new Ajax.Updater(
'VoteHits_DIV',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars
});
}
var sortAuthor=function(page,author)
{
updateAuthorListingRow(author,page);
var link="videosByAuthor.php";
$cs('VideoList_DIV').innerHTML="";
var pars="page="+page+"&ownerID="+author;
var myAjax = new Ajax.Request(
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars,
onComplete:showPageResponse
});
}
var updatePagingRow=function(url,pars)
{
pars=pars+"&paging=1";
var myAjax = new Ajax.Updater(
'VideoList_Paging_DIV',
url,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars
});
}
var updateAuthorListingRow=function(author,page)
{
var link="videoAuthorPaging.php";
var pars="page="+page+"&ownerID="+author;
var myAjax = new Ajax.Updater(
'VideoListTitle_DIV',
link,
{
method: 'GET',
asynchronous:true,
evalScripts:true,
parameters:pars
});
updatePagingRow(link,pars);
}
/* Main functions */
function updateComments()
{
//needed for CSS bug
removeWindow();
$cs('VideoInfo_Comments').className="InfoBG";
$cs('VidCommentMain_DIV').innerHTML="";
_loadVideo();
}
function showComments()
{
// $cs('VideoInfo_IMG').src=detailsOff;
$cs('VideoInfo_Div').style.display="none";
$cs('CommentsBody_Div').style.display="block";
$cs('VideoInfo_Comments').className="CommentsBG";
$cs('info_image').src="images/Info_Comments/Info_OFF.jpg";
$cs('comments_image').src="images/Info_Comments/Comments.jpg";
}
function showVideoInfo()
{
//$cs('VideoInfo_IMG').src=detailsOn;
$cs('VideoInfo_Div').style.display="block";
$cs('CommentsBody_Div').style.display="none";
$cs('VideoInfo_Comments').className="InfoBG";
$cs('info_image').src="images/Info_Comments/Info.jpg";
$cs('comments_image').src="images/Info_Comments/Comments_OFF.jpg";
}