$(document).ready(function() {

	function close(id) {
		$(id).stop().animate({height: '0px'}, 'fast', '', function(){ $(this).hide();});
	}
	
	function open(id, magas) {
		$(id).stop().animate({height: magas}, 'fast', '', function() { $(this).show();});
	}
	
	$('a.menu_element').each(function() {
		var name = this.className.split(' ').slice(-1);
		var height = $('ul#menu_' + name).height();
		var left = parseInt($('a.' + name).position().left);
		
		$('a.' + name).mouseover(function() {
			open('ul#menu_' + name, height);
		}).mouseout(function() {
			close('ul#menu_' + name);
		});
		
		$('ul#menu_' + name).css('left', left);
		
		$('ul#menu_' + name).mouseover(function() {
			open('ul#menu_' + name, height);
		}).mouseout(function() {
			close('ul#menu_' + name);
		});
	});
	
});

function generatePassword(element, element2) {
    var pwchars = "abcdefhjmnpqrstuvwxyz23456789ABCDEFGHJKLMNPQRSTUVWYXZ.?%:/\@!,()";
    var passwordlength = 16;
    var passwd = document.getElementById(element);
    passwd.value = '';

    for ( i = 0; i < passwordlength; i++ ) {
        passwd.value += pwchars.charAt( Math.floor( Math.random() * pwchars.length ) )
    }
    
    if (element2) {
    	
    	var el2 = document.getElementById(element2);
    	el2.innerHTML = passwd.value;
    }
    return passwd.value;
}