﻿function setImageSize(imgLarge){
    var imgLarge = document.getElementById? document.getElementById(imgLarge) : eval("document.all."+imgLarge)
    var theHeight = document.documentElement.clientHeight;

    if (theHeight < 600){
        imgLarge.style.height = theHeight -10 + "px";
    }
}

function linkFocus(objName, intZ){
    
    var myObj = document.getElementById(objName);
    
    var strSrc = myObj.src;
        
    var strSrc1 = strSrc.substring(0,strSrc.lastIndexOf("/")+1);
    var strSrc2 = strSrc.substring(strSrc.lastIndexOf("/")+1,strSrc.length-4);
    var strSrc3 = strSrc.substring(strSrc.length-4);
    
    
    if(strSrc2.substring(strSrc2.length-3) == '_sm'){
        strSrc2 = strSrc2.substring(0, strSrc2.length-3);
    } else {
        strSrc2 = strSrc2 + '_sm';
    }
    
    strSrc = strSrc1 + strSrc2 + strSrc3;
    myObj.src = strSrc;
    myObj.style.zIndex=intZ;
}

function moveRabbit(){
    var rabbit = document.getElementById('rabbit');
    var height = document.documentElement.clientHeight-100;
    var width = document.documentElement.clientWidth-100;
    var top = Math.floor(Math.random()*height);
    var left = Math.floor(Math.random()*width);

    rabbit.style.top = top + 'px';
    rabbit.style.left = left + 'px';

    setTimeout('moveRabbit()', 8000);
}

/* stuff for the big tree */

function showHide(strWhat){
    var target = document.getElementById('ul' + strWhat)
    
    if (target.style.display == 'none'){
        document.getElementById('ul' + strWhat).style.display = 'block';
        document.getElementById('img' + strWhat).src = where + 'images/minus.gif';
    } else {
        document.getElementById('ul' + strWhat).style.display = 'none';
        document.getElementById('img' + strWhat).src = where + 'images/plus.gif';
    }
}
function showAll(){
    document.getElementById('divShowAll1').style.display = 'none';
    document.getElementById('divShowAll2').style.display = 'none';
    document.getElementById('divHideAll1').style.display = 'block';
    document.getElementById('divHideAll2').style.display = 'block';
    
    document.getElementById('treeNav2').style.display = 'block';
    
    //document.getElementById('Felis_catus').style.fontWeight = 'normal';
    
    for (i=0; i < allElements.length; i++){
        if (document.getElementById('ul' + allElements[i])){
            document.getElementById('ul' + allElements[i]).style.display = 'block';
        }
        if (document.getElementById('img' + allElements[i])){
            document.getElementById('img' + allElements[i]).src = where + 'images/minus.gif';
        }
        if (document.getElementById('ul' + catElements[0])){    
            document.getElementById('ul' + catElements[0]).style.fontWeight = 'normal';
        }
        if (document.getElementById('ul' + dogElements[0])){
            document.getElementById('ul' + dogElements[0]).style.fontWeight = 'normal';
        }
    }
}
function hideAll(){
    document.getElementById('divShowAll1').style.display = 'block';
    document.getElementById('divShowAll2').style.display = 'block';
    document.getElementById('divHideAll1').style.display = 'none';
    document.getElementById('divHideAll2').style.display = 'none';
    
    document.getElementById('treeNav2').style.display = 'none';
    
    //document.getElementById('Felis_catus').style.fontWeight = 'normal';
       
    for (i=0; i < allElements.length; i++){
        if (document.getElementById('ul' + allElements[i])){
            document.getElementById('ul' + allElements[i]).style.display = 'none';
        }
        if (document.getElementById('img' + allElements[i])){
            document.getElementById('img' + allElements[i]).src = where + 'images/plus.gif';
        }
        if (document.getElementById('ul' + catElements[0])){
            document.getElementById('ul' + catElements[0]).style.fontWeight = 'normal';
        }
        if (document.getElementById('ul' + dogElements[0])){
            document.getElementById('ul' + dogElements[0]).style.fontWeight = 'normal';
        }
    }
}
function findSpecific(type){
    var thisArr
    
    hideAll()
   
    if (type == 'cat'){
        thisArr = catElements;
    } else if (type == 'dog') {
        thisArr = dogElements;
    }
    
    document.getElementById('treeNav2').style.display = 'block';
    
    document.getElementById('divShowAll1').style.display = 'block';
    document.getElementById('divShowAll2').style.display = 'block';
    document.getElementById('divHideAll1').style.display = 'block';
    document.getElementById('divHideAll2').style.display = 'block';
    
    document.getElementById('ul' + thisArr[0]).style.fontWeight = 'bold';
        
    for (i=1; i < thisArr.length; i++){
        if (document.getElementById('ul' + thisArr[i])){
            document.getElementById('ul' + thisArr[i]).style.display = 'block';
        }
        if (document.getElementById('img' + thisArr[i])){
            document.getElementById('img' + thisArr[i]).src = where + 'images/minus.gif';
        }
    }
}

/* stuff for the scrolling div */

var iedom=document.all||document.getElementById
var scrollySpeed=3
var moving=""

var actualwidth=''
var scrolly
var isLoaded=0

function goLeft() {
    if (isLoaded) {
        moving="lefty"
        if (iedom&&parseInt(scrolly.style.left)<0) {
            scrolly.style.left=parseInt(scrolly.style.left)+scrollySpeed+"px"
        }
    }
    lefttime=setTimeout("goLeft()",10)
}

function goRight() {
    if (isLoaded==0) {doIt()}
    
    if (isLoaded) {
        moving="righty"
        if (iedom&&parseInt(scrolly.style.left)>(menuwidth-actualwidth)) {
            scrolly.style.left=parseInt(scrolly.style.left)-scrollySpeed+"px"
        }
    }
    righttime=setTimeout("goRight()",10)
}

function stopIt(){
    moving=""
    if (window.lefttime) clearTimeout(lefttime)
    if (window.righttime) clearTimeout(righttime)
}

function doIt(){
    if (iedom){
        var crossmain=document.getElementById? document.getElementById("outerContainer") : document.all.outerContainer
        menuwidth=parseInt(crossmain.style.width)
        scrolly=document.getElementById? document.getElementById("imageGallery") : document.all.imageGallery
        actualwidth=document.all? scrolly.offsetWidth : document.getElementById("imageContainer").offsetWidth
    }
    isLoaded=1
   
    if(actualwidth > menuwidth){
        var leftArrow=document.getElementById? document.getElementById("imgLeftArrow") : document.all.imgLeftArrow;
        var rightArrow=document.getElementById? document.getElementById("imgRightArrow") : document.all.imgRightArrow;
        
        leftArrow.style.display = 'block';
        rightArrow.style.display = 'block';
    }
}

/* */

function changeImage(strImage, strTaken){
    var theImage=document.getElementById? document.getElementById("imgLarge") : document.all.imgLarge;
    var spanImgTaken=document.getElementById? document.getElementById("spanImgTaken") : document.all.spanImgTaken;
    
    theImage.src = strImage;
    
    spanImgTaken.innerHTML  = strTaken;
}

/* Set a cookie to be sure that one exists. Note that this is outside the function*/ 
document.cookie = 'killme' + escape('nothing') ;

function cc() 
{ 
	/* check for a cookie */ 
	if (document.cookie == "") { 
		/* if a cookie is not found - alert user - change cookieexists field value to false */ 
		alert("COOKIES need to be enabled!"); 
		/* If the user has Cookies disabled an alert will let him know that cookies need to be enabled to log on.*/ 
		document.getElementById("cookieexists").value ="False" 
	} else { 
		/* this sets the value to true and nothing else will happen, the user will be able to log on*/ 
		document.getElementById("cookieexists").value ="True" 
	} 
} 

/* facebook link stuff*/

function fbs_click() 
{
    u=location.href;
    t=document.title;
    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}

function imageSwap(strImage, ctlImage){
    var ctlImage=document.getElementById? document.getElementById(ctlImage) : eval("document.all.") + ctlImage;
    
    ctlImage.src = strImage;
}

function setLargeGalleryImage(btnFirePopup, imgLarge, strUrl, strAlt, labCaption, strCaption){
    
    var btnFirePopup=document.getElementById? document.getElementById(btnFirePopup) : eval('document.all.') + btnFirePopup;
    var imgLarge=document.getElementById? document.getElementById(imgLarge) : eval('document.all.') + imgLarge;
    var labCaption=document.getElementById? document.getElementById(labCaption) : eval('document.all.') + labCaption;
    
    imgLarge.src = "loading.png";
    imgLarge.alt = "Just loading it up for you!"
    imgLarge.title = "Just loading it up for you!"
       
    imgLarge.src = strUrl;
    imgLarge.alt = strAlt;
    imgLarge.title = strAlt;
    labCaption.innerHTML = strCaption;
    pausecomp(1000);
    btnFirePopup.click();
}
function setLargeGalleryImage(btnFirePopup, imgLarge, strUrl, intImage, intTotal){
       
    var btnFirePopup=document.getElementById? document.getElementById(btnFirePopup) : eval('document.all.') + btnFirePopup;
    var imgLarge=document.getElementById? document.getElementById(imgLarge) : eval('document.all.') + imgLarge;
    var labCaption=document.getElementById? document.getElementById(labCaption) : eval('document.all.') + labCaption;
    
    var btnPrev=document.getElementById? document.getElementById('btnPrev') : eval('document.all.btnPrev');
    var btnNext=document.getElementById? document.getElementById('btnNext') : eval('document.all.btnNext');
    
    var prefix = imgLarge.id.substr(0,imgLarge.id.indexOf("imgLarge"));
    var intPrev = intImage-1;
    var intNext = intImage+1;
    
    var imgThis = document.getElementById? document.getElementById(prefix + 'img' + intImage) : eval(prefix + 'img' + intImage);
    var imgPrev = document.getElementById? document.getElementById(prefix + 'img' + intPrev) : eval(prefix + 'img' + intPrev);
    var imgNext = document.getElementById? document.getElementById(prefix + 'img' + intNext) : eval(prefix + 'img' + intNext);  
    
    if (intImage == 1){
        btnPrev.style.display = 'none';
    } else {   
        btnPrev.style.display = 'inline';
        btnPrev.onclick = new Function("setLargeGalleryImage('" + btnFirePopup.id + "', '" + imgLarge.id + "', '" + imgPrev.src + "', " + eval(intImage-1) + "," + intTotal + ");");
    }
    if (intImage == intTotal){
        btnNext.style.display = 'none';
    } else {   
        btnNext.style.display = 'inline';
        btnNext.onclick = new Function("setLargeGalleryImage('" + btnFirePopup.id + "', '" + imgLarge.id + "', '" + imgNext.src + "', " + eval(intImage+1) + "," + intTotal + ");");
    }
    
    imgLarge.src = "loading.png";
    imgLarge.alt = "Just loading it up for you!"
    imgLarge.title = "Just loading it up for you!"
       
    imgLarge.src = strUrl;
    imgLarge.alt = imgThis.alt;
    imgLarge.title = imgThis.alt;
    //labCaption.innerHTML = strCaption;
    pausecomp(1000);
    btnFirePopup.click();
}
function setLargeImage(btnFirePopup, imgLarge, strPath, strAlt, intImage, intTotal){

    var btnPrev=document.getElementById? document.getElementById('btnPrev') : eval('document.all.btnPrev');
    var btnNext=document.getElementById? document.getElementById('btnNext') : eval('document.all.btnNext');
    
    if (intImage == 1){
        btnPrev.style.display = 'none';
    } else {   
        btnPrev.style.display = 'inline';
        btnPrev.onclick = new Function("setLargeImage('" + btnFirePopup + "', '" + imgLarge + "', '" + strPath + "', '" + strAlt + "', " + eval(intImage-1) + "," + intTotal + ");");
    }
    if (intImage == intTotal){
        btnNext.style.display = 'none';
    } else {   
        btnNext.style.display = 'inline';
        btnNext.onclick = new Function("setLargeImage('" + btnFirePopup + "', '" + imgLarge + "', '" + strPath + "', '" + strAlt + "', " + eval(intImage+1) + "," + intTotal + ");");
    }

    var btnFirePopup=document.getElementById? document.getElementById(btnFirePopup) : eval('document.all.') + btnFirePopup;
    var imgLarge=document.getElementById? document.getElementById(imgLarge) : eval('document.all.') + imgLarge;
        
    var strUrl = strPath + intImage + '.jpg'
    
    imgLarge.src = "loading.png";
    imgLarge.alt = "Just loading it up for you!"
    imgLarge.title = "Just loading it up for you!"
       
    imgLarge.src = strUrl;
    imgLarge.alt = strAlt;
    imgLarge.title = strAlt;
    pausecomp(1000);
    btnFirePopup.click();
}

function pausecomp(millis){
    var date = new Date();
    var curDate = null;

    do { curDate = new Date(); }
    while(curDate-date < millis);
} 

function showNextPic(theDiv, direction){
    var theImg;
    var intCurrent = 1;
    var intNext;
    
    theDiv = theDiv.parentNode.parentNode.id;
    
    for (i=1; i<=12; i++){
        theImg=document.getElementById? document.getElementById(theDiv + '_' + i) : eval('document.all.' + theDiv + '_' + i);
        
        if (theImg != null) {
            if (theImg.style.zIndex == 76){
                intCurrent = i;
            }   
        } else {
            intPics = i-1;
            break;
        }
    }
    
    if (direction == 'f'){
        if (intCurrent+1 > intPics){
            intNext = 1;
        } else {
            intNext = intCurrent+1;
        }
    } else {
        if (intCurrent-1 < 1){
            intNext = intPics;
        } else {
            intNext = intCurrent-1;
        }
    }
    
    theImg=document.getElementById? document.getElementById(theDiv + '_' + intCurrent) : eval('document.all.' + theDiv + '_' + intCurrent);
    theImg.style.zIndex = '1';
    theImg=document.getElementById? document.getElementById(theDiv + '_' + intNext) : eval('document.all.' + theDiv + '_' + intNext);
    theImg.style.zIndex = '76';
}

function showBack(intId){
    var theP = document.getElementById("p" + intId);
    var theImg = document.getElementById("img" + intId);
    
    if (theP.style.display == 'block')
    {
        theP.style.display = 'none';
        theImg.src = where + 'images/show.gif';
    } else {
        theP.style.display = 'block';
        theImg.src = where + 'images/hide.gif';
    }
}
function showReview(intId){
    var thePL = document.getElementById("revL" + intId);
    var thePS = document.getElementById("revS" + intId);
    
    if (thePL.style.display == 'block')
    {
        thePL.style.display = 'none';
        thePS.style.display = 'block';
    } else {
        thePL.style.display = 'block';
        thePS.style.display = 'none';
    }
}