function loginModule(){
    var strLoginBox='';
    var dir = location.href.substring(0,location.href.lastIndexOf('/')+1);
    var url = location.href.substring(dir.length,location.href.length+1).toUpperCase();

    /* Login Box Start */
    strLoginBox+='<div id="loginbox" class="logincontentbg">';
    strLoginBox+='<table border="0" cellpadding="0" cellspacing="0">';
    strLoginBox+='<tr><td><img src="images/tab_login_top.gif" width="243" height="10" alt="" border="0"></td></tr>';
    strLoginBox+='<tr><td class="loginTxt">Customer Login</td></tr>';
    strLoginBox+='<tr><td><img src="images/login_inner_top.gif" width="243" height="6" alt="" border="0"></td></tr>';
    strLoginBox+='</table>';

    /* Mutual Login Div Start */
    strLoginBox+='<div id="auto_login_tab">';
    strLoginBox+='<form name="PrimaryloginForm" action="/Amica/AWFServlet" method="post" id="PrimaryloginForm" onsubmit="return false;"><input type="hidden" name="pagename" value="loginRequest"><input type="hidden" name="application" value="PHSMemberServices"><input type="hidden" name="event" id="event" value="">';
    strLoginBox+='<table border="0" cellpadding="0" cellspacing="0" width="222" class="logininnerbg">';
    strLoginBox+='<tr><td><table border="0" cellpadding="1" cellspacing="0" height="81">';
    strLoginBox+='<tr><td colspan="2"><img src="images/spacer.gif" width="15" height="1" alt="" border="0"></td></tr>';
    if (get_cookie("iPlanetDirectoryPro")==""){
    strLoginBox+='<tr><td class="loginSpaceMd"><input tabindex="1" type="text" name="username" id="username" autocomplete="off" value="User Name" size="22" maxlength="20" onfocus="javascript:if(this.value ==\'User Name\')this.value=\'\';this.style.color=\'#000000\';" onkeypress="if (submitOnEnter(this.form,event)) { validatePage(\'CustomerLogin\');}" onblur="javascript:if(this.value == \'\'){this.value=\'User Name\';this.style.color=\'#596774\';}" style="color:#596774;font-style:verdana;font-size:11px;width:121px;"></td></tr>';   
    strLoginBox+='<tr><td class="loginSpaceMd"><input tabindex="2" type="password" name="password" id="password" autocomplete="off" size="22" maxlength="20" onfocus="this.style.background=\'#FFFFFF\'" onkeypress="if (submitOnEnter(this.form,event)) { validatePage(\'CustomerLogin\');}" onChange="this.style.background=\'#FFFFFF\'" onblur="if(this.value == \'\'){this.style.backgroundImage = \'url(/images/login_password_bg.gif)\'; this.style.backgroundRepeat = \'no-repeat\'; }" style="border: solid; border-width: 1px 1px 1px 1px; border-color: #7f9db9 #7f9db9 #7f9db9 #7f9db9; width:123px; height:15px; font-family: verdana; font-size: 11px; color: #5B5B5B; text-align: left; background-image: url(\'images/login_password_bg.gif\'); background-repeat: no-repeat; background-color:#FFFFFF"></td></tr>'; 	
    strLoginBox+='<tr><td class="loginbtngrnSS"><a href="#" name="homeLogin" title="Login" onclick="validatePage(\'CustomerLogin\');"><span>Login</span></a></td></tr>';
    strLoginBox+='<tr><td><table border="0" cellpadding="2" cellspacing="0" width="100%">';
    strLoginBox+='<tr><td colspan="2" class="loginSpacer"></td></tr>';
    strLoginBox+='<tr><td class="loginSpaceMd"><a name="forgotUserName" href="javascript:forgotUserName()">Forgot User Name</a></td><td class="loginSpaceSm" align="right"><input type="checkbox" name="rememberMeCheckbox" id="rememberMeCheckbox" value="rememberMe"><span class="orangeTxt"> Remember me<a name="homeRememberMeIcon" href="javascript:popcaseLogin(\'/customer_service/rememberMeInfoPop.html\')"><img src="images/quote_icon_info.gif" hspace="5" alt="Click here for more information" border="0"></a></span></td>';
    strLoginBox+='<tr><td class="loginSpaceMd"><a name="forgotPwCheckUser" href="javascript:forgotPwCheckUser()">Forgot Password</a></td><td class="loginSpaceSm" align="right"><a href="javascript:registerNewUser()">Create New Login</a><a name="homeCreateNewLoginIcon" href="javascript:popcaseLogin(\'/customer_service/createNewLoginPop.html\')"><img src="images/quote_icon_info.gif" hspace="5" alt="Click here for more information" border="0"></a></td>';
	} else {
	strLoginBox+='<tr><td><table border="0" cellpadding="2" cellspacing="0" width="100%">';
	strLoginBox+='<script>document.globalLogin.event.value="processLogin";</script>';
	strLoginBox+='<tr><td class="loginSpaceMd"><a name="backToYourAccount" href="#" onclick="submitForms(document.globalLogin);">Back to Your Account</a></td></tr>';
	strLoginBox+='<tr><td class="loginSpaceMd"><a name="homeLogout" href="javascript:submitForms(document.globalLogout);">Logout</a></td></tr>';
	}
    strLoginBox+='</table></td></tr>';
    strLoginBox+='<tr><td div align="center" id="errorMsg" class="errorPHS"></div></td></tr>';
    strLoginBox+='</table></td></tr>';
    strLoginBox+='<tr><td><img src="images/tab_inner_bot.gif" width="243" height="5" alt="" border="0"></td></tr>';
    strLoginBox+='<tr><td><img src="images/tab_login_bot.gif" width="243" height="10" alt="" border="0"></td></tr>';
    strLoginBox+='</table>';
    strLoginBox+='</form>';
    strLoginBox+='</div>';    

    strLoginBox+='</div>';
    document.write(strLoginBox);    
}
loginModule();
handlePersistentUserName();



function handlePersistentUserName()
{
	var cookieValue = getCookieValue('persistentUserNameCookie');
	if(cookieValue.length > 0)
	{
		if(document.getElementById('username') != null)
			document.getElementById('username').value = cookieValue;
		if(document.getElementById('rememberMeCheckbox') != null)
			document.getElementById('rememberMeCheckbox').checked = true;
	}	
}

function getCookieValue(cookieName) 
{
	var search = cookieName + "=";
	var returnValue = "";
	if (document.cookie.length > 0) 
	{
		offset = document.cookie.indexOf(search);
		// if cookie exists
		if (offset != -1) 
		{
			offset += search.length;
			// set index of beginning of value
			end = document.cookie.indexOf(";", offset);
			// set index of end of cookie value
			if (end == -1) 
			{
				end = document.cookie.length;
			}
			returnValue=unescape(document.cookie.substring(offset, end));
		}
	}
	return returnValue;
}

function showHideLoginBox()
{
    var andivDiv = document.getElementById('loginbox');
    if(!andivDiv.style.display || andivDiv.style.display=='none')
    {
        andivDiv.style.display='block';
        andivDiv.style.visibility = 'visible';
    } else
    {
        andivDiv.style.display='none';
        andivDiv.style.visibility = 'hidden';

    }
}



function hideDiv(div)
{
    if (div != null)
    {
        div.style.display='none';
        div.style.visibility = 'hidden';
    }
}

function showDiv(div)
{
    if (div != null)
    {
        div.style.display='block';
        div.style.visibility = 'visible';
    }
}

function forgotPwCheckUser() {                
        document.getElementById("event").value = "forgotPassword"
        Director.directRequest('NeedSSOPW');     
}
function forgotUserName() {                
    document.getElementById("event").value = "forgotUserName"
    Director.directRequest('ForgotUserName');              
}
function registerNewUser() {                 
    document.getElementById("event").value = "newUserRegistration"
    Director.directRequest('NewUser');            
}