﻿//if (!window.testfor)
//	window.testfor = {};

//testfor.Scene = function() 
//{
//}
//var _plugIn;
//testfor.Scene.prototype =
//{
//	handleLoad: function(plugIn, userContext, rootElement) 
//	{
//		this.plugIn = plugIn;
//		_plugIn = this.plugIn;
//		
//		
//	}
//	
//	
//}
//var mouseDownPosition = 0;
//var mouseDownValue = -1;
//var thumbCenter = 0;
//var newValueContainter = 0;
//var playOrPause = 0;
//var on = 1;
//////.................volume.....................
//function slider_Loaded(sender, args) {
//    slider_SetValue(sender, 0);
//}

//function slider_MouseLeftButtonDown(sender, args) {
//    
//    var coordinate = args.getPosition(null).x;
//    var slider = sender.findName("volumeSlider");
//    coordinate -= slider["Canvas.Left"];
//    slider_SetValue(slider, coordinate - thumbCenter - 35);  
//}

//function slider_thumb_MouseLeftButtonDown(sender, args) {
//    var slider = sender.findName("volumeSlider");
//    sender.captureMouse();
//    mouseDownValue = slider_GetValue(slider);
//    mouseDownPosition = args.getPosition(null).x;
//}

//function slider_thumb_MouseLeftButtonUp(sender, args) {
//    var slider = sender.findName("volumeSlider");
//    slider.releaseMouseCapture();
//    mouseDownValue = -1;
//}

//function slider_thumb_MouseMove(sender, args) {
//    var slider = sender.findName("volumeSlider");
//    if (mouseDownValue != -1) {
//        var newValue = mouseDownValue + (args.getPosition(null).x - mouseDownPosition);    
//        slider_SetValue(slider, newValue);
//    }   
//}

//function slider_GetValue(sender) {
//    var thumb = sender.findName("volumeSlider_Thumb");
//    return thumb["Canvas.Left"]; 
//}

//function slider_SetValue(sender, newValue) {
//    
//    if (newValue > sender.width ) {
//        newValue = sender.width;
//        mouseDownValue = -1;
//    }
//    if (newValue < - thumbCenter) {
//        newValue = - thumbCenter;
//        mouseDownValue = -1;
//    }
//    var thumb = sender.findName("volumeSlider_Thumb");
//    
//    thumb["Canvas.Left"] = newValue;
//    var volume = 100/59*newValue;
//    setVolume(volume);    
//}
//function setDefaultVolume(sender,args)
//{
//    _plugIn.content.findName("volumeSlider_Thumb")["Canvas.Left"] = 59/100*defaultVolume;
//    _plugIn.content.findName("videoSlider_Thumb")["Canvas.Left"] = 0;   
//}

//////............video process..............
//function slider_LoadedProcess(sender, args) {
//    slider_SetValueProcess(sender, 0);
//}

//function slider_MouseLeftButtonDownProcess(sender, args) {
//    
//    var coordinate = args.getPosition(null).x;
//    var slider = sender.findName("videoSlider");
//    coordinate -= slider["Canvas.Left"];
//    slider_SetValueProcess(slider, coordinate - thumbCenter - 37);  
//}

//function slider_thumb_MouseLeftButtonDownProcess(sender, args) {
//    var slider = sender.findName("videoSlider");
//    sender.captureMouse();
//    mouseDownValue = slider_GetValueProcess(slider);
//    mouseDownPosition = args.getPosition(null).x;
//}

//function slider_thumb_MouseLeftButtonUpProcess(sender, args) {
//    var slider = sender.findName("videoSlider");
//    slider.releaseMouseCapture();
//    mouseDownValue = -1;
//}

//function slider_thumb_MouseMoveProcess(sender, args) {
//    var slider = sender.findName("videoSlider");
//    if (mouseDownValue != -1) {
//        var newValue = mouseDownValue + (args.getPosition(null).x - mouseDownPosition);    
//        slider_SetValueProcess(slider, newValue);
//    }   
//}

//function slider_GetValueProcess(sender) {
//    var thumb = sender.findName("videoSlider_Thumb");
//    return thumb["Canvas.Left"]; 
//}

//function slider_SetValueProcess(sender, newValue) {
//    
//    if (newValue > sender.width ) {
//        newValue = sender.width;
//        mouseDownValue = -1;
//    }
//    if (newValue < - thumbCenter) {
//        newValue = - thumbCenter;
//        mouseDownValue = -1;
//    }
//    var thumb = sender.findName("videoSlider_Thumb");  
//    
//    
//    thumb["Canvas.Left"] = newValue;
//    seekTo(newValue*videoTotalDuration/121);   
//    
//}
////video progress
//function videoProgress(sender, args)
//{
//    if (onOrOff == 1 && videoCurrentTime != 0)//  
//    {
//        videoTotalDuration = getDuration(); 
//        _plugIn.content.findName("videoSlider_Thumb")["Canvas.Left"] = 121/videoTotalDuration*videoCurrentTime;
//        if (videoTotalDuration/60<10)
//        {               
//            var videoTotalDuration_Minute = "" + Math.floor(videoTotalDuration/60) + "";
//        }
//        else
//        {
//            var videoTotalDuration_Minute = "" + Math.floor(videoTotalDuration/60) + "";
//        }
//        if (videoTotalDuration%60<10)
//        {               
//            var videoTotalDuration_Second = "0" + Math.floor(videoTotalDuration%60) + "";
//        }
//        else
//        {
//            var videoTotalDuration_Second = "" + Math.floor(videoTotalDuration%60) + "";
//        } 
//        if (videoCurrentTime/60<10)
//        {               
//            var videoCurrentTime_Minute = "" + Math.floor(videoCurrentTime/60) + "";
//        }
//        else
//        {
//            var videoCurrentTime_Minute = "" + Math.floor(videoCurrentTime/60) + "";
//        }
//        if (videoCurrentTime%60<10)
//        {               
//            var videoCurrentTime_Second = "0" + Math.floor(videoCurrentTime%60) + "";
//        }
//        else
//        {
//            var videoCurrentTime_Second = "" + Math.floor(videoCurrentTime%60) + "";
//        } 
//        var currentTime = videoCurrentTime_Minute + ":" + videoCurrentTime_Second;
//        _plugIn.content.findName("currentTimeDisplay").Text =currentTime + " / " + videoTotalDuration_Minute + ":" + videoTotalDuration_Second;
//    }
//}
////Bytes Progress
//function videoBytesProgress(sender, args)
//{
//    
//    if (onOrOff == 1 && videoCurrentBytes > 0) 
//    {
//        videoTotalBytes = getBytesTotal();         
//        _plugIn.content.findName("videoSlider_Progress").width = 127/videoTotalBytes*getStartBytes() + 127/videoTotalBytes*videoCurrentBytes; 
//    }
//}
//function playvid(sender, args)
//{
//    if (on == 1)
//    {
//        loadNewVideo("XGo_fCcfYpc", 0);
//        on = 0;
//    }else
//    {
//        play();
//    }
//    sender.findName("playShadow")["Visibility"] = "Visible"
//}
//function stopvid(sender,args)
//{
//    sender.findName("stopShadow")["Visibility"] = "Visible"
//}
//function playvidoff(sender,args)
//{
//    sender.findName("playShadow")["Visibility"] = "Collapsed"
//}
//function stopvidoff(sender,args)
//{
//    sender.findName("stopShadow")["Visibility"] = "Collapsed"
//}
if (!window.testfor)
	window.testfor = {};

testfor.Scene = function() 
{
}
var _plugIn;
testfor.Scene.prototype =
{
	handleLoad: function(plugIn, userContext, rootElement) 
	{
		this.plugIn = plugIn;
		_plugIn = this.plugIn;		
		
	}
	
	
}
var mouseDownPosition = 0;
var mouseDownValue = -1;
var thumbCenter = 0;
var newValueContainter = 0;
var playOrPause = null;
var on = 1;
var m = 0;
//window.setTimeout("cuevideo()",3000);
////.................volume.....................
function slider_Loaded(sender, args) {
    slider_SetValue(sender, 0);
}
function slider_MouseLeftButtonDown(sender, args) {
    
    var coordinate = args.getPosition(null).x;
    var slider = sender.findName("volumeSlider");
    coordinate -= slider["Canvas.Left"];
    slider_SetValue(slider, coordinate - thumbCenter - 35);  
}

function slider_thumb_MouseLeftButtonDown(sender, args) {
    var slider = sender.findName("volumeSlider");
    sender.captureMouse();
    mouseDownValue = slider_GetValue(slider);
    mouseDownPosition = args.getPosition(null).x;
}

function slider_thumb_MouseLeftButtonUp(sender, args) {
    var slider = sender.findName("volumeSlider");
    slider.releaseMouseCapture();
    mouseDownValue = -1;
}

function slider_thumb_MouseMove(sender, args) {
    var slider = sender.findName("volumeSlider");
    if (mouseDownValue != -1) {
        var newValue = mouseDownValue + (args.getPosition(null).x - mouseDownPosition);    
        slider_SetValue(slider, newValue);
    }   
}

function slider_GetValue(sender) {
    var thumb = sender.findName("volumeSlider_Thumb");
    return thumb["Canvas.Left"]; 
}

function slider_SetValue(sender, newValue) {
    
    if (newValue > sender.width ) {
        newValue = sender.width;
        mouseDownValue = -1;
    }
    if (newValue < - thumbCenter) {
        newValue = - thumbCenter;
        mouseDownValue = -1;
    }
    var thumb = sender.findName("volumeSlider_Thumb");
    
    thumb["Canvas.Left"] = newValue;
    var volume = 100/59*newValue;
    setVolume(volume);    
}
function setDefaultVolume(sender,args)
{
    _plugIn.content.findName("volumeSlider_Thumb")["Canvas.Left"] = 59/100*defaultVolume;
    _plugIn.content.findName("videoSlider_Thumb")["Canvas.Left"] = 0;   
}

////............video process..............
function slider_LoadedProcess(sender, args) {
    slider_SetValueProcess(sender, 0);
}

function slider_MouseLeftButtonDownProcess(sender, args) {
    
    var coordinate = args.getPosition(null).x;
    var slider = sender.findName("videoSlider");
    coordinate -= slider["Canvas.Left"];
    slider_SetValueProcess(slider, coordinate - thumbCenter - 37);  
}

function slider_thumb_MouseLeftButtonDownProcess(sender, args) {
    var slider = sender.findName("videoSlider");
    sender.captureMouse();
    mouseDownValue = slider_GetValueProcess(slider);
    mouseDownPosition = args.getPosition(null).x;
}

function slider_thumb_MouseLeftButtonUpProcess(sender, args) {
    var slider = sender.findName("videoSlider");
    slider.releaseMouseCapture();
    mouseDownValue = -1;
}

function slider_thumb_MouseMoveProcess(sender, args) {
    var slider = sender.findName("videoSlider");
    if (mouseDownValue != -1) {
        var newValue = mouseDownValue + (args.getPosition(null).x - mouseDownPosition);    
        slider_SetValueProcess(slider, newValue);
    }   
}

function slider_GetValueProcess(sender) {
    var thumb = sender.findName("videoSlider_Thumb");
    return thumb["Canvas.Left"]; 
}

function slider_SetValueProcess(sender, newValue) {
    
    if (newValue > sender.width ) {
        newValue = sender.width;
        mouseDownValue = -1;
    }
    if (newValue < - thumbCenter) {
        newValue = - thumbCenter;
        mouseDownValue = -1;
    }
    var thumb = sender.findName("videoSlider_Thumb");  
    
    
    thumb["Canvas.Left"] = newValue;
    seekTo(newValue*videoTotalDuration/121);   
    
}
//video progress
function videoProgress(sender, args)
{
    if (onOrOff == 1 && videoCurrentTime != 0)//  
    {
        videoTotalDuration = getDuration(); 
        _plugIn.content.findName("videoSlider_Thumb")["Canvas.Left"] = 121/videoTotalDuration*videoCurrentTime;
        if (videoTotalDuration/60<10)
        {               
            var videoTotalDuration_Minute = "" + Math.floor(videoTotalDuration/60) + "";
        }
        else
        {
            var videoTotalDuration_Minute = "" + Math.floor(videoTotalDuration/60) + "";
        }
        if (videoTotalDuration%60<10)
        {               
            var videoTotalDuration_Second = "0" + Math.floor(videoTotalDuration%60) + "";
        }
        else
        {
            var videoTotalDuration_Second = "" + Math.floor(videoTotalDuration%60) + "";
        } 
        if (videoCurrentTime/60<10)
        {               
            var videoCurrentTime_Minute = "" + Math.floor(videoCurrentTime/60) + "";
        }
        else
        {
            var videoCurrentTime_Minute = "" + Math.floor(videoCurrentTime/60) + "";
        }
        if (videoCurrentTime%60<10)
        {               
            var videoCurrentTime_Second = "0" + Math.floor(videoCurrentTime%60) + "";
        }
        else
        {
            var videoCurrentTime_Second = "" + Math.floor(videoCurrentTime%60) + "";
        } 
        var currentTime = videoCurrentTime_Minute + ":" + videoCurrentTime_Second;
        _plugIn.content.findName("currentTimeDisplay").Text =currentTime + " / " + videoTotalDuration_Minute + ":" + videoTotalDuration_Second;
    }
}
//Bytes Progress
function videoBytesProgress(sender, args)
{
    
    if (onOrOff == 1 && videoCurrentBytes > 0) 
    {
        videoTotalBytes = getBytesTotal();         
        _plugIn.content.findName("videoSlider_Progress").width = 127/videoTotalBytes*getStartBytes() + 127/videoTotalBytes*videoCurrentBytes; 
    }
}
function playvid(sender,args)
{
    if  (playOrPause == null){
    
        loadNewVideo("XGo_fCcfYpc", 0);   
        sender.findName("pauseB")["Visibility"] = "Visible"
        sender.findName("playB")["Visibility"] = "Collapsed"
    }
    else if (playOrPause == 1){
        
        play();
        sender.findName("pauseB")["Visibility"] = "Visible"
        sender.findName("playB")["Visibility"] = "Collapsed"
    }
    else if (playOrPause == 2){
        
        pause();
        sender.findName("pauseB")["Visibility"] = "Collapsed"
        sender.findName("playB")["Visibility"] = "Visible"
    }
    sender.findName("playShadow")["Visibility"] = "Visible"
}
function stopvid(sender,args)
{
    stop();
    sender.findName("stopShadow")["Visibility"] = "Visible"
    sender.findName("volumeSlider_Thumb")["Canvas.Left"] = "0"
    sender.findName("videoSlider_Thumb")["Canvas.Left"] = "0"
    sender.findName("videoSlider_Progress").width = "0"
    sender.findName("currentTimeDisplay").Text = "0:00 / 0:00"
}
function playvidoff(sender,args)
{
    sender.findName("playShadow")["Visibility"] = "Collapsed"
}
function stopvidoff(sender,args)
{
    sender.findName("stopShadow")["Visibility"] = "Collapsed"
}
function muteOrunmute(sender,args)
{
    if (m == 0)
    {
        mute();
        m = 1;
        sender.findName("muteS")["Visibility"] = "Visible"
    }
    else 
    {
        sender.findName("muteS")["Visibility"] = "Collapsed"
        unMute();
        m = 0;
    }
}
//function cuevideo()
//{
//    loadNewVideo("XGo_fCcfYpc", 0);
//    window.setTimeout("cueV()",1000)
//}
//function cueV()
//{
//    cueNewVideo("XGo_fCcfYpc",0.5);
//}