
  var hideOnPrintArray = new Array();
  function hideOnPrint(inObjName) {
	var tempObj = document.getElementById(inObjName);
	if( tempObj != null ) {
      hideOnPrintArray[hideOnPrintArray.length] = tempObj;
	}
  }
  
  function prePrint() {
    document.getElementById("div_doc").style.width = "100%";
    document.getElementById("div_doc").style.border = "1px solid #ffffff";
    document.getElementById("div_top_printable").style.display = "";
    for( x=0; x < hideOnPrintArray.length; x++ ) {
	  hideOnPrintArray[x].style.display = "none";
	}
  }
  
  function postPrint() {
    document.getElementById("div_doc").style.width = "768px";
    document.getElementById("div_doc").style.border = "1px solid #d5d5d5";
    document.getElementById("div_top_printable").style.display = "none";
    for( x=0; x < hideOnPrintArray.length; x++ ) {
	  hideOnPrintArray[x].style.display = "";
	}
  }

  function adjustLayout() {
    var pagemin = 768;
    var pagewidth = 0;
    var pagemargin = 0;
    if( window.innerWidth ) {
      pagewidth = window.innerWidth;
    } else {
      pagewidth = document.body.clientWidth;
    }
    pagemargin = (pagewidth-pagemin)/2;
    
    // adjust absolute positioned objects
    document.getElementById("div_loading").style.left = 384+pagemargin;
    var featuredArtistPageNav = document.getElementById("featured_artists_page_nav");
    if( featuredArtistPageNav != null ) {
      featuredArtistPageNav.style.left = 21+pagemargin;
    }
  }
  
  var iarray = new Array();
  // iarray format = id, type, title, description
  var ishow_index = 1;  // current image
  var ishow_max = 1;   // total number of images
  var iload_index = 1;  // current column
  var iload_max = 4;    // total number of columns
  var iload_rows = 4;   // number of rows

  function iload(inIndex) {
    if( inIndex < 1 ) inIndex = 1;
    inIndex = Math.ceil(inIndex / iload_rows);
    if( inIndex > iload_max ) inIndex = iload_max;
    if( inIndex % 2 != 0 ) {
      iscroll((inIndex*83));
    }
    iload_index = inIndex;
  }
  
  function iload_next() {
    if( iload_index >= iload_max ) iload_index = 0;
    iload(iload_index+1);
  }
  
  function iload_prev() {
    if( iload_index <= 1 ) iload_index = iload_max+1;
    iload(iload_index-1);
  }
  
  function ishow(inIndex) {
    document.getElementById("ithumb_" + ishow_index).style.border = "2px solid white";
    document.getElementById("ithumb_" + inIndex).style.border = "2px solid #ed3f0d";
    if( iarray[inIndex-1][1] == "image" ) {
      document.getElementById("imageview_medium").src = "/work/" + iarray[inIndex-1][0] + "_w450.jpg";
      document.getElementById("imageview_medium").alt = iarray[inIndex-1][2] + " - Click to View Larger";
      document.getElementById("imageview_medium").title = iarray[inIndex-1][2] + " - Click to View Larger";
      document.getElementById("wm_imageTitle").innerHTML = iarray[inIndex-1][2];
      document.getElementById("wm_imageDesc").innerHTML = iarray[inIndex-1][3];
	  document.getElementById("wm_copyright").innerHTML = iarray[inIndex-1][4];
    }
    ishow_index = inIndex;
    iload(ishow_index);
  }
  
  function ishow_next() {
    if( ishow_index >= ishow_max ) { 
      ishow(1);
    } else {
      ishow(ishow_index+1);
    }
  }
  
  function ishow_prev() {
    if( ishow_index <= 1 ) {
      ishow(ishow_max);
    } else {
      ishow(ishow_index-1);
    }
  }
 
  var scroll_interval = null;
  var scroll_whereIamGoing = 0;
  var scroll_whereIamNow = 0;
  var scroll_diff = 0;
  function iscroll(inLeft) {
    scroll_whereIamGoing = inLeft;
    if( scroll_interval != null ) clearInterval(scroll_interval);
    scroll_interval = setInterval("iscrollSmooth()", 10);
  }
  
  
  function iscrollSmooth() {
    scroll_whereIamNow = document.getElementById("div_body_imgscroll").scrollLeft;
    if( scroll_whereIamNow == scroll_whereIamGoing ) {
      clearInterval(scroll_interval);
    } else {
      if(scroll_whereIamNow < scroll_whereIamGoing) { // move forward (right)
        scroll_diff = scroll_whereIamGoing - scroll_whereIamNow;
        if( scroll_diff > 100 ) {
          scroll_whereIamNow += 30;
        } else if ( scroll_diff > 50 ) {
          scroll_whereIamNow += 20;
        } else if ( scroll_diff > 30 ) {
          scroll_whereIamNow += 10;
        } else if ( scroll_diff > 10 ) {
          scroll_whereIamNow += 5;
        } else {
          scroll_whereIamNow = scroll_whereIamGoing;
        }
      } else { // move backwards (left)
        scroll_diff = scroll_whereIamNow - scroll_whereIamGoing;
        if( scroll_diff > 100 ) {
          scroll_whereIamNow -= 30;
        } else if ( scroll_diff > 50 ) {
          scroll_whereIamNow -= 20;
        } else if ( scroll_diff > 30 ) {
          scroll_whereIamNow -= 10;
        } else if ( scroll_diff > 10 ) {
          scroll_whereIamNow -= 5;
        } else {
          scroll_whereIamNow = scroll_whereIamGoing;
        }
      }
      document.getElementById("div_body_imgscroll").scrollLeft = scroll_whereIamNow;
    }
  }
  
  function ishowBig() {
    document.getElementById("div_body_viewallimages").style.display = "none";
    document.getElementById("div_body_portfolio").style.display = "none";
    document.getElementById("div_body_bigimagedisplay").style.display = "";
    ishowBigLoad(ishow_index);
  }
  
  function ishowNormal() {
    document.getElementById("div_body_viewallimages").style.display = "none";
    document.getElementById("div_body_bigimagedisplay").style.display = "none";
    document.getElementById("div_body_portfolio").style.display = "";
    iload(ishow_index);
  }
  
  
  function ishowViewAll() {
    document.getElementById("div_body_bigimagedisplay").style.display = "none";
    document.getElementById("div_body_portfolio").style.display = "none";
    document.getElementById("div_body_viewallimages").style.display = "";
  }
  
  function ishowBigLoad(inIndex) {
    if( iarray[inIndex-1][1] == "image" ) {
      checkLoading();
      document.getElementById("imageview_large").src = "/work/" + iarray[inIndex-1][0] + "_w700.jpg";
      document.getElementById("wb_imageTitle").innerHTML = iarray[inIndex-1][2];
      document.getElementById("wb_imageDesc").innerHTML = iarray[inIndex-1][3];
	  document.getElementById("wb_copyright").innerHTML = iarray[inIndex-1][4];
    }
    ishow(inIndex);
  }
  
  function ishowBig_next() {
    if( ishow_index >= ishow_max ) { 
      ishowBigLoad(1);
    } else {
      ishowBigLoad(ishow_index+1);
    }
  }
  
  function ishowBig_prev() {
    if( ishow_index <= 1 ) {
      ishowBigLoad(ishow_max);
    } else {
      ishowBigLoad(ishow_index-1);
    }
  }

  var showShowLoading = false;
  function checkLoading() {
    showShowLoading = true;
    setTimeout("showLoading()", 1000);
  }
  
  function showLoading() {
    if( showShowLoading ) document.getElementById("div_loading").style.display = "";
  }
 
  function hideLoading() {
    showShowLoading = false;
    document.getElementById("div_loading").style.display = "none";
  }
  

  function GetElementLeft(eElement) {
    var nLeftPos = eElement.offsetLeft;
    var eParElement = eElement.offsetParent;
    while (eParElement != null) {
      nLeftPos += eParElement.offsetLeft;
      eParElement = eParElement.offsetParent;
    }
    return nLeftPos;
  }

  function GetElementTop(eElement) {
    var nTopPos = eElement.offsetTop;
    var eParElement = eElement.offsetParent;
    while (eParElement != null) {
      nTopPos += eParElement.offsetTop;
      eParElement = eParElement.offsetParent;
    }
    return nTopPos;
  }
