var mAction;
var mSelected;
var mPicSel;
var mPosCounter;

var aniText1;
var aniText2;
var aniText3;
var aniPhrase;

function showByline() {

 aniText1.style.top=-20;
 aniText1.style.visibility = "visible";
 aniText2.style.top=-20;
 aniText2.style.visibility = "visible";
 aniText3.style.top=-20;
 aniText3.style.visibility = "visible";
 aniPhrase.style.left=-400;
 aniPhrase.style.visibility = "visible";
 mAction = window.setInterval("animateByline()",90);
 mPosCounter=10;
 resize();
}

function animateByline() {

 aniText1.style.top = mPosCounter;
 mPosCounter += 10;

 if (mPosCounter >= 150) {
  aniText1.style.top=150;
  aniText2.style.top = mPosCounter - 150;
  if (mPosCounter >= 300) {
   aniText2.style.top=150;
   aniText3.style.top = mPosCounter - 300;
   if (mPosCounter >= 450) {
    aniText3.style.top=150;
    mPosCounter += 15;
    aniPhrase.style.left = mPosCounter - 850;
    if (mPosCounter >= 900) {
     aniPhrase.style.left=50;
     window.clearInterval(mAction);
     mPosCounter=0;
    }
   }
  }
 }
}

function mClick(evtElem) {
 mClear();
 mSelected = evtElem;
 mSelect();
 if (mSelected.id=='mHome') {
  window.location='Default.aspx';
 }
 if (mSelected.id=='mPortfolio') {
  window.location='Portfolio.aspx';
 }
 if (mSelected.id=='mArticles') {
  window.location='Articles.aspx';
 }
 if (mSelected.id=='mPricing') {
  window.location='Pricing.aspx';
 }
 if (mSelected.id=='mAbout') {
  window.location='About.aspx';
 }
 if (mSelected.id=='mLinks') {
  window.location='Links.aspx';
 }
 if (mSelected.id=='mContact') {
  window.location='Contact.aspx';
 }
}

function mOver(evtElem) {
 if (evtElem != mSelected) {
  evtElem.style.color='darkslategray';	//'#A3C4C7'; //#3399CC
  var tabL = document.getElementById(evtElem.id+"L");
  var tabR = document.getElementById(evtElem.id+"R");
  if (tabL && tabR) 
  {
   evtElem.className="tabOver";
   tabL.className="tabOverLeft";
   tabR.className="tabOverRight";
 }
 }
}

function mOut(evtElem) {
 if (evtElem != mSelected) {
  evtElem.style.color='slategray';
  var tabL = document.getElementById(evtElem.id+"L");
  var tabR = document.getElementById(evtElem.id+"R");
  if (tabL && tabR) 
  {
   evtElem.className="tab";
   tabL.className="tabLeft";
   tabR.className="tabRight";
 }
 }
}

function resize() {

alert('resize');

 var eContent;

 eContent=document.getElementById('content');

 // Firefox
 if (document.height) {
  eContent.style.height = document.height - 180 - 140 - 4;
 }
 // IE
 else {
  var ePage1;
  ePage1=document.getElementById('page1');
  eContent.style.height = ePage1.style.pixelHeight - 180 - 140;
 }

return;

 if (document.body.clientWidth < 510) {
  menu.style.pixelLeft = 400;
 }
 else {
  menu.style.pixelLeft = document.body.clientWidth-110;
  content.style.pixelWidth = menu.style.pixelRight + 100;
 }

}

function loadCommonPageElements() {

return;

 var elemCopyright = document.getElementById('copyright2');
 if(elemCopyright) {
  var updated = new Date(document.fileModifiedDate);
  elemCopyright.innerHTML="Last updated " + updated.toLocaleDateString() + ".";
 }

}

function bLoad(pageId) {

 loadCommonPageElements();

/*
 aniText1=document.getElementById('byline1');
 aniText2=document.getElementById('byline2');
 aniText3=document.getElementById('byline3');
 aniPhrase=document.getElementById('catchphrase');
*/

 mClear();
 if (pageId=='mHome') {
/*
  showByline();
*/
  mSelected=document.getElementById('mHome');
 }
 else {
/*
  resize();
  aniText1.style.pixelTop=150;
  aniText2.style.pixelTop=150;
  aniText3.style.pixelTop=150;
  aniPhrase.style.pixelLeft=50;
  aniText1.style.visibility = "visible";
  aniText2.style.visibility = "visible";
  aniText3.style.visibility = "visible";
  aniPhrase.style.visibility = "visible";
*/
 }
 if (pageId=='mPortfolio') {
  mSelected=document.getElementById('mPortfolio');
  projClick(document.getElementById('pf82'));
 }
 if (pageId=='mArticles') {
  mSelected=document.getElementById('mArticles');
 }
 if (pageId=='mPricing') {
  mSelected=document.getElementById('mPricing');
 }
 if (pageId=='mAbout') {
  mSelected=document.getElementById('mAbout');
 }
 if (pageId=='mLinks') {
  mSelected=document.getElementById('mLinks');
 }
 if (pageId=='mContact') {
  mSelected=document.getElementById('mContact');
 }
 mSelect();
}

function mClear() {
 if (mSelected) {
/*  mSelected.style.textDecoration='none'; */
  mSelected.style.color='slategray';

  var tabL = document.getElementById(mSelected.id+"L");
  var tabR = document.getElementById(mSelected.id+"R");
  if (tabL && tabR) 
  {
   mSelected.className="tab";
   tabL.className="tabLeft";
   tabR.className="tabRight";
 }

 }
}

function mSelect() {
/* mSelected.style.textDecoration='underline'; */
 mSelected.style.color='darkslategray';

  var tabL = document.getElementById(mSelected.id+"L");
  var tabR = document.getElementById(mSelected.id+"R");
  if (tabL && tabR) 
  {
   mSelected.className="tabActive";
   tabL.className="tabLeftActive";
   tabR.className="tabRightActive";
 }
}

function projClick(evtElem) {
 mPicSel = evtElem;
 if (!mPicSel) { return; }
 document.all.portfolioEnlarged.src=evtElem.attributes.getNamedItem('preview').nodeValue;
 document.all.portfolioText.innerHTML=evtElem.attributes.getNamedItem('description').nodeValue;
}

function portImg_click() {
 if (!mPicSel) { return; }
 window.open(mPicSel.attributes.getNamedItem('fullsize').nodeValue, '_blank');
}

function thumbOver2(thumb) {
 thumb.style.borderColor="darkslategray";
 thumb.src = thumb.attributes.getNamedItem('thumbOver').nodeValue;
}

function thumbOut(thumb) {
 thumb.style.borderColor="#CCDCB1";
 thumb.src = thumb.attributes.getNamedItem('thumb').nodeValue;
}

function categoryChange(ThumbsAreVertical) {
 var selCat = document.getElementById('selCategory');
 var thumbsParent = document.getElementById('divThumbs');
 var thumbs = thumbsParent.getElementsByTagName('IMG');
 var aThumbs = document.getElementById('divAllThumbs').getElementsByTagName('IMG');
 var strCat = "";
 if (selCat.selectedIndex > 0) {
  strCat = selCat.options.item(selCat.selectedIndex).attributes.getNamedItem('Cid').nodeValue+'_';
 }
 while(thumbsParent.childNodes.length>0) {
  thumbsParent.removeChild(thumbsParent.childNodes.item(0));
 } 
 for (iThA=0;iThA<aThumbs.length;iThA++) {
  var thumb = aThumbs.item(iThA);
  var thCats = thumb.attributes.getNamedItem('categories').nodeValue;
  if (thCats.indexOf(strCat)>=0) {
   thumbsParent.appendChild(thumb.cloneNode(true));
   if (ThumbsAreVertical == '1') {
    var elBr = document.createElement('br');
    thumbsParent.appendChild(elBr);
   }
  }
 }
}
