
/*-----------------------------------------------------------------------------------------------------------
  main.js - method/browser check
------------------------------------------------------------------------------------------------------------*/
if(!document.getElementById)
{
  document.location.replace("v3_browser.html")
}
/*-----------------------------------------------------------------------------------------------------------
  variables
------------------------------------------------------------------------------------------------------------*/
var pageReady=false;
/*-----------------------------------------------------------------------------------------------------------
  nav mouse events
------------------------------------------------------------------------------------------------------------*/
function imgCache()
{
	hN=new Image;
	hN.src="img/nav_home.gif";
	hS=new Image;
	hS.src="img/nav_home_s.gif";
	pN=new Image;
	pN.src="img/nav_portfolio.gif";
	pS=new Image;
	pS.src="img/nav_portfolio_s.gif";
	rN=new Image;
	rN.src="img/nav_resume.gif";
	rS=new Image;
	rS.src="img/nav_resume_s.gif";
	aN=new Image;
	aN.src="img/nav_about.gif";
	aS=new Image;
	aS.src="img/nav_about_s.gif";
	cN=new Image;
	cN.src="img/nav_contact.gif";
	cS=new Image;
	cS.src="img/nav_contact_s.gif";
}

function ibpOver(oTarget) //nav image bar project
{
  oTarget.style.backgroundColor='#616F72';
}

function ibpOut(oTarget)
{
  oTarget.style.backgroundColor='';
}

function pnOver(oTarget) //projectnav mouseover events
{
  if(oTarget.id==selectedProjectTitle)
  {
    //do nothing
  }
  else
  {
    oTarget.style.backgroundColor='#AEA993';
    oTarget.style.color='#ffffff';
    oTarget.style.cursor='hand';
  }
}

function pnOut(oTarget) //projectnav mouseout events
{
  if(oTarget.id==selectedProjectTitle)
  {
    //do nothing
  }
  else
  {
    oTarget.style.backgroundColor='#F6F5EF';
    oTarget.style.color='#8D8876';
  }
}

function dbOver(oTarget) //projectnav mouseover events
{
  if(!lv)
  {
    //do nothing
  }
  else
  {
    oTarget.style.backgroundColor='#AEA993';
    oTarget.style.color='#ffffff';
    oTarget.style.cursor='hand';
  }
}

function dbOut(oTarget) //projectnav mouseout events
{
  if(!lv)
  {
    //do nothing
  }
  else
  {
    oTarget.style.backgroundColor='#F6F5EF';
    oTarget.style.color='#8D8876';
  }
}

function pniOver(oTarget) //projectnav icon mouseover events
{
  oTarget.style.borderColor='#ff6600';
}

function pniOut(oTarget) //projectnav icon mouseout events
{
  oTarget.style.borderColor='#AEA993';
}
/*-----------------------------------------------------------------------------------------------------------
  utility functions
------------------------------------------------------------------------------------------------------------*/
function mailer(oName,oDomain)
{
  email="mailto:"+oName+"@"+oDomain;
	window.location=email;
}

function newWindow(oPage,oName,oWidth,oHeight,oScroll,oResize)
{
  var win=null;
  LeftPosition = (screen.width) ? (screen.width-oWidth)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-oHeight)/2 : 0;
  settings='height='+oHeight+',width='+oWidth+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+oScroll+',resizable='+oResize;
  win = window.open(oPage,oName,settings);
  win.focus();
}
/*-----------------------------------------------------------------------------------------------------------
  portfolio functions
------------------------------------------------------------------------------------------------------------*/
function initProject(oHref)
{
  var url=oHref.split("?");
  var vals=url[1];
  var valSegs=vals.split("&");
  var valSeg1=valSegs[0].split("=");
  var t=valSeg1[1];
  var valSeg2=valSegs[1].split("=");
  var a=valSeg2[1];
  var valSeg3=valSegs[2].split("=");
  var an=valSeg3[1];
  var oArray=eval(a);
  sPL(t,oArray,an);
}
function sPL(oThumb,oArray,oArrayNum)//COMBINE WITH sP()
{
  var thumb=document.getElementById(oThumb);
  var source=thumb.src;
  var num=returnNum(source);
  var img=source.split("img/t");
  var seg1=img[1];
  thumb.src="img/ts"+seg1;
  if(selectedThumb=="")
  {
    //do nothing
  }
  else
  {
    var prevThumb=document.getElementById(selectedThumb);
    var ptsource=prevThumb.src;
    var img=ptsource.split("img/ts");
    var seg1=img[1];
    prevThumb.src="img/t"+seg1;
  }
  var oId=thumb.id;
  selectedThumb=oId;
  selectedArrayNum=oArrayNum;
  
  var img=document.getElementById("i");
  img.src="img/"+oArray[num-1];
  selectedArray=oArray;
  
  uC();
}
function sP(oThumb,oArray,oArrayNum)
{
  var source=oThumb.src;
  var num=returnNum(source);
  var img=source.split("img/t");
  var seg1=img[1];
  oThumb.src="img/ts"+seg1;
  
  var prevThumb=document.getElementById(selectedThumb);
  var ptsource=prevThumb.src;
  var img=ptsource.split("img/ts");
  var seg1=img[1];
  prevThumb.src="img/t"+seg1;
  var oId=oThumb.id;
  selectedThumb=oId;
  selectedArrayNum=oArrayNum;
  
  var img=document.getElementById("i");
  img.src="img/"+oArray[num-1];
  selectedArray=oArray;
  
  uC();
}
function returnNum(oSource)
{
  var oLength=oSource.length;
  var oChar=oLength-5;
  var oNum=oSource.charAt(oChar);
  return oNum;
}
function nP(oDirection)
{
  var img=document.getElementById("i");
  var oSrc=img.src;
  var num=returnNum(oSrc);
  if(oDirection)//next
  {
    if(num==selectedArray.length)//end of current project
    {
      selectedArrayNum=parseInt(selectedArrayNum)+1;
      if(selectedArrayNum==pMax+1)//end of projects collection
      {
        selectedArray="p1";
        selectedArrayNum=1;
      }
      else
      {
        selectedArray="p"+selectedArrayNum;
      }
      var oArray=eval(selectedArray);
      img.src="img/"+oArray[0];
      selectedArray=oArray;
    }
    else
    {
      img.src="img/"+selectedArray[num];
    }
    hT(img,'n');
  }
  else
  {
    if(num==1)//start of current project
    {
      selectedArrayNum=parseInt(selectedArrayNum)-1;
      if(selectedArrayNum==0)//start of projects collection
      {
        selectedArray="p"+pMax;
        selectedArrayNum=pMax;
      }
      else
      {
        selectedArray="p"+selectedArrayNum;
      }
      var oArray=eval(selectedArray);
      var oLength=oArray.length-1;
      img.src="img/"+oArray[oLength];
      selectedArray=oArray;
    }
    else
    {
      img.src="img/"+selectedArray[num-2];
    }
    hT(img);
  }
  uC();
}
function hT(oImg,oDir)
{
  var prevThumb=document.getElementById(selectedThumb);
  var ptsource=prevThumb.src;
  var img=ptsource.split("img/ts");
  var seg1=img[1];
  prevThumb.src="img/t"+seg1;
  
  var thumbNum=selectedThumb.split("t");
  var thumbNumSeg1=thumbNum[1];
  if(oDir)//next
  {
    if(thumbNumSeg1==tMax)
    {
    var newThumbNum=1;//end of projects collection
    }
    else
    {
    var newThumbNum=parseInt(thumbNumSeg1)+1;
    }
  }
  else//previous
  {
    if(thumbNumSeg1==1)
    {
    var newThumbNum=tMax;//beginning of projects collection
    }
    else
    {
    var newThumbNum=parseInt(thumbNumSeg1)-1;
    }
  }
  var newThumbId="t"+newThumbNum;
  var newThumb=document.getElementById(newThumbId);
  var seg1=oImg.src.split("img/p_");
  var seg2=seg1[1].split(".");
  var seg3=seg2[0];
  newThumb.src="img/ts_"+seg3+".gif";
  selectedThumb=newThumbId;
  return;
}
function uC()
{
  var oContentPrev=document.getElementById(selectedContent);
  var thumbNum=selectedThumb.split("t");
  var thumbNumSeg1=thumbNum[1];
  selectedContent="c"+thumbNumSeg1;
  var oContent=document.getElementById(selectedContent);
  oContentPrev.style.display="none";
  oContent.style.display="block";
  
  oTitle=document.getElementById("ct");
  var newTitle=selectedArrayNum-1;
  oTitle.innerHTML=titles[newTitle];
  
  uT();
}
function uT()
{
  oProjectTitlePrev=document.getElementById(selectedProjectTitle);
  var newProjectTitle="pt"+selectedArrayNum;
  var oProjectTitle=document.getElementById(newProjectTitle);
  oProjectTitlePrev.style.color="#8D8876";
  oProjectTitlePrev.style.backgroundColor="#F6F5EF";
  oProjectTitle.style.backgroundColor="#AEA993";
  oProjectTitle.style.color="#ffffff";
  selectedProjectTitle=newProjectTitle;
  lV();
}
function lV()
{
  var lvb=document.getElementById("lv");
  var lvlabel=document.getElementById("lvlbl");
  for(var thumbIds=0;thumbIds<lvs.length;thumbIds++)
  {
    if(selectedThumb==(lvs[thumbIds]))
    {
      lvb.style.color="#8D8876";
      lvlabel.title="Click to View Large Version";
      lv=true;
      lvArrayPos=thumbIds;
      return;
    }
  }
  lvb.style.color="#D8D6C8";
  lvlabel.title="No Large Version Available for this Image";
  lv=false;
}
function goLv()
{
  var img=document.getElementById("i");
  var source=img.src;
  var seg1=source.split("img/");
  var seg2=seg1[1];
  var seg3=seg2.split(".");
  var root=seg3[0];
  var val=root+"x."+seg3[1];
  var pos=lvArrayPos;
  var size=sizes[pos];
  var url="plv.html?"+val+"&"+size;
  newWindow(url,'plv','850','700','yes','yes');
}
function swapIbProject(n)
{
  var title=document.getElementById("ibprojecttitle");
  var a=document.getElementById("ib");
  var b=a.style.backgroundImage;
  var c=b.split(".jpg");
  var d=c[0];
  var e=d.split("ib_");
  var f=e[1];
  var g=parseInt(f);
  if(n) //next
  {
    var h=g+1;
    var i=h-1;
    if(h==ibpmax+1)
    {
      h=1;
      i=0;
    }
  }
  else //previous
  {
    var h=g-1;
    var i=h-1;
    if(h==0)
    {
      h=ibpmax;
      i=ibpmax-1;
    }
  }
  var url="url(img/ib_"+h+".jpg)";
  a.style.backgroundImage=url;
  title.innerHTML=ibp[i];
  title.href=ibpa[i];
}
