var lastVisible = "vle_contents";

if (!window.LaunchH)
  window.LaunchH = {};

LaunchH.Page = function()
{
}

LaunchH.Page.prototype =
{
  handleLoad: function(control, userContext, rootElement)
  {
    this.control = control;

    // Sample event hookup:
    rootElement.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown));
    
    var showButtons = document.getElementById("media_cool_stuff_id");
    var btn1 = this.control.content.findName("buttonStory");
    var btn2 = this.control.content.findName("buttonComic");
		
	if (showButtons == null) 
	{
	    btn1["Visibility"] = "Visible";
	    btn2["Visibility"] = "Visible";
	}
	else
	{
	    btn1["Visibility"] = "Collapsed";
	    btn2["Visibility"] = "Collapsed";
	}

  },

  // Sample event handler
  handleMouseDown: function(sender, eventArgs)
  {
    // The following line of code shows how to find an element by name and call a method on it.
    // this.control.content.findName("Timeline1").Begin();
  },
  
	
	onBtnMouseLeftButtonDown: function(sender, args)
	{
	    //LogEvent("http://www.microsoft.com/virtualevents/uk","Register :: UK");
	    window.open("http://www.microsoft.com/virtualevents/uk", "events","width=1024,height=768, resizable=yes, scrollbars=yes, toolbar=yes, location=yes, directories=yes, status=yes, menubar=yes");
	}

}

function hideLast(s)
{
  if (lastVisible != "")
  {
    hide = s.findName(lastVisible);
    hide.Visibility = "Collapsed";

    if (lastVisible == "vle_contents")
    {
      vleVideo = s.findName("vle_contents");
      vleVideo.findName("vle_video").Stop();
    }
  }
}


function selectVle(s)
{
  hideLast(s);

  vleVideo = s.findName("vle_contents");
  vleVideo.Visibility = "Visible";
  vleVideo.findName("vle_video").Play();

  lastVisible = "vle_contents";
}

function selectCommunity(s)
{
  hideLast(s);
  communityImage = s.findName("community_contents");
  communityImage.Visibility = "Visible";
  lastVisible = "community_contents";

}


function selectStory(s)
{
  hideLast(s);
  storyImage = s.findName("story_contents");
  storyImage.Visibility = "Visible";
  lastVisible = "story_contents";

}


function selectComic(s)
{
  hideLast(s);
  comicImage = s.findName("comic_contents");
  comicImage.Visibility = "Visible";
  lastVisible = "comic_contents";

}


var currentCanvasZIndex = 0;

function handleMouseEnter(s) {

  if (s["Name"]) {

    // Set the collection's ZIndex
    currentCanvasZIndex = s.GetParent()["Canvas.ZIndex"];
    s.GetParent()["Canvas.ZIndex"] = 100;

    // Get the event handler
    handlerStoryBoard = s.findName(s["Name"] + "_MouseEnter");
    handlerStoryBoard.Begin();
  }
}

function handleMouseLeave(s) {

  if (s["Name"]) {

    // Reset the ZIndex
    s.GetParent()["Canvas.ZIndex"] = currentCanvasZIndex;

    // Get the event handler
    handlerStoryBoard = s.findName(s["Name"] + "_MouseLeave");
    handlerStoryBoard.Begin();
  }
}

function goToVLE()
{
  //window.open("http://www.microsoft.com/virtualevents/uk");
  location.href = "http://www.microsoft.com/virtualevents/uk";
}

function goToCommunity()
{
  window.open("http://www.heroescommunitylaunch.com/");
}

function goToStory()
{
  window.open("http://www.microsoft.com/heroeshappenhere/portraitgallery");
  // location.href = "/heroeshappenhere/cool-stuff/portrait-gallery/default.mspx";
}

function goToComic()
{
  window.open("http://www.itdevcomics.com");
}

function goToComicTeaser()
{
 // window.open("http://www.microsoft.com/heroeshappenhere/images/comic_teaser.jpg");
  location.href = "/heroeshappenhere/cool-stuff/comic/default.mspx";
}

function goToComicRSS()
{
  window.open("http://blogs.technet.com/hhh_comic/rss.xml");
}