        function closePopup(e)
        {
	    jQuery ( '#Popup' ).remove();
	    jQuery( '#PopupBackground' ).remove();
	    if (jQuery.browser.msie) if (e) e.preventDefault();	
        }

		function validateUser()
		{
		var userid = jQuery('#f_userid').attr('value');
		var password = jQuery('#f_pwd').attr('value');
		//alert("checking user....");user id: SEPPLATING Password: plating1979 

		if ((userid == "") || ((userid != "") && (userid != "SEPPLATING")))
		{
		jQuery ('#useriderrorCode').show();
		jQuery ('#pwderrorCode').show();
		}
		if ((userid == "SEPPLATING") && (password != "plating1979"))
		{
		jQuery ('#useriderrorCode').hide();
		jQuery ('#pwderrorCode').show();		
		}
        if ((userid == "SEPPLATING") && (password == "plating1979"))
		{
		jQuery ('#useriderrorCode').hide();
		jQuery ('#pwderrorCode').hide();
		closePopup();
		window.location.href = 'http://sepvmsp1/sep/plating';
		}		
		
		}


        function staffLogin()
        {
		var content = '<form id="DownloadForm" method="post" class="popupForm" action="#">';
		content += '<fieldset><div class="formItem fi1 clear"><div id="useriderrorCode" class="f_error_text">Please enter a valid user id</div><label for="f_userid">User   ID :</label><div class="fi_content"><input type="text" id="f_userid" name="userid" size="40" class="ft_text" maxlength="40" value=""></div></div><br/><br/><p/>';
        content += '<div class="formItem fi1 clear"><div id="pwderrorCode" class="f_error_text">Please enter a valid password</div><label for="f_pwd">Password :</label><div class="fi_content"><input type="password" id="f_pwd" name="password" size="40" class="ft_text" maxlength="35" value=""></div></div><br/><br/><br/><br/>';
		content += '<div class="formButtons"><strong class="buttonBlue"><input id="submitLogin" type="button" name="submitLogin" value="Login"></strong><strong>  </strong><a id="Cancel" class="button" href="#"><span>Cancel</span></a></div>';	
        content += '</fieldset></form>';		
		var popupElement = jQuery( '<div id="Popup" class="genericRoundedCorners genericPopup"><div class="header"><div class="headerContent"><p>Staff Login</p><div class="closeButton"><a href="#" class="buttonBlueClose"><span>close</span></a></div></div></div><div class="content clearfix">' + content + '</div><div class="bottom"><div class="bl"></div><div class="br"></div><div class="b"></div></div></div>' );
		popupElement.find( '.closeButton a' ).bind( 'click', closePopup );
        popupElement.find( '#Cancel' ).bind( 'click', closePopup );		
		popupElement.find( '#submitLogin' ).bind( 'click', validateUser );

		jQuery ( '#container' ).append( popupElement );
		$('#useriderrorCode').hide();
		$('#pwderrorCode').hide();
		var positions = ( jQuery( window ).height() / 2 ) - ( popupElement.height() / 2 );

		jQuery('#Popup').css( { top:positions+'px' } );

		if ( jQuery.browser.msie && parseInt( jQuery.browser.version ) == 6 ) jQuery( window ).bind( 'scroll', position );

		// render backdrop
		jQuery ( '#container' ).append( jQuery( '<div id="PopupBackground"></div>' ).css( { width:jQuery( window ).width()+'px', height:jQuery( window ).height()+'px' } ) );
		
        }

        function position()	
		{
		var positions = ( jQuery( window ).height() / 2 ) - ( jQuery('#Popup').height() / 2 );
		if ( jQuery.browser.msie && parseInt( jQuery.browser.version ) == 6 ) positions += document.documentElement.scrollTop;
		jQuery('#Popup').css( { top:positions+'px' } );		
		jQuery ( '#PopupBackground' ).css( { top:document.documentElement.scrollTop+'px' } );
		jQuery ( '#PopupBackground' ).css( { width:jQuery( window ).width()+'px', height:jQuery( window ).height()+'px' } );
		}
