// Copyright 2009 - 2010, Jason Sinclair Astorquia, All rights reserved

function gallery()
{
	this.sections			= null;	
	this.selectedSection 	= null;

	this.galleryNode;
	this.contentsNode;
	
	this.tocNode;
	
	this.headerNode;
	
	this.displayNode;
	
	this.infoNode;
	this.displayBodyNode;
	this.sellersNode;

	this.initSections();
}
gallery.prototype.WIDTH  		= 1110;
gallery.prototype.HEIGHT 		= 700;
gallery.prototype.HEADER_HEIGHT = 40;
gallery.prototype.INFO_WIDTH	= 200;
gallery.prototype.DISPLAY_WIDTH	= 910;


function gallery_initSections()
{
	var lSection;	
	
	// init the sections
	this.sections = new Array();

	// home
	lSection = new section('home', section.prototype.TYPE_SPLASH);
	lSection.idx = this.sections.length;
	lSection.parentObj = this;
	
	this.configureHome(lSection);
	this.sections.push(lSection);
	
	// writing/painting
	lSection = new section('portfolios', section.prototype.TYPE_PORTFOLIO);
	lSection.idx = this.sections.length;
	lSection.parentObj = this;
	
	var lPortfolios = new portfolio();
	
	lPortfolios.parentObj = lSection;
	
	this.configureAcrylics(lPortfolios);
	this.configureWritings(lPortfolios);
	
	lSection.displayObj = lPortfolios;
	this.sections.push(lSection);
	
	// bio/about
	lSection = new section('about', section.prototype.TYPE_CONTACTINFO);
	lSection.idx = this.sections.length;
	lSection.parentObj = this;

	var lAbout = new about();
	lSection.displayObj = lAbout;
	this.sections.push(lSection);	

	// shows
	lSection = new section('shows', section.prototype.TYPE_SHOWS);
	lSection.idx = this.sections.length;
	lSection.parentObj = this;
	
	this.configureShowList(lSection);
	this.sections.push(lSection);
	
	// contact
	lSection = new section('contact', section.prototype.TYPE_CONTACTINFO);
	lSection.idx = this.sections.length;
	lSection.parentObj = this;

	var lContact = new contact();
	lSection.displayObj = lContact;
	this.sections.push(lSection);	
	
}
gallery.prototype.initSections = gallery_initSections;


function gallery_configureHome(section)
{
	var lSplash;
	var lPhoto;
	
	lSplash = new splash();
	lSplash.parentObj = section;
	
	// name, thumb, img, height, width, text
	lPhoto = new photo('crane', null, 'images/crane.jpg', 600, 494, null);
	lSplash.addPhoto(lPhoto);

	lPhoto = new photo('online i', null, 'images/Online_I_2010.jpg', 600, 490, null);
	lSplash.addPhoto(lPhoto);

	lPhoto = new photo('sitting around', null, 'images/SittingAround_2010.jpg', 600, 449, null);
	lSplash.addPhoto(lPhoto);

	lPhoto = new photo('mannequin i', null, 'images/MannequinI_2010.jpg', 600, 495, null);
	lSplash.addPhoto(lPhoto)

	lPhoto = new photo('town crier', null, 'images/townCrier.jpg', 600, 473, null);
	lSplash.addPhoto(lPhoto);

	lPhoto = new photo('under the bridge', null, 'images/UnderTheBridge_2010.jpg', 600, 745, null);
	lSplash.addPhoto(lPhoto)

	lPhoto = new photo('suess flowers i', null, 'images/seussFlowerI.jpg', 600, 501, null);
	lSplash.addPhoto(lPhoto);

	lPhoto = new photo('cascade iii', null, 'images/cascadeIII.jpg', 600, 663, null);
	lSplash.addPhoto(lPhoto)

	lPhoto = new photo('new york morning', null, 'images/NewYorkMorning_2010.jpg', 600, 604, null);
	lSplash.addPhoto(lPhoto)

	// set the display object	
	section.displayObj = lSplash;
}
gallery.prototype.configureHome = gallery_configureHome;

function gallery_configureWritings(portfolios)
{
	var writings;
	var lSeries;
	var lWriting;
	
	var nav = new Array();
	nav.push('<br/><b>Experienced Writer & Editor:</b><br/>');
	nav.push('<div style=\"padding-left:3px;\">Marketing content</div>');
	nav.push('<div style=\"padding-left:3px;\">Catalog copy</div>');
	nav.push('<div style=\"padding-left:3px;\">Advertising copy</div>');
	nav.push('<div style=\"padding-left:3px;\">Newsletters</div>');
	nav.push('<div style=\"padding-left:3px;\">News articles</div>');
	nav.push('<br/>');
	nav.push('<b>Certificate in Editing:</b><br/>');
	nav.push('<div style=\"padding-left:3px;\">Univ. of Washington Feb 2010</div>');

	
	writings = new portfolio('writing', 'images/writings.jpg', nav.join(''));
	writings.parentObj = portfolios;
	
	// ajac
	lSeries = new series('Aerospace Apprenticeship News and Articles', 'images/ajac.jpg', '');
	writings.addSeries(lSeries);

	lWriting = new writing('outcomes and accomplishments 2010', 'images/ajacAccomplishmentsThumb.jpg', 'documents/AJAC_2010OutcomesAndAccomplishments.pdf');
	lSeries.addWriting(lWriting);
	
	lWriting = new writing('july 2010 newsletter', 'images/ajacNewsletterThumb.jpg', 'documents/AJACNewsletter_July_2010.pdf');
	lSeries.addWriting(lWriting);
	
	lWriting = new writing('department of commerce aerospace bulletin june 2010', 'images/ajacBulletinThumb.jpg', 'documents/DeptOfCommerceAerospaceBulletinArticle_June 2010.pdf');
	lSeries.addWriting(lWriting);
	

	// brochure
	lSeries = new series('Brochure copywriting', 'images/pacificQuest.jpg', '');
	writings.addSeries(lSeries);
	
	lWriting = new writing('pacific quest brochure', 'images/pacificQuestThumb.jpg', 'documents/PacificQuestBrochure.pdf');
	lSeries.addWriting(lWriting);

	// daniel smith
	lSeries = new series('Daniel Smith Artist Materials copywriting', 'images/danielSmith.jpg', '');
	writings.addSeries(lSeries);
	
	lWriting = new writing('english rose copy', 'images/englishRoseThumb.jpg', 'documents/EnglishRoseCopy.pdf');
	lSeries.addWriting(lWriting);
	
	lWriting = new writing('thistle copy', 'images/thistleCopy.jpg', 'documents/ThistleCopy.pdf');
	lSeries.addWriting(lWriting);
	
	lWriting = new writing('kyoto copy', 'images/kyotoCopy.jpg', 'documents/KyotoCopy.pdf');
	lSeries.addWriting(lWriting);
	
	portfolios.addPortfolio(writings);
	
}
gallery.prototype.configureWritings = gallery_configureWritings;

function gallery_configureAcrylics(portfolios)
{
	var acrylics;
	var lSeries;
	var lPhoto;
	var medium = 'acrylic on canvas';
	
	acrylics = new portfolio('painting', 'images/paintings.jpg');
	acrylics.parentObj = portfolios;
	
	// crows I
	lSeries = new series('crows I', 'images/crowsISeries.jpg', '');
	acrylics.addSeries(lSeries);
	
	lPhoto = new photo('low flyer i', 'images/LowFlyerI_2010_Thumb.jpg', 'images/LowFlyerI_2010.jpg', 600, 495, medium, '20" x 24"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('low flyer ii', 'images/LowFlyerII_2010_Thumb.jpg', 'images/LowFlyerII_2010.jpg', 600, 499, medium, '20" x 24"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('low flyer iii', 'images/LowFlyerIII_2010_Thumb.jpg', 'images/LowFlyerIII_2010.jpg', 600, 498, medium, '20" x 24"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('online i', 'images/Online_I_Thumb_2010.jpg', 'images/Online_I_2010.jpg', 600, 490, medium, '20" x 24"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('duet', 'images/Duet_2010_Thumb.jpg', 'images/Duet_2010.jpg', 600, 474, medium, '8" x 10"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('search', 'images/Search_2010_Thumb.jpg', 'images/Search_2010.jpg', 600, 498, medium, '20" x 24"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('sentry', 'images/Sentry_2010_Thumb.jpg', 'images/Sentry_2010.jpg', 600, 472, medium, '8" x 10"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('solo', 'images/Solo_2010_Thumb.jpg', 'images/Solo_2010.jpg', 600, 479, medium, '8" x 10"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('crow i', 'images/CrowI_2010_Thumb.jpg', 'images/CrowI_2010.jpg', 600, 473, medium, '24" x 30"', null, 'private collection');
	lSeries.addPhoto(lPhoto);


	// around series
	lSeries = new series('the around series', 'images/aroundSeries.jpg', '');
	acrylics.addSeries(lSeries);

	lPhoto = new photo('nobody sticks around', 'images/NobodySticksAround_2010_Thumb.jpg', 'images/NobodySticksAround_2010.jpg', 600, 793, medium, '36" x 48"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('hanging around', 'images/HangingAround_2010_Thumb.jpg', 'images/HangingAround_2010.jpg', 600, 454, medium, '30" x 40"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('hanging around again', 'images/HangingAroundAgain_2010_Thumb.jpg', 'images/HangingAroundAgain_2010.jpg', 600, 450, medium, '30" x 40"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('turkish moon & vase', 'images/TurkishMoonAndVase_2010_Thumb.jpg', 'images/TurkishMoonAndVase_2010.jpg', 600, 603, medium, '36" x 36"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('sitting around', 'images/SittingAround_2010_Thumb.jpg', 'images/SittingAround_2010.jpg', 600, 449, medium, '30" x 40"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('out of season', 'images/OutOfSeason_2010_Thumb.jpg', 'images/OutOfSeason_2010.jpg', 600, 481, medium, '24" x 30"', null, 'private collection');
	lSeries.addPhoto(lPhoto);



	// crows II
	lSeries = new series('crows II', 'images/crowsIISeries.jpg', '');
	acrylics.addSeries(lSeries);
	
	lPhoto = new photo('ambush', 'images/ambushThumb.jpg', 'images/ambush.jpg', 600, 542, medium, '54" x 60"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('a difference of opinion', 'images/ADifferenceofOpinion_2010_Thumb.jpg', 'images/ADifferenceofOpinion_2010.jpg', 536, 900, medium, '24" x 40"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('three', 'images/Three_2010_Thumb.jpg', 'images/Three_2010.jpg', 600, 744, medium, '30" x 36"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('online ii', 'images/onlineIIThumb.jpg', 'images/onlineII.jpg', 600, 498, medium, '24" x 30"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('town crier', 'images/townCrierThumb.jpg', 'images/townCrier.jpg', 600, 473, medium, '30" x 36"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('fountain and oak', 'images/fountainOakThumb.jpg', 'images/fountainOak.jpg', 600, 497, medium, '30" x 36"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('found', 'images/Found_2010_Thumb.jpg', 'images/Found_2010.jpg', 600, 500, medium, '20" x 24"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('taking flight', 'images/TakingFlight_2010_Thumb.jpg', 'images/TakingFlight_2010.jpg', 600, 451, medium, '30" x 36"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('crows on a wire', 'images/CrowsOnAWire_2010_Thumb.jpg', 'images/CrowsOnAWire_2010.jpg', 600, 479, medium, '24" x 30"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	
	// figures
	lSeries = new series('figures', 'images/figuresSeries.jpg', '');
	acrylics.addSeries(lSeries);
	
	lPhoto = new photo('crane', 'images/crane_Thumb.jpg', 'images/crane.jpg', 600, 494, medium, '30" x 36"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('bison', 'images/Bison_2010_Thumb.jpg', 'images/Bison_2010.jpg', 600, 801, medium, '30" x 40"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('julie at the window', 'images/JulieAtWindowThumb.jpg', 'images/JulieAtWindow450.jpg', 335, 450, medium, '20" x 24"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('mannequin i', 'images/MannequinI_2010_Thumb.jpg', 'images/MannequinI_2010.jpg', 600, 495, medium, '30" x 36"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('mannequin ii', 'images/MannequinII_2010_Thumb.jpg', 'images/MannequinII_2010.jpg', 600, 156, medium, '6" x 22"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('laughing buddha', 'images/LaughingBuddha_2010_Thumb.jpg', 'images/LaughingBuddha_2010.jpg', 600, 449, medium, '30" x 40"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('contentment', 'images/ContentmentThumb.jpg', 'images/Contentment.jpg', 400, 359, 'pastels on paper', '14" x 14"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('this old man', 'images/ThisOldMan_2010_Thumb.jpg', 'images/ThisOldMan_2010.jpg', 600, 154, medium, '6" x 22"', null, 'private collection');
	lSeries.addPhoto(lPhoto);



	// cascades and seuss flowers
	lSeries = new series('cascades and seuss flowers', 'images/cascadesSeussSeries.jpg', '');
	acrylics.addSeries(lSeries);
	
	lPhoto = new photo('cascade i', 'images/CascadeI_2010_Thumb.jpg', 'images/CascadeI_2010.jpg', 600, 723, medium, '30" x 36"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('cascade ii', 'images/CascadeII_2010_Thumb.jpg', 'images/CascadeII_2010.jpg', 600, 746, medium, '24" x 30"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('cascade iii', 'images/cascadeIIIThumb.jpg', 'images/cascadeIII.jpg', 600, 663, medium, '54" x 60"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('cascade iv', 'images/cascade4Thumb.jpg', 'images/cascade4.jpg', 600, 667, medium, '54" x 60"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('suess flowers i', 'images/seussFlowerIThumb.jpg', 'images/seussFlowerI.jpg', 600, 501, medium, '30" x 36"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('suess flowers ii', 'images/seussFlowerIIThumb.jpg', 'images/seussFlowerII.jpg', 600, 449, medium, '24" x 30"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	
	// landscapes and fancy
	lSeries = new series('landscapes & fancy', 'images/landscapesSeries.jpg', '');
	acrylics.addSeries(lSeries);

	lPhoto = new photo('musical chairs', 'images/FooFoo_2010_Thumb.jpg', 'images/FooFoo_2010.jpg', 600, 740, medium, '24" x 30"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('manzanita beach at night', 'images/ManzanitaBeach_2010_Thumb.jpg', 'images/ManzanitaBeach_2010.jpg', 600, 800, medium, '36" x 48"', null, null);
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('under the bridge', 'images/UnderTheBridge_2010_Thumb.jpg', 'images/UnderTheBridge_2010.jpg', 600, 745, medium, '24" x 30"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('21st heaven', 'images/21stHeaven_2010_Thumb.jpg', 'images/21stHeaven_2010.jpg', 600, 899, medium, '24" x 30"', null, 'private collection');
	lSeries.addPhoto(lPhoto);

	lPhoto = new photo('new york morning', 'images/NewYorkMorning_2010_Thumb.jpg', 'images/NewYorkMorning_2010.jpg', 600, 604, medium, '24" x 24"', null, 'private collection');
	lSeries.addPhoto(lPhoto);


	portfolios.addPortfolio(acrylics);

	// set the display object	
	//section.displayObj = acrylics;
}
gallery.prototype.configureAcrylics = gallery_configureAcrylics;


function gallery_configureShowList(section)
{
	var lShowList;
	var lShow;
	var lVenue;
	var lPhoto;
	var lReception;
	
	lShowList = new showList();
	lShowList.parentObj = section;
	
	// steven barrett
				   //   name, logo, addr1, addr2, city, state, zip, webURL, phone
	lVenue = new venue('Steven Barrett Salon', 'images/stevenBarrett.jpg', '1907 2nd Avenue', null, 'Seattle', 'WA', '98101', 'http://stevenbarrettsalon.com', '206.448.8466');
	
				  // venue,  start,                  end,  desc
	lShow = new show(lVenue, new Date(2010, 07, 01), new Date(2010, 09, 01), null);
	lShowList.addShow(lShow);
	
	// alki arts
	lVenue = new venue('Alki Arts', null, '2820 Alki Avenue SW', null, 'Seattle', 'WA', '98116', 'http://www.alkiarts.com', '206.432.9936');
	lShow = new show(lVenue, new Date(2010, 09, 01), new Date(2012, 07, 01), null);
	lShowList.addShow(lShow);

	// local color
	lVenue = new venue('Local Color', null, '1606 Pike', 'Pike Place Market', 'Seattle', 'WA', '98101', 'http://www.localcolorseattle.com', '206.728.1717');
	lShow = new show(lVenue, new Date(2010, 09, 01), new Date(2010, 09, 01), null);
	lShowList.addShow(lShow);

	
	// alki arts
	//lVenue = new venue('Alki Arts', null, '2820 Alki Avenue SW', null, 'Seattle', 'WA', '98116', 'http://www.alkiarts.com', '206.432.9936');
	//lShow = new show(lVenue, new Date(2010, 07, 01), new Date(2010, 10, 01), 'impressions');
	//lShowList.addShow(lShow);

	
	// caffe vita
	lVenue = new venue('Caffe Vita', null, '1005 East Pike Street', null, 'Seattle', 'WA', '98122', 'http://www.caffevita.com', '206.709.4440');
	lShow = new show(lVenue, new Date(2010, 04, 01), new Date(2010, 05, 01), null);
	lShowList.addShow(lShow);


	// sweetie
	lVenue = new venue('Sweetie', null, '4508 California Ave SW', null, 'Seattle', 'WA', '98116', 'http://www.sweetieboutique.com', '206.923.3533');
	lShow = new show(lVenue, new Date(2010, 00, 01), new Date(2010, 00, 01), null);
	lShowList.addShow(lShow);
	
	
	// coffee to a tea
	lVenue = new venue('Coffee to a Tea', null, '4541 California Ave. SW', null, 'Seattle', 'WA', '98116', 'http://www.sugarrushbakingcompany.com', '206.937.1495');
	lShow = new show(lVenue, new Date(2009, 10, 01), new Date(2009, 10, 01), null);
	lShowList.addShow(lShow);	
	
	// circa
	lVenue = new venue('Circa', null, '2605 California Ave. SW', null, 'Seattle', 'WA', '98116', 'http://www.circawestseattle.com', '206.923.1102');
	lShow = new show(lVenue, new Date(2010, 01, 01), new Date(2010, 01, 01), null);
	lShowList.addShow(lShow);	
	
	lShow = new show(lVenue, new Date(2009, 07, 01), new Date(2009, 07, 01), null);
	lShowList.addShow(lShow);	
	
	// elliott bay
	lVenue = new venue('Elliott Bay Brewery', null, '4720 California Ave. SW', null, 'Seattle', 'WA', '98116', 'http://www.elliottbaybrewing.com', '206.932.8695');
	lShow = new show(lVenue, new Date(2010, 02, 01), new Date(2010, 03, 01), null);
	lShowList.addShow(lShow);	
	


	// set the display object	
	section.displayObj = lShowList;
}
gallery.prototype.configureShowList = gallery_configureShowList;


function gallery_draw()
{
	var section;
	var top;
	var obj;
	var x;

	this.galleryNode = obtainElement('div');
	this.galleryNode.style.top = '0px';
	this.galleryNode.style.left = '0px';

	obj = obtainElement('div');
	obj.className = 'header';
	obj.style.top = '0px';
	obj.style.left = '0px';
	obj.style.height = this.HEADER_HEIGHT + 'px';
	obj.style.width = '100%';
	this.galleryNode.appendChild(obj);

	this.contentsNode = obtainElement('div');
	this.contentsNode.style.height = '100%';
	this.contentsNode.style.width = this.WIDTH + 'px';
	this.contentsNode.style.top = '0px';
	//this.contentsNode.style.backgroundColor = 'blue';
	this.galleryNode.appendChild(this.contentsNode);

	this.headerNode = obtainElement('div');
	this.headerNode.className = 'header';
	this.headerNode.style.top = '0px';
	this.headerNode.style.left = '0px';
	this.headerNode.style.height = this.HEADER_HEIGHT + 'px';
	this.headerNode.style.width = '100%';
	this.contentsNode.appendChild(this.headerNode);
	
	obj = obtainElement('div');
	obj.className = 'headerText';
	obj.style.top = '2px';
	obj.style.left = '152px';
	obj.style.height = (this.HEADER_HEIGHT - 7) + 'px';
	obj.style.width = '600px';
	obj.innerHTML = '<i>cara granger astorquia <span style=\"font-size:16pt;\">- artist/writer</smaller></i>';
	obj.style.opacity = '.2'; 
	obj.style.filter = 'alpha(opacity=20)';
	obj.style.color = '#000000';
	this.headerNode.appendChild(obj);

	obj = obtainElement('div');
	obj.className = 'headerText';
	obj.style.top = '0px';
	obj.style.left = '150px';
	obj.style.height = this.HEADER_HEIGHT + 'px';
	obj.style.width = '600px';
	obj.innerHTML = '<i>cara granger astorquia <span style=\"font-size:16pt;\">- artist/writer</smaller></i>';
	this.headerNode.appendChild(obj);
	
	// display
	top = this.HEADER_HEIGHT;
	this.displayNode = obtainElement('div');
	this.displayNode.style.top = top + 'px';
	this.displayNode.style.width = '100%';
	this.displayNode.style.left = '0px';
	
	this.infoNode = obtainElement('div');
	this.infoNode.style.top = '0px';
	this.infoNode.style.left = '0px';
	this.infoNode.style.height = '100%';
	this.infoNode.style.width = this.INFO_WIDTH + 'px';
	this.displayNode.appendChild(this.infoNode);
	
	this.tocNode = obtainElement('div');
	this.tocNode.className = 'toc';
	this.tocNode.style.top = '0px';
	this.tocNode.style.left = '0px';
	this.tocNode.style.width = '100%';
	//this.tocNode.style.left = this.INFO_WIDTH + 'px';
	this.tocNode.style.height = '25px';
	this.tocNode.style.textAlign = 'center';
	
	this.tocNode.innerHTML = this.getTOC(0);
	
	this.displayNode.appendChild(this.tocNode);

	
	this.displayBodyNode = obtainElement('div');
	this.displayBodyNode.style.top = '23px';
	this.displayBodyNode.style.left = this.INFO_WIDTH + 'px';
	this.displayBodyNode.style.height = '100%';
	this.displayBodyNode.style.width = (this.WIDTH - this.INFO_WIDTH) + 'px';
	this.displayBodyNode.style.backgroundImage = 'url(images/progress.gif)';
	this.displayBodyNode.style.backgroundRepeat = 'no-repeat';
	this.displayBodyNode.style.backgroundPosition = Math.floor((this.WIDTH / 2) - this.INFO_WIDTH) + ' center';
	//this.displayBodyNode.style.backgroundColor='red';
	this.displayNode.appendChild(this.displayBodyNode);
		
	this.contentsNode.appendChild(this.displayNode);
	
	//this.sellersNode = obtainElement('div');
	//this.sellersNode.style.height = '20px';
	//this.sellersNode.style.width = '300px';
	//this.sellersNode.style.backgroundColor = 'blue';
	
	//var contents = new Array();
	//contents.push('<div class=\"showDetail\" style=\"padding-left:3px;\">@ photos: <a class=\"showDetail\" href=\"http://drewsellers.com\" target=newwindow style=\"font-weight:bold;\">');
	//contents.push('<u>Drew Sellers</u>');
	//contents.push('</a></div>');
	//this.sellersNode.innerHTML = contents.join('');
		
	obj = document.getElementById('galleryHome');
	obj.appendChild(this.galleryNode);
	//obj.appendChild(this.sellersNode);

	this.redraw();
	
	// show the splash
	this.sections[0].load();
	this.selectedSection = this.sections[0];
}
gallery.prototype.draw = gallery_draw;

function gallery_getTOC(selectedIdx)
{
	var sections = new Array();
	sections.push('<center><table><tr>');
	for (x = 0; x < this.sections.length; x++) {
		section = this.sections[x];
		
		if (x == selectedIdx) {
			sections.push('<td nowrap class="tocHover" valign=middle onclick="gallery_showSection(');
			sections.push(section.idx);
			sections.push(');">')		
		} else {
			sections.push('<td nowrap class="toc" valign=middle onclick="gallery_showSection(');
			sections.push(section.idx);
			sections.push(');" onmouseover="this.className=\'tocHover\'" onmouseout="this.className=\'toc\';">')		
		}
		sections.push(section.text);
		sections.push('</td>');
	}

	sections.push('</tr></table></center>');
	
	return sections.join('');
}
gallery.prototype.getTOC = gallery_getTOC;

function gallery_showSection(id)
{
	var section;
	var selectedSection;
	
	// get the section
	section = gallery.sections[parseInt(id)];
	if (section == null) return;

	// clear out the display
	gallery.clearDisplay();
	
	// reset the menu 
	gallery.tocNode.innerHTML = gallery.getTOC(id);
	
	// get the selectedSection
	selectedSection = gallery.selectedSection;
	gallery.selectedSection = section;
		
	// load the section
	section.load();
	
	// set it as selected
	if (selectedSection != null) {
		selectedSection.deselect();
	}	
}


function gallery_redraw(isResize)
{
	var width;
	var height;
	var left;
	var top;

	width = document.body.clientWidth;
	width = Math.max(width, this.WIDTH);

	height = document.body.clientHeight;
	height = Math.max(height, this.HEIGHT);

	this.galleryNode.style.height 	= height + 'px';
	this.galleryNode.style.width	= width + 'px';
	
	left = Math.max(0, Math.floor((width - this.WIDTH) / 2))
	this.contentsNode.style.left = left + 'px';
	//this.sellersNode.style.left = left + 'px';
	//this.sellersNode.style.top = (height - 75) + 'px';

	this.displayNode.style.height = (height - this.HEADER_HEIGHT) + 'px';	
	
	if (isResize) setTimeout('gallery.redraw()', 0);
	
	if (this.displayBodyNode == null) return;
	if (!this.displayBodyNode.hasChildNodes()) return;

	var bodyNode;
	var infoNode;
	bodyNode = this.displayBodyNode.childNodes[0];
	if (this.infoNode.hasChildNodes()) infoNode = this.infoNode.childNodes[0];
	
	while (this.infoNode.hasChildNodes()) {
		this.infoNode.removeChild(this.infoNode.childNodes[0]);
	}
	
	this.setDisplay(bodyNode, infoNode);
}
gallery.prototype.redraw = gallery_redraw;

function gallery_adjustWidth()
{
	var width;

	width = document.body.clientWidth;
	width = Math.max(width, gallery.WIDTH);

	gallery.galleryNode.style.width	= width + 'px';
}

function gallery_setDisplay(bodyNode, infoNode, showPhoto, showInfo)
{	
	this.displayBodyNode.style.backgroundImage = '';
	this.displayBodyNode.appendChild(bodyNode);
	
	var height = parseInt(bodyNode.style.height) + 20;

	//this.sellersNode.style.display = 'none';
	//if (showPhoto) this.sellersNode.style.display = 'block';

	if (this.selectedSection != null) {
		switch (this.selectedSection.type) {
			case 1:
 				if (infoNode == null) {
 					infoNode = obtainElement('div');
					infoNode.className = 'mail';
					infoNode.style.top = '10px';
					infoNode.style.left = '0px';
					infoNode.style.width = '100%';
					infoNode.style.height = '400px';
					
					var contents = new Array();
					contents.push('Now showing:<br/>');
					contents.push('<div style=\"padding-left:3px;\"><a class=\"mail\" href=\"http://alkiarts.com\" target=newwindow style=\"font-weight:bold;\">');
					contents.push('<u>Alki Arts</u>');
					contents.push('</a></div>');
					//contents.push('<div style=\"padding-left:3px;\"><a class=\"mail\" href=\"http://www.stevenbarrettsalon.com\" target=newwindow style=\"font-weight:bold;\">');
					//contents.push('<u>Steven Barrett Salon</u>');
					//contents.push('</a></div>');
					infoNode.innerHTML = contents.join('');
				}
				break;
		}
	}
	if (showInfo == null) showInfo = true;
	if (infoNode) {
		
		infoNode.style.top = '85px';
		this.infoNode.appendChild(infoNode);

		if ((showInfo) && (this.selectedSection != null)) {
			if (this.selectedSection.type == 2) {
				if (this.selectedSection.displayObj.activePortfolio) {
					var lPortfolio = this.selectedSection.displayObj.activePortfolio;
					var node = obtainElement('div');
					node.id = lPortfolio.oid;
					node.innerHTML = '&bull; '+ lPortfolio.name + ' portfolio';
					node.style.top = '35px';
					node.style.left = '0px';
					node.style.width = '100%';
					node.style.height = '20px';
					node.style.cursor = 'pointer';
					node.style.fontWeight = 'bold';
					node.style.color = '#FFFFFF';
					this.infoNode.appendChild(node);
				}
			}
		}
	
		
		var infoHeight = parseInt(infoNode.style.height);
		if (infoHeight > height) height = infoHeight;
	}

	this.displayNode.style.height = height + 'px';
	height += this.HEADER_HEIGHT;

	this.galleryNode.style.height = height + 'px';
	gallery_adjustWidth();
}
gallery.prototype.setDisplay = gallery_setDisplay;

function gallery_clearDisplay()
{
	this.displayBodyNode.style.backgroundImage = 'url(images/progress.gif)';
	while (this.displayBodyNode.hasChildNodes()) {
		this.displayBodyNode.removeChild(this.displayBodyNode.childNodes[0]);
	}
	while (this.infoNode.hasChildNodes()) {
		this.infoNode.removeChild(this.infoNode.childNodes[0]);
	}
}
gallery.prototype.clearDisplay = gallery_clearDisplay;


function section(text, type)
{
	this.text 	= text;
	this.type 	= type;
	
	this.idx;
	this.parentObj;
	
	this.displayObj;
		
	this.oid = cortex.getOID();
	cortex.addObj(this);
}
section.prototype.TYPE_SPLASH		= 1;
section.prototype.TYPE_PORTFOLIO 	= 2;
section.prototype.TYPE_ABOUT 		= 3;
section.prototype.TYPE_CONTACTINFO 	= 4;
section.prototype.TYPE_BLOG 		= 5;
section.prototype.TYPE_SHOWS		= 6;

function section_load()
{
	this.displayObj.load();
}
section.prototype.load = section_load;

function section_append(node)
{
	this.parentObj.append(node);
}
section.prototype.append = section_append;

function section_deselect()
{
	if (this.displayObj && this.displayObj.deselect) this.displayObj.deselect();
}
section.prototype.deselect = section_deselect;


function splash()
{
	this.photos = new Array();
	this.slideShow;
	this.parentObj;
	
	this.oid = cortex.getOID();
	cortex.addObj(this);
}

function splash_addPhoto(photo) 
{
	photo.idx = this.photos.length;
	photo.parentObj = this;
	
	this.photos.push(photo);
}
splash.prototype.addPhoto = splash_addPhoto;

function splash_load()
{
	var lPhoto;
	var x;
	
	for (x = 0; x < this.photos.length; x++) {
		lPhoto = this.photos[x];
		lPhoto.load();
	}
}
splash.prototype.load = splash_load;

function splash_draw()
{
	var lPhoto;
	var x;
	
	// have all the photos been loaded for display?
	for (x = 0; x < this.photos.length; x++) {
		lPhoto = this.photos[x];
		if (!lPhoto.imgLoaded) return;
	}

	// create the slideShow
	if (this.slideShow == null) {
		this.slideShow = new slideShow(null, this.photos, false);
	}
	
	// play
	if (this.parentObj == gallery.selectedSection) this.slideShow.play();
}
splash.prototype.draw = splash_draw;

function splash_deselect()
{
	if (this.slideShow) this.slideShow.pause();
}
splash.prototype.deselect = splash_deselect;

function about()
{
}

function about_load()
{
	var div = obtainElement('div');
	var contents = new Array();
	
	contents.push('<center><table width=100%>');
	
	contents.push('<tr>');
	contents.push('<td align=center class="about" style="font-weight:normal;padding:10px;">');
	contents.push('A native of the west coast, I grew up in Oakland, California and Newport, Oregon, two places about as socially opposite as one could imagine, but both beautifully inspiring to the fledgling artist and writer.<br/><br/>');  
	contents.push('I graduated college with that ubiquitous degree in English Literature, and since moving to Seattle, have spent many years writing creative copy for art retail, marketing departments, and private clients. I love to puzzle out the right words and the right order, to entirely engage the readers\' senses. <br/><br/>');
	contents.push('My love of painting grew out of living-room-floor art sessions with my best friend; cheap paints, cut up cardboard boxes for canvas, and no brushes, only nimble fingers. Eventually, fingers gave way to finer tools and substrates filched from my college theater department: leftover plywood and masonite from stricken sets of Three Penny Opera and Terra Nova, dregs of gesso and house paint. <br/><br/>');
	contents.push('Over the past 20 years of painting, my subjects have wildly varied and my materials steadily improved. My inspiration comes in waves, often generating a series of work. A trip through my portfolios elucidates my wide range and whims.<br/><br/>');
	contents.push('Thank you for stopping in.<br/><br/>');
	contents.push('Cara');
	contents.push('</td>');
	contents.push('</tr>');


	contents.push('</table></center>')
	
	div.innerHTML = contents.join('');
	div.style.top = '10px';
	div.style.left = '0px';
	div.style.height = '600px';
	div.style.width = '800px';
	
	var infoNode = obtainElement('div');
	infoNode.style.width = '100%';
	infoNode.style.height = '300px';
	infoNode.style.backgroundImage = 'url(images/cara.jpg)';
	infoNode.style.backgroundRepeat = 'no-repeat';
	infoNode.style.backgroundPosition = 'top center';
	
	
	gallery.setDisplay(div, infoNode);
}
about.prototype.load = about_load;


function contact()
{
}

function contact_load()
{
	var div = obtainElement('div');
	var contents = new Array();
	
	contents.push('<center><table width=100%>');
	
	contents.push('<tr>');
	contents.push('<td class="contactHead">');
	contents.push('cara granger astorquia');
	contents.push('</td>');
	contents.push('</tr>');

	contents.push('<tr>');
	contents.push('<td class="contact">');
	contents.push('&nbsp;&nbsp;artist / writer');
	contents.push('</td>');
	contents.push('</tr>');

	contents.push('<tr>');
	contents.push('<td class="contact">');
	contents.push('&nbsp;&nbsp;west seattle, wa');
	contents.push('</td>');
	contents.push('</tr>');

	contents.push('<tr>');
	contents.push('<td class="contact">');
	contents.push('&nbsp;&nbsp;206.300.1198');
	contents.push('</td>');
	contents.push('</tr>');

	contents.push('<tr>');
	contents.push('<td class="contact">');
	contents.push('&nbsp;&nbsp;<a class="mail" href="bojari99@hotmail.com">bojari99@hotmail.com</a>');
	contents.push('</td>');
	contents.push('</tr>');
	
	contents.push('</table></center>')
	
	div.innerHTML = contents.join('');
	div.style.backgroundImage = 'url(images/rolodex.gif)';
	div.style.backgroundRepeat = 'no-repeat';
	div.style.backgroundPosition = '190px 102px';
	div.style.top = '0px';
	div.style.left = '0px';
	div.style.height = '300px';
	div.style.width = '100%';
	
	gallery.setDisplay(div);
}
contact.prototype.load = contact_load;

function portfolio(name, img, nav)
{
	this.series = new Array();
	this.parentObj;
	this.activeSeries;
	
	this.name 	= name;
	this.img	= img;
	this.nav	= nav;

	this.loaded = false;

	this.portfolios;
	this.activePortfolio;
	
	this.displayNode;
	this.portfolioNode;
	this.textNode;
	
	this.oid = cortex.getOID();
	cortex.addObj(this);
}
portfolio.prototype.TEXT_HEIGHT = 45;

function portfolio_addSeries(series)
{
	series.idx = this.series.length;
	series.parentObj = this;
	
	this.series.push(series);
}
portfolio.prototype.addSeries = portfolio_addSeries;

function portfolio_addPortfolio(portfolio)
{
	if (this.portfolios == null) this.portfolios = new Array();
	
	portfolio.parentObj = this;
	this.portfolios.push(portfolio);
}
portfolio.prototype.addPortfolio = portfolio_addPortfolio;

function portfolio_load()
{
	var lPortfolio;
	var lSeries;
	var x;
	
	if (this.portfolios != null) {
		for (x = 0; x < this.portfolios.length; x++) {
			lPortfolio = this.portfolios[x];
			lPortfolio.loadPortfolio();
		}
		return;
	}

	for (x = 0; x < this.series.length; x++) {
		lSeries = this.series[x];
		lSeries.loadSeries();
	}
}
portfolio.prototype.load = portfolio_load;

function portfolio_draw()
{
	var lSeries;
	var x;
	
	// have all the series been loaded for display?
	if (this.portfolios == null) {
		for (x = 0; x < this.series.length; x++) {
			lSeries = this.series[x];
			if (!lSeries.loaded) return;
		}
	} else {
		for (x = 0; x < this.portfolios.length; x++) {
			var lChild = this.portfolios[x];
			if (!lChild.loaded) return;
		}
	}

	if (this.displayNode != null) return;
	this.displayNode = obtainElement('div');
	this.displayNode.id = this.oid;
	this.displayNode.style.height = (2 * series.prototype.HEIGHT) + 20 + 'px'; 
	this.displayNode.style.width = gallery.DISPLAY_WIDTH + 'px';
	
	//this.textNode = obtainElement('div')
	//this.textNode.style.top = '0px';
	//this.textNode.style.width = '100%';
	//this.textNode.style.height = this.TEXT_HEIGHT;
	//this.textNode.className = 'portfolioTitle';
	//this.textNode.innerHTML = this.parentObj.text;
	//this.displayNode.appendChild(this.textNode);
	
	var perRow;
	if (this.portfolios != null) {
		perRow = this.portfolios.length;
	} else {
		if (this.series.length <= 3) {
			perRow = this.series.length;
		} else {
			perRow = Math.ceil(this.series.length / 2);
		}
	}
	
	var cellWidth = Math.floor(gallery.DISPLAY_WIDTH / perRow);
	var top = 20; //this.TEXT_HEIGHT;
	var left = 0;
	var leftPad = Math.floor((cellWidth - series.prototype.IMG_WIDTH) / 2);

	//this.textNode.style.left = leftPad + 'px';
	
	var infoNode = null;
	if (this.portfolios != null) {
		var lPortfolio;
		top = 70;
		for (x = 0; x < this.portfolios.length; x++) {
			lPortfolio = this.portfolios[x];
			lPortfolio.drawPortfolio();
			
			lPortfolio.portfolioNode.style.top = top + 'px';
			lPortfolio.portfolioNode.style.left = (left + 20) + 'px';
			
			if (x == (perRow - 1)) {
				top += series.prototype.HEIGHT;
				left = 0;
			} else {
				left += cellWidth;
			}
		}
		
	} else {
		if (this.series.length <= 3) top = 70;
		for (x = 0; x < this.series.length; x++) {
			lSeries = this.series[x];
			lSeries.drawSeries();
			
			lSeries.displayNode.style.top = top + 'px';
			lSeries.displayNode.style.left = (left + 20) + 'px';
			//this.displayNode.appendChild(lSeries.displayNode);
			
			if (x == (perRow - 1)) {
				top += lSeries.HEIGHT;
				left = 0;
			} else {
				left += cellWidth;
			}
		}
		if (this.nav) {
 			infoNode = obtainElement('div');
			infoNode.className = 'mail';
			infoNode.style.top = '15px';
			infoNode.style.left = '0px';
			infoNode.style.width = '100%';
			infoNode.style.height = '400px';
			infoNode.innerHTML = this.nav;
		}
	}

	gallery.setDisplay(this.displayNode, infoNode, true, false);
	
	// append children
	setTimeout('portfolio_appendChild(\'' + this.oid + '\', 0)', 50)
}
portfolio.prototype.draw = portfolio_draw;

function portfolio_drawPortfolio()
{
	if (this.portfolioNode != null) return;
	
	this.portfolioNode = obtainElement('div');
	this.portfolioNode.id = this.oid;
	this.portfolioNode.className = 'seriesTitle';
	this.portfolioNode.style.height = series.prototype.HEIGHT + 'px'; 
	this.portfolioNode.style.width = series.prototype.IMG_WIDTH + 'px';

	var buf = new Array();
	buf.push('<table>');
	
	// image
	buf.push('<tr>');
	buf.push('<td>');
	buf.push('<img src="');
	buf.push(this.img);
	buf.push('" border=0 height=');
	buf.push(series.prototype.IMG_HEIGHT);
	buf.push(' width=');
	buf.push(series.prototype.IMG_WIDTH);
	buf.push('>');
	buf.push('</td>');	
	buf.push('</tr>');
	
	// name
	buf.push('<tr>');
	buf.push('<td class="seriesTitle">');
	buf.push(this.name);
	buf.push('</td>');	
	buf.push('</tr>');
	
	buf.push('</table>');
	
	this.portfolioNode.innerHTML = buf.join('');	
}
portfolio.prototype.drawPortfolio = portfolio_drawPortfolio;


function portfolio_loadPortfolio()
{
	var obj = obtainElement('div');
	
	this.loaded = false;
	
	obj.style.top = '0px';
	obj.style.left = '0px';
	obj.style.width = '1px';
	obj.style.height = '1px';
	obj.style.opacity = '0';
	obj.style.filter = 'alpha(opacity=0)';	
	obj.innerHTML = '<img src="' + this.img + '" onload="javascript:portfolio_imgLoaded(\'' + this.oid + '\');"/>'

	document.body.appendChild(obj);
}
portfolio.prototype.loadPortfolio = portfolio_loadPortfolio;

function portfolio_imgLoaded(id)
{
	var portfolio = cortex.getObjByID(id);
	if (portfolio == null) return;
	if (portfolio.loaded) return;
	
	portfolio.loaded = true;
	portfolio.parentObj.draw();	
}


function portfolio_deselect()
{
	this.displayNode = null;
	if (this.activeSeries) this.activeSeries.deselect();
	if (this.activePortfolio) this.activePortfolio.deselect();
}
portfolio.prototype.deselect = portfolio_deselect;


function portfolio_appendChild(oid, idx)
{
	var lPortfolio = cortex.getObjByID(oid);
	
	if (lPortfolio.portfolios != null) {
		if (idx >= lPortfolio.portfolios.length) return;
		var lChild = lPortfolio.portfolios[idx];
		lPortfolio.displayNode.appendChild(lChild.portfolioNode);
	} else {
		if (idx >= lPortfolio.series.length) return;
		var lSeries = lPortfolio.series[idx];
		
		lPortfolio.displayNode.appendChild(lSeries.displayNode);
	}

	// append children
	var nextIdx = parseInt(idx) + 1;
	setTimeout('portfolio_appendChild(\'' + oid + '\', ' + nextIdx + ')', 50)
}

function portfolio_handleClick()
{
	// clear out the display
	gallery.clearDisplay();
	
	if (gallery.selectedSection != null) gallery.selectedSection.deselect();

	this.parentObj.activePortfolio = this;
	this.load();
}
portfolio.prototype.handleClick = portfolio_handleClick;


function series(name, img, desc)
{
	this.name 	= name;
	this.img	= img;
	this.desc 	= desc;
	
	this.photos = new Array();
	this.writings;
	this.slideShow;
	
	this.idx;
	this.parentObj;
	
	this.loaded = false;
	
	this.displayNode;
	
	this.oid = cortex.getOID();
	cortex.addObj(this);
}
series.prototype.IMG_HEIGHT = 200;
series.prototype.IMG_WIDTH 	= 200;
series.prototype.HEIGHT 	= 250;

function series_addPhoto(photo)
{
	photo.idx 		= this.photos.length;
	photo.parentObj = this;
	
	this.photos.push(photo);
}
series.prototype.addPhoto = series_addPhoto;

function series_addWriting(writing)
{
	if (this.writings == null) this.writings = new Array();
	
	writing.idx = this.writings.length;
	writing.parentObj = this;
	
	this.writings.push(writing);
}
series.prototype.addWriting = series_addWriting;

function series_loadSeries()
{
	var obj = obtainElement('div');
	
	this.loaded = false;
	
	obj.style.top = '0px';
	obj.style.left = '0px';
	obj.style.width = '1px';
	obj.style.height = '1px';
	obj.style.opacity = '0';
	obj.style.filter = 'alpha(opacity=0)';	
	obj.innerHTML = '<img src="' + this.img + '" onload="javascript:series_imgLoaded(\'' + this.oid + '\');"/>'

	document.body.appendChild(obj);
}
series.prototype.loadSeries = series_loadSeries;

function series_imgLoaded(id)
{
	var series = cortex.getObjByID(id);
	if (series == null) return;
	if (series.loaded) return;

	series.loaded = true;
	series.parentObj.draw();	
}

function series_drawSeries()
{
	if (this.displayNode != null) return;
	
	this.displayNode = obtainElement('div');
	this.displayNode.id = this.oid;
	this.displayNode.className = 'seriesTitle';
	this.displayNode.style.height = this.HEIGHT + 'px'; 
	this.displayNode.style.width = this.IMG_WIDTH + 'px';

	var buf = new Array();
	buf.push('<table>');
	
	// image
	buf.push('<tr>');
	buf.push('<td>');
	buf.push('<img src="');
	buf.push(this.img);
	buf.push('" border=0 height=');
	buf.push(this.IMG_HEIGHT);
	buf.push(' width=');
	buf.push(this.IMG_WIDTH);
	buf.push('>');
	buf.push('</td>');	
	buf.push('</tr>');
	
	// name
	buf.push('<tr>');
	buf.push('<td class="seriesTitle">');
	buf.push(this.name);
	buf.push('</td>');	
	buf.push('</tr>');
	
	// desc
	buf.push('<tr>');
	buf.push('<td class="series">');
	buf.push(this.desc);
	buf.push('</td>');	
	buf.push('</tr>');
	
	buf.push('</table>');
	
	this.displayNode.innerHTML = buf.join('');	
}
series.prototype.drawSeries = series_drawSeries;


function series_load()
{
	var lPhoto;
	var x;
	
	if (this.writings != null) {
		var lWriting;
		for (x = 0; x < this.writings.length; x++) {
			lWriting = this.writings[x];
			lWriting.load();
		}
		return;
	}
	
	for (x = 0; x < this.photos.length; x++) {
		lPhoto = this.photos[x];
		lPhoto.load();
	}
}
series.prototype.load = series_load;

function series_draw()
{
	var lPhoto;
	var x;
	
	if (this.writings != null) {
		var lWriting;
		for (x = 0; x < this.writings.length; x++) {
			lWriting = this.writings[x];
			if (!lWriting.thumbLoaded) return;
		}
		
		if (this.slideShow == null) {
			this.slideShow = new slideShow(this.name, null, true, this.writings);
		}
		
		this.slideShow.showWritings();
		return;
	}
	

	// have all the photos been loaded for display?
	for (x = 0; x < this.photos.length; x++) {
		lPhoto = this.photos[x];
		//if (!lPhoto.imgLoaded || !lPhoto.thumbLoaded) alert(x + ' not loaded fully');
		if (!lPhoto.imgLoaded) 		return;
		if (!lPhoto.thumbLoaded)	return;
	}

	// create the slideShow
	if (this.slideShow == null) {
		this.slideShow = new slideShow(this.name, this.photos, true);
	}
	
	// play
	this.slideShow.play();
}
series.prototype.draw = series_draw;


function series_handleClick()
{
	// clear out the display
	gallery.clearDisplay();

	this.parentObj.activeSeries = this;
	this.load();
}
series.prototype.handleClick = series_handleClick;

function series_deselect()
{
	this.parentObj.activeSeries = null;
	if (this.slideShow) this.slideShow.pause();
}
series.prototype.deselect = series_deselect;


function photo(name, thumb, img, height, width, medium, dimension, year, otherInfo)
{
	this.name 	= name;
	this.thumb 	= thumb;
	this.img 	= img;
	this.height = height;
	this.width 	= width;
	
	this.medium 	= medium;
	this.dimension 	= dimension;	
	this.year		= year;
	this.otherInfo	= otherInfo;
	
	this.thumbLoaded 	= false;
	this.imgLoaded		= false;
	
	this.idx;
	this.parentObj;
	
	this.thumbButton;
	
	this.oid = cortex.getOID();
	cortex.addObj(this);
}
photo.prototype.THUMB_WIDTH 	= 50;
photo.prototype.THUMB_HEIGHT 	= 50;


function photo_drawThumb()
{
	if (this.thumbButton == null) {
		this.thumbButton = new button(this.thumb, this.THUMB_HEIGHT, this.THUMB_WIDTH, this.text);
		this.thumbButton.draw();
		this.thumbButton.parentObj = this;
		this.thumbButton.idx = this.idx;
		this.thumbButton.displayNode.style.opacity = '.7';
		this.thumbButton.displayNode.style.filter = 'alpha(opacity=70)';
	}
	return this.thumbButton.displayNode;
}
photo.prototype.drawThumb = photo_drawThumb;

function photo_load()
{
	var obj = obtainElement('div');

	this.thumbLoaded = false;
	this.imgLoaded = false;
	
	if (this.thumb) {
		obj.style.top = '0px';
		obj.style.left = '0px';
		obj.style.width = '1px';
		obj.style.height = '1px';
		obj.style.opacity = '0';
		obj.style.filter = 'alpha(opacity=0)';	
		obj.innerHTML = '<img src="' + this.thumb + '" onload="javascript:photo_thumbLoaded(\'' + this.oid + '\');"/>';
	
		document.body.appendChild(obj);
	} else {
		this.thumbLoaded = true;
	}
	
	obj = obtainElement('div');
	
	obj.style.top = '0px';
	obj.style.left = '0px';
	obj.style.width = '1px';
	obj.style.height = '1px';
	obj.style.opacity = '0';
	obj.style.filter = 'alpha(opacity=0)';	
	
	var img = new Array();
	img.push('<img ');
	if (this.name) img.push('alt="' + this.name +  '" ');
	img.push('src="' + this.img + '" onload="javascript:photo_imgLoaded(\'' + this.oid + '\');"/>');
	obj.innerHTML = img.join(''); 

	document.body.appendChild(obj);
}
photo.prototype.load = photo_load;

function photo_handleMouseOver(idx)
{
	if (this.thumbButton && this.thumbButton.displayNode) {
		this.thumbButton.displayNode.style.opacity = '1';
		this.thumbButton.displayNode.style.filter = 'alpha(opacity=100)';
	}
}
photo.prototype.handleMouseOver = photo_handleMouseOver;

function photo_handleMouseOut(idx)
{
	if (this.thumbButton && this.thumbButton.displayNode) {
		this.thumbButton.displayNode.style.opacity = '.7';
		this.thumbButton.displayNode.style.filter = 'alpha(opacity=70)';
	}
}
photo.prototype.handleMouseOut = photo_handleMouseOut;

function photo_handleClick(idx)
{
	this.parentObj.slideShow.setActive(idx);
}
photo.prototype.handleClick = photo_handleClick;


function photo_thumbLoaded(oid)
{
	var lPhoto = cortex.getObjByID(oid);
	if (lPhoto == null) return;
	if (lPhoto.thumbLoaded) return;
	
	lPhoto.thumbLoaded = true;
	lPhoto.parentObj.draw();	
}

function photo_imgLoaded(oid)
{
	var lPhoto = cortex.getObjByID(oid);
	if (lPhoto == null) return;
	if (lPhoto.imgLoaded) return;
	
	lPhoto.imgLoaded = true;
	lPhoto.parentObj.draw();	
}

function writing(name, thumb, pdf)
{
	this.name 	= name;
	this.thumb 	= thumb;
	this.pdf 	= pdf;
	this.height = 600;
	this.width 	= 900;
	
	this.thumbLoaded 	= false;

	this.idx;
	this.parentObj;
	
	this.thumbButton;
	
	this.oid = cortex.getOID();
	cortex.addObj(this);
}
writing.prototype.THUMB_WIDTH 	= 50;
writing.prototype.THUMB_HEIGHT 	= 50;


function writing_drawThumb()
{
	if (this.thumbButton == null) {
		this.thumbButton = new button(this.thumb, this.THUMB_HEIGHT, this.THUMB_WIDTH, this.text);
		this.thumbButton.draw();
		this.thumbButton.parentObj = this;
		this.thumbButton.idx = this.idx;
		this.thumbButton.displayNode.style.opacity = '.7';
		this.thumbButton.displayNode.style.filter = 'alpha(opacity=70)';
	}
	return this.thumbButton.displayNode;
}
writing.prototype.drawThumb = writing_drawThumb;

function writing_load()
{
	var obj = obtainElement('div');

	this.thumbLoaded = false;
	
	if (this.thumb) {
		obj.style.top = '0px';
		obj.style.left = '0px';
		obj.style.width = '1px';
		obj.style.height = '1px';
		obj.style.opacity = '0';
		obj.style.filter = 'alpha(opacity=0)';	
		obj.innerHTML = '<img src="' + this.thumb + '" onload="javascript:writing_thumbLoaded(\'' + this.oid + '\');"/>';
	
		document.body.appendChild(obj);
	} else {
		this.thumbLoaded = true;
	}
	
}
writing.prototype.load = writing_load;

function writing_handleMouseOver(idx)
{
	if (this.thumbButton && this.thumbButton.displayNode) {
		this.thumbButton.displayNode.style.opacity = '1';
		this.thumbButton.displayNode.style.filter = 'alpha(opacity=100)';
	}
}
writing.prototype.handleMouseOver = writing_handleMouseOver;

function writing_handleMouseOut(idx)
{
	if (this.thumbButton && this.thumbButton.displayNode) {
		this.thumbButton.displayNode.style.opacity = '.7';
		this.thumbButton.displayNode.style.filter = 'alpha(opacity=70)';
	}
}
writing.prototype.handleMouseOut = writing_handleMouseOut;

function writing_handleClick(idx)
{
	this.parentObj.slideShow.setActiveWriting(idx);
}
writing.prototype.handleClick = writing_handleClick;


function writing_thumbLoaded(oid)
{
	var lWriting = cortex.getObjByID(oid);
	if (lWriting == null) return;
	if (lWriting.thumbLoaded) return;
	
	lWriting.thumbLoaded = true;
	lWriting.parentObj.draw();	
}



function slideShow(name, photos, hasThumbs, writings)
{
	this.name			= name;
	this.photos 		= photos;
	this.hasThumbs 		= hasThumbs;
	
	this.writings		= writings;
	this.activeWriting;
	
	this.activePhoto;
	this.isPlaying;
	
	this.infoNode;
	
	this.buttonsNode;
	this.playBtn;
	this.pauseBtn;
	this.previousBtn;
	this.nextBtn;
		
	this.timer;
	
	this.opacity;
	
	this.displayNode;
	this.titleNode;
	this.descNode;
	this.lineNode;
	this.photoNode;
	
	this.drop;
	
	this.oid = cortex.getOID();
	cortex.addObj(this);
	
	if (this.hasThumbs) this.configureBtns();
}
slideShow.prototype.DURATION 			= 4500;
slideShow.prototype.HEADER_HEIGHT		= 40;
slideShow.prototype.PHOTO_HEIGHT 		= 600;
slideShow.prototype.BUTTONS_HEIGHT 		= 35;
slideShow.prototype.THUMBS_PAD			= 5;
slideShow.prototype.BTN_IDX_PLAY		= 1;
slideShow.prototype.BTN_IDX_PAUSE		= 2;
slideShow.prototype.BTN_IDX_PREVIOUS	= 3;
slideShow.prototype.BTN_IDX_NEXT		= 4;
slideShow.prototype.BTN_IDX_THUMBS		= 5;
slideShow.prototype.BTN_IDX_CLOSE		= 6;
slideShow.prototype.BTN_IDX_SCROLL_UP	= 7;
slideShow.prototype.BTN_IDX_SCROLL_DOWN	= 8;
slideShow.prototype.REF_PHOTO			= 'PHOTO';


function slideShow_configureBtns()
{
	if (this.hasThumbs && this.photos) {
		this.playBtn = new button('images/play1.jpg', 25, 25, null);
		this.playBtn.idx = this.BTN_IDX_PLAY;
		this.playBtn.parentObj = this;
		 
		this.pauseBtn = new button('images/pause1.jpg', 25, 25, null);
		this.pauseBtn.idx = this.BTN_IDX_PAUSE;
		this.pauseBtn.parentObj = this;
	
		//this.previousBtn = new button('images/previous.jpg', 20, 20, 'previous');
		//this.previousBtn.idx = this.BTN_IDX_PREVIOUS;
		//this.previousBtn.parentObj = this;
	
		//this.nextBtn = new button('images/next.jpg', 20, 20, 'next');
		//this.nextBtn.idx = this.BTN_IDX_NEXT;
		//this.nextBtn.parentObj = this;
	}
}
slideShow.prototype.configureBtns = slideShow_configureBtns;

function slideShow_initWritings()
{
	if (this.displayNode != null) return;
	
	// the displayNode
	this.displayNode = obtainElement('div');
	this.displayNode.id = this.oid;
	this.displayNode.style.height = (this.PHOTO_HEIGHT + this.HEADER_HEIGHT + 12) + 'px'; 
	this.displayNode.style.width = gallery.DISPLAY_WIDTH + 'px';	

	var right = 2;
	var pad = 2;
	var btns = 0;
	if (this.hasThumbs) {
		
		this.initWritingInfo();
		
		this.lineNode = obtainElement('div');
		this.lineNode.style.width = '900px';
		this.lineNode.style.height = '1px';
		this.lineNode.style.left = Math.floor((gallery.DISPLAY_WIDTH - 900) / 2) + 'px';
		this.lineNode.style.top = (this.HEADER_HEIGHT - 7) + 'px';
		this.lineNode.style.backgroundColor = '#FFFFFF';
		this.displayNode.appendChild(this.lineNode);

		this.titleNode = obtainElement('div');
		this.titleNode.className = 'title';
		this.titleNode.style.height = this.HEADER_HEIGHT + 'px';
		this.titleNode.style.top = '0px';
		this.displayNode.appendChild(this.titleNode);
		
	}
	
}
slideShow.prototype.initWritings = slideShow_initWritings;

function slideShow_initWritingInfo()
{
	if (this.infoNode != null) return;
	
	var top;
	var left;
	var obj;
	
	this.infoNode = obtainElement('div');
	this.infoNode.style.width = '100%';
	
	// series name
	obj = obtainElement('div');
	obj.style.top = '0px';
	obj.style.left = '0px';
	obj.style.height = '18px';
	obj.style.width = '100%';
	obj.className = 'info';
	obj.innerHTML = this.name;
	
	this.infoNode.appendChild(obj);	
	
	top = 23;	

	var lWriting;
	var left = this.THUMBS_PAD;
	var count = 0;
	for (var x = 0; x < this.writings.length; x++) {
		
		lWriting = this.writings[x];
		obj = lWriting.drawThumb();
		obj.style.top 	= top + 'px';
		obj.style.left 	= left + 'px';
		this.infoNode.appendChild(obj);
		
		count += 1;
		if (count < 3) {
			left += this.THUMBS_PAD + writing.prototype.THUMB_WIDTH;
		} else {
			count = 0;
			top += this.THUMBS_PAD + writing.prototype.THUMB_HEIGHT;
			left = this.THUMBS_PAD
		}
	}
	this.infoNode.style.height = (top + this.THUMBS_PAD + writing.prototype.THUMB_HEIGHT) + 'px';
}
slideShow.prototype.initWritingInfo = slideShow_initWritingInfo;

function slideShow_showActiveWriting()
{
	if (this.activeWriting == null) return;
	
	var obj;
			
	// show the active photo
	if (this.displayNode == null) this.initWritings();
	
	// add the photo
	if (this.photoNode == null) {
		this.photoNode = obtainElement('div');
		this.photoNode.id = this.oid;
		this.displayNode.appendChild(this.photoNode);		
	}
	
	var pdf = new Array();
	pdf.push('<center><iframe src="');
	pdf.push(this.activeWriting.pdf); 
	pdf.push('#toolbar=0&navpanes=0" frameborder=0 style="width:');
	pdf.push(this.activeWriting.width);
	pdf.push('px;height:')
	pdf.push(this.activeWriting.height);
	pdf.push('px"></iframe></center>');
	
	var top = 20;
	if (this.name != null) top = this.HEADER_HEIGHT;
	this.photoNode.style.top = top + 'px';
	this.photoNode.style.height = this.activeWriting.height + 'px'; 
	this.photoNode.style.width = this.activeWriting.width + 'px';	
	this.photoNode.style.left = Math.floor((gallery.DISPLAY_WIDTH - this.activeWriting.width) / 2);
	this.photoNode.innerHTML = pdf.join('');
	this.photoNode.abbr = this.REF_PHOTO;
	

	var height = this.activeWriting.height;
	var width = this.activeWriting.width;
	
	if (this.hasThumbs) {
		if (this.activeWriting.name) {
			this.titleNode.style.left = (parseInt(this.lineNode.style.left) + 5) + 'px';
			this.titleNode.style.width = (parseInt(this.lineNode.style.width) - 10) + 'px';
			this.titleNode.innerHTML = this.activeWriting.name;
		}
	}

	this.displayNode.style.height = (top + height + 12) + 'px';
	//this.displayNode.style.backgroundColor = 'green';
	gallery.setDisplay(this.displayNode, this.infoNode, true);
}
slideShow.prototype.showActiveWriting = slideShow_showActiveWriting;


function slideShow_init()
{
	if (this.displayNode != null) return;
	
	// the displayNode
	this.displayNode = obtainElement('div');
	this.displayNode.id = this.oid;
	this.displayNode.style.height = (this.PHOTO_HEIGHT + this.HEADER_HEIGHT + 12) + 'px'; 
	this.displayNode.style.width = gallery.DISPLAY_WIDTH + 'px';	
	
	var clone;
	var obj;	
	this.drop = obtainElement('div');
	
	clone = obtainElement('div');
	clone.style.backgroundColor = '#000000';
	
	obj = clone.cloneNode(false);
	obj.style.opacity = '.08';
	obj.style.filter = 'alpha(opacity=8)';
	obj.style.top = '5px';
	obj.style.left = '0px';
	this.drop.appendChild(obj);
	
	obj = clone.cloneNode(false);
	obj.style.opacity = '.08';
	obj.style.filter = 'alpha(opacity=8)';
	obj.style.top = '0px';
	obj.style.left = '5px';
	this.drop.appendChild(obj);
	
	obj = clone.cloneNode(false);
	obj.style.opacity = '.08';
	obj.style.filter = 'alpha(opacity=8)';
	obj.style.top = '3px';
	obj.style.left = '1px';
	this.drop.appendChild(obj);
	
	obj = clone.cloneNode(false);
	obj.style.opacity = '.08';
	obj.style.filter = 'alpha(opacity=8)';
	obj.style.top = '1px';
	obj.style.left = '3px';
	this.drop.appendChild(obj);
	
	obj = clone.cloneNode(false);
	obj.style.opacity = '.08';
	obj.style.filter = 'alpha(opacity=8)';
	obj.style.top = '2px';
	obj.style.left = '2px';
	this.drop.appendChild(obj);
		
	this.displayNode.appendChild(this.drop);
	
	var right = 2;
	var pad = 2;
	var btns = 0;
	if (this.hasThumbs) {
		
		this.initInfo();
		
		this.lineNode = obtainElement('div');
		this.lineNode.style.width = '900px';
		this.lineNode.style.height = '1px';
		this.lineNode.style.left = Math.floor((gallery.DISPLAY_WIDTH - 900) / 2) + 'px';
		this.lineNode.style.top = (this.HEADER_HEIGHT - 7) + 'px';
		this.lineNode.style.backgroundColor = '#FFFFFF';
		this.displayNode.appendChild(this.lineNode);

		this.titleNode = obtainElement('div');
		this.titleNode.className = 'title';
		this.titleNode.style.height = this.HEADER_HEIGHT + 'px';
		this.titleNode.style.top = '0px';
		this.displayNode.appendChild(this.titleNode);
		
		this.descNode = obtainElement('div');
		this.descNode.className = 'desc';
		this.descNode.style.height = this.HEADER_HEIGHT + 'px';
		this.descNode.style.top = '0px';
		this.displayNode.appendChild(this.descNode);
		
	}
}
slideShow.prototype.init = slideShow_init;

function slideShow_initInfo()
{
	if (this.infoNode != null) return;
	
	var top;
	var left;
	var obj;
	
	this.infoNode = obtainElement('div');
	this.infoNode.style.width = '100%';
	
	// series name
	obj = obtainElement('div');
	obj.style.top = '0px';
	obj.style.left = '0px';
	obj.style.height = '18px';
	obj.style.width = '100%';
	obj.className = 'info';
	obj.innerHTML = this.name;
	
	this.infoNode.appendChild(obj);	
	
	top = 23;	
	
	this.playBtn.draw();
	this.playBtn.displayNode.style.top 		= top + 'px';
	this.playBtn.displayNode.style.right 	= '0px';
	this.infoNode.appendChild(this.playBtn.displayNode);

	this.pauseBtn.draw();
	this.pauseBtn.displayNode.style.top 	= top + 'px';
	this.pauseBtn.displayNode.style.right 	= '0px';
	this.infoNode.appendChild(this.pauseBtn.displayNode);


	var lPhoto;
	var left = this.THUMBS_PAD;
	var count = 0;
	for (var x = 0; x < this.photos.length; x++) {
		
		lPhoto = this.photos[x];
		obj = lPhoto.drawThumb();
		obj.style.top 	= top + 'px';
		obj.style.left 	= left + 'px';
		this.infoNode.appendChild(obj);
		
		count += 1;
		if (count < 3) {
			left += this.THUMBS_PAD + photo.prototype.THUMB_WIDTH;
		} else {
			count = 0;
			top += this.THUMBS_PAD + photo.prototype.THUMB_HEIGHT;
			left = this.THUMBS_PAD
		}
	}
	this.infoNode.style.height = (top + this.THUMBS_PAD + photo.prototype.THUMB_HEIGHT) + 'px';
}
slideShow.prototype.initInfo = slideShow_initInfo;

function slideShow_showActive()
{
	if (this.activePhoto == null) return;
	
	var obj;
			
	// show the active photo
	if (this.displayNode == null) this.init();
	
	// add the photo
	if (this.photoNode == null) {
		this.photoNode = obtainElement('div');
		this.photoNode.id = this.oid;
		if (ie) this.photoNode.className = 'photo'; 
		this.displayNode.appendChild(this.photoNode);		
	}
	
	var img = new Array();
	img.push('<center><img src="');
	img.push(this.activePhoto.img);
	img.push('" border=0 width=');
	img.push(this.activePhoto.width);
	img.push(' height=')
	img.push(this.activePhoto.height);
	if (this.activePhoto.name) {
		//img.push(' alt="' + this.activePhoto.name + '"');
	}
	img.push('></center>');
	
	if (ie && this.photoNode.filters.length > 0) this.photoNode.filters[0].apply();
	var top = 20;
	if (this.name != null) top = this.HEADER_HEIGHT;
	this.photoNode.style.top = top + 'px';
	this.photoNode.style.height = this.activePhoto.height + 'px'; 
	this.photoNode.style.width = this.activePhoto.width + 'px';	
	this.photoNode.style.left = Math.floor((gallery.DISPLAY_WIDTH - this.activePhoto.width) / 2);
	this.photoNode.innerHTML = img.join('');
	if (!ie && !mobile) {
		this.photoNode.style.opacity = '.6';
		this.drop.style.opacity = '.6';
		this.opacity = 60;
	}
	if (ie && this.photoNode.filters.length > 0) this.photoNode.filters[0].play();
	this.photoNode.abbr = this.REF_PHOTO;
	

	var height = this.activePhoto.height;
	var width = this.activePhoto.width;
	this.drop.style.height 	= height + 'px';
	this.drop.style.width	= width + 'px';
	this.drop.style.top 	= (parseInt(this.photoNode.style.top) + 10) + 'px';
	this.drop.style.left 	= (parseInt(this.photoNode.style.left) + 8) + 'px';
	
	this.drop.childNodes[0].style.height 	= (height - 10) + 'px';
	this.drop.childNodes[0].style.width 	= width + 'px';
	
	this.drop.childNodes[1].style.height 	= height + 'px';
	this.drop.childNodes[1].style.width 	= (width - 10) + 'px';
	
	this.drop.childNodes[2].style.height 	= (height - 6) + 'px';
	this.drop.childNodes[2].style.width 	= (width - 2) + 'px';
	
	this.drop.childNodes[3].style.height 	= (height - 2) + 'px';
	this.drop.childNodes[3].style.width 	= (width - 6) + 'px';
	
	this.drop.childNodes[4].style.height 	= (height - 4) + 'px';
	this.drop.childNodes[4].style.width 	= (width - 4) + 'px';
	
	if (this.hasThumbs) {
		if (this.activePhoto.name) {
			this.titleNode.style.left = (parseInt(this.lineNode.style.left) + 5) + 'px';
			this.titleNode.style.width = (parseInt(this.lineNode.style.width) - 10) + 'px';
			this.titleNode.innerHTML = this.activePhoto.name;
			if (this.activePhoto.otherInfo) {
				this.titleNode.innerHTML += '&nbsp;<span class=\"desc\" style=\"padding-left:0px;font-style:italic;\">(' + this.activePhoto.otherInfo + ')</span>';
			}
		}
		this.descNode.style.left = parseInt(this.titleNode.style.left) + 'px';
		this.descNode.style.width = parseInt(this.titleNode.style.width) + 'px';
		
		var desc = new Array();
		if (this.activePhoto.year != null) {
			desc.push(this.activePhoto.year);
			desc.push('&nbsp;|&nbsp;');
		}
		desc.push(this.activePhoto.medium);
		desc.push('&nbsp;|&nbsp;');
		desc.push(this.activePhoto.dimension);
		this.descNode.innerHTML = desc.join('');
	}

	this.displayNode.style.height = (top + height + 12) + 'px';
	//this.displayNode.style.backgroundColor = 'green';
	gallery.setDisplay(this.displayNode, this.infoNode, true);
	
	// not ie, manual fade in
	if (!ie && !mobile) {
		setTimeout('slideShow_fadeIn(\'' + this.oid + '\')', 0);
		setTimeout('slideShow_fadeIn(\'' + this.oid + '\')', 0);
		setTimeout('slideShow_fadeIn(\'' + this.oid + '\')', 0);
		setTimeout('slideShow_fadeIn(\'' + this.oid + '\')', 0);
	}
	
	// if we're playing, schedule the next for showing
	if (this.isPlaying) this.timer = setTimeout('slideShow_next(\'' + this.oid + '\')', this.DURATION);
}
slideShow.prototype.showActive = slideShow_showActive;


function slideShow_fadeIn(oid)
{
	var lSlideShow = cortex.getObjByID(oid);
	if (lSlideShow == null) 			return;
	if (lSlideShow.photoNode == null) 	return;
	if (lSlideShow.opacity >= 100)		return;
	
	lSlideShow.opacity += 1;
	lSlideShow.photoNode.style.opacity = (lSlideShow.opacity / 100) + '';
	lSlideShow.drop.style.opacity = (lSlideShow.opacity / 100) + '';
	
	if (lSlideShow.opacity < 100) setTimeout('slideShow_fadeIn(\'' + oid + '\')', 0);
}


function slideShow_showWritings()
{
	// init the active writing?
	if (this.activeWriting == null) this.activeWriting = this.writings[0];

	// show the activeWriting
	this.showActiveWriting();	
}
slideShow.prototype.showWritings = slideShow_showWritings


function slideShow_play()
{
	if (this.isPlaying) return;

	// flag playing status
	this.isPlaying = true;

	// kill the clock
	this.killClock();
	
	// init the active photo?
	if (this.activePhoto == null) this.activePhoto = this.photos[0];

	// set button state
	if (this.playBtn) 	this.playBtn.hide();
	if (this.pauseBtn) 	this.pauseBtn.show();

	// show the activePhoto
	this.showActive();	
}
slideShow.prototype.play = slideShow_play;

function slideShow_pause()
{
	// flag playing status
	this.isPlaying = false;

	// kill the clock
	this.killClock();
	
	// set button state
	if (this.playBtn) 	this.playBtn.show();
	if (this.pauseBtn) 	this.pauseBtn.hide();
}
slideShow.prototype.pause = slideShow_pause;

function slideShow_killClock()
{
	if (this.timer != null) clearTimeout(this.timer);
}
slideShow.prototype.killClock = slideShow_killClock;

function slideShow_setActiveWriting(idx)
{
	this.activeWriting = this.writings[idx];
	this.showActiveWriting();
}
slideShow.prototype.setActiveWriting = slideShow_setActiveWriting;

function slideShow_setActive(idx)
{
	this.pause();
	this.activePhoto = this.photos[idx];
	this.showActive();
}
slideShow.prototype.setActive = slideShow_setActive;

function slideShow_next(oid)
{
	var lSlideShow = cortex.getObjByID(oid);
	if (lSlideShow == null) return;
	
	var nextIdx = 0;
	if (lSlideShow.activePhoto) {
		nextIdx = lSlideShow.activePhoto.idx + 1;
		if (nextIdx >= lSlideShow.photos.length) nextIdx = 0;
	}

	lSlideShow.killClock();
	lSlideShow.activePhoto = lSlideShow.photos[nextIdx];
	lSlideShow.showActive();
}
slideShow.prototype.next = slideShow_next;


function slideShow_previous(oid)
{
	var lSlideShow = cortex.getObjByID(oid);
	if (lSlideShow == null) return;
	
	var nextIdx = 0;
	if (lSlideShow.activePhoto) {
		nextIdx = lSlideShow.activePhoto.idx - 1;
		if (nextIdx < 0) nextIdx = lSlideShow.photos.length - 1;
	}
	
	lSlideShow.killClock();
	lSlideShow.activePhoto = lSlideShow.photos[nextIdx];
	lSlideShow.showActive();
}
slideShow.prototype.previous = slideShow_previous;


function slideShow_handleClick(btnIdx)
{
	switch (btnIdx) {
		case this.BTN_IDX_PLAY:
			this.play();
			break;
			
		case this.BTN_IDX_PAUSE:
			this.pause();
			break;
			
		case this.BTN_IDX_PREVIOUS:
			this.previous(this.oid);
			break;
			
		case this.BTN_IDX_NEXT:
			this.next(this.oid);
			break;	
	}
}
slideShow.prototype.handleClick = slideShow_handleClick;

function slideShow_handleMouseUp(btnIdx)
{
	this.handleMouseOut(btnIdx);
}
slideShow.prototype.handleMouseUp = slideShow_handleMouseUp;

function slideShow_handleMouseOver(ce)
{
}
slideShow.prototype.handleMouseOver = slideShow_handleMouseOver;

function slideShow_handleMouseOut(btnIdx)
{
}
slideShow.prototype.handleMouseOut = slideShow_handleMouseOut;


function showList()
{
	this.shows = new Array();
	this.parentObj;
}

function showList_addShow(show)
{
	this.shows.push(show);
	this.shows.sort(showList_sort);
}
showList.prototype.addShow = showList_addShow;

function showList_load()
{
	var div = obtainElement('div');
	var contents = new Array();
	
	contents.push('<table width=80%>');

	var show;
	for (var i = 0;  i < this.shows.length; i++) {	
		
		show = this.shows[i];
		
		contents.push('<tr>');
		contents.push('<td class="title">');
		
		contents.push('<div style=\"border-bottom:1px dashed #FFFFFF;padding-bottom:10px;\">');
		contents.push(show.draw());
		contents.push('</div>');
	
		contents.push('</td>');
		contents.push('</tr>');
	}

	
	contents.push('</table>')
	
	//container.innerHTML = contents.join('');
	//container.style.border = 'solid 1px #AAAAAA';
	//container.style.backgroundColor = 'white';
	//container.style.height = '98%';
	//container.style.width = '80%';
	//container.style.left = '10%';
	
	//div.appendChild(container);
	//div.style.overflowY = 'auto';
	div.style.top = '10px';
	div.style.height = (show.HEIGHT * this.shows.length) + 'px';
	div.style.width = '100%';
	div.innerHTML = contents.join('');
	//div.style.textAlign = 'center';
	
	gallery.setDisplay(div);
}
showList.prototype.load = showList_load;

function showList_sort(showA, showB)
{
	var sortStart = false;
	if ((showA.end == null) && (showB.end != null)) return -1;
	if ((showA.end != null) && (showB.end == null)) return 1;
	if ((showA.end == null) && (showB.end == null)) sortStart = true;

	if (!sortStart) {
		if (showA.end.getTime() < showB.end.getTime()) return 1;
		if (showA.end.getTime() > showB.end.getTime()) return -1;
	}
	
	if (showA.start.getTime() < showB.start.getTime()) return 1;
	if (showA.start.getTime() > showB.start.getTime()) return -1;
	
	return 0;
}



function show(venue, start, end, desc)
{
	this.venue 	= venue;
	
	this.start 	= start;
	this.end 	= end;
	
	this.desc	= desc;
	
	this.receptions;
	this.photos;
}
show.prototype.HEIGHT = 140;

function show_addReception(reception)
{
	if (this.receptions == null) this.receptions = new Array();
	this.receptions.push(reception);
}
show.prototype.addReception = show_addReception;

function show_addPhoto(photo)
{
	if (this.photos == null) this.photos = new Array();
	this.photos.push(photo);
}
show.prototype.addPhoto = show_addPhoto;

function show_draw()
{
	var buf = new Array();
	
	buf.push('<table cellpadding=0 cellspacing=0 border=0>');

	// venue name and date
	buf.push('<tr>');
	buf.push('<td class=\"showHead\" colspan=2 width=95%>');
	buf.push(this.venue.name);
	buf.push('</td>');
	buf.push('<td class=\"showDate\" align=right nowrap width=5%>');
	
	var rightNow = new Date();
	if (this.start.getTime() > rightNow.getTime()) {
		buf.push('<i>UPCOMING:</i> ');
		buf.push(this.getMonth(this.start) + ' ' + this.start.getFullYear());
		if ((this.end != null) && (this.end.getTime() > this.start.getTime())) {
			buf.push(' - ');
			buf.push(this.getMonth(this.end) + ' ' + this.end.getFullYear());	
		}
	}
	else
	{
		if (this.end == null) {
			buf.push('NOW ON DISPLAY');
		}
		else
		{
			if (this.end.getTime() > rightNow.getTime()) {
				buf.push('NOW ON DISPLAY');
			}
			else
			{
				buf.push(this.getMonth(this.start) + ' ' + this.start.getFullYear());
				if (this.end.getTime() > this.start.getTime()) {
					buf.push(' - ');
					buf.push(this.getMonth(this.end) + ' ' + this.end.getFullYear());
				}
			}
		}
	}
	
	buf.push('</td>');
	buf.push('</tr>');

	// venue details & desc
	buf.push('<tr>');
	buf.push('<td nowrap width=5%>');
	
	buf.push('</td>');
	buf.push('<td class=\"showDetail\" nowrap width=95%>');
	buf.push(this.venue.getDetails());
	buf.push('</td>');
	buf.push('<td class=\"showDate\" nowrap align=right valign=middle width=5%><i>');
	if (this.desc) buf.push(this.desc);
	buf.push('</i></td>');
	buf.push('</tr>');
	
	buf.push('</table>');
	
	return buf.join('');
}
show.prototype.draw = show_draw;

function show_getMonth(d)
{
	if (d == null) return '';
	switch (d.getMonth()) {
		case 0:
			return 'Jan';
		case 1:
			return 'Feb';
		case 2:
			return 'Mar';
		case 3:
			return 'Apr';
		case 4:
			return 'May';
		case 5:
			return 'Jun';
		case 6:
			return 'Jul';
		case 7:
			return 'Aug';
		case 8:
			return 'Sept';
		case 9:
			return 'Oct';
		case 10:
			return 'Nov';
		case 11:
			return 'Dec';
	}
}
show.prototype.getMonth = show_getMonth;

function reception(show, flyer, start, end, desc)
{
	this.show 	= show;
	this.flyer	= flyer;
	
	this.start 	= start;
	this.end 	= end;
	
	this.desc	= desc;
}

function venue(name, logo, addr1, addr2, city, state, zip, webURL, phone)
{
	this.name	= name;
	this.logo	= logo;
	
	this.addr1	= addr1;
	this.addr2	= addr2;
	this.city	= city;
	this.state	= state;
	this.zip	= zip;
	
	this.webURL	= webURL;
	this.phone	= phone;
}


function venue_getDetails()
{
	var buf = new Array();
	
	if (this.addr1 != null) buf.push('@ ' + this.addr1 + '<br/>');
	if (this.addr2 != null) buf.push('@ ' + this.addr2 + '<br/>');
	if (this.city != null) {
		buf.push('@ ' + this.city);
		if (this.state != null) {
			buf.push(', ');
			buf.push(this.state);
			if (this.zip != null) buf.push('  ' + this.zip);
		}
		buf.push('<br/>');
	}
	if (this.webURL != null) {
		buf.push('@ ' + '<a class=\"showDetail\" href=\"');
		buf.push(this.webURL);
		buf.push('\" target=\"newwindow\" style=\"padding:0px;\">');
		buf.push(this.webURL);
		buf.push('</a><br/>');
	}
	if (this.phone != null) buf.push('@ ' + this.phone);
		
	return buf.join('');
}
venue.prototype.getDetails = venue_getDetails;

function button(img, height, width, hoverText) 
{
	this.img 		= img;
	this.height 	= height;
	this.width 		= width;
	this.hoverText	= hoverText;
	
	this.idx;
	this.parentObj;
	
	this.displayNode;
		
	this.oid = cortex.getOID();
	cortex.addObj(this);
}

function button_draw()
{
	if (this.displayNode == null) {
		this.displayNode = obtainElement('div');
		this.displayNode.id = this.oid;
		this.displayNode.className = 'btn';
		this.displayNode.style.height = this.height + 'px'; 
		this.displayNode.style.width = this.width + 'px';
		this.displayNode.innerHTML = '<img src="' + this.img + '" border=0 height="' + this.height + '" width="' + this.width + '">';	
	}
	return this.displayNode;	
}
button.prototype.draw = button_draw;

function button_show()
{
	if (this.displayNode) this.displayNode.style.display = '';
}
button.prototype.show = button_show;

function button_hide()
{
	if (this.displayNode) this.displayNode.style.display = 'none';
}
button.prototype.hide = button_hide;

function button_getHoverContents()
{
	if (this.hoverText) {
		if (ie) {
			return this.hoverText + ' '
		}
		return this.hoverText;
	}
}
button.prototype.getHoverContents = button_getHoverContents;

function button_handleClick()
{
	if (this.parentObj == null) 			return;
	if (this.parentObj.handleClick == null)	return;
	
	this.parentObj.handleClick(this.idx);
}
button.prototype.handleClick = button_handleClick;

function button_handleMouseOver()
{
	if (this.hoverText) cortex.scheduleHover(this);
	
	if (this.parentObj == null)					return;
	if (this.parentObj.handleMouseOver == null)	return;
	
	this.parentObj.handleMouseOver(this.idx);
}
button.prototype.handleMouseOver = button_handleMouseOver;

function button_handleMouseOut()
{
	if (this.parentObj == null)					return;
	if (this.parentObj.handleMouseOut == null)	return;
	
	this.parentObj.handleMouseOut(this.idx);
}
button.prototype.handleMouseOut = button_handleMouseOut;

function button_handleMouseDown()
{
	if (this.parentObj == null)					return;
	if (this.parentObj.handleMouseDown == null)	return;
	
	this.parentObj.handleMouseDown(this.idx);
}
button.prototype.handleMouseDown = button_handleMouseDown;

function button_handleMouseUp()
{
	if (this.parentObj == null)					return;
	if (this.parentObj.handleMouseUp == null)	return;
	
	this.parentObj.handleMouseUp(this.idx);
}
button.prototype.handleMouseUp = button_handleMouseUp;



