function login_flip(what) {
	if (what == 1) {
		$('login_login').setStyle('display', 'none');
		$('login_pswd').setStyle('display', 'block');
	} else {
		$('login_login').setStyle('display', 'block');
		$('login_pswd').setStyle('display', 'none');
	}
}
function login(show) {

	if (show == 1) {
		
		$('login_shader').setStyle('opacity', 0);
		$('login_shader').setStyle('display', 'block');
		
		$('login_shader').effect('opacity', {duration: 500, transition: Fx.Transitions.linear, onComplete: function() {
			
			$('login_form').setStyle('display', 'block');
			$('login_form').setStyle('position', 'absolute');
			$('login_form').setStyle('z-index', '100');
		
			$('login_form').setStyle('left', ((getWidth() - $('login_form').getSize().size.x) / 2) + 'px');
			$('login_form').setStyle('top', '200px');
			
			$('login_korime_1').focus();
			
		}}).start(0.8);
	
	} else {
	
		$('login_form').setStyle('display', 'none');
		
		$('login_shader').effect('opacity', {duration: 500, transition: Fx.Transitions.linear, onComplete: function() {
		
			$('login_shader').setStyle('display', 'none');
			
		}}).start(0);
		
	}

}

function login_check() {
	
	if ($('login_korime').getValue() == '' || $('login_pswd').getValue() == '') {
	
	
	} else {
	
		$('login_former').submit();
	
	}

}
function send_pswd() {
	var username = $('for_username').getValue();
	var mail = $('for_mail').getValue();
	if (username != '' && mail != '' && echeck(mail) == true) {
		new Ajax('http://wm.com.hr/index.php?module=ajax&function=zaboravljena_lozinka', {
			method: 'post', 
			data: 'username='+username+'&email='+mail,
			onComplete: function() {
				$('for_stat').setStyle('display', 'block');
			},
			update: $('for_stat')
		}).request();;
	}
}
function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
		return false
	}
		
	if (str.indexOf(" ")!=-1){
	    return false
	}

	return true;
}