﻿function SetSelectedMenuItem(thisSelectedItem)
{
    var i = 0;
    topTage = document.getElementById('mainmenu');
    thisMenuItem = topTage.childNodes[0].childNodes[0];
    while(i < thisMenuItem.childNodes.length)
    {
        var thisItem = thisMenuItem.childNodes[i];
        if(thisItem.innerText != "|") thisItem.all[0].className = "menuitem";
        i++;
    }
    thisTag = document.getElementById(thisSelectedItem);
    thisTag.className="menuitemselected";
}

function LoadHome()
{
    SetFrame('home.htm')
    SetSelectedMenuItem('homelink');
}

function LoadAbout()
{
    SetFrame('about.htm')
    SetSelectedMenuItem('aboutlink');
}

function LoadPortfolio()
{
    baseImg = 0;
    imgOffsetCount = 0;
    selectedGallery = PortfolioGallery;
    theQuoteText = "\"It’s that thin, that wild mercury sound. It’s metallic and bright gold, with whatever that conjures up. That’s my particular sound.\""
    theQuoteCredit = "- Bob Dylan"
    SetFrame('thumbnail.htm')
    SetSelectedMenuItem('portfoliolink');
}
function LoadNew()
{
    baseImg = 0;
    imgOffsetCount = 0;
    theQuoteText = "\"In this business, by the time you realize you're in trouble, it's too late to save yourself. Unless you're running scared all the time, you're gone.\""
    theQuoteCredit = "- Bill Gates"
    
    selectedGallery = NewGallery;
    SetFrame('thumbnail.htm')
    SetSelectedMenuItem('newlink');
}
function LoadLuckyDip()
{
    baseImg = 0;
    imgOffsetCount = 0;
    theQuoteText = "\"I have called this principle, by which each slight variation, if useful, is preserved, by the term of Natural Selection.\""
    theQuoteCredit = "- Charles Darwin"

    selectedGallery = LuckyDipGallery;
    SetFrame('thumbnail.htm')
    SetSelectedMenuItem('luckydiplink');
}
function LoadNews()
{
    SetFrame('news.htm')
    SetSelectedMenuItem('newslink');
}
function LoadSpecialOffer()
{
    SetFrame('special.htm')
    SetSelectedMenuItem('printlink');
}
function LoadStyle()
{
    SetFrame('style.htm')
    SetSelectedMenuItem('stylelink');
}
function LoadLinks()
{
    SetFrame('links.htm')
    SetSelectedMenuItem('linkslink');
}
function SetFrame(thisPage)
{
    thisFrame = parent.document.getElementById('containerframe');
    thisFrame.src = thisPage;
}

function DefaultAllParams()
{
    baseImg = 0;
    imgOffsetCount = 0;
    
    GetPortfolio()
    GetNew()
    GetLuckyDip()
    
    thisFrame = document.getElementById('containerframe');
    thisFrame.src = 'home.htm';
    SetSelectedMenuItem('homelink');
}

function GetPortfolio()
{
    var i = 0;
    while(i < AllImages.length)
    {
        if(AllImages[i][5]=="Portfolio")
        {
            PortfolioGallery.push(AllImages[i]);
        }
        i++;
    }
}
function GetNew()
{
    var theCount = 0;
    var i = AllImages.length - 1;

    while( i > 0 && theCount < NumInNew)
    {
        NewGallery.push(AllImages[i]);
        i = i - 1;
        theCount = theCount + 1;
    }
}
rnd.today=new Date();
rnd.seed=Math.floor(rnd.today.getTime() / 86400000);

function rnd() {
	rnd.seed = (rnd.seed*9301+49297) % 233280;
	return rnd.seed/(233280.0);
};

function rand(number) {
	return Math.floor(rnd()*number);
};
function GetLuckyDip()
{
    var tempLib = new Array();
    var rndIndices = new Array();
    var i = 0;
    while(i < AllImages.length)
    {
        if(AllImages[i][5]=="Library")
        {
            tempLib.push(AllImages[i]);
        }
        i++;
    }
    var maxIndex = tempLib.length;
    var today = new Date();
    var thisRnd = rand(maxIndex);
    rndIndices.push(thisRnd)
    i = 1;
    while(i < NumInLucky)
    {
        thisRnd = rand(maxIndex);
        var j = 0;
        var unique = true;
        while(j < rndIndices.length)
        {
            if(rndIndices[j] == thisRnd)
            {
                unique = false;
            }
            j++;
        }
        if(unique)
        {
            i++;
            rndIndices.push(thisRnd);
        }
    }
    i = 0;
    while(i < NumInLucky)
    {
        LuckyDipGallery.push(tempLib[rndIndices[i]]);
        i++;
    }
}


