function checkrequired(which) {
var DFrom=document.FlightSearch.SelectCountry.selectedIndex;
var DTo=document.getElementById("Destination").selectedIndex;
if(DFrom=="0")
{
alert("Please Select Country")
document.FlightSearch.SelectCountry.focus();
return false;
}

if(DTo=="0")
{
alert("Please Select Destination")
document.getElementById("Destination").focus();
return false;
}

document.getElementById("SelectCountryVal").value=document.getElementById("SelectCountry").options[document.FlightSearch.SelectCountry.selectedIndex].text
document.getElementById("SelectDestinationVal").value=document.getElementById("Destination").options[document.getElementById("Destination").selectedIndex].text
document.getElementById("DurationVal").value=document.getElementById("Duration").options[document.FlightSearch.Duration.selectedIndex].text
document.getElementById("agerangeVal").value=document.getElementById("ageRange").options[document.FlightSearch.ageRange.selectedIndex].text
var groupType=document.FlightSearch.groupType.selectedIndex;
if(groupType=="0")
{
alert("Please Select groupType")
document.FlightSearch.groupType.focus();
return false;
}
var ageRange=document.FlightSearch.ageRange.selectedIndex;
document.getElementById("GrpVal").value=document.getElementById("groupType").options[document.FlightSearch.groupType.selectedIndex].text
document.getElementById("currencyVal").value=document.getElementById("currency").options[document.FlightSearch.currency.selectedIndex].text
if (document.FlightSearch.requiredConfEmail.value!="")
{
	if (document.FlightSearch.requiredEmail.value!=document.FlightSearch.requiredConfEmail.value)
	{
		alert("Email address must be same")
		document.FlightSearch.requiredEmail.focus();
		return false;
	}
}
//remove_XS_whitespace();
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if(tempobj.type=="text"||tempobj.type=="textarea"){
	remove_XS_whitespace(tempobj);
}

if (tempobj.name.substring(0,8)=="required") {
if (((tempobj.type=="text"||tempobj.type=="textarea") && tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s" && tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(8,30).toUpperCase();
alert("All fields marked * are mandatory.\nPlease ensure that mandatory information is properly entered.");
tempobj.focus();
return false;
}
else if(ageRange=="0")
{
	alert("Please Select ageRange")
	document.FlightSearch.ageRange.focus();
	return false;
}
else

return emailCheck(document.FlightSearch.requiredEmail.value);

}
function emailCheck (emailStr) {
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null) {
alert("Email address seems incorrect (check @ and .'s)");
document.FlightSearch.requiredEmail.focus()
return false;
}
var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}
if (user.match(userPat)==null) {
alert("The username doesn't seem to be valid.");
return false;
}
var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}
if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}
if (len<2) {
alert("This address is missing a hostname!");
return false;
}
return true;
}

function remove_XS_whitespace(item)
{
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}

function checkfields(event,in_id,validation_type) 
{
		var key = null;
	if (window.event) 
	{
		//ie
		key = window.event.keyCode;
	}
	 else if (event.which)
	 {
		//Mozilla,Safari
		key = event.which;
	 }

	if (key != null) 
	{
		if(validation_type=='string_data')
		{
		
			if ((key  > 64 && key  < 91) || (key  > 96 && key  < 123) || (key==32)) 
			{
			event.returnValue = true; 
			} 
			else 
		{
			event.returnValue = false;
			//document.getElementById(in_id).value="";
		}
			
		}
		if(validation_type=='num_data')
		{
		
			if (key >= 48 && key <= 57)	 
			{
			event.returnValue = true; 
			} 
			else 
		    {			
			event.returnValue = false;
		     }
			
		}
		if(validation_type=='add_data')
		{
		
			if ((key > 32 && key < 48) || (key > 57 && key < 65) || (key > 90 && key < 97) || (key == 126) || (key == 124) || (key == 125) || (key == 123))
			{
			event.returnValue = false; 
			} 
			else 
		    {			
			event.returnValue = true;
		    }
			
		}

	}
}

function txtKeywordKeyPress(f,key)
{
 if(key=="num")
 {
  var re = /^[0-9]*$/;
  if (!re.test(f.value))
  {
   //alert("Please Enter a Valid Number");
   f.value = f.value.replace(/[^0-9]/g,"");
  }
 }
 else if (key=="str")
 {
  var re = /^[a-z]*$/;
  if (!re.test(f.value))
  {  
   f.value = f.value.replace(/[^A-Z]/g,"");
  }
} 
}

function UperCase(Textboxid)
{
var txtval=Textboxid
var abc
abc=document.getElementById(txtval).value.toUpperCase()
document.getElementById(txtval).value=document.getElementById(txtval).value.toUpperCase()
}

function LowerCase(Textboxid)
{
var txtval=Textboxid
var abc
abc=document.getElementById(txtval).value.toLowerCase()
document.getElementById(txtval).value=document.getElementById(txtval).value.toLowerCase()
}
function fields()
{
alert(1)
}