var bClicked = new Array(false,false,false);
var menu=new Array("","index","research","resume","interests","collaboration");
var tabID=0;
var cImg = "base";
var page = 0;
var xmlhttp;
function test(){
document.write("<h2>"+tabID+"</h2>");
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
// alert('Query Variable ' + variable + ' not found');
}

var idContent = " ";
var activePage = 0;
function on_mouseover(imgobject,id)
{
if(bClicked[id])
return;
imgobject.src = "images/over"+id+".gif";
}
function on_mouseout(imgobject,id)
{
if(bClicked[id])
return;
imgobject.src = "images/base"+id+".gif";
}
function on_click(imgobject,id)
{
//activePage = id;
setCookie("showID",id);
setCookie("page","page");

//imgobject.src = "images/over"+id+".gif";



//bClicked[id]=true;
//imgobject.src = "images/click"+id+".gif";
}
/*
   name - name of the cookie
   value - value of the cookie
   [expires] - expiration date of the cookie
     (defaults to end of current session)
   [path] - path for which the cookie is valid
     (defaults to path of calling document)
   [domain] - domain for which the cookie is valid
     (defaults to domain of calling document)
   [secure] - Boolean value indicating if the cookie transmission requires
     a secure transmission
   * an argument defaults when it is assigned null as a placeholder
   * a null placeholder is not required for trailing omitted arguments
*/

function setCookie(name, value, expires, path, domain, secure) {

//	var today = new Date(); //

//	thisDay = today.getDate(); 

	
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
//	document.write("<table border=1><tr><td>This is:"+expires.toGMTString+"</td></tr></table>");
}
function getCookie(name) {
  var dc = document.cookie;
  var prefix = name + "=";
  var begin = dc.indexOf("; " + prefix);
  if (begin == -1) {
    begin = dc.indexOf(prefix);
    if (begin != 0) return null;
  } else
    begin += 2;
  var end = document.cookie.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
  return unescape(dc.substring(begin + prefix.length, end));
}

function createTab(cat,id) {
	var cImg="base"+id;
	var aImg="unclick";
	var tabID=getQueryVariable("sid");
	if(tabID == null) tabID = 1;
	bClicked[tabID]=true;
	if(tabID==id) {cImg="over"+id; aImg="click";}
	if(cat == 1) document.write("<a href='"+menu[id]+".html'><img border=0 name='tab"+id+"' src='images/"+cImg+".gif' onmouseover=on_mouseover(this,"+id+"); onmouseout=on_mouseout(this,"+id+"); onclick=on_click(this,"+id+"); /></a>");
	else document.write("<a href='"+menu[cat]+".html?sid="+id+"'><img border=0 name='tab"+id+"' src='images/"+cImg+".gif' onmouseover=on_mouseover(this,"+id+"); onmouseout=on_mouseout(this,"+id+"); onclick=on_click(this,"+id+"); /><img border=0 src='images/"+aImg+".gif'></a>");
	
}

function showPage() {
var sid=(getQueryVariable("sid"))?getQueryVariable("sid"):"1";
var page=(getQueryVariable("page"))?getQueryVariable("page"):"page";
include(page+sid+".html");
document.write("<table border='0' id='frame' width=100% height=100%><tr><td>"+xmlhttp.responseText+"</td></tr></table>"); 
}

function include(pURL) {
    if (window.XMLHttpRequest) { // code for Mozilla, Safari, ** And Now IE 7 **, etc
        xmlhttp=new XMLHttpRequest();
    } else if (window.ActiveXObject) { //IE
        xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
    }
    if (typeof(xmlhttp)=='object') {
        xmlhttp.onreadystatechange=postFileReady;
        xmlhttp.open('GET', pURL, true);
        xmlhttp.send(null);
    }
}

// function to handle asynchronous call
function postFileReady() {
   if (xmlhttp.readyState==4) {
      if (xmlhttp.status==200) {
         document.getElementById('theDivToLoad').innerHTML=xmlhttp.responseText;
      }
   }
}