// JavaScript Document
function load_iframe(url, domNode, width, height, myclass) {
	exists = false;
	nodeId = 0;
	htmlId = hash(url);
	for(i=0;i<domNode.childNodes.length;i++) {
		cObj = domNode.childNodes[i];
		if((cObj.nodeType == 1) && (cObj.getAttribute('src') == url)) {
			exists = true;
			nodeId = i;
		}
	}
	if(!exists) {
		embryo = document.createElement('iframe');
		embryo.setAttribute('width', width);
		embryo.setAttribute('height', height);
		embryo.className = myclass;
		embryo.id = htmlId;
		embryo.setAttribute('src',url);
		domNode.appendChild(embryo);
	}
	else {
		cObj = domNode.childNodes[nodeId];
		cObj.setAttribute('width', width);
		cObj.setAttribute('height', height);
		cObj.id = htmlId;
		cObj.className = myclass;
	}
} 
function good_place(node) {
	return node.parentNode.parentNode.nextSibling.firstChild;
}
function suicide() {
	id = hash(document.baseURI)
	child = (parent.document.getElementById(id)) ? parent.document.getElementById(id) : parent.document.getElementsByTagName('iframe')[0];
	child.parentNode.removeChild(child);
}
function resize_me() {
	id = hash(document.baseURI)
	child = (parent.document.getElementById(id)) ? parent.document.getElementById(id) : parent.document.getElementsByTagName('iframe')[0];
	if(child.getAttribute('height') < document.height) {
		child.setAttribute('height',document.height+10);
	}
}
function hash(text) {
	// don't consider this secure in anyway :)
	num = 65536;
	for(var i=0;i<text.length;i++) {
		num += text.charCodeAt(i)*Math.pow(3,i);
	}
	return dec2hex(num).substr(0,16);
}
function dec2hex(int){
	var len=16
	var base = 'abcdefghijklmnop';
	var ret='';
	while(int>0){
		ret = base.charAt(int%len) + ret;
		int = Math.floor(int/len);
	}
	return ret;
}