function GetVideosCategory(category,page) {
    //window.alert("category: "+category);
    
    xmlhttpPost("getcategory.jsp","content","category="+category+"&page="+page);
}



function GetCompetitionInfo() {
    //window.alert("category: "+category);
    
    xmlhttpPost("getcompetitioninfo.jsp","content","");
}

function GetMonthlyWinners() {
    //window.alert("category: "+category);
    
    xmlhttpPost("getmonthlywinners.jsp","content","");
}

function GetGrandPrize() {
    //window.alert("category: "+category);
    
    xmlhttpPost("getgrandprize.jsp","content","");
}


function GetInformation(vid) {
   var h = document.getElementById("contentRight").scrollHeight;
    document.getElementById("overlay").style.height = h+"px";
    
    document.getElementById("overlay").style.display="block";
    document.getElementById("divinfo").style.display="block";
    
    xmlhttpPost("getinfo.jsp","divinfo","videoid="+vid);
}

function GetPlayVideo(index,  videourl) {
    
    var h = document.getElementById("contentRight").scrollHeight;
    document.getElementById("overlay").style.height = h+"px";
    document.getElementById("overlay").style.display="block";
    loadPlayVideoDivLayout(index);
    
    var so = new SWFObject('../javascript/mediaplayer.swf','mpl','250','234','8', "#000000");
    so.addParam('allowscriptaccess','always');
    so.addParam('allowfullscreen','true');
    so.addVariable('width','250');
    so.addVariable('height','234');
    var url = "";
    if (videourl.length>0) {
        url = videourl;
    }
    so.addVariable('file',url);
    so.addVariable("enablejs","true");
    so.addVariable("javascriptid","mpl");
    so.write('vidcontainter');
    xmlhttpPost("getplayvideo.jsp","playinformation","index="+index);    
}


function GetComments(index, page) {
    
    document.getElementById("overlay").style.display="block";
    xmlhttpPost("getvideocomments.jsp","commentBox","index="+index+"&page="+page);
    document.getElementById("commentBox").style.display="block";
}




function loadPlayVideoDivLayout(videoid) {
   
    document.getElementById("divplay").innerHTML="";
    document.getElementById("divplay").innerHTML="<div class=\"rateApBut\"><a href=\"#\" onclick=\"closeoptions(); return false;\"><img src=\"../images/Close.gif\" width=\"80\" height=\"21\" border=\"0\" /></a></div><div class=\"videoContainer\" id=\"vidcontainter\"><img src=\"../images/GenericRating.jpg\" width=\"280\" height=\"234\" /></div><div id=\"playinformation\"></div>";
    document.getElementById("divplay").style.display="block";
    document.getElementById("divplay").className = "play video";
}


function getrating(videoid){
    document.getElementById("vidcontainter").innerHTML="";
    var h = document.getElementById("divplay");
    h.className = "play rate";
   xmlhttpPost("getrate.jsp","divplay","index="+videoid);
}

function setrating(videoid, rating){
    
  //add rating function
  xmlhttpPost("setrating.jsp","divplay","index="+videoid+"&rating="+rating);
}

function getvideooptions(videoid){
    
    var h = document.getElementById("divplay");
    h.className = "options";
    xmlhttpPost("getvideooptions.jsp","divplay","index="+videoid);
}

function addvideotofavorites(videoindex){
    
    xmlhttpPost("addvideotofavourites.jsp","divResult","index="+videoindex);
}

function addartisttofavorites(videoindex){
    
    xmlhttpPost("addartisttofavourites.jsp","divResult","index="+videoindex);
}

function addcomment(videoindex){
    
    var comment = "";
    comment = document.getElementById("textarea").value;
    //alert(comment);
    document.getElementById("textarea").value = "";
    if (comment!="") {
    xmlhttpPost("addvideocomment.jsp","divComments","index="+videoindex+"&comment="+comment);
    } else {
        window.alert("Comment field is empty.");
    }
}


function getmrbigcomment(videoid){
 
  //add rating function
  xmlhttpPost("getmrbigcomment.jsp","divplay","index="+videoid);
}









function sendtobuddy(videoindex){
    //document.getElementById("divplay").style.display="none";
    document.getElementById("divplay").innerHTML = "";
    document.getElementById("divplay").className="artistChat sendtobuddy";
    xmlhttpPost("getsendtobuddy.jsp","divplay","index="+videoindex);
}


function refertofriend(videoindex){
    var message  = document.getElementById("textarea").value;
    var username = document.getElementById("friendname").value;
    var cellno   = document.getElementById("friendnumber").value;
    if (message.length==0) {
        window.alert("No message entered.");
    } else if (username.length==0 && cellno.length==0) {
        window.alert("Please enter a username or cell number.");
    }else {
        xmlhttpPost("sendvideotobuddy.jsp","divplay","index="+videoindex+"&message="+message+"&username="+username+"&cellno="+cellno);
    }
}

function commenttoartist(videoindex){
    
// add comment to artist function
    document.getElementById("divplay").innerHTML = "";
    document.getElementById("divplay").className="artistChat sendtobuddy";
    xmlhttpPost("getartistcomments.jsp","divplay","index="+videoindex);
}


function sendartistcomment(videoindex,userid,artistid){
    
// add comment to artist function
    var message = document.getElementById("textarea").value;
    document.getElementById("divplay").innerHTML = "";
    document.getElementById("divplay").className="artistChat sendtobuddy";
    xmlhttpPost("sendartistcomment.jsp","divplay","index="+videoindex+"&message="+message+"&userid="+userid+"&artistid="+artistid);
}



function closediv(divname) {
    
    var divcontainer = document.getElementById(divname);
    if (divcontainer!=null) {
        divcontainer.style.display="none";
    }
}

function closeinfo() {
    closediv("overlay");
    closediv("divinfo");
    
}

function closeoptions() {
    closediv("overlay");
    closediv("divplay");
    
}

function loadVideo() {
    
}


function closeComment() {
    closediv("overlay");
    closediv("commentBox");
}







