function setClass(cls) {
document.getElementById("form-border").className=cls;
}

function Jump(theSelect){
    selindex = theSelect.selectedIndex
    selvalue = theSelect.options[selindex].value
    window.location.href = selvalue
}

function OpenJSLWindow(url, jmeno, w, h) 
{
    Fokus = window.open(url, jmeno,'resizable=1,srollbar=1,top=10,left=30,menubar=0,width=' + w + ',height=' + h);
    Fokus.focus()
}

function zobrazblok(tag) {
      var div = document.getElementById(tag);
       (div.style.display == "none") ? div.style.display = "block" : div.style.display = "none";	  
}

function count(field)
{
    var checkNUM = "0123456789";
    for (i = 0;  i < field.length;  i++)
    {
      ch = field.charAt(i);
      for (j = 0;  j < checkNUM.length;  j++)
        if (ch == checkNUM.charAt(j))
          break;
      if (j == checkNUM.length)
      {
        return(false);
        break;
      }    
    }
    return(true);
}    

function formCheck(form)		{     
			var checkOK = "0123456789.,";      
			var checkStr = form.amount.value;
			var allValid = true;
			var decPoints = 0;
			var allNum = "";
			var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
			var check=/@[\w\-]+\./;
			var checkend=/\.[a-zA-Z]{2,3}$/;

		
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
          break;
      if (j == checkOK.length)
      {
        allValid = false;
        break;
      }
      if (ch == ".")
      {
        allNum += ".";
        decPoints++;
      }
      else if (ch != ",")
        allNum += ch;
    }
    if (!allValid)
    {
      alert("Please enter only digit characters in the \"amount\" field.");
      form.amount.focus();
      return (false);
    }
    
    if (decPoints > 1)
    {
      alert("Please enter a valid number in the \"amount\" field.");
      form.amount.focus();
      return (false);
    }

		if(form.dta.value=="Select")
			{ 
			alert("Do you require your insurance to decrease alongside your repayment mortgage");
			form.dta.focus();
			return(false);
			} 
		else if(form.amount.value=="")
			{ 
			alert("Please enter the amount of cover you would like");
			form.amount.focus();
			return(false);
			} 
		else if(form.term_standard.value=="Select")
			{ 
			alert("Please enter the term of the life cover");
			form.term_standard.focus();
			return(false);
			} 	
		else if(form.company.value=="")
			{ 
			alert("You have forgotten to enter your Surename");
			form.company.focus();
			return(false);
			} 
		else if(form.bDay.value=="-")
			{ 
			alert("Please enter a valid birthdate");
			form.bDay.focus();
			return(false);
			} 
		else if(form.bMonth.value=="-")
			{ 
			alert("Please enter a valid birth month");
			form.bMonth.focus();
			return(false);
			} 
		else if(form.bYear.value=="-")
			{ 
			alert("Please enter a valid birth year");
			form.bYear.focus();
			return(false);
			}
    else if(form.sex.value=="")
			{ 
			alert("Please enter your gender");
			form.sex.focus();
			return(false);
			} 
		else if(form.smoker.value=="")
			{ 
			alert("Please confirm whether you are a smoker");
			form.smoker.focus();
			return(false);
			}
  	else if(form.upword.value=="")
			{ 
			alert("Please select a Password");
			form.upword.focus();
			return(false);
			}
    else if(form.upword.value.length<6)
			{ 
			alert("Please use at least 6 characters");
			form.upword.focus();
			return(false);
			}
    else if(form.zip.value=="")
			{ 
			alert("We require a valid Postcode");
			form.zip.focus();
			return(false);
			} 
		else if(form.phone1.value=="" && form.phone3.value=="")
			{ 
			alert("A telephone number helps us to help you");
			form.phone1.focus();
			return(false);
			}
		else if(!count(form.phone1.value))
			{ 
			alert("Please enter only digit characters in the \"phone\" field");
			form.phone1.focus();
			return(false);
			}
		else if(form.email.value=="")
			{ 
			alert("Our service operates through email only");
			form.email.focus();
			return(false);
			}
		else if(((form.email.value.search(exclude)!=-1)
				||(form.email.value.search(check)) == -1)
				||(form.email.value.search(checkend) == -1))
			{ 
			alert("Invalid email address");
			form.email.focus();
			return(false);
			} 
		else if(form.Additional_info2.value=="")
			{ 
			alert("Please select your lifestyle ratings");
			form.Additional_info2.focus();
			return(false);
			}
		else if(form.spam.value=="")
			{ 
			alert("Please fill antispam check field");
			form.spam.focus();
			return(false);
			}
	return (true);
}

function formCheck2(form)
{
	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;
  
  if(form.company.value=="")
			{ 
			alert("You have forgotten to enter your Name");
			form.company.focus();
			return(false);
			}
    else if(form.address1.value=="")
			{ 
			alert("Please enter your address");
			form.address1.focus();
			return(false);
			}  
		else if(form.phone1.value=="")
			{ 
			alert("A telephone number helps us to help you");
			form.phone1.focus();
			return(false);
			}
		else if(!count(form.phone1.value))
			{ 
			alert("Please enter only digit characters in the \"phone\" field");
			form.phone1.focus();
			return(false);
			}
		else if(form.email.value=="")
			{ 
			alert("Our service operates through email only");
			form.email.focus();
			return(false);
			}
		else if(((form.email.value.search(exclude)!=-1)
				||(form.email.value.search(check)) == -1)
				||(form.email.value.search(checkend) == -1))
			{ 
			alert("Invalid email address");
			form.email.focus();
			return(false);
			}
     else if(form.spam.value=="")
			{ 
			alert("Please fill antispam check field");
			form.spam.focus();
			return(false);
			}        
  return (true);
}


function formCheck3(form)
{
	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
	var check=/@[\w\-]+\./;
	var checkend=/\.[a-zA-Z]{2,3}$/;
  
  if(form.company.value=="")
			{ 
			alert("You have forgotten to enter your Name");
			form.company.focus();
			return(false);
			}  
		else if(form.email.value=="")
			{ 
			alert("Our service operates through email only");
			form.email.focus();
			return(false);
			}
		else if(((form.email.value.search(exclude)!=-1)
				||(form.email.value.search(check)) == -1)
				||(form.email.value.search(checkend) == -1))
			{ 
			alert("Invalid email address");
			form.email.focus();
			return(false);
			}
		else if(form.phone1.value=="")
			{ 
			alert("A telephone number helps us to help you");
			form.phone1.focus();
			return(false);
			}
		else if(!count(form.phone1.value))
			{ 
			alert("Please enter only digit characters in the \"phone\" field");
			form.phone1.focus();
			return(false);
			}
     else if(form.spam.value=="")
			{ 
			alert("Please fill antispam check field");
			form.spam.focus();
			return(false);
			}        
  return (true);
}
