function SubmitIt(vValue){
if (CheckForm()){
            if (vValue==1)
            {
                        //document.form1.action='<#WEBPATH>/formelement.asp';
                       document.form1.action='/tc.dll?ac=search&st=fares&tid=MIDEAST';
					   document.form1.target='_parent';
            }
            else
            {
                        //document.form1.action='<#WEBPATH>/formelement.asp';
                        document.form1.action='/tc.dll?ac=search&st=fares&tid=MIDEAST';
						document.form1.target='_parent';
            
            }
			showsearch();
            document.form1.submit();
}
}
function CheckForm(){
if (!CheckDate()){
            return false;
}else if (!IsDestinationSelected()){
            return false;
}
return true;
}

function IsDestinationSelected(){
if (document.form1.CA1[document.form1.CA1.selectedIndex].value=='none'){
            alert("Please Select a Destination Airport");
            return false;
}
return true;
}

function CheckDate(){
var strDepartDay=document.form1.DD1[document.form1.DD1.selectedIndex].value;
var strReturnDay=document.form1.DD2[document.form1.DD2.selectedIndex].value;
var strDepartDate=document.form1.MD1[document.form1.MD1.selectedIndex].value;
var strReturnDate=document.form1.MD2[document.form1.MD2.selectedIndex].value;
if (IsReturnDateAfterDepartureDate(strDepartDay, strReturnDay,  strDepartDate, strReturnDate)!=1 ){
alert("   Return Date MUST BE AFTER Departure Date \n \nTo return on the same day click DETAILED SEARCH"); return false;}
return true;
}

function IsReturnDateAfterDepartureDate(vD1,vD2,vM1,vM2){
var m1,y1,m2,y2;if (vM1.substr(0,1) == "0"){m1=parseInt(vM1.substr(1,1));}else{m1=parseInt(vM1.substr(0,2));}y1=parseInt(vM1.substr(2,4));
if (vM2.substr(0,1) == "0"){m2=parseInt(vM2.substr(1,1));}else{m2=parseInt(vM2.substr(0,2));}y2=parseInt(vM2.substr(2,4));
vD1=parseInt(vD1);vD2=parseInt(vD2);
if (y1>y2){return 0;}else if (y1==y2){if (m1>m2){return 0;}else if ((m1==m2) && (vD1>=vD2)){return 0;}}return 1;}

function MM_checkPlugin(plgIn, theURL, altURL, autoGo) { //v3.0
  var ok=false; document.MM_returnValue = false;
  with (navigator) if (appName.indexOf('Microsoft')==-1) ok=(plugins && plugins[plgIn]);
  else if (appVersion.indexOf('3.1')==-1) { //not Netscape or Win3.1
    if (plgIn.indexOf("Flash")!=-1 && window.MM_flash!=null) ok=window.MM_flash;
    else if (plgIn.indexOf("Director")!=-1 && window.MM_dir!=null) ok=window.MM_dir;
    else ok=autoGo; }
  if (!ok) theURL=altURL; if (theURL) window.location=theURL;
}

function CheckDest()
{
            var blnField;
            if (document.form.Field.value.length == 0)
            {
                        if (document.form.List.options[document.form.List.selectedIndex].value == 'none')
                        {
                                    alert("Please select a destination airport.");
                                    return;
                        }
                        
                        blnField = false;
            }
            else
                        blnField = true;
            
            if (blnField)
                        document.form.CA1.value = document.form.Field.value;
            else
                        document.form.CA1.value = document.form.List.options[document.form.List.selectedIndex].value;

            setqueryURL('form');       
}

var arrMonth = ["Jan", "Feb", "Mar", "Apr",
                                                               "May", "Jun", "Jul", "Aug", "Sep",
                                                               "Oct", "Nov", "Dec"];

var g_intDay, g_strMonthYear;

function GenerateDayList(strID, intDaysOffset)
{

            GenerateBookDate(intDaysOffset);

            document.write('<select name="' + strID + '" onSubmit="CheckDate()" class="info">');
            
            var intCount;
            for(intCount=1; intCount <= 31; intCount++)
            {
                        document.write('<option value="' + intCount + '"');
                        if (g_intDay == intCount)
                                    document.write(' selected');
                        document.write('>' + intCount + '</option>');
            }
            
            document.write('</select> ');
}

function GenerateMonthList(strID, intDaysOffset)
{

            document.write('<select name="' + strID + '" onSubmit="CheckDate()" class="info">');
            GenerateBookDate(intDaysOffset);
            var dateCurrent = new Date();
            dateCurrent.setDate(1);
            var intCount, strCurMonthYear, strMonthYearValue;
            for(intCount=0; intCount < 12; intCount++)
            {
                        strCurMonthYear = arrMonth[dateCurrent.getMonth()] + " " + dateCurrent.getFullYear();
                        if (dateCurrent.getMonth() < 9)
                                    strCurMonthYearValue = "0" + (dateCurrent.getMonth()+1) + dateCurrent.getFullYear();
                        else
                                    strCurMonthYearValue = "" + (dateCurrent.getMonth()+1) + dateCurrent.getFullYear();
                        document.write('<option value="' + strCurMonthYearValue + '"');
                        if (strCurMonthYear == g_strMonthYear)
                                    document.write(' selected');
                        document.write('>' + strCurMonthYear + '</option>');
                        
                        // Add a month to the current date
                        dateCurrent.setMonth(dateCurrent.getMonth()+1);
            }
            
            document.write('</select>');
}

function GenerateBookDate(intDaysOffset)
{
            // Get the current date

            var dateBook = new Date;
            
            // Add 7 days to the date
            g_intDay = dateBook.getDate() + 7 + intDaysOffset;
            dateBook.setDate(g_intDay);
            
            // Get the booking date
            g_intDay = dateBook.getDate();
            g_strMonthYear = arrMonth[dateBook.getMonth()] + " " + dateBook.getFullYear();
            return dateBook;
}

var winCal = null;
function OpenCal(strDay,strMonth)
{
            if (winCal == null || winCal.closed == true)
            {
                        var intLeft = (window.screen.width - 160)/2;
                        var intTop = (window.screen.height - 210)/2;
                        winCal = window.open('MIDEAST/calendar.asp?day='+strDay+'&month='+strMonth, 'calendar','dependent=yes,scrollbars=no,left='+intLeft+',top='+intTop+',width=130,height=180');
            }
            else
            {
                        winCal.document.location.href='MIDEAST/calendar.asp?day='+strDay+'&month='+strMonth;
                        winCal.focus();
            }
            return true;
}

function CloseWin()
{
            if (winCal != null && winCal.closed == false) winCal.close();
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1)
         end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function showsearch() {
	document.getElementById("search").style.display = "none";
	document.getElementById("SP").style.display = "block";
}

function hidesearch() {
	document.getElementById("search").style.display = "block";
	document.getElementById("SP").style.display = "none";
}

<!--

<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}*/


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_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];}
}

