window.onload = init;

function init(){
	menuhover();
}

function menuhover(){
	var elements = document.getElementsByTagName('li');
	for( var i = 0; i < elements.length; i++ ){
		if( elements[i].className == 'parent'){
			if (typeof document.body.currentStyle != 'undefined') {
				var e = elements[i];
				if (e.lastChild.style) {
					e.onmouseover = function(){this.lastChild.style.display = 'block';}
					e.onmouseout = function(){this.lastChild.style.display = 'none';}
				}
			}
		}
		if( elements[i].className == 'login'){
			var e = elements[i];
			e.onmouseover = function(){this.className = 'loginhover';}
			e.onmouseout = function(){this.className = 'login';}
		}
	}
}

function menuopenclose(element){
	if(element.className == "parentoff") {
		element.className = "parenton";
		element.childNodes(1).display = "block";
	} else {
		element.className = "parentoff";
		element.childNodes(1).display = "none";
	}
}

function openpopup(element,target) {

	var features = ""
	if (target == "popup")
		if (navigator.appName.indexOf("Micro") >= 0) {
			var x = screen.width - 8
			var y = screen.height - 148
		} else {
			var x = event.clientX - 8
			var y = event.clientY - 148
		}
		features = "top=0,left=0,width=" + x + ",height=" + y + ",directories=no,menubar=no,resizable=yes,scrollbars=yes,titlebar =no,toolbar=no,status=yes,alwaysLowered=no,alwaysRaised=no,dependent=yes"
	window.open(element.href,target,features,true);
}

function changeviewstate(action,which) {
	if (action == "readwrite") {
		changecss('',which)
		document.getElementById(which + "ro").style.display = "none"
		document.getElementById(which + "rw").style.display = "block"
	} else {
		changecss('inputro',which)
		document.getElementById(which + "ro").style.display = "block"
		document.getElementById(which + "rw").style.display = "none"
	}
}

function changecss(value,which) {
	var elements = document.getElementById(which).getElementsByTagName("input")
	for (var i = 0; i < elements.length; i++) {
		if (elements[i].type != "button" && elements[i].type != "submit") {
			elements[i].className = value;
			elements[i].readonly = !elements[i].readonly;
			elements[i].disabled = !elements[i].disabled;
		}
	}	
}

function enlarge(userid,photoid,x,y){
	
	var features = "width=" + x + ",height=" + y + ",directories=no,menubar=no,resizable=no,scrollbars=no,titlebar =no,toolbar=no,status=no,alwaysLowered=no,alwaysRaised=no,dependent=yes"
	window.open("enlarge.asp?a=" + userid + "&b=" + photoid + "&c=" + x + "&d=" + y,"foto" + photoid,features);
	
}
