// JScript source code
function SubmitSelect1(value) {
if (value.name == "selCourseId"){
	document.webform.selCityId.selectedIndex = 0;
	document.webform.selCourseDateId.selectedIndex = 0;
}
if (value.name == "selCityId" && value.value == ""){
	document.webform.selCourseDateId.selectedIndex = 0;
}

	document.webform.submit();
}
		
function ValidatorWebForm(webform){
	/* Kursval */
	if (webform.selCourseId.selectedIndex == 0 )
	{		
		alert("You have to choose course city.");
		form1.selCourseId.focus();
		return (false);		
	}
	if (webform.selCourseDateId.selectedIndex == 0 )
	{		
		alert("You have to choose activity.");
		form1.selCourseDateId.focus();
		return (false);		
	}	

	
	/* Namn */
	if (document.webform.FirstName.value == "" )
	{
	  alert("First name is mandatory.");
	  document.webform.FirstName.focus();
	  return (false);
	}
	if (document.webform.LastName.value == "" )
	{
	  alert("Last name is mandatory.");
	  document.webform.LastName.focus();
	  return (false);
	}
	if (document.webform.Phone.value == "" )
	{
	  alert("Phone is mandatory.");
	  document.webform.Phone.focus();
	  return (false);
	}
	if (document.webform.Mail.value == "" )
	{
	  alert("E-mail is mandatory.");
	  document.webform.Mail.focus();
	  return (false);
	}
	
	if (document.webform.Mail.value != "" )
	{
	var checkOK = "@";
	var checkStr = document.webform.Mail.value;
	var allValid = (false);
		
   for (i = 0;  i < checkStr.length;  i++)
   {
	 ch = checkStr.charAt(i);
	  for (j = 0;  j < checkOK.length;  j++){			    
	    if (ch == checkOK.charAt(j)){	      
	      allValid = true;
	    }
	  }
	}
	if(allValid == false){	
		alert("E-mail is not valid.");
		document.webform.Mail.focus();
		return (false);  
	}

	var checkOK = ".";
	var checkStr = document.webform.Mail.value;
	var allValid = false;
		
   for (i = 0;  i < checkStr.length;  i++)
   {
	 ch = checkStr.charAt(i);
	  for (j = 0;  j < checkOK.length;  j++){			    
	    if (ch == checkOK.charAt(j)){	      
	      allValid = true;
	    }
	  }
	}
	}
	if(allValid == false){	
		alert("E-mail is not valid.");
		document.webform.Mail.focus();
		return (false);  
	}
	
	/* Företagets uppgifter */
	if (document.webform.CompanyName.value == "" )
	{
	  alert("Company name is mandatory.");
	  document.webform.CompanyName.focus();
	  return (false);
	}
	
	if (document.webform.rdoInvoiceAddress[0].checked == true )
	{
		if (document.webform.CompanyStreetAddress.value == "" && document.webform.CompanyBox.value == "")
		{
		alert("Company street address is mandatory.");
		return (false);
		}
		if (document.webform.CompanyZip.value == "" )
		{
		alert("Company zip code is mandatory");
		document.webform.CompanyZip.focus();
		return (false);
		}
		if (document.webform.CompanyCity.value == "" )
		{
		alert("Company city is mandatory");
		document.webform.CompanyCity.focus();
		return (false);
		}
		
		if (document.webform.CompanyCountry.value == "" )
		{
		alert("Company country is mandatory");
		document.webform.CompanyCountry.focus();
		return (false);
		}
	
	}
	
	if (document.webform.rdoInvoiceAddress[1].checked == true )
	{
		if (document.webform.InvoiceStreetAddress.value == "" && document.webform.InvoiceBox.value == "")
		{
		alert("Invoice street address is mandatory");
		return (false);
		}
		if (document.webform.InvoiceZip.value == "" )
		{
		alert("Invoice zip is mandatory");
		document.webform.InvoiceZip.focus();
		return (false);
		}
		if (document.webform.InvoiceCity.value == "" )
		{
		alert("Invoice city is mandatory");
		document.webform.InvoiceCity.focus();
		return (false);
		}
		
		if (document.webform.InvoiceCountry.value == "" )
		{
		alert("Invoice country is mandatory");
		document.webform.InvoiceCountry.focus();
		return (false);
		}
	}

	document.webform.hidSave.value = "True";
	alert("Your booking request will be processed.");
	document.webform.action='Formpage1.asp'
    return (true);
}
function PopUp(url,x,y) {
window.open(url,x,y);
}