// The below code is copyright 2008 by Crossface Records and may not be used for commercial purposes without expressed written consent
var image_url;
var preload_image_object;

function redirectYa(loc)
{
   window.location = loc;
}

function hideContentDivs()
{
   var x=document.getElementsByTagName("div");
   var i;
   var el;
   
   for (i=0;i<x.length;i++) {
      el = x[i];
      
      if (el.id.toLowerCase() != "title")
         el.style.display = 'none';
   }
}

function switchMenu(obj, goToBottomOfPage) {
	var el = document.getElementById(obj);
	if ( el.style.display != "none" ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
   
   if (goToBottomOfPage.toLowerCase() == "true")
      location.hash="AnchorBottomOfPage";
}

function roll(img_name, img_src)
{
   document[img_name].src = img_src;
}

function changeSource(newSource)
{ 
   window.frames['mainPane'].location.href = newSource + ".html";
   window.frames['mainPane'].style.overflowX = "hidden";
} 

function preloadImages()
{
   var max = 38;
   var i = 3;
   var fileUrl;
   
   preload_image_object = new Array(37);
   image_url = new Array(37);   
   
   for(i=3; i<=max; i++)
   {
      fileUrl = "images/slices/images/layout_";
      
      if (i < 10)
         fileUrl = fileUrl + "0" + i.toString();
      else
         fileUrl = fileUrl + i.toString();
      
      fileUrl = fileUrl + ".png";
      
      image_url[i-1] = fileUrl;
   }
   
   for(i=0; i<max; i++)
   {
      preload_image_object[i] = new Image();       
      preload_image_object[i].src = image_url[i];
   }
   
   max = 6;
   i = 0;
   
   preload_image_object = new Array(6);
   image_url = new Array(6);
   image_url[0] = "images/slices/images/layout_04_over.png"
   image_url[1] = "images/slices/images/layout_05_over.png"
   image_url[2] = "images/slices/images/layout_06_over.png"
   image_url[3] = "images/slices/images/layout_07_over.png"
   image_url[4] = "images/slices/images/layout_08_over.png"
   image_url[5] = "images/slices/images/layout_09_over.png"

   for(i=0; i<max; i++)
   {
      preload_image_object[i] = new Image();       
      preload_image_object[i].src = image_url[i];
   }
   
   max = 17;
   i = 0;   
   
   preload_image_object = new Array(17);      
   image_url = new Array(17);
   image_url[0] = "images/gallery/backulock.png";
   image_url[1] = "images/gallery/buttons.png";
   image_url[2] = "images/gallery/clock1s.png";
   image_url[3] = "images/gallery/col2s.png";
   image_url[4] = "images/gallery/do2s.png";
   image_url[5] = "images/gallery/DObc.png";
   image_url[6] = "images/gallery/frisBC.png";
   image_url[7] = "images/gallery/frisbeeBC.png";
   image_url[8] = "images/gallery/grafbottleBC.png";
   image_url[9] = "images/gallery/heartstencilBC.png";
   image_url[10] = "images/gallery/knifestickerBC.png";
   image_url[11] = "images/gallery/peacebc.png";
   image_url[12] = "images/gallery/rope1sbc.png";   
   image_url[13] = "images/gallery/stencil.png";
   image_url[14] = "images/gallery/tv1sBC.png";
   image_url[15] = "images/gallery/ulockBC.png";
   image_url[16] = "images/gallery/writers1sBC.png";
   
   for(i=0; i<max; i++)
   {
      preload_image_object[i] = new Image();       
      preload_image_object[i].src = image_url[i];
   }

   max = 10;
   i = 0;   
   
   preload_image_object = new Array(10);      
   image_url = new Array(10);
   image_url[0] = "images/family/alligatorarms.png";
   image_url[1] = "images/family/crossface.png";
   image_url[2] = "images/family/empire.png";
   image_url[3] = "images/family/flamingtsunamis.png";
   image_url[4] = "images/family/hotlife.png";
   image_url[5] = "images/family/lymprintshop.png";
   image_url[6] = "images/family/mchc.png";
   image_url[7] = "images/family/tigerstyle.png";
   image_url[8] = "images/family/wearetheunion.png";
   image_url[9] = "images/family/wonderyears.png";
   
   for(i=0; i<max; i++)
   {
      preload_image_object[i] = new Image();       
      preload_image_object[i].src = image_url[i];
   } 
}

var thumbnailviewer={
enableTitle: true, 
enableAnimation: true,
definefooter: '<div class="footerbar">CLOSE X</div>', 
defineLoading: '<img src="images/loading.gif" /> Loading Image...',
scrollbarwidth: 16,
opacitystring: 'filter:progid:DXImageTransform.Microsoft.alpha(opacity=10); -moz-opacity: 0.1; opacity: 0.1',
targetlinks:[],
createthumbBox:function(){

      document.write('<div id="thumbBox" onClick="thumbnailviewer.closeit()"><div id="thumbImage"></div>'+this.definefooter+'</div>')
      document.write('<div id="thumbLoading">'+this.defineLoading+'</div>')
      this.thumbBox=document.getElementById("thumbBox")
      this.thumbImage=document.getElementById("thumbImage") 
      this.thumbLoading=document.getElementById("thumbLoading") 
      this.standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body 
   },
   
centerDiv:function(divobj){ 
      var ie=document.all && !window.opera
      var dom=document.getElementById
      var scroll_top=(ie)? this.standardbody.scrollTop : window.pageYOffset
      var scroll_left=(ie)? this.standardbody.scrollLeft : window.pageXOffset
      var docwidth=(ie)? this.standardbody.clientWidth : window.innerWidth-this.scrollbarwidth
      var docheight=(ie)? this.standardbody.clientHeight: window.innerHeight
      var docheightcomplete=(this.standardbody.offsetHeight>this.standardbody.scrollHeight)? this.standardbody.offsetHeight : this.standardbody.scrollHeight 
      var objwidth=divobj.offsetWidth 
      var objheight=divobj.offsetHeight 
      var topposition=(docheight>objheight)? scroll_top+docheight/2-objheight/2-10+"px" : scroll_top+"px" 
	  var landscapeadj=(objwidth>objheight)? -50 : 0;
      divobj.style.left=docwidth-objwidth+0+"px" 
      divobj.style.top=Math.floor(parseInt(topposition))+landscapeadj+"px"
      divobj.style.visibility="visible"
   },

showthumbBox:function(){ 
      thumbnailviewer.thumbLoading.style.visibility="hidden" 
      this.centerDiv(this.thumbBox)
      if (this.enableAnimation){ 
         this.currentopacity=0.1 
         this.opacitytimer=setInterval("thumbnailviewer.opacityanimation()", 20)
      }
   },


loadimage:function(link){ 
      if (this.thumbBox.style.visibility=="visible") 
      this.closeit() 
      var imageHTML='<img src="'+link.getAttribute("name")+'" style="'+this.opacitystring+'" />' 
      if (this.enableTitle && link.getAttribute("title")) 
      imageHTML+='<br />'+link.getAttribute("title")
      this.centerDiv(this.thumbLoading) 
      this.thumbImage.innerHTML=imageHTML 
      this.featureImage=this.thumbImage.getElementsByTagName("img")[0] 
      if (this.featureImage.complete)
      thumbnailviewer.showthumbBox()
      else{
         this.featureImage.onload=function(){ 
            thumbnailviewer.showthumbBox() 
         }
      }
      if (document.all && !window.createPopup) 
      this.featureImage.src=link.getAttribute("name")
      this.featureImage.onerror=function(){ 
         thumbnailviewer.thumbLoading.style.visibility="hidden" 
      }
   },

setimgopacity:function(value){ 
      var targetobject=this.featureImage
      if (targetobject.filters && targetobject.filters[0]){ //IE syntax
         if (typeof targetobject.filters[0].opacity=="number") //IE6
         targetobject.filters[0].opacity=value*100
         else //IE 5.5
         targetobject.style.filter="alpha(opacity="+value*100+")"
      }
      else if (typeof targetobject.style.MozOpacity!="undefined") //Old Mozilla syntax
      targetobject.style.MozOpacity=value
      else if (typeof targetobject.style.opacity!="undefined") //Standard opacity syntax
      targetobject.style.opacity=value
      else 
      this.stopanimation()
   },

opacityanimation:function(){ 
      this.setimgopacity(this.currentopacity)
      this.currentopacity+=0.1
      if (this.currentopacity>1)
      this.stopanimation()
   },

stopanimation:function(){
      if (typeof this.opacitytimer!="undefined")
      clearInterval(this.opacitytimer)
   },


closeit:function(){  
      this.stopanimation()
      this.thumbBox.style.visibility="hidden"
      this.thumbImage.innerHTML=""
      this.thumbBox.style.left="-2000px"
      this.thumbBox.style.top="-2000px"
   },

cleanup:function(){ 
      this.thumbLoading=null
      if (this.featureImage) this.featureImage.onload=null
      this.featureImage=null
      this.thumbImage=null
      for (var i=0; i<this.targetlinks.length; i++)
      this.targetlinks[i].onclick=null
      this.thumbBox=null
   },

dotask:function(target, functionref, tasktype){ 
      var tasktype=(window.addEventListener)? tasktype : "on"+tasktype
      if (target.addEventListener)
      target.addEventListener(tasktype, functionref, false)
      else if (target.attachEvent)
      target.attachEvent(tasktype, functionref)
   },

init:function(){ 
      if (!this.enableAnimation)
      this.opacitystring=""
      var pagelinks=document.getElementsByTagName("a")
      for (var i=0; i<pagelinks.length; i++){ 
         if (pagelinks[i].getAttribute("rel") && pagelinks[i].getAttribute("rel")=="thumbnail"){ 
            pagelinks[i].onmouseover=function(){
               thumbnailviewer.stopanimation() 
               thumbnailviewer.loadimage(this) 
               return false
            }
            this.targetlinks[this.targetlinks.length]=pagelinks[i] 
         } 
      } 
      
      this.dotask(window, function(){if (thumbnailviewer.thumbBox.style.visibility=="visible") thumbnailviewer.centerDiv(thumbnailviewer.thumbBox)}, "resize")


   } 

}

thumbnailviewer.createthumbBox() 
thumbnailviewer.dotask(window, function(){thumbnailviewer.init()}, "load") 
thumbnailviewer.dotask(window, function(){thumbnailviewer.cleanup()}, "unload")