
var videoSlidesOn = false;

function showCommentInformation(vid){
    videoSlidesOn = false;
    //hide tagging
    $('Tagging').style.display = "none";
    $('VideoSlides').style.display = "none";
    $('VideoInformation').style.display = "none";
    $('CommentInformation').style.display = "inline";
    getCommentInformation(vid);
}


function showTagging(){
    videoSlidesOn = false;
    $('VideoInformation').style.display = "none";
    $('VideoSlides').style.display = "none";
    $('Tagging').style.display = "inline";
    $('CommentInformation').style.display = "none";
    slidesTrackingActive = false;
    $("slides").innerHTML = "";
    
    if (onPage>1) {
        ScrollSlides('slides', '-', (onPage-1)*435, (onPage-1));   
    }
}		

function showVideoInformation(vid){
    videoSlidesOn = false;
    //hide tagging
    $('Tagging').style.display = "none";
    $('VideoSlides').style.display = "none";
    $('CommentInformation').style.display = "none";
    $('VideoInformation').style.display = "inline";
    slidesTrackingActive = false;
    $("slides").innerHTML = "";
    
    if (onPage>1) {
        ScrollSlides('slides', '-', (onPage-1)*435, (onPage-1));   
    }	
    getVideoInformation(vid);
}	

function showVideoSlides(vid){
    if (!videoSlidesOn) {
        videoSlidesOn = true;
        $('Tagging').style.display = "none";
        $('VideoInformation').style.display = "none";
        $('CommentInformation').style.display = "none";
        $('VideoSlides').style.display = "inline";
        slidesTrackingActive = true;	
        getVideoSlides(vid);	
        
        // reset the variables
        slides_pause = false;
        onPage     = 1;
        maxPages   = 1;
        countSlides = 0;
        slidesTimes = new Array();
        currentSlide = 0;
        checksSlidesPosition(); // start the player tracking process 
    }
}		

self.getVideoInformation = function (vid) {
    var url = '/VideoInformation;jsessionid=' + jsid;
    var pars = 'vid=' + vid; 
    var myAjax = new Ajax.Request( url, {
        method: 'get', 
        parameters: pars, 
        onComplete: getVideoInformationCallback
    });	        
}
function getVideoInformationCallback(transport) {
    var msg = transport.responseText;
    $("videoInformation").innerHTML = msg; 
    if (msg == "false"){
        // nothing
    } else {
        // nothing
    }   
    
}	

self.getVideoSlides = function (vid) {
    var url = '/VideoSlides;jsessionid=' + jsid;
    var pars = 'vid=' + vid; 
    var myAjax = new Ajax.Request( url, {
        method: 'get', 
        parameters: pars, 
        onComplete: getVideoSlidesCallback
    });	        
}

function getVideoSlidesCallback(transport) {
    var msg = transport.responseText;
    if (msg == 0){
        $('slides').innerHTML = "No slides available.";
        _setClassValue('Slides_bg', ''); 
    } else {
        $("slides").innerHTML = msg;
        maxPages = parseInt($('slides_maxPages').value);
        countSlides = $('slides_count').value;
        for (var i=0; i<countSlides; i++) {
            slidesTimes[i] = $("slides_number_"+(i+1)+"_time").value;
        }
    } 
}	



function hideVideoInformation() {
    $("videoInformation").innerHTML = '<u>Show more information</u>';  
}	

function getVideoSegments(vid) {
    if (document.getElementById) {        
        var getURL = '/VideoSegments' + "?vid=" + vid; 
        var ajax = new AJAXInteractionTEXT(getURL, getVideoSegmentsCallback);
        ajax.doGet();
    }		
}

function getVideoSegmentsCallback(responseText) {
    var msg = responseText
    $("videoSegments").innerHTML = msg; 
    if (msg == "false"){
        // nothing
    } else {
        // nothing
    }   
}



function getVideoRating(vid) {
	
	var url = '/RateVideo;jsessionid=' + jsid; 
	var pars = "get=true&vid="+vid;
	var myAjax = new Ajax.Request( url, {
	    method: 'get', 
	    parameters: pars, 
	    onComplete: getVideoRatingCallback
	});
}
function getVideoRatingCallback(transport) {
    var msg = transport.responseText;
	if (msg!='') {
	    $("StarRating").innerHTML = msg;
	}
}


/* server request for SET video star rating */
function rateVideo(ratingValue) {
    var vid = $("current_vid").value;
	var url = '/RateVideo;jsessionid=' + jsid; 
	var pars = "rate=" + ratingValue + "&vid="+vid;
	var myAjax = new Ajax.Request( url, {
	    method: 'get', 
	    parameters: pars, 
	    onComplete: rateVideoCallback
	});
}
function rateVideoCallback(transport) {
    var msg = transport.responseText;
	getVideoRating($("current_vid").value);
}	


