// <script type="text/javascript">
<!--  to hide script contents from old browsers

window.onload = init;

function init()
{
	setup_email();
}

/**************************************************************************************************
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. In between the <span> tags will be displayed
the email address.

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['Managing'] = 'dirwbg, gmail, com';
	email_array['Exhibitions'] = 'exhibitwbg, gmail, com';
	email_array['PR'] = 'PR13wbg, gmail, com';
	email_array['Membership'] = 'memberswbg, gmail, com';
	email_array['Communications'] = 'PR13wbg, gmail, 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];

    tag.innerHTML = '<a href="mailto:' + address + '">' + address + '</a>';
}

/*********************************************************************************
This file contains most of the universally used javascript functions. It is called
by the various artist_info.js files that are unique for each artist.
*********************************************************************************/

function preload_thumbnails()
{	for (x = 0; x < n_images; x++)
	{	tn_image[x] = new Image();
		tn_image[x].src = image_file_tn[x];
	}
}


function display_target_image(file, title, medium, height, width)
{
	if (document.images)
	{
		/* If Safari loads another image and both height and with are not different, then Safari 
		stretches the image to the same width as the previous image. The following code checks if
		Safari browser, and if true, loads a 1px x 1px image before loading the new image.
		******************************************************************************************/
		safari = (navigator.userAgent.indexOf('Safari') != -1);	
		if (safari)
		{	document.images.targetImage.src = '../images/MsSpacer.gif';
		}
		
		document.images.targetImage.src = file;
	}

	if (height != "" && width != "")
	{	
		medium += ', ' + height + '"' + ' x ' + width + '"';
	}
	else
	{	
		medium += ', ' + height + '"';
	}

	/***************************************************************************************************
	The following lines work fine in all browsers except Safari. In Safari, the new strings do not 
	align properly. For example, they should be centered horizontally, but instead, the 1st string 
	displayed is properly centered, but subsequent strings are left aligned with the left position of 
	the 1st string. To get around this, display_image_info() was added.

		document.getElementById("imageName").firstChild.nodeValue = image_name[n];
		document.getElementById("imageDescription").firstChild.nodeValue = medium_string;
	
	tag = document.getElementById("imageName");
	tag.firstChild.nodeValue = image_name[n];
	tag.style.textAlign = "center";							// Attempt to center in Safari. Does not work

	tag = document.getElementById("imageDescription");
	tag.firstChild.nodeValue = medium_string;
	tag.style.marginLeft = "auto";							// Attempt to center in Safari. Does not work
	tag.style.marginRight = "auto";
	***************************************************************************************************/

	display_image_info(title, medium);
	
	return false;
}

function display_image_info(image_name, image_description)
{
	var newElem = document.createElement("p");
	var newText = document.createTextNode(image_name);
	var oldChild = document.getElementById("imageName").childNodes[0];
	document.getElementById("imageName").replaceChild(newText, oldChild);
	
	var newElem = document.createElement("p");
	var newText = document.createTextNode(image_description);
	var oldChild = document.getElementById("imageDescription").childNodes[0];
	document.getElementById("imageDescription").replaceChild(newText, oldChild);
}




// end hiding contents from old browsers  -->
// </script>