function iddisp(id,disp) {
  try { document.getElementById(id).style.display=disp; } catch(e) { }
}

function isBigScreen() {
  if ((screen.width > 961) && (screen.height > 799)) {
    return true;
  } else {
    return false;
  }
}

function glowbox(id) {
// keep to less than 1Hz
var object = document.getElementById(id);
object.style.borderWidth = '2px';
object.style.borderColor = '#00f';
object.style.borderStyle = 'dotted';
var timetext = 'document.getElementById("'+id+'").style.borderColor = "#aaa";document.getElementById("'+id+'").style.borderStyle = "solid";document.getElementById("'+id+'").style.borderWidth = "1px"';
setTimeout(timetext,2500);
}


// inserts a messageObject div just after the given divid
function insertMessagePlain(divid,idname,message,onclickaction,insparent) {
  var d = document.getElementById(divid);
  var newDiv = document.createElement("div");
  newDiv.id = "message_"+idname;
  newDiv.className = "dynamicDiv";
  newDiv.innerHTML = message;
  if (onclickaction != '') { 
//newDiv.setAttribute('onclick',onclickaction); 
newDiv.onclick=function(){ eval(onclickaction); }
}
  if (insparent==1) {
    if (d.parentNode) { d.parentNode.insertBefore(newDiv,d.nextSibling); }
  } else { 
    if (d) { d.appendChild(newDiv); }
  }
}

function gsClickOMOa(){ 
  document.getElementById('gsClickText').style.color='#ff0099';
  document.getElementById('gsClick').style.borderStyle='dotted none dotted dotted'; 
}
function gsClickOMOb(){ 
  document.getElementById('gsClickText').style.color='white';
  document.getElementById('gsClick').style.borderStyle='solid none solid solid'; 
}

function hideLHNsecondbit() {
  try { 
    document.getElementById('secondarynavgroupa').style.display='none'; document.getElementById('secondarynavgroupb').style.display='none';
    var current_page_ancestor_ele = document.getElementsByClassName('current_page_ancestor')[0];
    current_page_ancestor_ele.className=current_page_ancestor_ele.className+' current_page_item';
  } catch(e) { }
}

function insertGetSatisfaction(placeUnderId) {

var gsTag1 = document.createElement("script");
gsTag1.type="text/javascript";
gsTag1.src = "http://askit.bris.ac.uk/uob/widgets/javascripts/00cd7865d8/widgets.js";
document.getElementById('footer').appendChild(gsTag1);

var gsTag2 = document.createElement("script");
gsTag2.type="text/javascript";
gsTag2.src = 'http://www.wireless.bris.ac.uk/styles/gs-floating-menu.js';

var gsDiv1 = document.createElement('div');
gsDiv1.id = 'gsfn_search_widget';
gsDiv1.style.display = 'none';

var gsDiv7 = document.createElement('div');
gsDiv7.id = 'gsfn_search_widget_inner';

var gsA1 = document.createElement('a');
gsA1.href = 'http://askit.bris.ac.uk/uob';
gsA1.className = 'widget_title';
gsA1.innerHTML = '&bull; AskIT - get help on mobile IT from the community of Bristol staff and students';

var gsDiv2 = document.createElement('div');
gsDiv2.id = 'gsfn_content';

var gsForm1 = document.createElement('form');
gsForm1.setAttribute('accept-charset','utf-8');
gsForm1.action = 'http://askit.bris.ac.uk/uob';
gsForm1.method = 'get';
gsForm1.id = 'gsfn_search_form';
//gsForm1.setAttribute ('onsubmit', "gsfn_search(this); return false");
gsForm1.onsubmit=function(){ gsfn_search(this); return false; }

var gsDiv3 = document.createElement('div');

var gsInput1 = document.createElement('input');
gsInput1.name = 'style';
gsInput1.setAttribute('type','hidden');
gsInput1.setAttribute('value','');

var gsInput2 = document.createElement('input');
gsInput2.name = 'limit';
gsInput2.setAttribute('type','hidden');
gsInput2.setAttribute('value','3');

var gsInput3 = document.createElement('input');
gsInput3.name = 'utm_medium';
gsInput3.setAttribute('type','hidden');
gsInput3.setAttribute('value','widget_search');

var gsInput4 = document.createElement('input');
gsInput4.name = 'utm_source';
gsInput4.setAttribute('type','hidden');
gsInput4.setAttribute('value','widget_uob');

var gsInput5 = document.createElement('input');
gsInput5.name = 'callback';
gsInput5.setAttribute('type','hidden');
gsInput5.setAttribute('value','gsfnResultsCallback');

var gsInput6 = document.createElement('input');
gsInput6.name = 'format';
gsInput6.setAttribute('type','hidden');
gsInput6.setAttribute('value','widget');

var gsLabel1 = document.createElement('label');
gsLabel1.className = 'gsfn_label';
gsLabel1.setAttribute('for','gsfn_search_query');
gsLabel1.innerHTML='Ask a question, share an idea, or discuss a problem:';

var gsInput7 = document.createElement('input');
gsInput7.name = 'query';
gsInput7.setAttribute('type','text');
gsInput7.setAttribute('value','');
gsInput7.id = 'gsfn_search_query';
gsInput7.setAttribute('maxlength','120');

var gsImg2 = document.createElement('img');
gsImg2.src = '/gfx/help-qm.png';
// sensible
gsImg2.style.cssFloat = 'right';
// IE
gsImg2.style.styleFloat = 'right';

var gsInput8 = document.createElement('input');
gsInput8.id = 'continue';
gsInput8.setAttribute('type','submit');
gsInput8.setAttribute('value','Continue');

var gsDiv4 = document.createElement('div');
gsDiv4.id = 'gsfn_search_results';
gsDiv4.style.height = 'auto';

var gsDiv5 = document.createElement('div');
gsDiv5.className = 'powered_by';

var gsA2 = document.createElement('a');
gsA2.href = 'http://askit.bris.ac.uk/uob';

var gsImg1 = document.createElement('img');
gsImg1.src = 'http://askit.bris.ac.uk/favicon.gif';
gsImg1.setAttribute('alt','');
gsImg1.style.verticalAlign = 'middle';
gsImg1.style.marginRight = '0.5em';
gsImg1.style.width = '16px';
gsImg1.style.height = '16px';

var gsA3 = document.createElement('a');
gsA3.href = 'http://askit.bris.ac.uk/uob';
gsA3.innerHTML = 'AskIT community support network for mobile IT';

//var gsBR93 = document.createElement('br');

var gsP93 = document.createElement('p');
gsP93.style.borderTop = '1px solid #aaa';
gsP93.style.padding = '0.5em 0em 0.5em 0em'; 
gsP93.innerHTML = '<strong>&bull; Or contact the Bristol IT Service Desk</strong>:<br>Phone: +44 (0)117 928 7870 (87870 internal).<br>Email: service-desk@bristol.ac.uk<br>Visit: The Computer Centre, Tyndall Avenue, next to the Arts &amp; Social Sciences Library.';

var gsDiv6 = document.createElement('div');
gsDiv6.style.textAlign = 'center';

var gsA4 = document.createElement('a');
gsA4.name = 'closeGS';
gsA4.innerHTML = '[Close this]';
gsA4.style.cursor='pointer';
//gsA4.setAttribute('onclick',"document.getElementById('gsfn_search_form').reset(); document.getElementById('gsfn_search_widget').style.display='none'; document.getElementById('gsClick').style.display='block';");
gsA4.onclick=function(){ document.getElementById('gsfn_search_form').reset(); document.getElementById('gsfn_search_widget').style.display='none'; document.getElementById('gsClick').style.display='block'; }
gsA4.style.textDecoration = 'underline';

var gsA94 = document.createElement('a');
gsA94.innerHTML = '[Jump to wireless FAQs page]';
gsA94.style.cursor='pointer';
gsA94.style.marginRight='6em';
//gsA94.setAttribute('onclick',"window.location='http://www.wireless.bris.ac.uk/help/help-faq/'");
gsA94.onclick=function(){ window.location='http://www.wireless.bris.ac.uk/help/help-faq/'; }
gsA94.style.textDecoration = 'underline';



// put it all together:

//gsDiv7.appendChild(gsTag1);
gsDiv7.appendChild(gsImg2);
gsDiv7.appendChild(gsA1);
gsDiv3.appendChild(gsInput1);
gsDiv3.appendChild(gsInput2);
gsDiv3.appendChild(gsInput3);
gsDiv3.appendChild(gsInput4);
gsDiv3.appendChild(gsInput5);
gsDiv3.appendChild(gsInput6);
gsDiv3.appendChild(gsLabel1);
gsDiv3.appendChild(gsInput7);
gsDiv3.appendChild(gsInput8);
gsForm1.appendChild(gsDiv3);
gsDiv2.appendChild(gsForm1);
gsDiv2.appendChild(gsDiv4);
gsA2.appendChild(gsImg1);
gsDiv5.appendChild(gsA2);
gsDiv5.appendChild(gsA3);
// gsDiv5.appendChild(gsBR93);
gsDiv5.appendChild(gsP93);
gsDiv6.appendChild(gsA94);
gsDiv6.appendChild(gsA4);
gsDiv5.appendChild(gsDiv6);
gsDiv2.appendChild(gsDiv5);
gsDiv7.appendChild(gsDiv2);
gsDiv1.appendChild(gsDiv7);

document.getElementById('footer').appendChild(gsDiv1);

if (isBigScreen()) {
  document.body.appendChild(gsTag2);
} 

var gsSpan90 = document.createElement('p');
gsSpan90.innerHTML = 'G<br />O<br />T<br /> <br />A<br /> <br />Q<br />U<br />E<br />S<br />T<br />I<br />O<br />N<br />?';
gsSpan90.id = 'gsClickText';
gsSpan90.style.textAlign = 'center';
gsSpan90.style.fontWeight = 'bold';

var gsDiv90 = document.createElement('div');
gsDiv90.onclick=function(){ gsClickDO(); };
gsDiv90.id='gsClick';
gsDiv90.onmouseover=gsClickOMOa; 
gsDiv90.onmouseout=gsClickOMOb;

gsDiv90.appendChild(gsSpan90);
document.body.appendChild(gsDiv90);
          
if (navigator.userAgent.indexOf('MSIE 6.') > -1) { document.getElementById('gsClick').style.position='absolute'; }

}

function gsClickDO() {
try {
  iddisp('gsfn_search_widget','block');
  iddisp('gsClick','none');
  if (!isBigScreen()) { window.scrollTo(100,100); }
}
catch(e) {
 // nothing
}
}

function gsClickFly(minwindow) {
  var winW = 0;
  if (navigator.appName.indexOf("Microsoft")!=-1) {
    winW = document.body.offsetWidth;
  } else  {
    winW = window.innerWidth;
  }

  try {
    if ((isBigScreen()) && (winW > minwindow)) {
      floatingMenu.targetX = -420;
      floatingMenu.targetY = 350;
      gsClickDO();
    }
  }
  catch(e) {
    // nothing
  }
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function isInstructionsNet(maybeYourIP){
 if (maybeYourIP.substr(0,9) != '172.21.0.') {
    if (maybeYourIP.substr(0,9) != '172.21.1.') {
      if (maybeYourIP.substr(0,9) != '172.21.2.') {
        if (maybeYourIP.substr(0,9) != '172.21.3.') {
	  return false;
	}
      }
    }
  }
 return true;
}

if (document.getElementsByClassName == undefined) {
    document.getElementsByClassName = function(className) {
      var hasClassName = new RegExp("(?:^|\\s)" + className + "(?:$|\\s)");
      var allElements = document.getElementsByTagName("*");
      var results = [];
      var element;
      for (var i = 0; (element = allElements[i]) != null; i++) {
        var elementClass = element.className;
        if (elementClass && elementClass.indexOf(className) != -1 && hasClassName.test(elementClass))
          results.push(element);
      }
      return results;
    }
}




function doonload() {
  // LHN is a bit excessive on these pages 
  if (window.location.pathname.substr(0,10) ==   '/help/faq/') { hideLHNsecondbit(); }
  if (window.location.pathname.substr(0,25) ==   '/eduroam/instructions/go-') { hideLHNsecondbit(); }

  // for the map
  try {
    if (loadTheMAP === 1) { MAPload();}
  } catch (e) { }

// return true;

  // can not do GET SATISFACTION where there is no Internet
  var maybeYourIP = '';
  try { maybeYourIP = document.getElementById('thisisahacktogiveyouriptojavascriptbutdontrelyonit').innerHTML; } catch(e) { }

  // resnet stuff
  if (window.location.hash == '#spoofresnetip') { try { if (maybeResNet('1')=='1') { return true; } } catch(e) { } }
  else if (maybeYourIP == '137.222.12.76') { try { if (maybeResNet()=='1') { return true; } } catch(e) { } }
  else if (maybeYourIP.substr(0,7) == '172.23.') { try { if (maybeResNet()=='1') { return true; } } catch(e) { } }
  else if (maybeYourIP.substr(0,8) == '137.222.') {
    var thirdoctet = maybeYourIP.substr(8,3);
    if ((thirdoctet > 207) && (thirdoctet < 239)) {
      try { if (maybeResNet()=='1') { return true; } } catch(e) { } 
    }
    if ((thirdoctet == 12)) {
      try { if (maybeResNet()=='1') { return true; } } catch(e) { } 
    }
  }

  // not resnet stuff
  if (!isInstructionsNet(maybeYourIP)) {
            if (window.location.pathname.substr(0,25) ==   '/eduroam/instructions/go-') { 
              insertMessagePlain('pagetitle','bristolwirelesshelpnote','You can get to these instructions on campus by choosing the <strong>Bristol-WiFi-Setup</strong> wireless signal (login not required)','',1); 
            }
            //if (window.location.pathname == '/eduroam/instructions/') { insertGetSatisfaction('pagetitle'); }
            if (window.location.pathname.substr(0,9) ==   '/eduroam/') { insertGetSatisfaction('pagetitle'); }
            if ((window.location.pathname.substr(0,6) ==   '/help/') && (window.location.pathname !=   '/help/locations/') && (window.location.pathname.substr(0,14) != '/help/itstaff/')) { insertGetSatisfaction('pagetitle'); }
            if (window.location.pathname ==   '/wireless-web-index/') { insertGetSatisfaction('pagetitle'); }
  } else {
    // these are not useful on the instructions network
    try { document.getElementById('deptnavul').style.display='none'; } catch(e) { }
    try { document.getElementById('uobnavbottomul').style.display='none'; } catch(e) { }
  }

  if (window.location.pathname.substr(0,25) ==   '/eduroam/instructions/go-') { 
    insertMessagePlain('uobcms-content','nonBrisUsersWarning','&bull; These instructions will only work if you have a Bristol username - If you are from a different eduroam organisation, you will need to refer to your home organisation for the correct instructions - click for more information.','window.location="http://www.wireless.bris.ac.uk/help/help-faq/faq-different-instructions/";');
    insertMessagePlain('uobcms-col1','copypermission','Eduroam participating organisations are free to re-use the text or screenshots of the eduroam information on this page - attribution is optional.<br /><br />Other organisations can request permission by emailing<br />wireless-help&#064;&#098;&#114;&#105;&#115;&#116;&#111;&#108;&#046;ac.uk'); 
  }

  try {
    var searchboxinput=document.getElementById('search');
    var searchboxinputmsg='search wireless';
    searchboxinput.style.fontStyle='italic';
    searchboxinput.value=searchboxinputmsg;
    searchboxinput.style.color='#888';
    searchboxinput.onfocus=function(){ if (this.value == searchboxinputmsg) {this.value=''}; this.style.color='#000'; this.style.fontStyle='normal'; }
    searchboxinput.onblur=function(){ if (this.value == '') {this.value=searchboxinputmsg; this.style.color='#888'; this.style.fontStyle='italic'; }}
  }
  catch(e) { }

  if (!document.getElementsByClassName('current_page_item')[0]) { 
    try {
      var current_page_ancestor_ele = document.getElementsByClassName('current_page_ancestor')[0];
      current_page_ancestor_ele.className=current_page_ancestor_ele.className+' current_page_item';
    } catch(e) { }
  }


}

