function logIn(retpage) {
	if (document.getElementById) {
		if (retpage != undefined) {
			$('membersret').value = retpage;
		}
		if (document.getElementById('retmessage'))
			Element.hide('retmessage');
		if (Element.visible('members')) {
			Element.hide('members');
		} else {
			Element.show('members');
		}
	}
}

function HasClass(obj,cName){ return (!obj || !obj.className)?false:(new RegExp("\\b"+cName+"\\b")).test(obj.className) }
function AddClass(obj,cName){ if (!obj) return; if (obj.className==null) obj.className=''; return obj.className+=(obj.className.length>0?' ':'')+cName; }
function KillClass(obj,cName){ if (!obj) return; return obj.className=obj.className.replace(RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),''); }

function sameSize(variable) {
	var max = 0;
	var max_id = 0;
    var argv = sameSize.arguments;
	
	if (document.getElementById) {
			for (var i = 0; i < argv.length; i++) {
				if (!document.getElementById(argv[i]))
					continue;
				val = document.getElementById(argv[i]).offsetHeight;
		  		if (val > max) {
					max = val;
					max_id = i;
				}
			}
			for (var i = 0; i < argv.length; i++) {
				if (!document.getElementById(argv[i]))
					continue;
				document.getElementById(argv[i]).style.height = max+'px';				
			}
	}
}

function alignBottom(variable) {
	
	var max = 0;
   	var argv = alignBottom.arguments;
	
	if (document.getElementById) {
			for (var i = 0; i < argv.length; i++) {
				element = document.getElementById(argv[i]);
				if (element != null) {
					var kids = element.parentNode.childNodes;
					var totalHeight = 0;
					
					for (var j = 0; j < kids.length; j++) {
						 if (kids[j] != element && kids[j].offsetHeight > 0 && !HasClass(kids[j], 'dontcount')) {
							totalHeight += kids[j].offsetHeight;
						}
					}
					height_el = element.offsetHeight;
					height_par = element.parentNode.offsetHeight;
					element.style.marginTop = (height_par-height_el-totalHeight)+'px';
				}
			}
	}
}


function menuOver(element, cls) {
	var kids = element.parentNode.childNodes;
	if (cls == undefined) {
		cls = 'boxhover';
	}
	for (var j = 0; j < kids.length; j++) {
		if (kids[j].nodeName == "DIV" && Element.hasClassName(kids[j], 'box')) {
			Element.addClassName(kids[j], cls);
			return;
		}
	}
}

function menuOut(element, cls) {
	var kids = element.parentNode.childNodes;
	if (cls == undefined) {
		cls = 'boxhover';
	}				
	for (var j = 0; j < kids.length; j++) {
		if (kids[j].nodeName == "DIV" && Element.hasClassName(kids[j], 'box')) {
			Element.removeClassName(kids[j], cls);
			return;
		}
	}
}
function visibilityHide(element) {
	if (document.getElementById) {
		element = document.getElementById(element);
		if (!HasClass(element, 'elhide')) {
			KillClass(element, 'elvisible');
			AddClass(element, 'elhide');
		}
	}
}

function visibilitySwitch(element) {
	if (document.getElementById) {
		element = document.getElementById(element);
		if (HasClass(element, 'elhide')) {
			KillClass(element, 'elhide');
			AddClass(element, 'elvisible');
		} else {
			KillClass(element, 'elvisible');
			AddClass(element, 'elhide');
		}
	}		
}

function inputEnter(element, val, leave) {
	if (leave == undefined) 
		leave = '';
	if (element.value == val) {
		element.value = leave;
	}
}

function inputLeave(element, val, leave) {
	if (leave == undefined) 
		leave = '';
	if (element.value == leave) {
		element.value = val;
	} else if (element.value == '') {
		element.value = val;
	}
}

function showMaximized(path) {
	var w=window;
	var width=screen.availWidth;
	var height=screen.availHeight;
	var props="width="+width+",height="+height+",top=0,left=0,scrollbars=yes,resizable=yes";
	var win = window.open(path, "w4bpopup", props);
	win.focus();
}

function showSlideshow(color, id, startid, size, startnow) {
	showMaximized("/popup.html?id="+id+"&color="+color+"&startid="+startid+"&startnow="+startnow+"&size="+size);
	
}

////////////////////////////////////////////////////////////////////////

var Initall = Class.create();

Initall.prototype = {
	initialize : function() {
   		this.initArr = new Array;
 	},
	
 	attachFunction : function(func) { 
		this.initArr.push(func);
	},
	
	onProcess : function() {
		try {
			this.initArr.each(function(item, index) {
				try {
					item();
				} catch (ee) {
					; // nothing
				}
			})
		} catch (e)	{
			
			; // nothing
		}
	}
}

initall = new Initall();

function init() {
	// quit if this function has already been called
	if (arguments.callee.done) return;
	
	// flag this function so we don't do the same thing twice
	arguments.callee.done = true;
	
	initall.onProcess();
};

/* init section */

/* for Mozilla/Opera9 */
if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
}

/* for Internet Explorer */
/*@cc_on @*/
/*@if (@_win32)
    document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
    var script = document.getElementById("__ie_onload");
    script.onreadystatechange = function() {
        if (this.readyState == "complete") {
            init(); // call the onload handler
        }
    };
/*@end @*/

/* for Safari */
if (/WebKit/i.test(navigator.userAgent)) { // sniff
    var _timer = setInterval(function() {
        if (/loaded|complete/.test(document.readyState)) {
            init(); // call the onload handler
        }
    }, 10);
}

/* for other browsers */
window.onload = init;

// menu initialization
initall.attachFunction(function() {
	if (!document.getElementById) return;
	sameSize('left', 'right', 'middle');
	
	var agt=navigator.userAgent.toLowerCase();
	var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie7up   = (is_ie && (is_major == 7) && (agt.indexOf("msie 7.")!=-1) );
	
	if (!is_ie7up) {
		// align footer
		prevheight = $('footer').offsetHeight;
		hgh = $('middle').offsetHeight - $('footer').offsetTop - 58  - 30  - 4 ;
		$('footer').style.height = hgh+'px';
		// align footer text
		if ((hgh - prevheight + 30) > 0) {
			$('subfooter').style.paddingTop = (hgh - prevheight + 30)+'px';
		}
	} 
});



