function GetContactsAndMessages() {
    xmlhttpPost("getcontactsandmessages.jsp","content","");
}

function GetMyClips(pageid) {
   
    xmlhttpPost("getmyclips.jsp","content","page="+pageid);
}

function GetMyProfile() {
    xmlhttpPost("getmyprofile.jsp","content","");
    
}

function GetProfileAvatar() {
    xmlhttpPost("getprofileavatar.jsp","profile","");
    
}

function GetCanteen() {
    
    xmlhttpPost("getcanteen.jsp","content","");
}

function GetChatMessages() {
    var requesttime = document.getElementById("hdnchatback").value;
    if (requesttime=="") {
        document.getElementById("hdnchatback").value = "Called";
        xmlhttpPostwithoutLoad("getchatmessages.jsp","divchat","",false);
    }
    
    
}

function addchatmessage() {
    var message = document.getElementById("textarea").value;
    document.getElementById("textarea").value="";
    if (message!="") {
      xmlhttpPostwithoutLoad("setchatmessages.jsp","divchat","message="+message,true);
    }
    
}

function GetInformation(videoid) {
    
    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="+videoid);
}



function GetComments(videoid) {
    document.getElementById("overlay").style.display="block";
    
    xmlhttpPost("getvideocomments.jsp","commentBox","videoid="+videoid+"&page="+0);
    document.getElementById("commentBox").style.display="block";
}




function GetPlayVideo(index, videoid, videourl) {
    
    var h = document.getElementById("contentRight").scrollHeight;
    document.getElementById("overlay").style.height = h+"px";
    document.getElementById("overlay").style.display="block";
    loadPlayVideoDivLayout();
    
    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","videoid="+videoid);    
}

function loadPlayVideoDivLayout() {
    
    document.getElementById("divplay").innerHTML="";
    document.getElementById("divplay").innerHTML="<div class=\"rateApBut\"><a href=\"#\" onclick=\"closeplay(); 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){
    var h = document.getElementById("divplay");
    h.className = "play rate";
   xmlhttpPost("getrate.jsp","divplay","index="+videoid);
}

function setrating(videoid){
  //add rating function
  xmlhttpPost("../getmrbigcomment.jsp","divplay","index="+videoid);
}

function getvideooptions(videoid){
    var h = document.getElementById("divplay");
    h.className = "options";
    xmlhttpPost("getvideooptions.jsp","divplay","videoid="+videoid);
}

function addvideotofavorites(videoindex){
    
    xmlhttpPost("../addvideotofavourites.jsp","divResult","index="+videoindex);
}

function addartisttofavorites(videoindex){
    xmlhttpPost("../addartisttofavourites.jsp","divResult","index="+videoindex);
}


function addcomment(videoid){
    
    var comment = "";
    comment = document.getElementById("textarea").value;
    document.getElementById("textarea").value = "";
   
    xmlhttpPost("addvideocomment.jsp","divComments","videoid="+videoid+"&comment="+comment);
}


function closediv(divname) {
    var divcontainer = document.getElementById(divname);
    if (divcontainer!=null) {
        divcontainer.style.display="none";
    }
}



function closeinfo() {
    closediv("overlay");
    closediv("divinfo");
    GetMyClips(0);
    
}

function GetContacts() {
    xmlhttpPost("getcontacts.jsp","contentRight","");
}

function GetMessages() {
    xmlhttpPost("getmessages.jsp","contentRight","");
}

function GetComposeMessage() {
    xmlhttpPost("getcomposemessage.jsp","contentRight","");
     //xmlhttpPost("getartistcomments.jsp","divcontent","artistid="+artistid+"&frompage="+frompage);
}

function closeplay() {
    closediv("overlay");
    closediv("divplay");
    
}

function removefavouriteartist(userid) {
      xmlhttpPost("removefavouriteartist.jsp","contentRight","userid="+userid);
    
}

function closeComment() {
    closediv("overlay");
    closediv("commentBox");
}

function updateProfile()
{
    
    var username = "";
    var firstname = "";
    var surname = "";
    var email = "";
    var registerage = "";
    var registergender = "";
    
    if (document.getElementById("registerusername") != null)
        username = document.getElementById("registerusername").value;
    
     
    if (document.getElementById("registerfirstname") != null)
        firstname = document.getElementById("registerfirstname").value;
    
    if (document.getElementById("registersurname") != null)
        surname = document.getElementById("registersurname").value;
    
    if (document.getElementById("registeremail") != null)
        email = document.getElementById("registeremail").value;  
    
    if (document.getElementById("registerage") != null)
        registerage = document.getElementById("registerage").value;  
    
    if (document.getElementById("registergender") != null)
        registergender = document.getElementById("registergender").value;  
 
    //alert("username="+username+"&firstname="+firstname+"&surname="+surname+"&email="+email+"&registergender="+registergender+"&registerage="+registerage);
    
    xmlhttpPost("updatemyprofile.jsp","contentRight","username="+username+"&firstname="+firstname+"&surname="+surname+"&email="+email+"&registergender="+registergender+"&registerage="+registerage);
    
}



function loadVideoDetails(videoid) {
    xmlhttpPost("getsingleclip.jsp","content","videoid="+videoid);
}

function editvideo(videoid) {
    xmlhttpPost("geteditvideo.jsp","divinfo","videoid="+videoid);
}

function savevideochanges(videoid) {
    var title = "";
    title = document.getElementById("title").value;
    xmlhttpPost("savevideochanges.jsp","divinfo","videoid="+videoid+"&title="+title);    
}

function deletevideo(videoid) {
    xmlhttpPost("deletevideo.jsp","divinfo","videoid="+videoid);    
}

function backtoinfo(videoid) {
    xmlhttpPost("getinfo.jsp","divinfo","videoid="+videoid);
}


function commenttoartist(artistid,frompage){
    
    // add comment to artist function
    document.getElementById("divcontent").innerHTML = "";
    document.getElementById("divcontent").className="artistChat sendtobuddy";
    xmlhttpPost("getartistcomments.jsp","divcontent","artistid="+artistid+"&frompage="+frompage);
}


function sendartistcomment(userid,artistid,frompage){
    
    // add comment to artist function
    var message = document.getElementById("textarea").value;
    if (message.length>0) {
        document.getElementById("divcontent").innerHTML = "";
        document.getElementById("divcontent").className="artistChat sendtobuddy";
        xmlhttpPost("sendartistcomment.jsp","divcontent","message="+message+"&userid="+userid+"&artistid="+artistid+"&frompage="+frompage);
    } else {
        window.alert("Please type a message for the artist");
    }
}

function sendmessage(userid){
    
    // add comment to artist function
    var artistid = document.getElementById("txtusername").value;
    var message = document.getElementById("textarea").value;
    if (message.length>0) {
        document.getElementById("divcontent").innerHTML = "";
        document.getElementById("divcontent").className="artistChat sendtobuddy";
        xmlhttpPost("sendartistcomment.jsp","divcontent","message="+message+"&userid="+userid+"&artistid="+artistid+"&frompage=sendmessage");
    } else {
        window.alert("Please type a message for the artist");
    }
}


