var xm_ci;

Event.observe(window, 'load', function() {
			new zoomImage();
// xm_ci = new collectionImage();
		}, false);

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {

		return document[movieName];
	}
}

function popWindowScrollable(url, name, newWidth, newHeight) { /*
																 * ,
																 * height='150',
																 * width='150',
																 * toolbar='yes',
																 * directories='no',
																 * status='no',
																 * scrollbars='no',
																 * resizable='yes'
																 */
	var dim = "width=" + newWidth + ", height=" + newHeight;
	newwindow = window.open(url, 'name=' + name, 'width=' + newWidth
			+ ',height=' + newHeight + ', resizable=yes, scrollbars=yes');
			if (window.focus) {
				newwindow.focus();
			}
	return false;
}
/* general helper */
function getChildNodeById(obj, idName) {
	var items = obj.childNodes;
	for ( var i = 0; i < items.length; i++) {
		// get identifiers --> // NOTE: List is live, Adding or removing
		// children will change the list // do something with each child as
		// children[i]
		if (items[i].id == idName) {
			return items[i]; // pid = id for parant (link|ref)
		}
	};
}
function getChildNodeByName(obj, idName) {
	var items = obj.childNodes;
	for ( var i = 0; i < items.length; i++) {
		// get identifiers --> // NOTE: List is live, Adding or removing
		// children will change the list // do something with each child as
		// children[i]
		if (items[i].name == idName) {
			return items[i]; // pid = id for parant (link|ref)
		}
	};
	return;
}
function getChildinDepth(obj, idName) {
	var items = obj.childNodes;
	for ( var i = 0; i < items.length; i++) {
		// get identifiers --> // NOTE: List is live, Adding or removing
		// children will change the list // do something with each child as
		// children[i]
		if (x = getChildNodeByName(items[i], idName)) {
			return x;
		} else {
			if (x = getChildinDepth(items[i], idName)) {
				return x;
			}
		}
	};
	return 0;
}
function doc_id(elem) {
	return document.getElementById(elem);
}
function xmSubmitSearch(obj, searchFieldID, baseAddress) { // search
	if (searchFieldID) {
		Q = doc_id(searchFieldID).value;
		if (ba = doc_id(baseAddress).value) {

		} else {
			ba = baseAddress;
		}
		go = ba + '|search=' + Q;
		window.location = go;
	}
}
/** ADD BUTTON ACTIONS TO MENU */
function xmMouseOverActions(obj, action, url, newCssStyle) {
	if (obj) { // check each element, in some cases af few of the vals will not
				// exist
		switch (action) {
			case 'over':
				if (newCssStyle) {
					var oid = obj.id;
					obj.id = newCssStyle;
					// obj.style.background ='#bbb';
					return oid;
				} else {
					return 0;
				}
			case 'down':
				// goto url;
				window.location = url;
				break;
			case 'out':
				// redo oldstyle
				if (newCssStyle) {
					obj.id = newCssStyle;
				}
		}// end sitch
	}// end object
}

var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
// global functions
// short hand attr // TODO: make global
function attr(node,attributeName){
	if (!node){return '';}
	if (isIE){
		var ret = node.getAttribute(attributeName);
		if ((ret == null)||(ret == undefined)){		return '';	}
		return ret;
	}else{
		// ff/ saf/chr
		if (!node.hasAttribute){ return ''; }
		if (node.hasAttribute(attributeName)){
			return node.getAttribute(attributeName);
		}else{
			return '';
		}
	}
}	
function isArray(obj) {
	if (!obj) { return false; }
	// returns true is it is an array
	if (obj.constructor.toString().indexOf("Array") == -1)
	return false;
	else
	return true;
}
// returns the element value of the given key
function nob(data, idVal){ 
	if (!data){ return ''; }
	if (data.childNodes){
		for(var i=0; i< data.childNodes.length; i++){
			if (idVal == data.childNodes[i].nodeName){
				if (data.childNodes[i].childNodes){
					if (data.childNodes[i].childNodes[0].nodeValue){
						return data.childNodes[i].childNodes[0].nodeValue;
					}else{
						return '';
					}
				}else{
					return data.childNodes[i].nodeValue;
				}
			}
		}
	}
	return '';
}
