// JavaScript Document
function PreloadImages(){
                MM_preloadImages('images/3on.gif','images/5on.gif','images/7on.gif','images/9on.gif','images/11on.gif','images/13on.gif','images/15on.gif')
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
}
function CheckNumber(num)
{
     if (num=="") return true;

     if(isNaN(num*1))
     {
          return true;
     }
     else
          return false;
}
function Email_refer_Validator()
{

  if (document.Email_refer.MAILFROM.value.indexOf ('@', 0) == -1 || document.Email_refer.MAILFROM.value.indexOf ('.', 0) == -1 )
  {
    alert("Please enter a value for the \"Send From E-Mail Address\" field.");
    document.Email_refer.MAILFROM.focus();
    return;
  }

  if (document.Email_refer.MAILTO.value.indexOf ('@', 0) == -1 || document.Email_refer.MAILTO.value.indexOf ('.', 0) == -1 )
  {
    alert("Please enter a value for the \"Send To E-Mail Address\" field.");
    document.Email_refer.MAILTO.focus();
    return;
  }

else {
document.Email_refer.submit();}
}
function validadd()
{
if (document.Add.firstname.value == "")
  {
    alert("Please enter a value for the \"Name\" field.");
    document.Add.firstname.focus();
    return ;
 }
if (document.Add.country.selectedIndex <= 0)
  {
    alert("Please select a value for the \"Country\" field.");
    document.Add.country.focus();
    return ;

}
if ( document.Add.Email.value.indexOf ('@', 0) == -1 || document.Add.Email.value.indexOf ('.', 0) == -1 )
{
alert("please enter a valid e-mail");
document.Add.Email.focus();
return;
}

 else document.Add.submit();
}

function Validform(){
	
	/*
	var adult='Arrivalcity';
	alert(adult);
	
	document.Add.elements[adult].value = 'test';
	alert(document.Add.elements[adult].value);
	
	var myItem = eval('document.Add.'+adult);
	myItem.value = 'TEST';
	alert(myItem.value);
	*/
	
if (document.Add.Arrivalcity.value == "")
  {
    alert("Please enter a value for the \"Arrival city\" field.");
    document.Add.Arrivalcity.focus();
    return ;
 }
 if (document.Add.MonthFrom1.value == "" || document.Add.DayFrom1.value == "" || document.Add.Time1.value == "")
  {
    alert("Please select a value for the \"Dep. Date\" field.");
    if (document.Add.MonthFrom1.value == "")document.Add.MonthFrom1.focus();
	else if (document.Add.DayFrom1.value == "")document.Add.DayFrom1.focus();
	else if (document.Add.Time1.value == "")document.Add.Time1.focus();
	
    return ;
 }
 if (document.Add.Ticket.value == "")
  {
    alert("Please select a value for the \"Ticket type\" field.");
    document.Add.Ticket.focus();
    return ;
 }
 if (document.Add.Class.value == "")
  {
    alert("Please select a value for the \"Class\" field.");
    document.Add.Class.focus();
    return ;
 }
 if(document.Add.Adults.value=='' && document.Add.Infants.value=='' && document.Add.Children.value=='')
 {
	 alert("Please enter a  value for the \"Adult passenger or Infants passenger or Children passenger\" field.");
	document.Add.Adults.focus();
	return ;
 }
 
  if (document.Add.Adults.value!='')
	 if (!IsNumeric(document.Add.Adults.value) && document.Add.Adults.value!='')
	  {
		alert("Please enter a Numeric value for the \"Adult passenger\" field.");
		document.Add.Adults.focus();
		return ;
	 }
	 else
		if(test1==0)
		{
			proceed('Adults');
			alert("Please enter a value for the \" passenger's \" fields.");
			document.Add.Adults1.focus();
			return;
		}
		else
		{
			for(i=1; i<=document.Add.Adults.value; i++)
			{
				var adult='';
				adult='Adults'+i;
				if (document.Add.elements[adult].value=='')
				{
					alert("Please enter a value for the \" passenger's \" field.");
					document.Add.elements[adult].focus();
					return;
				}
			}
		}
if (document.Add.Infants.value!='')
	if (!IsNumeric(document.Add.Infants.value))
	  {
		alert("Please enter a Numeric value for the \"Infants passenger\" field.");
		document.Add.Infants.focus();
		return ;
	 }	
	 else
		if(test2==0)
		{
			proceed('Infants');
			alert("Please enter a value for the \" passenger's \" fields.");
			document.Add.Infants1.focus();
			return;
		}
		else
		{
			for(i=1; i<=document.Add.Infants.value; i++)
			{
				var adult='';
				adult='Infants'+i;
				if (document.Add.elements[adult].value=='')
				{
					alert("Please enter a value for the \" passenger's \" field.");
					document.Add.elements[adult].focus();
					return;
				}
			}
		}
if (document.Add.Children.value!='')
	if (!IsNumeric(document.Add.Children.value))
	  {
		alert("Please enter a Numeric value for the \"Children passenger\" field.");
		document.Add.Children.focus();
		return ;
	 }
	 else
		if(test3==0)
		{
			proceed('Children');
			alert("Please enter a value for the \" passenger's \" fields.");
			document.Add.Children1.focus();
			return;
		}
		else
		{
			for(i=1; i<=document.Add.Children.value; i++)
			{
				var adult='';
				adult='Children'+i;
				if (document.Add.elements[adult].value=='')
				{
					alert("Please enter a value for the \" passenger's \" field.");
					document.Add.elements[adult].focus();
					return;
				}
			}
		}

if ( document.Add.Email.value.indexOf ('@', 0) == -1 || document.Add.Email.value.indexOf ('.', 0) == -1 )
{
alert("please enter a valid e-mail");
document.Add.Email.focus();
return;
}

 else document.Add.submit();
}
var test1=0;
var test2=0;
var test3=0;
function proceed(textfield)
{  
var coun = '';
var i;
var inputName='';
 switch(textfield)
 	{
	   case "Adults":
	   coun = '';
	   if (document.Add.Adults.value == "")
		  {
			alert("Please enter a value for the \"Adult passenger\" field.");
			document.Add.Adults.focus();
			return ;
		 }
		 else
		 if (!IsNumeric(document.Add.Adults.value))
		  {
			alert("Please enter a Numeric value for the \"Adult passenger\" field.");
			document.Add.Adults.focus();
			return ;
		 }
		 coun+='<br>';
	   for(i=1; i<=document.Add.Adults.value; i++)
		{
		inputName ='Adults'+i;
		coun+='Name of passenger '+i+'  <input  class="textfield" type="text" name='+inputName+'><br/>';
		}
		coun+='<br>';
		document.getElementById('hidefield').innerHTML=coun;
		test1=1;
		break;
		
		case "Infants":
		coun = '';
	   if (document.Add.Infants.value == "")
		  {
			alert("Please enter a value for the \"Infants passenger\" field.");
			document.Add.Infants.focus();
			return ;
		 }
		 else
		 if (!IsNumeric(document.Add.Infants.value))
		  {
			alert("Please enter a Numeric value for the \"Infants passenger\" field.");
			document.Add.Infants.focus();
			return ;
		 }
		 coun+='<br>';
	   for(i=1; i<=document.Add.Infants.value; i++)
		{
			inputName ='Infants'+i;
			coun+='Name of passenger '+i+'  <input  class="textfield" type="text" name='+inputName+'><br/>';
		}
		coun+='<br>';
		document.getElementById('hidefield1').innerHTML=coun;
		test2=1;
		break;
		
		case "Children":
		coun = '';
	   if (document.Add.Children.value == "")
		  {
			alert("Please enter a value for the \"Children passenger\" field.");
			document.Add.Children.focus();
			return ;
		 }
		 else
		 if (!IsNumeric(document.Add.Children.value))
		  {
			alert("Please enter a Numeric value for the \"Children passenger\" field.");
			document.Add.Children.focus();
			return ;
		 }
		 coun+='<br>';
	   for(i=1; i<=document.Add.Children.value; i++)
		{
			inputName ='Children'+i;
			coun+='Name of passenger '+i+'  <input  class="textfield" type="text" name='+inputName+'><br/>';
		}
		coun+='<br>';
		document.getElementById('hidefield2').innerHTML=coun;
		test3=1;
		break;
	}
	
}
function IsNumeric(strString)
   //  check for valid numeric strings
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}