
// checksubmit() has to be a function, not a subroutine, because the
// onSubmit attribute in the form tag which calls
// this function requires a Boolean return value of true or false
// if the return is true, the form is automatically submitted without
// the need to call document.formname.submit()
// if the return is false, the form submission will be aborted and the client is sent
// back to the form to fill out the missing field
//note that you use the name of the form and the field




function checksubmit(){
   
  
  if (document.regform.strUser_FirstName.value == "") {
      alert("Var god skriv förnamn för registrering av detta nyhetsbrev.")
      document.regform.strUser_FirstName.focus()
      return false
   }


  if (document.regform.strUser_LastName.value == "") {
      alert("Var god skriv efternamn för registrering av detta nyhetsbrev.")
      document.regform.strUser_LastName.focus()
      return false
   }
  
  
   // check to see if email address field is empty
   if (document.regform.strUser_email.value == "") {
      alert("Var god skriv e-postadress för registrering av detta nyhetsbrev.")
      document.regform.strUser_email.focus()
      return false
   }
   if (document.regform.strUser_email.value.length != "0") {
   	if (document.regform.strUser_email.value.indexOf("@")<2)  {
  		alert("Var god skriv e-postadress för registrering av detta nyhetsbrev.");
   		document.regform.strUser_email.focus()
   		return false;
   	} else {
		if (document.regform.strUser_email.value.indexOf(".",document.regform.strUser_email.value.indexOf("@")) < document.regform.strUser_email.value.indexOf("@")) {
			alert("Var god skriv e-postadress för registrering av detta nyhetsbrev.");
			document.regform.strUser_email.focus()
			return false;
		}
   	}
   }


   
   if (document.regform.strUser_Profession.value == "-88") {
      alert("Yrke har inte valts - Välj ett yrke i listan.")
      document.regform.strUser_Profession.focus()
      return false
   }
// check to see if gender field is empty
 blnChecked = new Boolean() 
 for(i=0; i<document.regform.strDummyE.length; i++) {
  	if (document.regform.strDummyE[i].checked) {
		blnChecked = true
	}
 }
  if (blnChecked != true){
	alert("Inget kön är valt.");
      	document.regform.strDummyE[0].focus();
     	return false
  } 



    if (document.regform.strSalesRep.value == "-99") {
      alert("Representant har inte valts - Välj en representant i listan.")
      document.regform.strSalesRep.focus()
      return false
   }
   
   	if (document.regform.strLegalApproval.value == "-2") {
      alert("Inget legalt godkännande är valt. Vänligen välj från listan.")
      document.regform.strLegalApproval.focus()
      return false
	
   }
   var newsletterChecked = false;
   
   if (document.regform.elements["eAlertID"].length > 0) 
   {
		for(var i = 0; i < document.regform.elements["eAlertID"].length; i++) 
		{
		if(document.regform.eAlertID[i].checked) 
			{
          	newsletterChecked = true; 
			}
		}

		if (!newsletterChecked)
			{
	   		alert("Nyhetsbrev har inte valts - Välj ett nyhetsbrev i listan.")
	   		return false
			}	
	}
  
   // if all fields are filled out, return true; this triggers the form submission
   return true
}



function redirectandclose(location) {
	window.open(location);
	self.close();
}
function confirmandredirectclose(location) {
	if (window.confirm("You are leaving the site. Links is nor responsible for the content of the site you are about to visit.")){
		window.open(location);
		self.close();
	}
}

function confirmandredirect(location) {
	if (window.confirm("You are leaving the site. Links is nor responsible for the content of the site you are about to visit.")){
	window.open(location);
	}
}

function PopupToMain(location) {
	if (typeof(window.opener)== "object"){
		window.opener.location = location;
		self.close();
	}else{
		window.location = location;
	}
}

function GotoLink(objLink, strRef, strPopupType) {
	if (strRef != "") {
		arrHeightWidth = strPopupType.split(";");
		MM_openBrWindow (strRef, 'download', 'width=' + arrHeightWidth[0] + ',height=' + arrHeightWidth[1] + ',resizable=yes,scrollbars=no');
	}
} 

function MM_openBrWindow(theURL,winName,features) { //v2.0
    var thewin = window.open(theURL,winName,features);
    thewin.focus;
    }
    
function CloseWindow(){
	self.close();	
}