// http://www.dustindiaz.com/top-ten-javascript/ Array.prototype.push = function(value) {  this[this.length] = value;}function toggleHTML(textid,f,s){	var tgo = document.getElementById(textid);	if(tgo.innerHTML != s){		tgo.innerHTML =s;	}else{		tgo.innerHTML =f;	}}function getElementsByClassName(className, parentElement) {  var children = ($(parentElement) || document.body).getElementsByTagName('*');  return $A(children).inject([], function(elements, child) {    if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)")))      elements.push(child);    return elements;  });}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;}function togIm(imId,o,n) {	var tgo = document.getElementById(imId);	var path = 'http://tibet.prm.ox.ac.uk/';	if ( tgo.src != path+'graphics/'+o ) {		tgo.src = path+'graphics/'+o;	}else {		tgo.src = path+'graphics/'+n;	}}function swIm(imId,n) {	var tgo = document.getElementById(imId);	var path = 'http://tibet.prm.ox.ac.uk/';	if ( tgo.src != path+'graphics/'+n ) {		tgo.src = path+'graphics/'+n;	}}function toggleImage(obj , jpgfile) {	var tgo = document.getElementById(obj);	var path = 'http://tibet.prm.ox.ac.uk/photos/';	if ( tgo.src != path+'opt/95/'+jpgfile ) {		tgo.src = path+'opt/95/'+jpgfile;	}else {		tgo.src = path+'opt/300/'+jpgfile;	}}function toggleRawImage(obj , jpgfile) {	var tgr = document.getElementById(obj);	var path = 'http://tibet.prm.ox.ac.uk/photos/';	if ( tgr.src != path+'raw/95/'+jpgfile ) {		tgr.src = path+'raw/95/'+jpgfile;	}else {		tgr.src = path+'raw/400/'+jpgfile;	}}function toggleText() {	a=toggleText.arguments;	for(i=0; i<a.length; i++){		if(tt = document.getElementById(a[i])){		  if ( tt.style.display != 'none' ) {			tt.style.display = 'none';		  }else {			tt.style.display = 'block';		  }		}	}}function toggleStyle(n,s,y) {// will toggle the class of element of id (n) between 2 styles s & y	if(tt = document.getElementById(n)){		if ( tt.className != y ) {			tt.className = y;		  }else {			tt.className = s;		  }			}}// http://www.bigbold.com/snippets/posts/show/1596 function compareImage(imType , imageFile){var path = 'http://tibet.prm.ox.ac.uk/photos/';var blnDOMSUPPORT = (document.getElementById) ? true : false;	if ( blnDOMSUPPORT ){		var el = document.getElementById('toCompare');		var imgNew = document.createElement('img');		//el.src = path+imType+'/400/'+imageFile;		imgNew.src = path+imType+'/400/'+imageFile;		imgNew.id = 'toCompare';		var divParent;		divParent = el.parentNode;		divParent.replaceChild(imgNew, el);	}else{		document.images['toCompare'].src = path+imType+'/400/'+imageFile;	}}function getCookie(Name) {	var search = Name + "="		if (document.cookie.length > 0) { // if there are any cookies			offset = document.cookie.indexOf(search) 			if (offset != -1) { // if cookie exists 				offset += search.length 				// set index of beginning of value				end = document.cookie.indexOf(";", offset) 				// set index of end of cookie value				if (end == -1) 					end = document.cookie.length				return unescape(document.cookie.substring(offset, end))			} 		}}function setCookie(value) {	var today = new Date();	var expire = new Date();	expire.setTime(today.getTime() + 60*60*24*30);	lastCookie = getCookie('myalbum');	document.cookie = "myalbum=" +lastCookie +"~"+ escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));}//my album javascriptfunction saveAnotationCookie(head,value) {// save any annotations head is the heading (accn number or notes or title) value is whatever user enters in form 	var today = new Date();	var expire = new Date();	expire.setTime(today.getTime() + 60*60*24*30);	document.cookie = head+"=" + escape(value) + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()));}function saveAlbum(){     if(document.myform.updateBut.value != 'updating' ){     toSave = getElementsByClass('userform');          for (var i in toSave) {                    saveAnotationCookie(toSave[i].name,toSave[i].value)          }    }}function deleteCookie( name, path, domain ) {	if ( getCookie( name ) ) document.cookie = name + '=' +			( ( path ) ? ';path=' + path : '') +			( ( domain ) ? ';domain=' + domain : '' ) +			';expires=Thu, 01-Jan-1970 00:00:01 GMT';}
