// john bishop images - common Javascript

/*
	drop-down menu structure using jquery
*/
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

/*
	decode ceaser cipher (2 step)
*/

function cc2(x) {
	var y=2; var z=0; var xx=""; 
	for (var i=0; i<x.length; i++) {
		z=x.charCodeAt(i);
		xx+=String.fromCharCode(z-y);
	}
	return xx;
}

/*
	onClick function to invoke mailto: protocol
	cipher encodes name@domain.com in main HTML
	prevents bots from scanning email addresses
*/

function email(x) {
	parent.location="mailto:"+cc2(x);
	return false;
}

/*
	cycling quote banner in header
	started via <body onLoad="quoteStartTimer()">
*/

var quote_count = 0;
var quote_delay = 30000;			// delay between changing quotes in milliseconds (30 seconds)
var quote_timer_control = 0;
var quote_timer_running = 0;

var quotes = new Array();
var authors = new Array();

/*
	define quotes and authors - must be matched
*/

quotes[0] = "taking pictures is savoring life intensely,<br />every hundredth of a second.";
authors[0] = "marc riboud";
quotes[1] = "i photograph to find out what<br />something will look like photographed.";
authors[1] = "garry winogrand";
quotes[2] = "photography &#8230; is about finding something interesting in an ordinary place.";
authors[2] = "elliott erwitt";
quotes[3] = "photographs &#8230; challenge<br />our assumptions of the world<br />by making unexpected connections.";
authors[3] = "keith a. boas";
quotes[4] = "as photographers, we must learn<br />to relax our beliefs.";
authors[4] = "aaron siskind";
quotes[5] = "i don't want my soul to get caught &#8230;<br />whose only way to experience life<br />is through a viewfinder.";
authors[5] = "j. d. marston";
quotes[6] = "if the way is made clear, it is not the way.";
authors[6] = "chuang-tzu";
quotes[7] = "i am not interested in shooting new things<br />i am interested to see things new.";
authors[7] = "ernst haas";
quotes[8] = "we are not interested in the unusual<br />but in the usual seen unusually.";
authors[8] = "beaumont newhall";
quotes[9] = "personal growth can fuel our photography<br />and our photography can fuel<br />our personal growth.";
authors[9] = "brooks jensen";
quotes[10] = "great understanding is broad and unhurried; little understanding is cramped and busy.";
authors[10] = "chuang-tzu";
quotes[11] = "in photography, the smallest thing can be<br />a great subject, the little &#8230; detail<br />become a leitmotiv.";
authors[11] = "henri cartier-bresson";
quotes[12] = "the winds of grace are blowing all the time<br />all you have to do is put up your sail.";
authors[12] = "a teacher in India on receiving grace";
quotes[13] = "i often think that the night is more alive and more brightly coloured than the day.";
authors[13] = "vincent van gogh";
quotes[14] = "leap into the boundless<br />and make it your home.";
authors[14] = "chuang-tzu";
quotes[15] = "the the best way to go into an<br /> unknown territory is to go in ignorant &#8230;.";
authors[15] = "dorothea lange";
quotes[16] = "looking is a gift, but seeing is a power.";
authors[16] = "jess berner";
quotes[17] = "when out photographing,<br />it's with a sense of play: &#8230; anything<br />is possible, and the unexpected welcome.";
authors[17] = "chip forelli";
quotes[18] = "anything &#8230; i will photograph;<br />not searching for unusual subject matter<br />but making the commonplace unusual.";
authors[18] = "edward weston";
quotes[19] = "chance favors the prepared mind.";
authors[19] = "amsel adams";
quotes[20] = "to quote out of context is the<br />essence of the photographer's craft.";
authors[20] = "john szarkowski";
quotes[21] = "my best work is often almost unconscious and<br />occurs ahead of my ability to understand it.";
authors[21] = "sam abell";
quotes[22] = "i enjoy just photographing<br />the surface &#8230; it can be as revealing<br />as going to the heart of the matter.";
authors[22] = "annie leibovitz";
quotes[23] = "there is a danger in that<br />photography is so easy.<br />the taking is easy. the feeling is difficult.";
authors[23] = "paul martin lester";
quotes[24] = "light is the symbol of truth.";
authors[24] = "james russell lowell";
quotes[25] = "everything that is visible<br />hides something that is invisible.";
authors[25] = "rene magritte";
quotes[26] = "i'm looking for the unexpected. i'm looking<br />for things i've never seen before.";
authors[26] = "robert mapplethorpe";
quotes[27] = "if you can see, you can also take pictures.<br />but learning to see may take a long time.";
authors[27] = "anonymous";
quotes[28] = "the painter constructs,<br />the photographer discloses.";
authors[28] = "susan sontag";
quotes[29] = "you can't depend on your eyes<br />if your imagination is out of focus.";
authors[29] = "mark twain";
quotes[30] = "great photographs flow from who we are.<br />[they] are fueled by new ways of<br />thinking, seeing, and living.";
authors[30] = "chris orwig";
quotes[31] = "the real voyage of discovery consists<br />not in seeking new landscapes<br />but in having new eyes.";
authors[31] = "marcel proust";
quotes[32] = "the chief enemy of creativity<br />is common sense.";
authors[32] = "picasso";
quotes[33] = "creativity is taking the ordinary<br />and making it extraordinary.";
authors[33] = "chris orwig";
quotes[34] = "composition is to photography <br />as rhythm is to music.";
authors[34] = "rodney smith";
quotes[35] = "the two most engaging powers of<br />[a photographer] are to make<br />new things familiar and familiar things new.";
authors[35] = "william makepeace thackeray";

/*
	start at random quote on page load
*/

// quote_count = 35;

quote_count = Math.floor(Math.random() * quotes.length);

function nextQuoteTimer(event) {

	if (document.all) { 							// IE method
		var quote_div = document.all['quote']; 
			quote_div.innerHTML = "&#8220;" + quotes[quote_count] + "&#8221;" + "<br /><span id='author'>" + "&#8211;&nbsp;" + authors[quote_count] + "</span>";
	}
	else { 											// Open standards method
		var quote_div = document.getElementById("quote");
			quote_div.innerHTML = "&#8220;" + quotes[quote_count] + "&#8221;" + "<br /><span id='author'>" + "&#8211;&nbsp;" + authors[quote_count] + "</span>";
	}
	
//	quote_count = quote_count + 1;
//	if (quote_count >= quotes.length) { quote_count = 0 }

	quote_count = Math.floor(Math.random() * quotes.length);

	quote_timer_control = setTimeout("nextQuoteTimer()",quote_delay);
}

function startQuoteTimer(event) {
	if (!quote_timer_running) {
		quote_timer_running = 1;
		nextQuoteTimer(event);
	}
}

/*
	get around ttg pages bug - clickTarget missing
*/

function clickTarget() { 
	return false;
}
