


function addLoadEvent(func) {
	// Found at:
	// http://simonwillison.net/2004/May/26/addLoadEvent/
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) { oldonload(); }
			func();
		}
	}
}

function getElementsByClassName(className, tag, elm){
	// Found at:
	// http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/
	var testClass = new RegExp("(^|\\\\s)" + className + "(\\\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements;
}

function UGal_ResizeGalleries() {

	galleries = getElementsByClassName("gallery_embed", "iframe");
	
	for (var i=0; i<length; i++) {
		//alert(galleries[i].name);
		var child_dom = false;
		try {
			window.frames[galleries[i].name].document.body
			child_dom = true;
		}
		catch (err) {
			//child_dom = false;
		}

		//if (window.frames[galleries[i].name].document.body) {
		if (child_dom) {
			var frame_height = window.frames[galleries[i].name].document.body.scrollHeight
			galleries[i].style.height = frame_height;
		}
		/*else if (window.location.hash.indexOf("#h:") == 0) {
			height = window.location.hash.substr(3) - 0 + 0;
			document.getElementById("gallery2").style.height = height + "px";
			window.location.hash = "#";
		}*/
	}

	/*var hash = document.location.hash;
	if (hash.indexOf("#h:") == 0) {
		height = hash.substr(3) - 0 + 0;
		document.getElementById("iframename").style.height = height + "px";
		document.location.hash = "#";
		//alert("resized");
	}*/
	//alert(document.getElementById("iframename").location.host);
}

//addLoadEvent(SetIFrameHeightFromHash);
addLoadEvent(UGal_ResizeGalleries);

