//	Login.js

var j_LFirstName = true;
var j_LFirstPw   = true;
var j_LUseShadow = false;
var j_LExpanded = false;
function j_LLogin1 (lnk) {
	var dv = document.getElementById ('LoginBase1');
	if (!dv || dv.nodeName != 'DIV') { return true; }
	
	var r = document.getElementById ('registerlink');
	if (r) { r = r.href; }
	else { r = '/mshop/register/index.html'; }
	
	var f = '/mshop/Login/index.html';
	try {
		var spc = document.getElementById ('LogInLink');
		f += spc.search;
	} catch (e) {}
	
	dv.innerHTML =	'<form name="loginform" action="/mshop/Login/index.html?DoIt=1;" method="post" class="loginform" onSubmit="return j_LLogin2(this, 0);">'+
			'<span class="login">Login</span>&nbsp;<input type="text" class="loginname" size="15" maxlength="40" value="account name" onFocus="j_LNameFocus(this);" onBlur="j_LNameBlur(this);" name="LiName" id="LiName">&nbsp;'+
			'<input type="password" class="loginname" size="12" maxlength="12" name="LiPass" onFocus="j_LPwFocus(this);" onBlur="j_LNameBlur(this);" style=\"display:none; visibility:hidden;\">&nbsp;'+
			'<input type="text" class="loginname" size="12" maxlength="12" name="xLiPass" onFocus="j_LxPwFocus(this);" value=\"Password\" onBlur="j_LxPwBlur(this);">'+
			'<input type="image" src="/gg/login.gif" class="loginimage">&nbsp;'+
			'<input type="hidden" name="LiFrom" value="">'+
			'<input type="hidden" name="FrName" value="">'+
			'<span class="login"><a href="'+f+'" class="black">forgot password</a>?&nbsp;|&nbsp;<a href="'+r+'" class="black">Register</a></span>'+
			'</form>';
	j_LExpanded = true;
	return false;
}


function j_LLogin2 (frm, typ) {
	if (!typ && j_LFirstName) { return false; }

	if (!frm.LiFrom.value.length) {
		if (typeof(LiFrom) == 'string') { frm.LiFrom.value = LiFrom;  }
		else { frm.LiFrom.value = window.location.pathname; }
	}
	
	if (!frm.FrName.value.length) {
		if (typeof(FrName) == 'string') { frm.FrName.value = FrName; }
		else { frm.FrName.value = window.document.title; }
	}
	
	frm.elements[0].value = frm.elements[0].value.replace (/^\s+|\s+$/g, '');
	frm.elements[1].value = frm.elements[1].value.replace (/^\s+|\s+$/g, '');
	
	if (!frm.elements[0].value.length) { return false; }
	if (!frm.elements[1].value.length) {
		if (j_LFirstPw) { frm.elements[2].focus(); }
		else { frm.elements[1].focus(); }
		return false;
	}
	
	return true;
}

function j_LNameFocus(ctl) {
	if (j_LFirstName) { ctl.value = ''; }
	j_LFirstName = false;
	ctl.style.backgroundColor = 'yellow';
}

function j_LNameBlur(ctl) {
	ctl.style.backgroundColor = 'white';
}

function j_LPwFocus (ctl) {
	ctl.style.backgroundColor = 'yellow';
}

function j_LxPwBlur (ctl) {
	ctl.style.backgroundColor = 'white';
	if (j_LUseShadow) { ctl.form.LiPass.value = ctl.value; }
}

function j_LxPwFocus(ctl) {
	if (j_LFirstPw) {
		ctl.style.backgroundColor = 'yellow';
		try {
			ctl.form.LiPass.style.display = 'inline';
			ctl.form.LiPass.style.visibility = 'inherit';
			ctl.form.LiPass.focus();
			ctl.style.visibility = 'hidden';
			ctl.style.display = 'none';
			ctl.value = '';
		} catch (e) {
			try { ctl.form.LiPass.style.visibility = 'hidden'; } catch (e) {}
			try { ctl.form.LiPass.style.display    = 'none';   } catch (e) {}
			try { ctl.style.visibility = 'inherit'; } catch (e) {}
			try { ctl.styyle.display   = 'inline';  } catch (e) {}
			ctl.focus();
			j_LUseShadow = true;
		}
		j_LFirstPw = false;
	}
}

