var req="featured";
var pag=1;
var cat=0;
var sea="";
function setRequest(str)
{
req=str;
pag=1;
cat=0;
sea="";
$(".widget_title").html(str.charAt(0).toUpperCase() + str.slice(1) + " Videos");
getData();
}
function display(number)
{
if(number==0)
{
number=pag;
}
if(cat==0 && sea=="")
{
setPage(number);
}
else if(sea!="")
{
setSearchPage(number);
}
else
{
setChannelPage(number);
}
}
function setPage(page)
{
pag=page;
getData();
}
function setChannelPage(page)
{
pag=page;
getVidChannel();
}
function setSearchPage(page)
{
pag=page;
getVidSearch();
}
function getData()
{
// display loading
$("#loadingResult").html('
');
// query data
$.ajax({
type: "GET",
url: "ajax.php?req=" + req +"&page="+ pag, // this is the path from above
success: function(response) {
$("#tempResult").html(response);
$("#loadingResult").html($("#records").html());
$("#pagingResult").html($("#pagination").html());
}
});
}
function subChannel(channel_id)
{
cat=channel_id;
getSubChannel()
}
function vidChannel(channel_id)
{
cat=channel_id;
getVidChannel()
}
function getSubChannel()
{
// display loading
$("#loadingResult").html('
');
// query data
$.ajax({
type: "GET",
url: "ajax.php?req=subchannel&cat_id=" + cat +"&page="+ pag, // this is the path from above
success: function(response) {
$("#tempResult").html(response);
$("#loadingResult").html($("#records").html());
$("#pagingResult").html($("#pagination").html());
}
});
}
function getVidChannel()
{
// display loading
$("#loadingResult").html('
');
// query data
$.ajax({
type: "GET",
url: "ajax.php?req=vidchannel&cat_id=" + cat +"&page="+ pag, // this is the path from above
success: function(response) {
$("#tempResult").html(response);
$("#loadingResult").html($("#records").html());
$("#pagingResult").html($("#pagination").html());
}
});
}
function setDisplay(vid)
{
playVideo(vid);
}
function playVideo(vid)
{
// display loading
$("#loadingResult").html('
');
// query data
$.ajax({
type: "GET",
url: "ajax.php?req=player&uniq_id="+ vid, // this is the path from above
success: function(response) {
$("#tempResult").html(response);
$("#loadingResult").html($("#records").html() + '');
$("#pagingResult").html("");
playSWF ($("#videoPath").html(), 'mediaspace', '192', '135', 'q4b6a9c8', 'true')
}
});
}
function playSWF (fileName, divName, vwidth, vheight, hw_cdn_id, autoplay) {
var so = new SWFObject("player.swf","Player",vwidth,vheight,"9","#FFFFFF");
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','always');
so.addVariable('logo.file','playerlogo.png');
so.addVariable('autostart', autoplay);
so.addVariable('stretching','fill');
so.addVariable('skin','glow.zip');
so.addVariable('playlistfile','mrss.php?file='+fileName+'%26hw_cdn_id='+hw_cdn_id);
so.addVariable('playlist','none');
so.addVariable('repeat','list');
so.addVariable('logo.hide','false');
so.addVariable('logo.position','bottom-right');
so.write(divName);
}
function search_video()
{
sea=$('#search').val();
if(sea!="")
{
getVidSearch();
}
else
{
alert('Please put some keyword');
}
}
function getVidSearch()
{
// display loading
$("#loadingResult").html('
');
// query data
$.ajax({
type: "GET",
url: "ajax.php?req=vidsearch&key=" + sea +"&page="+ pag, // this is the path from above
success: function(response) {
$("#tempResult").html(response);
$("#loadingResult").html($("#records").html());
$("#pagingResult").html($("#pagination").html());
}
});
}