//PMU 17.10.2011: Ny cookie for SM R12
function saveSMCookie(domain) {
	var date = new Date();
	date.setTime(date.getTime()+(600*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "logonURL="+encodeURI(window.location.href)+expires+"; domain="+domain+"; path=/";
}
function eraseSMCookies()
{
	eraseCookie('LtpaToken');
	eraseCookie('SMSESSION');
	eraseCookie('SMIDENTITY');
	eraseCookie('INTERNALSMSESSION');
	eraseCookie('LogonURL');
}
function checkForm() {
   eraseSMCookies();
   saveSMCookie(".storebrand.no");
   createCookie('LtpaToken', 'nothingatall', -1);
    var feil = "";	
	ant = 0;
	if (document.frmLogin.USER.value=="")  {
		ant +=1;
		feil +=  "Brukernavn (Fødselsnummer, 11 siffer)\n";
	}
	if (document.frmLogin.PASSWORD.value=="")  {
		ant +=1;
		feil +=  "Passord\n";		
	}
 
    if (feil != "") {
      if (ant==1) {
         alert("For å logge deg inn på Storebrands Internett-tjeneste må du fylle ut feltet:\n" + feil);
         feil="";
         ant=0;
         return false;
         }
      if (ant>=2) {
         alert("For å logge deg inn på Storebrands Internett-tjeneste må du fylle\nut følgende felter:\n\n" + feil);
         feil="";
         ant=0;
         return false;	
         }
      }
	  return true;	  
}
function submitForm(frm,nb){ 
if (checkForm() ) {
       createCookie("bplogin","n",0)
       frm.submit();
   }
} 
function checkFormBp() {
   eraseSMCookies();
   saveSMCookie(".storebrand.no");
   createCookie('LtpaToken', 'nothingatall', -1);
    var feil = "";	
	ant = 0;
	if (document.frmLoginBp.USER.value=="")  {
		ant +=1;
		feil +=  "Brukernavn (Fødselsnummer, 11 siffer)\n";
	}
	if (document.frmLoginBp.PASSWORD.value=="")  {
		ant +=1;
		feil +=  "Passord\n";		
	}
 
    if (feil != "") {
      if (ant==1) {
         alert("For å logge deg inn i Bedriftsportalen må du fylle ut feltet:\n" + feil);
         feil="";
         ant=0;
         return false;
         }
      if (ant>=2) {
         alert("For å logge deg inn i Bedriftsportalen må du fylle\nut følgende felter:\n\n" + feil);
         feil="";
         ant=0;
         return false;	
         }
      }
	  return true;	  
}
function submitFormBp(frm,nb){ 
if (checkFormBp() ) {
       createCookie("bplogin","y",0)
       frm.submit();
   }
} 

