///////////////////////////////////////////////////////////////////////////////
//
//  ExtendedPlayer
//
//  This extends the base player class, you may override the base player
//  member functions or add additional player functionality here.
//
///////////////////////////////////////////////////////////////////////////////
Type.registerNamespace('ExtendedPlayer');

ExtendedPlayer.Player = function(domElement) {
	ExtendedPlayer.Player.initializeBase(this, [domElement]);  
}
ExtendedPlayer.Player.prototype =  {
	onPluginLoaded: function(args) {    
		ExtendedPlayer.Player.callBaseMethod(this, 'onPluginLoaded', [args]); 
		
	},

	pluginDispose: function() {
		ExtendedPlayer.Player.callBaseMethod(this, 'pluginDispose');
	}
}
ExtendedPlayer.Player.registerClass('ExtendedPlayer.Player', ExpressionPlayer.Player);
var plugin, toolTip, mainCanvas;
var storyboard1, storyboard2;
var isVestiVisible;
function canvasLoaded(sender, args)
{

     plugin = sender.getHost();
    mainCanvas = sender;
    setTimeout(ChangeImage, 5000);
    storyboard1 = mainCanvas.findName('VestiLogoHide');
    storyboard2 = mainCanvas.findName('SilvLogoHide');
//    storyboard2.Begin();
    mainCanvas.findName('SilvLogo')["Opacity"] = "0";
    isVestiVisible = true;
//    mainCanvas.findName('VestiLogo')["Visibility"]== "Visible";
   // mainCanvas.findName('SilvLogo')["Opacity"] = "0";
  //  sender.getHost().content.onFullScreenChange = onFullScreenChanged;
    
}
function ChangeImage()
{
//if (mainCanvas.findName('VestiLogo')["Visibility"]== "Collapsed")
//{
//    mainCanvas.findName('VestiLogo')["Visibility"]== "Visible";
//   // mainCanvas.findName('SilverLogo')["Visibility"]== "Collapsed";
//}
//else
//{
//   //  mainCanvas.findName('SilverLogo')["Visibility"]== "Visible";
//    mainCanvas.findName('VestiLogo')["Visibility"]== "Collapsed";
//}
//if (mainCanvas.findName('VestiLogo')["Source"]== "vesti_telekana_blue.png")
//{
//    mainCanvas.findName('VestiLogo')["Visibility"]== "Collapsed"
//    mainCanvas.findName('VestiLogo')["Visibility"]= "Visible";
//    mainCanvas.findName('VestiLogo')["Source"]== "Sl_h_rgb_100.png"
//}
//else
//{
//    mainCanvas.findName('VestiLogo')["Source"]== "vesti_telekana_blue.png"
//}
 
//if (mainCanvas.findName('VestiLogo')["Visibility"]== "Collapsed")
//{
//    mainCanvas.findName('VestiLogo')["Visibility"]= "Visible";
//     mainCanvas.findName('SilvLogo')["Visibility"] = "Collapsed";
//}
//else
//{
//    mainCanvas.findName('VestiLogo')["Visibility"]= "Collapsed"
//     mainCanvas.findName('SilvLogo')["Visibility"] = "Visible";
//}
if (isVestiVisible)
{
    storyboard1.Begin();
    }
    else
    {
    storyboard2.Begin();
   }
   isVestiVisible = !isVestiVisible;
setTimeout(ChangeImage, 5000);
}
function OnFullScreenButtonMouseEnter(sender, args) {
    
    // Determine whether the tool tip is created.
    if (toolTip == null) {

        // Define the XAML fragment for the tool tip.
        var xamlFragment = '<Canvas Width="140" Height="30" Background="#FDFDFD">';
           xamlFragment +=   '<Rectangle Width="140" Height="30" Stroke="Black" />';
           xamlFragment +=   '<TextBlock Text=" На полный экран" FontSize="14" Canvas.Left="5" Canvas.Top="5" />';
           xamlFragment += '</Canvas>';

        // Create the XAML fragment for the tool tip.
        toolTip = plugin.content.createFromXaml(xamlFragment);

        // Position the tool tip at a relative x/y coordinate value.
        var cursorPosition = args.getPosition(sender);
        toolTip["Canvas.Left"] = cursorPosition.x + 10 + 242;
        toolTip["Canvas.Top"] = cursorPosition.y + 10;
    }

    // Add the tool tip to the Canvas object.
    mainCanvas.children.add(toolTip);
}

function OnFullScreenButtonMouseLeave(sender, args)
{
    // Determine whether the tool tip is created.
    if (toolTip != null)
    {
        // Remove the tool tip from the Canvas object.
        mainCanvas.children.remove(toolTip);
    }
}
function fullScreen_MouseLeftButtonDown(sender,args)
{
    var fullScreen = sender.getHost().content.fullScreen;
     if (fullScreen == true)
     {
         sender.getHost().content.fullScreen = !fullScreen;
     }
  //   ExtendedPlayer.Player.callBaseMethod(this, 'play');
}
function vesti_MouseLeftButtonDown(sender, args)
{
    if (isVestiVisible)
    {
        window.location = "http://www.vesti.ru";
    }
    else
    {
        window.location = "http://silverlight.net/";
    }
  
//    if (mainCanvas.findName('SilvLogo')["Visibility"]== "Collapsed")
//    {
//    window.location = "http://www.vesti.ru";
//    }
//    else
//    {
//    window.location = "http://silverlight.net/";
//    }
}

function silverlight_MouseLeftButtonDown(sender, args)
{
<!--    window.location = "http://www.microsoft.com/silverlight"; -->
}

function fullscreenbutton_MouseEnter(sender, args)
{
<!--    sender.findName("ToolTipCanvas").Opacity = 1;-->
}

function fullscreenbutton_MouseLeave(sender, args)
{
<!--    sender.findName("ToolTipCanvas").Opacity = 0;-->
}
function recfull_MouseLeftButtonDown(sender, args)
{
     var fullScreen = sender.getHost().content.fullScreen;
     if (fullScreen == true)
     {
         sender.findName('VestiLogo')["Visibility"]= "Collapsed";
     }
     else
     {
        sender.findName('VestiLogo')["Visibility"] = "Visible";
     }
     sender.getHost().content.fullScreen = !fullScreen;
     
    
     
    
}
function onFullScreenChanged(sender, args)
{
  // ExtendedPlayer.Player.callBaseMethod(this, '_onToggleFullScreen', [args]); 
}
