/////////////////////////////////////////////////////////////////////////
//      _
//    <' )_,  Copyright RealDecoy
//    (    )          2005
//   ~~~~~~~~
//
/////////////////////////////////////////////////////////////////////////

//	EXTERNAL LINKS
//	------------------------------------------------------------------	//
//	This script looks for all <A> tags with "REL=EXTERNAL" and assigns	//
//	a targer of "_blank".  This is needed since XHTML does not allow	//
//	<a...target="_blank"> in the XHTML code.  This JS script gets		//
//	allows new windows while still being Valid XHTML.					//

function externalLinks() {
	if (document.getElementsByTagName) {
		var anchors = document.getElementsByTagName("a");
		for (var i = 0; i < anchors.length; i++) {
			var anchor = anchors[i];
			if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
				anchor.target = "_blank";
			}
		}
	}
}
//	------------------------------------------------------------------	//





//
//	CLOSE LINKS FOR "TERMS OF USE" POP-UP WINDOW
//	------------------------------------------------------------------	//
function writeCloseLink() {
	if(document.getElementById) {
		document.write('<p class="close"><a href="#" onclick="document.getElementById(\'terms-of-use\').style.display = \'none\'; return false;">CLOSE</a></p>');
	}
}
//	--------------------------------------------------------------	//

//
//	CHANGE THE "TERMS OF USE" TEXT INTO A LINK
//	This also changes the style to allow the pop-up to work.
//	------------------------------------------------------------------	//
function setTermsOfUseAsLink() {
	if(document.getElementById) {
		
		//	Need to set this to 'none' here since if it is set in the style, Opera
		//	will not override that in the onClick event.
		document.getElementById('terms-of-use').style.display = "none";
		
		document.getElementById('terms-words').className = "terms-words-js-on";
		document.getElementById('terms-words').innerHTML = '<a href="#" onClick="document.getElementById(\'terms-of-use\').style.display = \'block\'; return false;">TERMS OF USE</a>';
		document.getElementById('terms-of-use').className = "terms-of-use-js-on";
	}
}
//	--------------------------------------------------------------	//


//
//	BACK LINKS FOR FULL-SIZED IMAGES
//	------------------------------------------------------------------	//
//	This function changes the "Back To Photo Gallery" link.  First, it	//
//	changes the link text to just "Link" and then it adds an onClick	//
//	event to use the History function to go back one page.				//

function changeBackLink() {
	if (document.getElementById) {
		
		//	Change the link text
		document.getElementById('backToGalleryLink').innerHTML = "Back";

		//	For IE, which uses the "onclick" event which needs to call a function
		if(document.all && (navigator.userAgent.toLowerCase().indexOf("opera") < 0)) {
			document.getElementById('backToGalleryLink').onclick = function() {
				history.go(-1);
				return false;
			}
		
		//	For everything else that follows the DOM
		} else {
			document.getElementById('backToGalleryLink').setAttribute('onClick', 'history.go(-1); return false;');
		}
	}
}
//	--------------------------------------------------------------	//


//	PHOTO GALLERY
//	------------------------------------------------------------------	//
//	Create the galleryImage object that will be used to randomly show	//
//	images in the right hand column.  This object has three methods:	//
//		* pageNum (string) = The number that relates to the name of 	//
//			HTML file where the larger image will be shown.  The		//
//			file name will be "imgX.html".								//
//		* isColor (boolean) = Is the image full-colour and without 		//
//			writing on it, because if not we will not show it.  This	//
//			value should be used for not only colour or not but any		//
//			image we do not want in the right-hand photos section.		//
//		* location (string) = The URL of the images						//
function galleryImage(iPageNum, bColor, fileName) {
	this.pageNum = iPageNum;
	this.isColor = bColor;
	this.location = "/gallery/hi_res/" + fileName;
}


//	Create an array to hold all of these images.						//
	var aGalleryImages = new Array();
	
	aGalleryImages.push(new galleryImage("1", 0, "a2a-colocal.jpg"));
	aGalleryImages.push(new galleryImage("2", 1, "coculture_egfp_13_15_usm_col.jpg"));
	aGalleryImages.push(new galleryImage("3", 1, "cropreserved_rat_hipocampal_neurons-on_cryopreservedastrocyte_layer_-4days_anti_gfap;antituj.jpg"));
	aGalleryImages.push(new galleryImage("4", 1, "cryoprerserved_rat_glia._anti_gfap;_hoechst.jpg"));
	aGalleryImages.push(new galleryImage("5", 1, "cryopreserved_cortical_and_striatal_cells._cocultured_21_days._anti_pgp._anti_nf.jpg"));
	aGalleryImages.push(new galleryImage("6", 0, "cryopreserved_cortical_neuronal_cells-neurotox_assay.jpg"));
	aGalleryImages.push(new galleryImage("7", 0, "cryopreserved_cortical_neuronal_cells-neurotoxicity_assay.jpg"));
	aGalleryImages.push(new galleryImage("8", 1, "cryopreserved_cpu-_day_14-_anti_pgp_&_antinf.jpg"));
	aGalleryImages.push(new galleryImage("9", 0, "cryopreserved-drg-_24dayculture-tuj.jpg"));
	aGalleryImages.push(new galleryImage("10", 1, "cryopreserved_gfp_mouse_cortical_cells_anti-synapsin.jpg"));
	aGalleryImages.push(new galleryImage("11", 1, "cryopreserved_gfp_mouse_cortical_cells._anti-synapsin.jpg"));
	aGalleryImages.push(new galleryImage("12", 1, "cryopreserved_gfp_mouse_-glia.jpg"));
	aGalleryImages.push(new galleryImage("13", 1, "cryopreserved_mouse_and_rat_neuronal_cells-_co_culture_-_21days-antiglut1antidarrp.jpg"));
	aGalleryImages.push(new galleryImage("14", 0, "cryopreserved_mouse_cortex-and_cpu._cocultured_14days-anti_synapsin_anti_darrp.jpg"));
	aGalleryImages.push(new galleryImage("15", 1, "cryopreserved_mouse_cortical_cells-cocultured_cryopreserved_gfp_mouse_striatal_cells_21days.jpg"));
	aGalleryImages.push(new galleryImage("16", 1, "cryopreserved_mouse_cortical_cells-_day_14_anti-pgp9.5.jpg"));
	aGalleryImages.push(new galleryImage("17", 1, "cryopreserved_mouse_cortical_neuronal_cells-_day_14-anti_tuj.jpg"));
	aGalleryImages.push(new galleryImage("18", 1, "cryopreserved_mouse-cortical_neuronal_cells-day_21-anti_synapsin.jpg"));
	aGalleryImages.push(new galleryImage("19", 0, "cryopreserved_mouse_cortical_neurons._anti_darpp-_12days.jpg"));
	aGalleryImages.push(new galleryImage("20", 1, "cryopreserved_mouse_cortical_neurons-_day_21;_anti-pgp9.5;_anti-tuj.jpg"));
	aGalleryImages.push(new galleryImage("21", 1, "cryopreserved_mouse_neuronal_cells-21_days_anti-vgat-anti_darpp.jpg"));
	aGalleryImages.push(new galleryImage("22", 1, "cryopreserved_mouse_neuronal_cells-_21_days_anti-vglu1-antidarpp-.jpg"));
	aGalleryImages.push(new galleryImage("23", 1, "cryopreserved_mouse_neuronal_cells-21_days-_anti-vglu1-antidarpp.jpg"));
	aGalleryImages.push(new galleryImage("24", 1, "cryopreserved_mouse_neuronal_cells-_anti-vglu1-antidarpp-_.jpg"));
	aGalleryImages.push(new galleryImage("25", 1, "cryopreserved_mouse_&_rat_neuronal_cells_day_12-_antiglut;antipgp-(gfp-mouse).jpg"));
	aGalleryImages.push(new galleryImage("26", 0, "cryopreserved_rat_astrocytes-_antigfap-day_4.jpg"));
	aGalleryImages.push(new galleryImage("27", 0, "cryopreserved_rat_astrocytes_cultured_4days_anti_gfap.jpg"));
	aGalleryImages.push(new galleryImage("28", 1, "cryopreserved_rat_caudate_putamen_neuronal_cells-day_14._giant_aspiny_neuron.jpg"));
	aGalleryImages.push(new galleryImage("29", 1, "cryopreserved_rat_co_culture_cortical_striatal_cells._medium_aspiny_neuron.jpg"));
	aGalleryImages.push(new galleryImage("30", 1, "cryopreserved_rat_cortical_and_caudate_putamen_cells_in_coculture-day_14._anti_pgp-anti_neurofilament.jpg"));
	aGalleryImages.push(new galleryImage("31", 1, "cryopreserved_rat_cortical_and_striatal_cells-cocultured_20days._anti.jpg"));
	aGalleryImages.push(new galleryImage("32", 0, "cryopreserved_rat_cortical_cell_morphology._10_days_in_culture._anti_tuj.jpg"));
	aGalleryImages.push(new galleryImage("33", 0, "cryopreserved_rat_cortical_cells_-13days-_k-fm1-43.jpg"));
	aGalleryImages.push(new galleryImage("34", 0, "cryopreserved_rat_cortical_cells_14days_in_culture-_glutamate_induced_neurotoxicity.jpg"));
	aGalleryImages.push(new galleryImage("35", 1, "cryopreserved_rat_cortical_cells._20_days_in_culture._anti-gaba;anti_gfap_images.jpg"));
	aGalleryImages.push(new galleryImage("36", 1, "cryopreserved_rat_cortical_cells-21_days_-anti_tuj;anti-synapsin.jpg"));
	aGalleryImages.push(new galleryImage("37", 1, "cryopreserved_rat_cortical_cells;_21_days._anti_vgat_anti_darpp.jpg"));
	aGalleryImages.push(new galleryImage("38", 1, "cryopreserved_rat_cortical_cells-21_days_culture-anti_vgat.jpg"));
	aGalleryImages.push(new galleryImage("39", 1, "cryopreserved_rat_cortical_cells._21_days_in_culture._anti_vgat_anti_darpp.jpg"));
	aGalleryImages.push(new galleryImage("40", 1, "cryopreserved_rat_cortical_cells._7days._anti-gfapanti-map2_hoechst.jpg"));
	aGalleryImages.push(new galleryImage("41", 1, "cryopreserved_rat_cortical_cells_anti-pgp9.5._anti_tuj.jpg"));
	aGalleryImages.push(new galleryImage("42", 1, "cryopreserved_rat_cortical_cells._anti_pgp_9.5;_hoechst.jpg"));
	aGalleryImages.push(new galleryImage("43", 1, "cryopreserved_rat_cortical_cells_antipgp_anti-neurofilament.jpg"));
	aGalleryImages.push(new galleryImage("44", 1, "cryopreserved_rat-cortical_cells._anti_pgp-anti_nf.jpg"));
	aGalleryImages.push(new galleryImage("45", 0, "cryopreserved_rat_cortical_cells.anti_tuj_-anti_gfap._7days_in_culture.jpg"));
	aGalleryImages.push(new galleryImage("46", 0, "cryopreserved_rat_cortical_cells._anti_tuj.jpg"));
	aGalleryImages.push(new galleryImage("47", 0, "cryopreserved_rat_cortical_cells-cultured_21_days_-anti_synapsin.jpg"));
	aGalleryImages.push(new galleryImage("48", 0, "cryopreserved_rat_cortical_cells._cultured_21_days._anti_vgat_anti_darpp.jpg"));
	aGalleryImages.push(new galleryImage("49", 0, "cryopreserved_rat_cortical_cells_-day_10._anti-gfap_anti_pgp_9.5.jpg"));
	aGalleryImages.push(new galleryImage("50", 0, "cryopreserved_rat_cortical_cells-day_14._anti-map2;anti-gfap;hoechst.jpg"));
	aGalleryImages.push(new galleryImage("51", 0, "cryopreserved_rat_cortical_cells._day_20._anti-gaba;anti_gfap.jpg"));
	aGalleryImages.push(new galleryImage("52", 0, "cryopreserved_rat_cortical_cells-day_21;_anti-synapsin;anti-phalloidin;anti-darrp.jpg"));
	aGalleryImages.push(new galleryImage("53", 0, "cryopreserved_rat_cortical_cells._day4_in_culture._gfp_transfection;anti_darrp_36.jpg"));
	aGalleryImages.push(new galleryImage("54", 0, "cryopreserved_rat_cortical_cells_egfptransfection._anti_darrp_36_day14_in_culture.jpg"));
	aGalleryImages.push(new galleryImage("55", 0, "cryopreserved_rat_cortical_cells_gfp_transfection_anti_darrp_36_day3_in_culture.jpg"));
	aGalleryImages.push(new galleryImage("56", 0, "cryopreserved_rat_cortical_cells._gfp_transfection-_day13._anti_darrp_36.jpg"));
	aGalleryImages.push(new galleryImage("57", 0, "cryopreserved_rat_cortical_cells_in_culture_6_days._gfp_transfection._anti_darrp_36.jpg"));
	aGalleryImages.push(new galleryImage("58", 0, "cryopreserved_rat_cortical_&_cpu_cells._cocultured_14days;antipgp;antinf.jpg"));
	aGalleryImages.push(new galleryImage("59", 0, "cryopreserved_rat_cortical_neuronal_cells-36days_in_culture._anti_gaba_anti_map2.jpg"));
	aGalleryImages.push(new galleryImage("60", 0, "cryopreserved_rat_cortical_neuronal_cells._day_21_-anti_ache.jpg"));
	aGalleryImages.push(new galleryImage("61", 0, "cryopreserved_rat_cortical_neuronal_cells-glutamate_toxicity.jpg"));
	aGalleryImages.push(new galleryImage("62", 0, "cryopreserved_rat_cortical_neuronal_cells-h2o2_toxicity.jpg"));
	aGalleryImages.push(new galleryImage("63", 0, "cryopreserved_rat_cortical_neuron;antituj-cultured_14days.jpg"));
	aGalleryImages.push(new galleryImage("64", 0, "cryopreserved_rat_cortical_neuron;antituj-day_14.jpg"));
	aGalleryImages.push(new galleryImage("65", 0, "cryopreserved_rat_cortical_neuron;antituj.jpg"));
	aGalleryImages.push(new galleryImage("66", 0, "cryopreserved_rat_cortical_neurons_cultured_on_feeder_layer_cryopreserved_rat_astrocytes.jpg"));
	aGalleryImages.push(new galleryImage("67", 0, "cryopreserved_rat_cortical_neurons_on_feeder_layer_cryopreserved_rat_astrocytes.jpg"));
	aGalleryImages.push(new galleryImage("68", 0, "cryopreserved_rat_cortical-striatal_cells-cocultured_21_days._anti_pgp9.5_anti_synapsin.jpg"));
	aGalleryImages.push(new galleryImage("69", 0, "cryopreserved_rat_cpu-_day21;_anti-darp.jpg"));
	aGalleryImages.push(new galleryImage("70", 0, "cryopreserved_rat_drg-24day_culture.jpg"));
	aGalleryImages.push(new galleryImage("71", 0, "cryopreserved_rat_drg-26days_on_micro-ruled_cover_slip.jpg"));
	aGalleryImages.push(new galleryImage("72", 0, "cryopreserved_rat_drg._7days_in_culture-anti_gap43.jpg"));
	aGalleryImages.push(new galleryImage("73", 0, "cryopreserved_rat_drg-antituj;_anticgrp.jpg"));
	aGalleryImages.push(new galleryImage("74", 0, "cryopreserved_rat_drg_cells-_anti_cgrp.jpg"));
	aGalleryImages.push(new galleryImage("75", 0, "cryopreserved_rat_drg_cells;antipgp9.5-day_24.jpg"));
	aGalleryImages.push(new galleryImage("76", 1, "cryopreserved_rat_drg_cells-colour.jpg"));
	aGalleryImages.push(new galleryImage("77", 0, "cryopreserved_rat_drg_cells-day_14-_anti_tuj(red)-anti_cgrp(green)_.jpg"));
	aGalleryImages.push(new galleryImage("78", 0, "cryopreserved_rat_drg_cells-day_24.jpg"));
	aGalleryImages.push(new galleryImage("79", 1, "cryopreserved_rat_drg_cells_.jpg"));
	aGalleryImages.push(new galleryImage("80", 1, "cryopreserved_rat_drg-day_10._anti-cgrp_and_anti-tuj.jpg"));
	aGalleryImages.push(new galleryImage("81", 0, "cryopreserved_rat_drg._day_24.jpg"));
	aGalleryImages.push(new galleryImage("82", 0, "cryopreserved_rat_drg_growth_cone-images_taken_by_tirf.jpg"));
	aGalleryImages.push(new galleryImage("83", 0, "cryopreserved_rat_drg_psuedounipolar_cell.jpg"));
	aGalleryImages.push(new galleryImage("84", 1, "cryopreserved_rat_hippocampal_cells_cultured_4days_on_glia_feeder_layer.jpg"));
	aGalleryImages.push(new galleryImage("85", 1, "cryopreserved_rat_hippocampal_cells._day_7._anti_vglut_anti_synapsin.jpg"));
	aGalleryImages.push(new galleryImage("86", 1, "cryopreserved_rat_hippocampal_cells-on_cryopreserved_astrocytes-_96well_antigfap-anti_pgp.jpg"));
	aGalleryImages.push(new galleryImage("87", 0, "cryopreserved_rat-hippocampal_neuronal_cells-21_days._anti_pgp-anti_synapsin.jpg"));
	aGalleryImages.push(new galleryImage("88", 0, "cryopreserved_rat-hippocampal_neuronal_cells-anti_glur1.jpg"));
	aGalleryImages.push(new galleryImage("89", 0, "cryopreserved_rat_hippocampal_neuronal_cells_cultured_on_mea(neurochip).jpg"));
	aGalleryImages.push(new galleryImage("90", 0, "cryopreserved_rat_hippocampal_neurons-21days-_anti_synapsin;_anti_glur1.jpg"));
	aGalleryImages.push(new galleryImage("91", 1, "cryopreserved_rat_hippocampal_neurons_day_14;_ant-pgp9.5_anti-synapsin.jpg"));
	aGalleryImages.push(new galleryImage("92", 1, "cryopreserved_rat_neuronal_cells-_anti_map2.jpg"));
	aGalleryImages.push(new galleryImage("93", 0, "cryopreserved_rat_neuronal_cells_culutred_in_micro-islands.jpg"));
	aGalleryImages.push(new galleryImage("94", 1, "cryopreserved_rat_striatal_cells_cultured_12days_anti-pgp9.5;anti-tuj.jpg"));
	aGalleryImages.push(new galleryImage("95", 1, "cryopreserved_rat_striatal_cells-cultured_12days-antituj;antipgp.jpg"));
	aGalleryImages.push(new galleryImage("96", 1, "cryopreserved_rat_striatal_cells-cultured_12days-antituj;antipgp_.jpg"));
	aGalleryImages.push(new galleryImage("97", 0, "cryopreserved_rat_striatal_neuronal_cells_3-20days_in_culture-anti_gaba.jpg"));
	aGalleryImages.push(new galleryImage("98", 1, "cryopreserved_rat_striatal_neurons-14days._anti-gaba;anti-tuj.jpg"));
	aGalleryImages.push(new galleryImage("99", 1, "cryopreserved_rat_striatal_neurons-day_10._anti-gfap;anti_pgp9.5(green).jpg"));
	aGalleryImages.push(new galleryImage("100", 0, "cryopreserved_&_transfected_big_projection_neuron.jpg"));
	aGalleryImages.push(new galleryImage("101", 0, "cryopreserved_&_transfected_rat_big_projection_neurons.jpg"));
	aGalleryImages.push(new galleryImage("102", 0, "drg_density_fig.jpg"));
	aGalleryImages.push(new galleryImage("103", 0, "growth_curve-cryopreserved_rat_cortical_neuronal_cells.jpg"));
	aGalleryImages.push(new galleryImage("104", 0, "montage-cryopreserved_cells_cultured_day1-14.jpg"));
	aGalleryImages.push(new galleryImage("105", 0, "mouse-cortical-syn-1.jpg"));
	aGalleryImages.push(new galleryImage("106", 0, "mouse-darpp-cortical.jpg"));
	aGalleryImages.push(new galleryImage("107", 0, "neurochemistry_of_cryopreserved_rat_brain_neuronal_cells_in_culture.jpg"));
	aGalleryImages.push(new galleryImage("108", 1, "rat_cortical_cell-growth_pattern.jpg"));
	aGalleryImages.push(new galleryImage("109", 1, "Cerebellar1.jpg"));
	aGalleryImages.push(new galleryImage("110", 1, "cardiac-6.jpg"));
	aGalleryImages.push(new galleryImage("111", 1, "cardiac-2.jpg"));
	aGalleryImages.push(new galleryImage("112", 1, "cardiac-11.jpg"));
	aGalleryImages.push(new galleryImage("113", 1, "cardiac-1.jpg"));
	aGalleryImages.push(new galleryImage("114", 1, "Cerebellar2.jpg"));


//	The setRandomPhotos function counts how many images there are, and	//
//	then randomly picks an image and link to fill in.					//
function setRandomPhotos() {
		//	Set a variable as the images within the "photos" DIV
		var thePhotos = document.getElementById("photos").getElementsByTagName("IMG");
	
		//	An array to hold the images that have been picked to prevent dupes
		var aTempImages = new Array();
		
		//	Cycle through these images to replace them.
		for (var a = 0; a < thePhotos.length; a++) {
			
			//	Set this variable here so it is reset each loop through, but cann
			//	access it within the FOR loop.
			var iRnd;
			
			//	Want to make sure the image is wrapped in an "A" tag
			if(thePhotos.item(a).parentNode.tagName == "A") {
			
				//	Assign a random image/link to each of the items in the photo
				//	DIV.  Use a Do / WHILE loop since this will need to execute
				//	at least once, so we are making sure the isColor property is
				//	true and we have not used this number alreadt.
				do {
					
					//	Random number
					iRnd = Math.floor(Math.random() * aGalleryImages.length);
					
					//	Temporary boolean value assuming that iRnd is *not* in the
					//	array unless proven otherwise.
					var bIsUnique = true;
					
					//	Compare this value with others already in the array
					for (var b = 0; b < aTempImages.length; b++) {
						if (iRnd == aTempImages[b]) {	//	If the value is there...	
							bIsUnique = false;			//	Set bIsUnique to false
						}
					}			
					thePhotos.item(a).parentNode.href = "/gallery/img" + aGalleryImages[iRnd].pageNum + ".html";
					thePhotos.item(a).src = aGalleryImages[iRnd].location;
				} while ((!aGalleryImages[iRnd].isColor) || (!bIsUnique))
			}
			
			//	Since we are out of the do / while loop, we will add the iRnd value
			//	to the array.
			aTempImages.push(iRnd);
		}
}

