﻿
function BrowserClosed() {
    alert('Browserclosed');
    var img = new Image();
    img.src = "BrowserClosed.ashx";
}

/*
function NotLoggedIn()
{
    window.setTimeout("alert(\'You must be logged in to view that content.\')",100);
}*/ 

function NotLoggedIn(Type, Url) {

    var iJustPlay = 0;

    if (iJustPlay == 1) {

        alert('You must be logged in to view this clip');
        return;
    }


    var msgWindow = document.getElementById("puCannotPlayMessage");
    var inner = document.getElementById("puCannotPlayMessageText");
   
    if (Type == 2) {
        //Free to registered users
        inner.innerHTML = "This clip is free to registered users. <a href=\"/Register.aspx\">Register</a> or log in to view this clip.<br><br>To see a time limited preview, click <a onclick=\"window.open('" + Url + "'); document.getElementById('puCannotPlayMessage').style.visibility='hidden';document.getElementById('puCannotPlayMessageText').style.visibility='hidden';\" href=\"javascript:void(0);\">here</a>.";
        inner.style.visibility = "visible";
        msgWindow.style.visibility = "visible";
    }

    if (Type == 5) {
        //Subscription required, but not logged in
        inner.innerHTML = "If this clip is already part of your subscription, login to view the clip.<br>If you'd like to start a Learning Clip subscription, visit our <a href=\"/subscribe.aspx\">subscribe</a> page. To see a time limited preview, click <a onclick=\"window.open('" + Url + "'); document.getElementById('puCannotPlayMessage').style.visibility='hidden';document.getElementById('puCannotPlayMessageText').style.visibility='hidden';\" href=\"javascript:void(0);\">here</a>.";
        inner.style.visibility = "visible";
        msgWindow.style.visibility = "visible";
    }

    if (Type == 6) {
        //Subscription required, logged in, but not part of subscription
        inner.innerHTML = "To add this clip to your Learning Clip subscription, visit our <a href=\"/subscribe.aspx\">subscribe</a> page.  To see a time limited preview, click <a onclick=\"window.open('" + Url + "'); document.getElementById('puCannotPlayMessage').style.visibility='hidden';document.getElementById('puCannotPlayMessageText').style.visibility='hidden';\" href=\"javascript:void(0);\">here</a>.";
        inner.style.visibility = "visible";
        msgWindow.style.visibility = "visible";
    }

    if (Type == 9) {
        //Pupil Logon subscription expired
        alert("Your teacher's account does not have a Class Login for this item!");
    }


}

function TooManyLogins() {
    alert('You have logged in at another location and have therefore been logged out of this session. To view content, you must log in again.');
    //window.setTimeout("alert(\'You have logged in at another location and have therefore been logged out of this session. To view content, you must log in again.\')", 100);
}

function PupilLoggedOut() {
    alert('You have been logged out! To watch Triangle Man and play games, log in again!');
    //window.setTimeout("alert(\'You have been logged out!  To watch Triangle Man and play games, log in again!\');location.href='index1.aspx'", 100);
}

function TeacherLoggedOut() {
    alert('Your teacher has logged out! To watch Triangle Man and play games, your teacher must be logged in!');
    //window.setTimeout("alert(\'Your teacher has logged out! To watch Triangle Man and play games, your teacher must be logged in!\');location.href='index1.aspx';", 100);
}

function LearningSessionExpired() {
    alert('Oh no! You have run out of time! Please tell your teacher.');
    //window.setTimeout("alert('Oh no! You've run out of time! Please tell your teacher.');location.href='index1.aspx';",100);
}

function doTheHide(e) {
    document.getElementById("SearchResults").style.visibility = 'hidden';

}

function jsHidePopups(evt) {

    var e;
    e = evt ? evt : window.event;
    var se; 
    if (window.event) {
        se = e.srcElement.id;
    }
    else {
        se = e.target.id;
    }

    //alert(se);

    if (se == 'SearchResults' || se=='SearchContent' || se=='searchlink') {
        e.cancelBubble = true;     
    }
    
    if (se!='SearchResults' && se!='SearchContent' && se!='searchlink')
    {
    window.setTimeout('doTheHide()', 100); }

}

function ka2(TGuid, PGuid) {
    //Keep alive
    var img = new Image();
    var d = new Date();

    if (TGuid != "" || PGuid != "") {
        img.src = "ka.ashx?TGuid=" + TGuid + "&PGuid=" + PGuid + "&cache=" + d.getTime();
    }
}

function showVotingOptions(sTicket) {

    //Do voting hardware/manager checks
    //REMOVE THIS LINES AFTER TESTING
  
    if (!gIsPresent)
	{
	  alert("Voting Manager not found.  Please start the Voting Manager application and try again.");
	  //location.href=location.href;	             
	  return;
	}
	 else
	{
      if (gHubInfo==0)
      {
            //0=nohub 1=legacy 2=2.4
          alert("There was a problem contacting your voting hardware.  Please check and try again.");       
          return;
      }    
	 }
  
    
    //Refresh the class list updatepanel
    refreshList();
  
    //Show the popup for "do you want to use voting"
    puVOCOID = sTicket;

    var o = document.getElementById("puVO");   
    o.style.visibility = 'visible';
}