// owenfreeman.com website variables
// preload is at bottom!

// ILLUSTRATION ORDER
// this is the list of illustration pieces. each name corresponds the the name of the jpg exactly.
// thumbnails should be named identically, with a single underscore after the filename, before the dot and extension. example: meric_.jpg
// the order of the list determines the order of the thumbnails.
var illustrationList =  ['memorial_day', 'visiting', 'idris_elba', 'naked_lunch', 'cohen_syndrome','herman_wouk', 'american_trypanosoma1', 'kind_of_blue', 'treme', 'panorama', 'eminem', 'january', 'inside_view',  'conchords', 'newyork_newyork', 'yesterdays_garbage', 'tempest', 'cirrhosis', 'to_end_all_wars', 'morello', 'malibu_creek', 'this_beautiful_life', 'aqualad', 'brutal_lemmy', 'tanker', 'mary_poppins','eight_hours', 'a_just_defiance', 'solitary_confinement', 'hollowmen', 'waiting'];

// SKETCHBOOK ORDER
// this is the list of sketchbook pieces. each name corresponds the the name of the jpg exactly.
// thumbnails should be named identically, with a single underscore after the filename, before the dot and extension. example: meric_.jpg
// the order of the list determines the order of the thumbnails.
var sketchbookList = ['natural_history', 'marlowe', 'courtyard', 'royal', 'fiftyfive', 'dustbowl_1', 'bogey', 'notebook05', 'dustbowl_2', 'birds', 'lecture', 'chinos', 'mels', 'one', 'dan_gerous', 'phantom', 'make_up', 'corner_man', 'forget_me_not', 'j_connor', 'obe', 'thunder', 'tony_bahama', 'draculaspajamaparty', 'charm', 'ad', 'litany'];

// ILLUSTRATION DESCRIPTIONS
memorial_day = "<strong>Memorial Day,</strong> illustration for <em>The New York Times</em> Op-Ed page on the origin of Memorial Day.";
visiting = "<strong>Visiting</strong>, illustration for a short story in <em>The Atlantic</em> about a father taking a trip with his estranged son.";
idris_elba = "<strong>Idris Elba,</strong> illustration for a <em>British GQ</em> feature on actor Idris Elba.";
naked_lunch = "<strong>Naked Lunch</strong>, paperback cover illustration for Harper Collins' reissue of the William Burroughs novel.";
cohen_syndrome = "<strong>Cohen Syndrome,</strong> illustration for <em>The Washington Post's</em> ongoing &quot;Medical Mysteries&quot; series.";
herman_wouk = "<strong>Herman Wouk Is Still Alive</strong>, illustration for a short story by Stephen King in <em>The Atlantic</em>.";
american_trypanosoma1 = "<strong>American Trypanosoma 1</strong>, excerpt from an epidemic inspired series of illustrations.";
kind_of_blue = "<strong>Kind of Blue</strong>, illustration for the <em>Los Angeles Times</em> book review of the novel by Miles Corwin.";
treme = "<strong>Treme</strong>, illustration for <em>The Washington Post</em> Style section preview of the HBO series &quot;Treme.&quot;";
panorama = "<strong>Panorama,</strong> illustration for the <em>Los Angeles Times</em> book review of the novel by H. G. Adler.";
eminem = "<strong>Eminem</strong>, portrait illustration for the <em>Rolling Stone</em> music review of the &quot;Recovery&quot; album.";
january = "<strong>January Jones</strong>, illustration for HeflinReps promotional series.";
inside_view = "<strong>The Inside View</strong>, illustration for <em>Securities & Investment Review</em> on insider dealing and enforcement.";
conchords = "<strong>Conchords</strong>, portrait of New Zealands' fourth most popular guitar-based digi-bongo acapella-rap-funk-comedy folk duo.";
newyork_newyork = "<strong>New York, New York</strong>, illustration for <em>New York Times</em> Op-Ed page on the 95th anniversary of Sinatra's birthday.";
yesterdays_garbage = "<strong>Yesterday&rsquo;s Garbage</strong>, illustration for a short story by Jon Hassler in <em>The Saturday Evening Post</em>.";
tempest = "<strong>Tempest</strong>, Los Angeles inspired illustration for the <em>LA Weekly</em>.";
cirrhosis = "<strong>Cirrhosis,</strong> illustration for <em>The Washington Post's</em> ongoing &quot;Medical Mysteries&quot; series.";
to_end_all_wars = "<strong>To End All Wars</strong>, illustration for the <em>Boston Globe</em> book review of the novel by Adam Hochschild.";
morello = "<strong>First Family</strong>, illustrating the brutal rise and fall of Giuseppe Morello for <em>FHM London</em>.";
malibu_creek = "<strong>Malibu Creek</strong>, Hollywood inspired illustration for the <em>LA Weekly</em>.";
this_beautiful_life = "<strong>This Beautiful Life</strong>, illustration for the <em>Boston Globe</em> book review of the novel by Helen Schulman.";
aqualad = "<strong>Aqualad</strong>, unpublished portrait.";
brutal_lemmy = "<strong>Brutal Lemmy</strong>, illustration for interview with Lemmy Kilmister in <em>Nylon Guys Magazine</em>.";
tanker = "<strong>Tanker</strong>, based on the <em>New York Times</em> article on the uptick of pirate attacks along the coast of Somalia.";
mary_poppins = "<strong>Mary Poppins</strong>, illustration for the <em>Picture Book Report</em>.";
eight_hours = "<strong>Eight Hours,</strong> illustration on sleep disorders for <em>The Washington Post's</em> Health & Science section.";
a_just_defiance = "<strong>A Just Defiance</strong>, wraparound cover illustration for the novel <em>A Just Defiance</em> by Peter Harris.";
solitary_confinement = "<strongSolitary Confinement,</strong> illustration for <em>The New York Times</em> Op-Ed page on solitary confinement.";
hollowmen = "<strong>The Hollow Men</strong>, illustration based on the poem by T.S. Eliot.";
waiting = "<strong>Waiting</strong>, illustration based on the daily risks in the lives of sex workers.";


// SKETCHBOOK DESCRIPTIONS
natural_history = "<strong>Natural History,</strong> pen/ink";
marlowe = "<strong>Marlowe,</strong> digital";
courtyard = "<strong>Courtyard,</strong> pen/ink";
royal = "<strong>Royal,</strong> ink/wash";
fiftyfive = "<strong>55,</strong> ink/wash";
dustbowl_1 = "<strong>Dustbowl 1,</strong> pencil/digital.";
bogey = "<strong>Dixon,</strong> crowquill/watercolor.";
notebook05 = "<strong>5.31,</strong> ink/watercolor.";
dustbowl_2 = "<strong>Dustbowl 2,</strong> pencil/digital.";
birds = "<strong>Birds,</strong> two-color etching/aquatint.";
lecture = "<strong>Lecture,</strong> ink.";
chinos = "<strong>Chinos,</strong> digital.";
mels = "<strong>Mel's,</strong> ink.";
one = "<strong>One,</strong> ink/wash.";
dan_gerous = "<strong>Dan Gerous,</strong> ink/digital.";
phantom = "<strong>Phantom,</strong> digital.";
make_up = "<strong>Make Up,</strong> ink/wash.";
corner_man = "<strong>Corner Man,</strong> digital";
forget_me_not = "<strong>Forget Me Not,</strong> ink/digital.";
j_connor = "<strong>J. Connor,</strong> digital.";
obe = "<strong>Old Blue Eyes,</strong> ink/digital.";
thunder = "<strong>Thunder,</strong> pastel.";
tony_bahama = "<strong>Tony Bahama,</strong> ink.";
draculaspajamaparty = "<strong>Dracula's Pajama Party,</strong> etching/aquatint.";
charm = "<strong>Charm,</strong> ink/digital.";
ad = "<strong>AD,</strong> ink/wash.";
litany = "<strong>Litany</strong>, digital.";

// PRELOAD SCRIPT
function preLoadTwo() {
Array.each.delay(4200,this,[
	['/illustration/memorial_day.jpg', '/illustration/visiting.jpg', '/illustration/idris_elba.jpg', '/illustration/naked_lunch.jpg', '/illustration/cohen_syndrome.jpg', 'illustration/herman_wouk.jpg', '/illustration/american_trypanosoma1.jpg', '/illustration/kind_of_blue.jpg', '/illustration/treme.jpg', '/illustration/panorama.jpg', '/illustration/eminem.jpg', '/illustration/january.jpg', '/illustration/inside_view.jpg', 'illustration/conchords.jpg', '/illustration/newyork_newyork.jpg', '/illustration/yesterdays_garbage.jpg', '/illustration/tempest.jpg', '/illustration/cirrhosis.jpg', '/illustration/to_end_all_wars.jpg', '/illustration/morello.jpg', '/illustration/malibu_creek.jpg', '/illustration/this_beautiful_life.jpg', '/illustration/aqualad.jpg', '/illustration/brutal_lemmy.jpg', '/illustration/tanker.jpg', '/illustration/mary_poppins.jpg', 'illustration/eight_hours.jpg', '/illustration/a_just_defiance.jpg', '/illustration/solitary_confinement.jpg', '/illustration/hollowmen.jpg', '/illustration/waiting.jpg', '/sketchbook/natural_history.jpg', '/sketchbook/marlowe.jpg', '/sketchbook/courtyard.jpg', '/sketchbook/royal.jpg', '/sketchbook/fiftyfive.jpg', '/sketchbook/dustbowl_1.jpg', '/sketchbook/bogey.jpg', '/sketchbook/notebook05.jpg', '/sketchbook/dustbowl_2.jpg', '/sketchbook/birds.jpg', '/sketchbook/lecture.jpg', '/sketchbook/chinos.jpg', '/sketchbook/mels.jpg', '/sketchbook/one.jpg', '/sketchbook/dan_gerous.jpg', '/sketchbook/phantom.jpg', '/sketchbook/make_up.jpg', '/sketchbook/corner_man.jpg', '/sketchbook/forget_me_not.jpg', '/sketchbook/j_connor.jpg', '/sketchbook/obe.jpg', '/sketchbook/thunder.jpg', '/sketchbook/tony_bahama.jpg', '/sketchbook/draculaspajamaparty.jpg', '/sketchbook/charm.jpg', '/sketchbook/ad.jpg', '/sketchbook/litany.jpg'],
	function(src){var img = new Image();img.src = src;}
]);
}


// DO NOT EDIT ANYTHING BELOW HERE
//
// functions
//

//
function slider() {
animatedcollapse.addDiv('illustration', 'fade=0,speed=300,group=art,hide=1')
animatedcollapse.addDiv('sketchbook', 'fade=0,speed=300,group=art,hide=1')
animatedcollapse.addDiv('about', 'fade=0,speed=300,group=info,hide=1')
animatedcollapse.addDiv('contact', 'fade=0,speed=300,group=info,hide=1')
animatedcollapse.init()
}

//
function illustrationThumbs() {
for (var i=0; i<illustrationList.length; i++)
{document.write('<a href="#'+illustrationList[i]+'" onclick="changeDiv(illustrationList['+i+'])"><img src="illustration/'+illustrationList[i]+'_.jpg" width="36" height="36" /></a>');}
}

//
function sketchbookThumbs() {
for (var i=0; i<sketchbookList.length; i++)
{document.write('<a href="#'+sketchbookList[i]+'" onclick="changeDivTwo(sketchbookList['+i+'])"><img src="sketchbook/'+sketchbookList[i]+'_.jpg" width="36" height="36" /></a>');}
}

// this loads content based on whether the URL has an anchor, tests to see which array that anchor is in
// and makes sure to not link to the next image if it is the last image in the array.
// FOR THE LOVE OF GOD, DON'T DELETE THESE!

// logic of loading page:
// if anchor is present
//    if that anchor is an illustration
//       if that anchor is the first illustration in the list
//          show next but not previous
//       else if that anchor is any number under the total number of illustrations in the list
//          show next AND previous
//       else if that anchor is the last illustration in the list
//         show previous but not next
//    else if that anchor is a sketch
//       if that anchor is the first sketch in the list
//          show next but not previous
//       else if that anchor is any number under the total number of sketches in the list
//          show next AND previous
//       else if that anchor is the last sketch in the list
//          show previous but not next
// else if anchor is not present
//    show the first image in the illustration list with next only


// logic of swapping illustrations from previous/next buttons, clicking on the main image (same as next), or clicking on a thumbnail:
//       if the illustration to be swapped in is the first illustration
//          show next but not previous
//       else if the illustration to be swapped in is any number under the total number of illustrations in the list
//          show next AND previous
//       else (only other possibility is the last illustration)
//         show previous but not next

// logic of swapping sketches from previous/next buttons, clicking on the main image (same as next), or clicking on a thumbnail:
//       if the sketch to be swapped in is the first sketch
//          show next but not previous
//       else if the sketch to be swapped in is any number under the total number of sketches in the list
//          show next AND previous
//       else (only other possibility is the last sketch)
//         show previous but not next


function contentLoader(){
var loadedHash = document.location.hash.replace(/#/,"");
// if the page is loaded with an anchor
if (document.location.hash)
{
// if that anchor is an illustration
if (loadedHash in oc(illustrationList) ) {

if (illustrationList.indexOf(loadedHash)==0) {
document.write('<em>Previous / </em><a href="#'+illustrationList[illustrationList.indexOf(loadedHash)+1]+'" onclick="changeDiv(illustrationList['+(illustrationList.indexOf(loadedHash)+1)+']);"><em>Next</em><br /><img src="illustration/'+document.location.hash.replace(/#/,"")+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[loadedHash]);
}
else
if (illustrationList.indexOf(loadedHash)<[illustrationList.length-1]) {
document.write('<em><a href="#'+illustrationList[illustrationList.indexOf(loadedHash)-1]+'" onclick="changeDiv(illustrationList['+(illustrationList.indexOf(loadedHash)-1)+']);">Previous</a> / </em><a href="#'+illustrationList[illustrationList.indexOf(loadedHash)+1]+'" onclick="changeDiv(illustrationList['+(illustrationList.indexOf(loadedHash)+1)+']);"><em>Next</em><br /><img src="illustration/'+document.location.hash.replace(/#/,"")+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[loadedHash]);
}
else {
document.write('<em><a href="#'+illustrationList[illustrationList.indexOf(loadedHash)-1]+'" onclick="changeDiv(illustrationList['+(illustrationList.indexOf(loadedHash)-1)+']);">Previous</a> / Next</em><br /><img src="illustration/'+document.location.hash.replace(/#/,"")+'.jpg" alt="" id="artspace" name="artspace" /><br />'+window[loadedHash]);

}
}
// if that anchor is a sketch
else
{

// (sketchbookList.indexOf(loadedHash)<[sketchbookList.length-1])

if (sketchbookList.indexOf(loadedHash)==0) {
document.write('<em>Previous / </em><a href="#'+sketchbookList[sketchbookList.indexOf(loadedHash)+1]+'" onclick="changeDivTwo(sketchbookList['+(sketchbookList.indexOf(loadedHash)+1)+']);"><em>Next</em><br /><img src="sketchbook/'+document.location.hash.replace(/#/,"")+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[loadedHash]);
}
else
if (sketchbookList.indexOf(loadedHash)<[sketchbookList.length-1]) {
document.write('<em><a href="#'+sketchbookList[sketchbookList.indexOf(loadedHash)-1]+'" onclick="changeDivTwo(sketchbookList['+(sketchbookList.indexOf(loadedHash)-1)+']);">Previous</a> / </em><a href="#'+sketchbookList[sketchbookList.indexOf(loadedHash)+1]+'" onclick="changeDivTwo(sketchbookList['+(sketchbookList.indexOf(loadedHash)+1)+']);"><em>Next</em><br /><img src="sketchbook/'+document.location.hash.replace(/#/,"")+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[loadedHash]);
}
else {
document.write('<em><a href="#'+sketchbookList[sketchbookList.indexOf(loadedHash)-1]+'" onclick="changeDivTwo(sketchbookList['+(sketchbookList.indexOf(loadedHash)-1)+']);">Previous</a> / Next</em><br /><img src="sketchbook/'+document.location.hash.replace(/#/,"")+'.jpg" alt="" id="artspace" name="artspace" /><br />'+window[loadedHash]);
}
}


}
else
{
// write the main image if there is no URL anchor
document.write('<em>Previous / </em><a href="#'+illustrationList[1]+'" onclick="changeDiv(illustrationList[1])"><em>Next</em><br /><img src="illustration/'+illustrationList[0]+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[illustrationList[0]]);
}
}
//
//


// this swaps the main div's content out with new content from the Illustration array
function changeDiv(thisPic){
if (illustrationList.indexOf(thisPic)==0)
{
document.getElementById('image').innerHTML = '<em>Previous / </em><a href="#'+illustrationList[illustrationList.indexOf(thisPic)+1]+'" onclick="changeDiv(illustrationList['+(illustrationList.indexOf(thisPic)+1)+']);"><em>Next</em><br /><img src="illustration/'+thisPic+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[thisPic];
}
else
if (illustrationList.indexOf(thisPic)<[illustrationList.length-1])
{
document.getElementById('image').innerHTML = '<em><a href="#'+illustrationList[illustrationList.indexOf(thisPic)-1]+'" onclick="changeDiv(illustrationList['+(illustrationList.indexOf(thisPic)-1)+']);">Previous</a> / </em><a href="#'+illustrationList[illustrationList.indexOf(thisPic)+1]+'" onclick="changeDiv(illustrationList['+(illustrationList.indexOf(thisPic)+1)+']);"><em>Next</em><br /><img src="illustration/'+thisPic+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[thisPic];
}

else
{
document.getElementById('image').innerHTML = '<em><a href="#'+illustrationList[illustrationList.indexOf(thisPic)-1]+'" onclick="changeDiv(illustrationList['+(illustrationList.indexOf(thisPic)-1)+']);">Previous</a> / Next</em><br /><img src="illustration/'+thisPic+'.jpg" alt="" id="artspace" name="artspace" /><br />'+window[thisPic];
}
}


// this swaps the main div's content out with new content from the Sketchbook array
function changeDivTwo(thisPic){
if (sketchbookList.indexOf(thisPic)==0)
{
document.getElementById('image').innerHTML = '<em>Previous / </em><a href="#'+sketchbookList[sketchbookList.indexOf(thisPic)+1]+'" onclick="changeDivTwo(sketchbookList['+(sketchbookList.indexOf(thisPic)+1)+']);"><em>Next</em><br /><img src="sketchbook/'+thisPic+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[thisPic];
}
else
if (sketchbookList.indexOf(thisPic)<[sketchbookList.length-1])
{
document.getElementById('image').innerHTML = '<em><a href="#'+sketchbookList[sketchbookList.indexOf(thisPic)-1]+'" onclick="changeDivTwo(sketchbookList['+(sketchbookList.indexOf(thisPic)-1)+']);">Previous</a> / </em><a href="#'+sketchbookList[sketchbookList.indexOf(thisPic)+1]+'" onclick="changeDivTwo(sketchbookList['+(sketchbookList.indexOf(thisPic)+1)+']);"><em>Next</em><br /><img src="sketchbook/'+thisPic+'.jpg" alt="" id="artspace" name="artspace" /></a><br />'+window[thisPic];
}
else
{
document.getElementById('image').innerHTML = '<em><a href="#'+sketchbookList[sketchbookList.indexOf(thisPic)-1]+'" onclick="changeDivTwo(sketchbookList['+(sketchbookList.indexOf(thisPic)-1)+']);">Previous</a> / Next</em><br /><img src="sketchbook/'+thisPic+'.jpg" alt="" id="artspace" name="artspace" /><br />'+window[thisPic];
}
}

// tests to see if a string is in an array, returns true or false
function oc(a)
{
  var o = {};
  for(var i=0;i<a.length;i++)
  {
    o[a[i]]='';
  }
  return o;
}

