// JavaScript Document
// author:   Bruce Blackburn
//           bruceblackburn.com
// created:  Oct 14, 2007
// modified: May 9, 2009

var d = document;

function writeMainNav(prefix) {
var str = 
 '    <ul id="mainnav">'
+'      <li><a id="homebtn"     href="/"                     >Home</a></li>'+"\n"
+'      <li><a id="projectsbtn" href="/projects.html"        >Projects</a></li>'+"\n"
+'      <li><a id="profilebtn"  href="/profile_history.html" >Profile</a></li>'+"\n"
+'      <li><a id="newsbtn"     href="/news.html"            >News</a></li>'+"\n"
+'      <li><a id="contactbtn"  href="/contact.html"         >Contact</a></li>'+"\n"
+'      <li><a id="leedbtn"     href="/leed.html" title="LEED and Green Design"           >LEED</a></li>'+"\n"
+'    </ul>'+"\n";
document.write(str);
}

function writeProjectSubNav() {
var str = 
 '		  <ul id="subnav">\n'
+'		    <li><a id="educbtn" href="education.html">Education</a></li>\n'
+'		    <li><a id="corpbtn" href="corporate.html">Corporate</a></li>\n'
+'		    <li><a id="combtn" href="commercial.html">Commercial</a></li>\n'
+'		    <li><a id="relbtn" href="religious.html">Religious</a></li>\n'
+'		    <li><a id="financialbtn"     href="financial.html">Financial</a></li>\n'
+'		    <li><a id="intbtn" href="interior.html">Interior Design</a></li>\n'
+'		    <li><a id="resbtn" href="residential.html">Residential</a></li>\n'
+'		    <li><a id="otherbtn" href="other.html">Other Projects</a></li>\n'
+'		  </ul>\n';
document.write(str);
}

function writeProfileSubNav() {
var str = 
 '		  <ul id="subnav">\n'
+'		    <li><a id="historybtn" href="profile_history.html">History</a></li>\n'
+'		    <li><a id="philosophybtn" href="profile_philosophy.html">Philosophy</a></li>\n'
+'		    <li><a id="awardsbtn" href="profile_awards.html">Awards</a></li>\n'
+'		  </ul>\n';
document.write(str);
}

function writeAddr(addr, inLine) {
addr += '@gvaarchitects.com';
var str='<a href="mailto:' + addr + '">' + addr + '</a>';
if (!inLine) {
  str = '<div>' + str + '</div>';
  }
document.write(str);
}

// separate out parse querystring function
var isPopup = false;
function writeWindowTitle() {
  var searchString = document.location.search.substring(1);
  var nvPairs = searchString.split("&");
  for (i=0; i<nvPairs.length; i++) {
    var nv = nvPairs[i].split("=");
    if (nv[0]=="t") {
      var title = "<title>GVA: " + unescape(nv[1]) +"</title>";
    }
    if (nv[0]=="pop") {
      isPopup = true;
    }
  }
  var alttitle = "<title>GVA Architects</title>";
  document.write(title?title:alttitle);
}

function closeButton() {
  if (isPopup) {
    document.write("<div id='closebutton'><a onclick='window.close()' >CLOSE</a></div>\n");
  }
}

var projWin;
function projectWindow(url) {
  projWin=window.open(url,"projviewer","height=495,width=755");
  if (window.focus) projWin.focus();
}

// from Dom Scripting, Jeremy Keith
function prepLinks() {
  var links = d.getElementsByTagName("a");
//  alert("preplinks lenth="+links.length);
  
  for(var i=0; i<links.length; i++) {
    var className = "";
    var link = links[i];
    var used = "";
    if (link.className) {
      used="className";
      className = link.className;
    } else if (link.getAttribute && link.getAttribute("class")) {
      used="getAttribute";
      className = link.getAttribute("class");
    } else {
      used ="neither";
    }
//    if (!className &&) className = links[i].getAttribute("className");
    if (className == "popup") {
//      alert("used "+used);
      var href;
      link.onclick = function() {
        if (this.getAttribute && this.getAttribute("href")) {
          href = this.getAttribute("href");
        }
        projectWindow(href);
        return false;
      };  //function
    } //if
  } //for 
} //preplinks 

// based on code from Dom Scripting, Jeremy Keith
function prepLinks2() {
//  alert("preplinks2 length="+links.length);
  if (!d.getElementById) return true;
  if (!d.getElementById("projectlinks")) return true;
  if (!d.getElementsByTagName) return true;
  if (!d.getElementsByTagName("a")) return true;
  var projectlinks=d.getElementById("projectlinks");
  var links = projectlinks.getElementsByTagName("a");
  for(var i=0; i<links.length; i++) {
    links[i].onclick = function() {
      if(!this.href) return true;
      projectWindow(this.href+'&pop=1');
      return false;
    };  //function
  } //for 
} //preplinks2