function Breakout()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}

function VariablePopup(SomeURL, WindowHeight, WindowWidth) {

   var ScreenWidth, ScreenHeight;
   var WindowTop, WindowLeft;
   var PopupWindow;

   ScreenHeight = 0;
   ScreenWidth  = 0;
   WindowTop    = 0;
   WindowLeft   = 0;

      if (GJSBrowserName == 'MSIE'){
          ScreenWidth  = document.body.clientWidth;
          ScreenHeight = document.body.clientHeight;
       }
      else{
         if (window.innerWidth) ScreenWidth = window.innerWidth;
         if (window.innerHeight) ScreenHeight = window.innerHeight;
       }

     Window_Top  = ScreenHeight - WindowHeight - 20;
     Window_Left = ScreenWidth  - WindowWidth  - 20;

      PopupWindow  = window.open(
                     SomeURL,
                     'Popup',
                     'width='+WindowWidth+',height='+WindowHeight+',top='+Window_Top+',left='+Window_Left+',scrollbars=yes,resizable=yes'
                     );

      PopupWindow.focus();

}


function ShowPopup(SomeURL) {

   VariablePopup(SomeURL, 350, 500);

}

//*******************************

function ClosePopup() {
   document.all['Popup'].close();
}

//*******************************

function ChangeParent(SomeURL){
 
 if(window.opener != null){
  window.parent.opener.location = SomeURL;
 }
  else window.location = SomeURL;
 
}

function CalendarPopup(PG_FormName, PG_FieldName){

   var SomeURL = '/global/php/popupcal.php?FormName=' + PG_FormName + '&FieldName=' + PG_FieldName;
   var WindowHeight =  350;
   var WindowWidth = 500;
   var ScreenHeight = 0;
   var ScreenWidth  = 0;
   var WindowTop    = 0;
   var WindowLeft   = 0;
 
   var CalendarWindow;


      if (GJSBrowserName == 'MSIE'){
          ScreenWidth  = document.body.clientWidth;
          ScreenHeight = document.body.clientHeight;
       }
      else{
         if (window.innerWidth) ScreenWidth = window.innerWidth;
         if (window.innerHeight) ScreenHeight = window.innerHeight;
       }

     Window_Top  = ScreenHeight - WindowHeight - 20;
     Window_Left = ScreenWidth  - WindowWidth  - 20;

      CalendarWindow  = window.open(
                     SomeURL,
                     'CalendarPopup',
                     'width='+WindowWidth+',height='+WindowHeight+',top='+Window_Top+',left='+Window_Left+',scrollbars=yes,resizable=yes'
                     );

      CalendarWindow.focus();
}

function ColourPopup2(PG_FormName, PG_FieldName){

   VariablePopup('/global/php/colourpopup.php?FormName=' + PG_FormName + '&FieldName=' + PG_FieldName, 350, 500);
}


function ColourPopup(PG_FormName, PG_FieldName){

   VariablePopup('/global/php/colourstrip.php?FormName=' + PG_FormName + '&FieldName=' + PG_FieldName, 350, 500);
}

function ChangeLanguage(Language){

    document.cookie = ('GLBLanguage=' + Language + '; path=/; domain=.mcgill.ca; expires=');
    window.location.reload();
}		

function ChangeTextSize(NewSize){

	document.cookie = ('GLBTextSize=' + NewSize + '; path=/; domain=.mcgill.ca; expires=');
	window.location.reload();
}

function UploadDirectory(DirName){

       document.cookie = ('UploadDir=' + DirName + '; path=/; domain=.mcgill.ca; expires=');
       window.location = 'https://upload.mcgill.ca/';
}

function SetCommittee(CommitteeID) {
		
	document.cookie = ('CommitteeID=' + CommitteeID + '; path=/; domain=.mcgill.ca; expires=');
	window.location = 'https://upload.mcgill.ca/minutes/';
}

function AdminDirectory(DirName){

	document.cookie = ('AdminFocus=' + DirName + '; path=/; domain=.mcgill.ca; expires=');
	if(location.hostname != ''){
		var MyHostname = location.hostname;
	}
	else{
		var MyHostname = 'home.mcgill.ca';
	}
	window.location = 'https://'+location.hostname+'/admin/site/';
}

function GetModuleName(SomeString){

  Start = SomeString.indexOf('$');
  End = SomeString.indexOf('-');
  ModName = SomeString.substring(Start + 1, End);  
  return ModName;
}	

function TurnOn(ImageName){

    if(document.getElementById){
        document.getElementById(ImageName).src = eval(ImageName + '_On.src');
    }
}

function TurnOff(ImageName){

    if(document.getElementById){
        document.getElementById(ImageName).src = eval(ImageName + '_Off.src');
    }
}
  var ImAPopup = 0;

