// <script type="text/javascript">
<!--  to hide script contents from old browsers

/**************************************************************************************
The variable "images_per_page" must be set equal to the number of images to display
per page.

File types of images must be jpg and end with extension ".jpg". There must be 2 files 
for each image--a thumbnail 75 pixels high and a larger image (currently no more than 
300 pixels high or 500 pixels wide). The thumbnail image file must be the exact same 
name as the larger image file, but with "_tn" appended to the end of the name. For 
example, "image1.jpg" and "image1_tn.jpg"

Filenames are case-sensitive and it is recommended to not have spaces in the file name. 
If spaces are used, then '%20' must be inserted wherever a space occurs.

When filling in the arrays below, the filename only needs to be specified once and without
the jpg extension. The 2 files specified in the preceding paragraph would be entered: 
image_file[0] = "image1"
**************************************************************************************/

window.onload = init;

function init()
{	
	display_urhere();
	setup_email();
	set_newWindow();
}

/* This function alters the style of the navigation bar to indicate urhere.
I added code from the original to shorten the href string so that it does
not include any bookmarks (....#bookmark). Otherwise, the strings would not
match and the urhere formatting would not be applied.
******************************************************************************/

function display_urhere()
{	
	var href;
	
	if (!document.getElementById)
	{	
		return;
	}

	var list = document.getElementById("navbar");
	var page = list.getElementsByTagName("a");
	var currentHref = document.location.href;

	var anchorPosition = currentHref.indexOf("#");
	if (anchorPosition >= 0)
	{	currentHref = currentHref.substring(0, anchorPosition);
	}

	currentHref = getSimpleHref(currentHref);

	for (var i = 0; i < page.length; i++)
	{	
		href = getSimpleHref(page[i].href)	

		if (href.length != currentHref.length)
			continue;

		// The following allows the navbar urhere to display for multiple sub pages.
		// For example, bouquets1.html and bouquets2.html
		a = currentHref.indexOf('.');
		temp_currentHref = currentHref.substring(0, a-1) +currentHref.substring(a, 100);
		
		b = href.indexOf('.');
		temp_href = href.substring(0, b-1) + href.substring(b, 100);

		if (temp_href == temp_currentHref)
		{	
			page[i].style.background = "#fff";
			page[i].style.color = "#000";
			//page[i].style.borderTop= "1px solid rgb(164, 179, 200)";
			//page[i].style.borderBottom= "1px solid rgb(164, 179, 200)";
			//page[i].style.verticalAlign= "middle";

			break;
		}
	}
	
	// Set urhere for Services subnavigation sidebar
	var id = document.getElementById("page-nav");
	if (id != null)
	{
		display_page_urhere(id);
	}
}

/**************************************************************************************************
This function was added because Mac Safari does not include the directory structure
before the href, so there was never a match. This function strips the beginning directory structure
away and just leaves the end part--such as about_us.htm
**************************************************************************************************/

function getSimpleHref(s)
{	var length;
	var anchorPosition = 0;	

	while (anchorPosition >= 0)
	{	anchorPosition = s.indexOf('/');
		length = s.length;

		if (anchorPosition >= 0)
		{	s = s.substring(anchorPosition + 1, length);
		}		
	}
	
	return(s);
}

/*******************************************************************************
This function sets the urhere for the subnavigation sidebar.  
*******************************************************************************/

function display_page_urhere(id)
{	
	var href;
	var page = id.getElementsByTagName("a");
	var currentHref = document.location.href;

	var anchorPosition = currentHref.indexOf("#");
	if (anchorPosition >= 0)
	{	currentHref = currentHref.substring(0, anchorPosition);
	}

	currentHref = getSimpleHref(currentHref);

	for (var i = 0; i < page.length; i++)
	{	
		href = getSimpleHref(page[i].href)	

		if (href == currentHref)
		{	
			page[i].style.color = "#000";
			page[i].style.background = "#a5092e";
			page[i].style.fontWeight = "bold";
			page[i].style.textDecoration = "none";

			//page[i].parentNode.style.background = "#fff";		// Parent node is <li>
			//page[i].parentNode.style.width = "150px";			// Parent node is <li>
			
			break;
		}
	}
}

/**************************************************************************************************
This function sets up a links associated with class names to send email. Email address cannot
be read by spambots. email_array is an associative array. Each array corresponds to 1 email address.

To use in html code, as an exampke, add <span class="emailMichele"></span> where each
email address has an email**** associated with it.

To add another email address, add to email_array.
**************************************************************************************************/

function setup_email()
{
	// Get all <span> tags
	var tags = document.getElementsByTagName("span");

	for (var i = 0; i < tags.length; i++)
	{
		// Get className of <span> tag
		var cname = tags[i].className;

		// Now look for classes that begin with 'email'
		var s = cname.indexOf('email');

		// If <span> tag and class starts with 'email'
		if (s == 0)
		{
			// Get index to email_array (strip off 'email')
			index = cname.substring(5);
			insert_email(tags[i], index);
		}
	}
}

/**************************************************************************************************
This function sets up a links associated with class names to send email. Email address cannot
be read by spambots. email_array is an associative array. Each array corresponds to 1 email address.

To use in html code, as an exampke, add <span class="emailMichele"></span> where each
email address has an email**** associated with it.

To add another email address, add to email_array and add another case statement.
**************************************************************************************************/
function insert_email(tag, index)
{
	var email_array = new Array();
	email_array['Dee'] = 'DeeSanchezArt, hotmail, com';

	var temp = email_array[index];

	// Remove any spaces, leave commas
	while (temp.indexOf(' ') != -1)
		temp = temp.replace(' ', '');

	// Split email string by commas
	var temp = temp.split(',');

	address = temp[0] + '@' + temp[1] + '.' + temp[2];

	// Hack to get around IE not inserting space after <span> tag
	// Automatically insert a space unless a period or comma follows.
	if (tag.nextSibling === null)
		var x = 0;
	else
		var x = tag.nextSibling.nodeValue.charAt(0);

	if (x == '.' || x == ',')
		tag.innerHTML = '<a href="mailto:' + address + '">' + address + '</a>';
	else
		tag.innerHTML = '<a href="mailto:' + address + '">' + address + '</a> ';
}

/**************************************************************************************************
This function causes a new window to open for any link <a> that has class "newWindow".
Remember that if the specified element does not exist, getElementsByTagName returns a NodeList of
length 0.
**************************************************************************************************/

function set_newWindow()
{	
	var anchors = document.getElementsByTagName("a");

	for (var i = 0; i < anchors.length; i++)
	{	
		if (anchors[i].className == "newWindow")
		{
			anchors[i].onclick = function()
			{
				window.open(this.href); 
				return false;
			}
		}
	}
}

/*******************************************************************************
It’s simple. It works just how you think getElementsByClass would work, except better.

1. Supply a class name as a string.

2. (optional) Supply a node. This can be obtained by getElementById, or simply by just 
throwing in “document” (it will be document if don’t supply a node)). It’s mainly useful 
if you know your parent and you don’t want to loop through the entire D.O.M.

3. (optional) Limit your results by adding a tagName. Very useful when you’re toggling 
checkboxes and etcetera. You could just supply “input“. Or, if you’re like me, and you 
said Good Bye to IE5, you can use the “*” asterisk as a catch-all (meaning ‘any element).
*******************************************************************************/
function getElementsByClass(searchClass, node, tag) 
{
	var classElements = new Array();
	
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
		
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	
	var pattern = new RegExp("(^|\s)"+searchClass+"(\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) 
	{
		if ( pattern.test(els[i].className) ) 
		{
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/******************************************************************************
 Names of image files without the jpg extension
/*****************************************************************************/

var folder = 'newwork/';		// Folder where all images are kept
var current_image_number = 0;			// Global variable to indicate what image is currently displayed
var DIV_FACTOR = 2; 

var current_image_array = new Array;
var main_image = new Array();
var main_image_loaded = new Array();

// Oil paintings
var series_oils_p1 = new Array(				
'396971-R1-E001', 'Behind Adobe Walls',
'396971-R2-E002', 'Hillside Riot',
'396971-R2-E003', 'Hollyhock Pathway',
'396971-R2-E004', 'Luau in the Desert',
'396971-R2-E005', 'Grass Menagerie',
'396971-R2-E006', 'Floral Path',
'396971-R2-E007', 'Aspen Hillside',
'396971-R2-E008', 'Vino del Valle',
'396971-R2-E009', 'Three Waiting',
'396971-R2-E010', 'Homegrown',
'396971-R3-E011', 'Coyote Fenceline',
'396971-R3-E012', 'Bouquet over Blue'
)

var series_oils_p2 = new Array(				
'396971-R4-E013', 'Wild Spring',
'396971-R4-E014', 'The Cutting Garden',
'396971-R4-E015', 'My Chimayo',
'396971-R5-E016', 'Spring Yellows II',
'396971-R5-E017', 'Red Duet',
'396971-R5-E018', 'NM Bouquet Tryptich left',
'396971-R5-E019', 'NM Bouquet Tryptich center',
'396971-R5-E020', 'NM Bouquet Tryptich right',
'396971-R5-E021', 'Majestic',
'396971-R5-E022', 'Three in Harmony',
'396971-R5-E023', 'Autumn Hills',
'396971-R5-E024', 'Through the Purple'
)

var series_oils_p3 = new Array(				
'396971-R5-E025', 'Among the Flowers',
'396971-R5-E026', 'Autumn Beauties',
'396971-R5-E027', 'Natives',
'396971-R5-E028', 'Autumn Canyon',
'396971-R5-E029', 'Spring Yellows',
'396971-R5-E030', 'Windowpots',
'396971-R5-E031', 'Poppy Meadow',
'396971-R6-E032', 'Bouquet Tryptich',
'396971-R6-E033', 'Blanket Hill',
'396971-R6-E034', 'Through the Grass',
'396971-R6-E035', 'Aspen Glade',
'396971-R6-E036', 'The View Beyond'
)

var series_oils_p4 = new Array(				
'396971-R6-E037', 'Hidden Glade',
'396971-R6-E038', 'Wild Spring II',
'396971-R6-E039', 'Forest Path',
'396971-R6-E040', 'Red Geraniums',
'396971-R6-E041', 'Poppies and Friends',
'396971-R6-E042', 'Ornaments I',
'396971-R6-E043', 'Ornaments II'
)

var series_oils_p5 = new Array(				
'403866_001', 'Homegrown Pears',
'403866_002', 'Royal Trio',
'403866_004', 'Below the Rim',
'403866_003', 'Placitas Path',
'403866_005', 'Placitas Wash-Subdued',
'403866_006', 'Chimayo Peace',
'403866_007', 'Taos Ridge',
'403866_012', 'Uno',
'403866_009', 'Algodones Sunset',
'403866_010', 'Rusty Hills',
'403866_011', 'Protection',
'403866_008', 'Placitas Arroyo'
)

var series_oils_p6 = new Array(				
'403866_013', 'Approaching Storm',
'403866_014', 'Single',
'403866_015', 'Serenity on Fire',
'403866_016', 'Duet',
'403866_017', 'Sunflower Menagerie',
'403866_018', 'Poppy Field',
'403866_019', 'Coneflower Menagerie',
'403866_020', 'Poppie Meadow II',
'403866_023', 'Coyote Fence',
'403866_021', 'Autumn Vines',
'403866_022', 'Fire Poppies',
'403866_024', 'EveningSplendor'
)

var series_oils_p7 = new Array(				
'403866_025', 'Chile Fields',
'403866_027', 'Heading Home',
'403866_028', 'Blossoms',
'403866_029', 'Little Church',
'403866_030', 'Tulips REaching',
'403866_031', 'Misty Wild',
'403866_032', 'Placitas Clouds',
'403866_033', 'Jemez Ridge',
'403866_034', 'Autumn Splendor',
'403866_035', 'Poppy Banquet',
'403866_026', 'Evening at Dusk'
)


/******************************************************************************
This function displays thumbnail images of all the paintings in a series.
******************************************************************************/

function display_thumbnail_paintings(page)
{
	var offset, i, j;
	var image_file;
	var n_columns = 4;
	
	if (page == 1)
		current_image_array = series_oils_p1;
	else if (page == 2)
		current_image_array = series_oils_p2;
	else if (page == 3)
		current_image_array = series_oils_p3;
	else if (page == 4)
		current_image_array = series_oils_p4;
	else if (page == 5)
		current_image_array = series_oils_p5;
	else if (page == 6)
		current_image_array = series_oils_p6;
	else
		current_image_array = series_oils_p7;

	NUMBER_OF_IMAGES = current_image_array.length / DIV_FACTOR;

	document.write('<table class="thumbnail-table">');

	for (i = 0, j = 0; i < NUMBER_OF_IMAGES; i++)
	{	offset = i * DIV_FACTOR;
	
		image_file = folder + current_image_array[offset];
		big_file = image_file + '.jpg';
		thumb_file = image_file + 'thumb.jpg';
		image_name = current_image_array[offset + 1];

		if (j == 0)
			document.write('<tr> \n');

		document.write('<td> \n');
		document.write('<a href="#" onClick="jkpopimage(' + "'" + big_file + "'" + ', 600, 500, ' + "'" + image_name + "'" + ');' + ' return false;" >');     
		document.write('<img id="tn' + i + '" ' + 'class="thumbnail" src="' + thumb_file + '"' + ' >');
		document.write('</a> \n');		
		document.write('<p>' + image_name + '</p>');		
		document.write('</td> \n');

		if (j == 3)
			document.write('</tr> \n');
			
		if (j++ == 3)
			j = 0;
	}

	document.write('</table>');
}

/******************************************************************************
From Luke Heath's files.
******************************************************************************/

var popbackground="C77E28" 
var windowtitle="Dee Sanchez Portfolio"  

function jkpopimage(imgpath, popwidth, popheight, textdescription)
{
	popwidth = 600;
	popheight = 500;

	if (screen.height == 600)
		toppos = 0;
	else
		toppos = (screen.height-popheight)/2;
	
	leftpos = (screen.width-popwidth)/2;
	
	if (leftpos < 0) leftpos = 0;
	if (toppos < 0) toppos = 0;

	var winattributes='width='+popwidth+',height='+popheight+',resizable=no,left='+leftpos+',top='+toppos
	var bodyattribute=(popbackground.indexOf(".")!=-1)? 'background="'+popbackground+'"' : 'bgcolor="'+popbackground+'"'

	if (typeof jkpopwin=="undefined" || jkpopwin.closed)
		jkpopwin=window.open("","",winattributes)
	else
	{
		//getpos() //uncomment these 2 lines if you wish subsequent popups to be centered too
		jkpopwin.moveTo(leftpos, toppos)
		jkpopwin.resizeTo(popwidth, popheight+30)
	}
	
	jkpopwin.document.open()
	jkpopwin.document.write('<html><title>'+windowtitle+'</title>');
	jkpopwin.document.write('<body ' + bodyattribute + 'style="font-family: arial, helvetica, sans-serif; text-align: center">');
	jkpopwin.document.write('<img src="' + imgpath + '">');
	jkpopwin.document.write('<p style="margin: 0px; padding: 10px 0px 5px 0px">' + textdescription + '</p>');
	jkpopwin.document.write('<p style="margin: 0px; padding: 0px"><a href="javascript:window.close()">Close Window</a></p></body></html>')
	jkpopwin.document.close()
	jkpopwin.focus()
}


// end hiding contents from old browsers  -->
// </script>