<!--

//CREDIT CARD EXAMPLE =4012888888881881

function Method1()
	{
		document.getElementById("Method1").style.visibility = "visible";
		document.getElementById("Method2").style.display = "none";
		document.getElementById("Method1").style.display ="block";
	}

function Method2()
	{
		document.getElementById("Method2").style.visibility = "visible";
		document.getElementById("Method2").style.display = "block";
		document.getElementById("Method1").style.display = "none";
	}


/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: David Leppek :: https://www.azcode.com/Mod10

Basically, the alorithum takes each digit, from right to left and muliplies each second
digit by two. If the multiple is two-digits long (i.e.: 6 * 2 = 12) the two digits of
the multiple are then added together for a new number (1 + 2 = 3). You then add up the 
string of numbers, both unaltered and new values and get a total sum. This sum is then
divided by 10 and the remainder should be zero if it is a valid credit card. Hense the
name Mod 10 or Modulus 10. */
function Mod10(ccNumb) {  // v2.0
var valid = "0123456789"  // Valid digits in a credit card number
var len = ccNumb.length;  // The length of the submitted cc number
var iCCN = parseInt(ccNumb);  // integer of ccNumb
var sCCN = ccNumb.toString();  // string of ccNumb
sCCN = sCCN.replace (/^\s+|\s+$/g,'');  // strip spaces
var iTotal = 0;  // integer total set at zero
var bNum = true;  // by default assume it is a number
var bResult = false;  // by default assume it is NOT a valid cc
var temp;  // temp variable for parsing string
var calc;  // used for calculation of each digit

// Determine if the ccNumb is in fact all numbers
for (var j=0; j<len; j++) {
  temp = "" + sCCN.substring(j, j+1);
  if (valid.indexOf(temp) == "-1"){bNum = false;}
}

// if it is NOT a number, you can either alert to the fact, or just pass a failure
if(!bNum){
  /*alert("Not a Number");*/bResult = false;
}

// Determine if it is the proper length 
if((len == 0)&&(bResult)){  // nothing, field is blank AND passed above # check
  bResult = false;
} else{  // ccNumb is a number and the proper length - let's see if it is a valid card number
  if(len >= 15){  // 15 or 16 for Amex or V/MC
    for(var i=len;i>0;i--){  // LOOP throught the digits of the card
      calc = parseInt(iCCN) % 10;  // right most digit
      calc = parseInt(calc);  // assure it is an integer
      iTotal += calc;  // running total of the card number as we loop - Do Nothing to first digit
      i--;  // decrement the count - move to the next digit in the card
      iCCN = iCCN / 10;                               // subtracts right most digit from ccNumb
      calc = parseInt(iCCN) % 10 ;    // NEXT right most digit
      calc = calc *2;                                 // multiply the digit by two
      // Instead of some screwy method of converting 16 to a string and then parsing 1 and 6 and then adding them to make 7,
      // I use a simple switch statement to change the value of calc2 to 7 if 16 is the multiple.
      switch(calc){
        case 10: calc = 1; break;       //5*2=10 & 1+0 = 1
        case 12: calc = 3; break;       //6*2=12 & 1+2 = 3
        case 14: calc = 5; break;       //7*2=14 & 1+4 = 5
        case 16: calc = 7; break;       //8*2=16 & 1+6 = 7
        case 18: calc = 9; break;       //9*2=18 & 1+8 = 9
        default: calc = calc;           //4*2= 8 &   8 = 8  -same for all lower numbers
      }                                               
    iCCN = iCCN / 10;  // subtracts right most digit from ccNum
    iTotal += calc;  // running total of the card number as we loop
  }  // END OF LOOP
  if ((iTotal%10)==0){  // check to see if the sum Mod 10 is zero
    bResult = true;  // This IS (or could be) a valid credit card number.
  } else {
    bResult = false;  // This could NOT be a valid credit card number
    }
  }
}
// change alert to on-page display or other indication as needed.
if(bResult) {
  alert("This IS a valid Credit Card Number!");
}
if(!bResult){
  alert("This is NOT a valid Credit Card Number!");
}
  return bResult; // Return the results
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateEmail(){
	var emailID=document.form1.Email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function ValidateCreditCard()
{
	var btn = valButton(form1.Card_type);
	if (btn == null) 
	{
		alert("Please put your card type ...")
		document.form1.Card_type.focus();
	}
	else
	{
		var cc = Mod10(document.form1.Card_number.value);
		if (cc==false)
		{
			//alert("Please put your card number ...")
			document.form1.Card_number.focus();
		}
		else
		{
			if (form1.Month_expiration.selectedIndex == 0) 
			{
				alert("Please put your month expiration ...")
				document.form1.Month_expiration.focus();
			}
			else
			{
				if (form1.Year_expiration.selectedIndex == 0) 
				{
					alert("Please put your year expiration ...")
					document.form1.Year_expiration.focus();
				}
				else
				{
					if (document.form1.Name_on_card.value=="")
					{
						alert("Please put your name on card ...")
						document.form1.Name_on_card.focus();
						return false;
					}
					else
					{
						return true;
					}
				}
			}
		}
	}

}

function checkCheckBoxes()
{
	if ( form1.checkbox.checked == false ) 
	{
		alert("Please check in I accept the prices ...")
		document.form1.checkbox.focus();
	}
	else 
	{
		if (form1.checkbox2.checked == false) 
		{
			alert("Please check in I accept the conditions ...")
			document.form1.checkbox2.focus();
		}
		else
		{
			return true;
		}
	}
}

function valButton(btn) 
{
var cnt = -1;
for (var i=btn.length-1; i > -1; i--) {
   if (btn[i].checked) {cnt = i; i = -1;}
   }
if (cnt > -1) return btn[cnt].value;
else return null;
}


function validateAcommodation(objForm)
{
	var returnStatus = 1;
	
	//alert (objForm.acommodation.selectedIndex);

	if (objForm.acommodation.selectedIndex == 0) 
	{
		var btn = valButton(form1.type_acomm);
		if (btn == null) 
			{
				return false;
			}
		else
			{
				return true;
			}
	}
	else
	{
	   return true;
	}
	
}

function CourseofInterest0(objForm)
{
	if ((objForm.type1.selectedIndex == 0)&& (objForm.type1.selectedIndex == 0))
	{
		alert("Please put Profesional Spanish Course or/and Standard Spanish Course ...")
		objForm.type1.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function CourseofInterest1(objForm)
{
	if (objForm.type.selectedIndex == 0) 
	{
		alert("Please put type for Course of Interest  ...")
		objForm.type.focus();
		return false;
	}
	else
	{
		if (objForm.week.selectedIndex == 0) 
		{
			alert("Please put week for Course of Interest  ...")
			objForm.week.focus();
			return false;
		}
		else
		{
			if (objForm.star.selectedIndex == 0) 
			{
				alert("Please put star for Course of Interest  ...")
				objForm.star.focus();
				return false;
			}
			else
			{
				return true;
			}
		}
	}
}


function validateCours(objForm)
{
	if (objForm.cours.selectedIndex == 0) 
	{
		return false;
	}
	else
	{
	   return true;
	}
}

function validateStar(objForm)
{
	if (objForm.Star.selectedIndex == 0) 
	{
		return false;
	}
	else
	{
	   return true;
	}
}

function checkRadioBoxes(theForm)
{
	if (
	theForm.checkbox.checked == false &&
	theForm.checkbox2.checked == false) 
	{
		return false;
	}
	else 
	{ 	
		return true;
	}
}

function validate(string) {
    if (!string) return false;
    var Chars = "0123456789-";

    for (var i = 0; i < string.length; i++) {
       if (Chars.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
} 

function checkForm()
{
	if (document.form1.First_Name.value=="")
	{
		alert("Please put your name ...")
		document.form1.First_Name.focus();
	}
	else
	{
		if (document.form1.Last_Name.value=="")
		{
			alert("Please put your last name ...")
			document.form1.Last_Name.focus();
		}
		else
		{
			if (document.form1.City.value=="")
			{
				alert("Please put your city ...")
				document.form1.City.focus();
			}
			else	
			{
				if (document.form1.Phone.value=="")
				{
					alert("Please put your Telephone / Fax ...")
					document.form1.Phone.focus();
				}
				else	
				{
					var vemail = ValidateEmail();
					if (vemail== false)
					{
						//alert("Please put your Email ...")
						document.form1.Email.focus();
					}
					else
					{
						if (document.form1.Nationality.value=="")
						{
							alert("Please put your nationality ...")
							document.form1.Nationality.focus();
						}
						else
						{	
							var btn = valButton(form1.Sex);
							if (btn == null) 
							{
								alert("Please put your sex ...")
								document.form1.Sex.focus();
							}
							else
							{
								if (document.form1.text_larn.value=="")
								{
									alert("Please put When and how did you learn Spanish? ...")
									document.form1.text_larn.focus();
								}
								else
								{
									if (document.form1.text_content.value=="")
									{
										alert("Please put What contents have you studied ? ...")
										document.form1.text_content.focus();		
									}
									else
									{
										var btn1 = valButton(form1.course_interest);
										if (btn1 == null) 
										{
											alert("Please put Course of Interest ...")
											document.form1.type.focus();
										}
										else	
										{
											var  x2 = CourseofInterest1(document.form1);
											if (x2 == false)
											{
												//alert("Please put Private Cours ...")
												//document.form1.cours.focus();
											}
											else
											{
												var  x = validateAcommodation(document.form1);
												if (x == false)
												{
													alert("Please put your acommodation ...")
													document.form1.acommodation.focus();
												}
												else
												{
													var btn = valButton(form1.method_);
													if (btn == null) 
													{
														alert("Please put your payment ...")
														document.form1.method_.focus();
													}
													else
													{
														var i	
														for (i=0;i<document.form1.method_.length;i++)
														{
															if (document.form1.method_[i].checked)
																break;
														}
														if (form1.method_[i].value =="bank")
														{
															var btn = valButton(form1.bank);
															if (btn == null) 
															{
																alert("Please select your bank ...")
																document.form1.bank.focus();
																completo == false;
															}
															else
															{
																var chk1 = checkCheckBoxes();
																if (chk1 == true )
																{
																	document.form1.submit();
																}
															}
														}
														else
														{
															var c1 = ValidateCreditCard();
															if (c1 == true)
															{
																var chk1 = checkCheckBoxes();
																if (chk1 == true )
																{
																	document.form1.submit();
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}