// Copyright (c) 2002-2005 Openwave Systems Inc. All rights reserved.
//
// The copyright to the computer software herein is the property of
// Openwave Systems Inc. The software may be used and/or copied only
// with the written permission of Openwave Systems Inc. or in accordance
// with the terms and conditions stipulated in the agreement/contract
// under which the software has been supplied.
//
// $Id: //webedge/webedge42-102-171-101-1/apps/src/webedge/docroot/lcommon/html/login/javascript_js.jsp#1 $







        var domain;
        var temp;
        temp = location.toString();
        temp = temp.replace(/http.*:\/\//,"");
        temp = temp.replace(/webmail\./,"");
        domain = "<sp" + "an class=\"redhilight\">" + "someone@" + temp.substring(0,temp.indexOf("/")) + "<\/s" + "pan>" + " or";

        function onKeyPressBlockNumbers(e)
	{
        	var key = window.event ? e.keyCode : e.which;
        	if (key == 13) {
               		 loginCompletion(document.loginForm);
        	}
        	return true;
	}


	function getCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}

	function loginCompletion(form) {
	   var account = document.loginForm.account.value;
	   var host    = document.loginForm.domain.value;
	   var newDomain  = host.substring(host.indexOf(".")+1);
	   var fqdn    = account.indexOf("@");
	   var locale = getCheckedValue(document.loginForm.locale);

	   if (fqdn == -1) {
	                document.loginForm.account.value = account + "@" + newDomain;
	   }

	   document.loginForm.action='/do/dologin?l=' + locale + '&v=' + document.loginForm.variant.value;
	   //document.loginForm.submit();
	   return true;
	}

