var framed=true;

//alert('loading ensureframing.js');

/*function checkframing()
{
   if (parent == self)
   {
      if (self.name != "justforprinting") {addcontrols();}
      framed=false;
   }
   else
   {
      framed=true;
   }
}*/

function checkframing()
{
   if (parent == self)
   {
      getframesetfromonefolderup();
   }
   //could put something here to stop people from loading illegal file into frame
   //if !top.samplenextbuttonon && illegal file then load questions fset. 
   //something like that
   //but I don't even know how you'd load a particular file into a frame
}

function addcontrols()
{
   document.getElementById("framelesscontrols").style.display = "block";
}


function getframesetfromonefolderup()
{
   var currenturl = self.location.href;
   var baseref1 = currenturl.substring(0,currenturl.lastIndexOf("/"));
   var baseref2 = baseref1.substring(0,baseref1.lastIndexOf("/")+1);
   
   var filenameandlocation = currenturl.substring(baseref1.lastIndexOf("/")+1,currenturl.length);
    
   //self.location.href = baseref2 + "ctt_questions_fset.html" + "?file=" + filenameandlocation;
   self.location.href = baseref2 + "ctt_questions_fset.html"; //don't want to load this file anyway used 
   //to have it set up in precache.js to do this after precaching was done but now don't want it at all.
   //see precache_old.js for the code
}

function getframesetfromcurrentfolder()
{
   var baseref = location.href.substring(0,location.href.lastIndexOf("/") + 1);
   
   if (top.location.href == self.location.href)
   {
      self.location.href = baseref + "ctt_questions_fset.html";
   }
}

function getindexdothtml()
{
   var baseref = location.href.substring(0,location.href.lastIndexOf("/") + 1);
   
      self.location.href = baseref + "index.html";
}

function getindextutoringdothtml()
{
   var baseref = location.href.substring(0,location.href.lastIndexOf("/") + 1);
   
      self.location.href = baseref + "index_tutoring.html";
}

function getindexdothtmlfromonefolderup()
{
    var baseref1 = location.href.substring(0,location.href.lastIndexOf("/"));
    var baseref2 = baseref1.substring(0,baseref1.lastIndexOf("/")+1);
    self.location.href = baseref2 + "index.html";
}

function checkforhomewindow()
{  
   //alert("in checkforhomewindow");
   //alert(top.opener.name);
   //alert('checked name');
   //apparently you can't turn display on and off for a whole division, it works sometimes then doesn't work
   //the id has to refer to a single element.
   //could check the framing since these popup are framed, but for consistency I'll use window name to check
   //for whether to put controls in popups and framing to check for controls for obviously framed documents.
   //I don't get that last phrase which is sad bec. I wrote it. anyway used framing to check for whether to put
   //in controls because when you load article using target there is no opener and you can get the controls erroneously
   //these popup articles might be opened by mainframe of might be opened by the top window which has a name
   //mainframe doesn't have a name although so far it seems it is always opened by the top window
   //the article popups are framed for some reason unlike the simpler popups on aristotleisdead
   
   if (parent == self) 
   {
      window.document.getElementById("outofcontext").style.display="block";
   }
   
   self.focus(); //this is in case some browser like firefox decides not to focus on the new window when target is used.
}