

// JScript File

// default & searchfareresult.aspx

function retmonth(monthname){
    switch(monthname){
        case "Jan":
            return "01";
            break;
        case "Feb":
            return "02";
            break;
        case "Mar":
            return "03";
            break;
        case "Apr":
            return "04";
            break;
        case "May":
            return "05";
            break;
        case "Jun":
            return "06";
            break;
        case "Jul":
            return "07";
            break;
        case "Aug":
            return "08";
            break;
        case "Sep":
            return "09";
            break;
        case "Oct":
            return "10";
            break;
        case "Nov":
            return "11";
            break;
        case "Dec":
            return "12";
            break;
    }
}

function check_date(date_){
var checkstr = "0123456789";
var Datevalue = "";
var DateTemp = "";
var seperator = ".";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue =date_;
   /* Delete all chars except 0..9 */
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* Always change date to 8 digits - string*/
   /* if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
      DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2); }
   if (DateValue.length != 8) {
      err = 19;}
   /* year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
   if (year == 0) {
      err = 20;
   }
   /* Validation of month*/
   month = DateValue.substr(2,2);
   if ((month < 1) || (month > 12)) {
      err = 21;
   }
   /* Validation of day*/
   day = DateValue.substr(0,2);
   if (day < 1) {
     err = 22;
   }
   /* Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 23;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 24;
   }
   /* Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 25;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 26;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 0; day = ""; month = ""; year = ""; seperator = "";
   }
   
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
   if (err == 0) {
      return true;
   }
   else {
      return false
   }
}

function checkarrdate(targ)
{    
    if(targ.Month.selectedIndex > targ.Return_Month.selectedIndex)
    {
        targ.Return_Month.selectedIndex = targ.Month.selectedIndex;
    }
    if(targ.Month.selectedIndex == targ.Return_Month.selectedIndex)
    {
        if(targ.Day.selectedIndex >= targ.Return_Day.selectedIndex)
        {
            if (targ.Day.value != 31)
            	targ.Return_Day.selectedIndex = targ.Day.selectedIndex + 1;
        }
    }
}

function checkdepdate(targ)
{    
    if(targ.Return_Month.selectedIndex < targ.Month.selectedIndex)
    {
        targ.Month.selectedIndex = targ.Return_Month.selectedIndex;
    }    
}

function populatefields()
{

CountryListOnChange();
faretypeOnChange();

var now = new Date();
now.setDate(now.getDate()+6);
var daylist = document.getElementById("lstdday");
var mthlist = document.getElementById("lstdmth");

var optionItem;
var checkmthindex;
    for(var i = 1; i<=31 ;i++){
        var k;
        if(i<10){
        k="0"+i;
        }
        else{
        k=i;
        }
        optionItem = new Option( i , k,  false, false);
		daylist.options[daylist.length] = optionItem;
    }
    daylist.selectedIndex = now.getDate()-1;

    var myDate=new Date(); 
    myDate.setDate(myDate.getDate()+6);
    myMonthNum=myDate.getMonth() ;
    
    for(var i = 0; i<=11 ;i++){
        var emptmonNum = "";
        emptmonNum = myMonthNum + i
        var retdate = new Date()
        retdate.setMonth(emptmonNum)         
        if(myDate.toString()==retdate.toString()){
        checkmthindex=i;
        }
        optionItem = new Option( getMonthName(retdate.getMonth()+1, retdate.getFullYear()) , getMonthName(retdate.getMonth()+1, retdate.getFullYear()),  false, false);
		mthlist.options[mthlist.length] = optionItem;
    }            
    mthlist.selectedIndex = checkmthindex;
    
    var Rdaylist = document.getElementById("lstrday");
    var Rmthlist = document.getElementById("lstrmth");
    var Rnow = new Date();
    Rnow.setDate(Rnow.getDate()+8);

    var RoptionItem;
    var Rcheckmthindex;
    for(var j = 1; j<=31 ;j++){
    var k;
    if(j<10){k="0"+j;}
    else{k=j;}
        RoptionItem = new Option( j , k,  false, false);
		Rdaylist.options[Rdaylist.length] = RoptionItem;
    }
    Rdaylist.selectedIndex = Rnow.getDate()-1;

    var RmyDate=new Date(); 
    RmyDate.setDate(RmyDate.getDate()+8);
    RmyMonthNum=RmyDate.getMonth() ;
    
    for(var j = 0; j<=11 ;j++){
        var RemptmonNum = "";
        RemptmonNum = RmyMonthNum + j
        var Rretdate = new Date()
        if(j==0){Rretdate.setDate(Rretdate.getDate()+8);}
        Rretdate.setMonth(RemptmonNum)         
        if(RmyDate.toString()==Rretdate.toString()){
        Rcheckmthindex=j;
        }
        RoptionItem = new Option( getMonthName(Rretdate.getMonth()+1, Rretdate.getFullYear()) , getMonthName(Rretdate.getMonth()+1, Rretdate.getFullYear()),  false, false);
		Rmthlist.options[Rmthlist.length] = RoptionItem;
    }            
    Rmthlist.selectedIndex = Rcheckmthindex;
}

function getMonthName(Mth,Yr){
    var monthname;
    var yrstr = Yr;
        switch(Mth)
        {
            case 1:
            
                monthname =  "Jan '" + (yrstr+"").substring(2,4);
                break;
            case 2:
                monthname =  "Feb '" + (yrstr+"").substring(2,4);
                break;
            case 3:
                monthname =  "Mar '" + (yrstr+"").substring(2,4);
                break;
            case 4:
                monthname =  "Apr '" + (yrstr+"").substring(2,4);
                break;
            case 5:
                monthname =  "May '" + (yrstr+"").substring(2,4);
                break;
            case 6:
                monthname =  "Jun '" + (yrstr+"").substring(2,4);
                break;
            case 7:
                monthname =  "Jul '" + (yrstr+"").substring(2,4);
                break;
            case 8:
                monthname =  "Aug '" + (yrstr+"").substring(2,4);
                break;
            case 9:
                monthname =  "Sep '" + (yrstr+"").substring(2,4);
                break;
            case 10:
                monthname =  "Oct '" + (yrstr+"").substring(2,4);
                break;
            case 11:
                monthname =  "Nov '" + (yrstr+"").substring(2,4);
                break;
            case 12:
                monthname =  "Dec '" + (yrstr+"").substring(2,4);
                break;
        }   
        return monthname;

}
// default & searchfareresult.aspx


// date validation 
function updatemonth(rowcount)
{
var rowcheck  = rowcount;

/// depart 1 =  true only then 0
/// depart 1 & 3 = true only then 1
/// depart 1,2,3 = true only then 2
/// depart 1,3,4 = true only then 3
/// depart 1,2,3,4 = true only then 4
if(rowcheck == null){
var dday = document.getElementById("Day");
var dmth = document.getElementById("Month");
var rday = document.getElementById("Return_Day");
var rmth = document.getElementById("Return_Month");
    if(dmth.selectedIndex > rmth.selectedIndex)
    {
        rmth.selectedIndex = dmth.selectedIndex;
        rday.selectedIndex = dday.selectedIndex;
    }
    if(dmth.selectedIndex == rmth.selectedIndex)
    {
        if(dday.selectedIndex >= rday.selectedIndex)
        {
            if(dday.selectedIndex == dday.length - 1)
            {
                rmth.selectedIndex = dmth.selectedIndex + 1;
                rday.selectedIndex = 0;
            }
            else
            {
                rday.selectedIndex=dday.selectedIndex+1;
            }
        }
    }
}
else{
    switch(rowcount)
    {
    case 1:
    
        var dmth11 = document.getElementById("dmth11");
        var dmth12 = document.getElementById("dmth12");
        var dmth13 = document.getElementById("dmth13");
        var dmth14 = document.getElementById("dmth14");
        var dday11 = document.getElementById("dday11");
        var dday12 = document.getElementById("dday12");
        var dday13 = document.getElementById("dday13");
        var dday14 = document.getElementById("dday14");
        var checkexistence;

            if(((dmth11)!=null) && ((dmth12)==null) &&((dmth13)==null) &&((dmth14)==null)) 
            {
            checkexistence = 0;
            }
            else if(((dmth11)!=null) && ((dmth12)==null) &&((dmth13)!=null) &&((dmth14)==null)) 
            {
            checkexistence = 1;
            }
            else if(((dmth11)!=null) && ((dmth12)!=null) &&((dmth13)!=null) &&((dmth14)==null)) 
            {
            checkexistence = 2;
            }
            else if(((dmth11)!=null) && ((dmth12)==null) &&((dmth13)!=null) &&((dmth14)!=null)) 
            {
            checkexistence = 3;
            }
            else if(((dmth11)!=null) && ((dmth12)!=null) &&((dmth13)!=null) &&((dmth14)!=null)) 
            {
            checkexistence = 4;
            }
            else
            {
            checkexistence = 5;
            }
                switch(checkexistence)
                {
                case 0:     
                    break;            
                case 1:
                    if(dmth11.selectedIndex > dmth13.selectedIndex)
                        {
                            dmth13.selectedIndex = dmth11.selectedIndex;
                            dday13.selectedIndex = dday11.selectedIndex;
                        }
                        if(dmth11.selectedIndex == dmth13.selectedIndex)
                        {
                            if(dday11.selectedIndex >= dday13.selectedIndex)
                            {
                                if(dday11.selectedIndex == dday13.length - 1)
                                {
                                    dmth13.selectedIndex = dmth11.selectedIndex + 1;
                                    dday13.selectedIndex = 0;
                                }
                                else
                                {
                                    dday13.selectedIndex=dday11.selectedIndex+1;
                                }
                            }
                        }  
                case 2:
                    break;            
                        if(dmth11.selectedIndex > dmth12.selectedIndex)
                            {
                                dmth12.selectedIndex = dmth11.selectedIndex;
                                dday12.selectedIndex = dday11.selectedIndex;
                            }
                            if(dmth11.selectedIndex == dmth12.selectedIndex)
                            {
                                if(dday11.selectedIndex >= dday12.selectedIndex)
                                {
                                    if(dday11.selectedIndex == dday12.length - 1)
                                    {
                                        dmth12.selectedIndex = dmth11.selectedIndex + 1;
                                        dday12.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday12.selectedIndex=dday11.selectedIndex+1;
                                    }
                                }
                            }                 
                            if(dmth12.selectedIndex > dmth13.selectedIndex)
                            {
                                dmth13.selectedIndex = dmth12.selectedIndex;
                                dday13.selectedIndex = dday12.selectedIndex;
                            }
                            if(dmth12.selectedIndex == dmth13.selectedIndex)
                            {
                                if(dday12.selectedIndex >= dday13.selectedIndex)
                                {
                                    if(dday12.selectedIndex == dday13.length - 1)
                                    {
                                        dmth13.selectedIndex = dmth12.selectedIndex + 1;
                                        dday13.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday13.selectedIndex=dday12.selectedIndex+1;
                                    }
                                }
                            }      
                    break;                                   
                case 3:
                            if(dmth11.selectedIndex > dmth13.selectedIndex)
                                {
                                    dmth13.selectedIndex = dmth11.selectedIndex;
                                    dday13.selectedIndex = dday11.selectedIndex;
                                }
                                if(dmth11.selectedIndex == dmth13.selectedIndex)
                                {
                                    if(dday11.selectedIndex >= dday13.selectedIndex)
                                    {
                                        if(dday11.selectedIndex == dday13.length - 1)
                                        {
                                            dmth13.selectedIndex = dmth11.selectedIndex + 1;
                                            dday13.selectedIndex = 0;
                                        }
                                        else
                                        {
                                            dday13.selectedIndex=dday11.selectedIndex+1;
                                        }
                                    }
                                }                 
                                if(dmth13.selectedIndex > dmth14.selectedIndex)
                                {
                                    dmth14.selectedIndex = dmth13.selectedIndex;
                                    dday14.selectedIndex = dday13.selectedIndex;
                                }
                                if(dmth13.selectedIndex == dmth14.selectedIndex)
                                {
                                    if(dday13.selectedIndex >= dday14.selectedIndex)
                                    {
                                        if(dday13.selectedIndex == dday14.length - 1)
                                        {
                                            dmth14.selectedIndex = dmth13.selectedIndex + 1;
                                            dday14.selectedIndex = 0;
                                        }
                                        else
                                        {
                                            dday14.selectedIndex=dday13.selectedIndex+1;
                                        }
                                    }
                                }  
                    break;                                                  
                case 4:
                            if(dmth11.selectedIndex > dmth12.selectedIndex)
                            {
                                dmth12.selectedIndex = dmth11.selectedIndex;
                                dday12.selectedIndex = dday11.selectedIndex;
                            }
                            if(dmth11.selectedIndex == dmth12.selectedIndex)
                            {
                                if(dday11.selectedIndex >= dday12.selectedIndex)
                                {
                                    if(dday11.selectedIndex == dday12.length - 1)
                                    {
                                        dmth12.selectedIndex = dmth11.selectedIndex + 1;
                                        dday12.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday12.selectedIndex=dday11.selectedIndex+1;
                                    }
                                }
                            } 
                            
                            if(dmth12.selectedIndex > dmth13.selectedIndex)
                            {
                                dmth13.selectedIndex = dmth12.selectedIndex;
                                dday13.selectedIndex = dday12.selectedIndex;
                            }
                            if(dmth12.selectedIndex == dmth13.selectedIndex)
                            {
                                if(dday12.selectedIndex >= dday13.selectedIndex)
                                {
                                    if(dday12.selectedIndex == dday13.length - 1)
                                    {
                                        dmth13.selectedIndex = dmth12.selectedIndex + 1;
                                        dday13.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday13.selectedIndex=dday12.selectedIndex+1;
                                    }
                                }
                            }  
                            
                            if(dmth13.selectedIndex > dmth14.selectedIndex)
                            {
                                dmth14.selectedIndex = dmth13.selectedIndex;
                                dday14.selectedIndex = dday13.selectedIndex;
                            }
                            if(dmth13.selectedIndex == dmth14.selectedIndex)
                            {
                                if(dday13.selectedIndex >= dday14.selectedIndex)
                                {
                                    if(dday13.selectedIndex == dday14.length - 1)
                                    {
                                        dmth14.selectedIndex = dmth13.selectedIndex + 1;
                                        dday14.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday14.selectedIndex=dday13.selectedIndex+1;
                                    }
                                }
                            }
                    break;
                case 5:
                        alert("error");
                        break;
                }
       break;            
    case 2:
    
            var dmth21 = document.getElementById("dmth21");
            var dmth22 = document.getElementById("dmth22");
            var dmth23 = document.getElementById("dmth23");
            var dmth24 = document.getElementById("dmth24");
            var dday21 = document.getElementById("dday21");
            var dday22 = document.getElementById("dday22");
            var dday23 = document.getElementById("dday23");
            var dday24 = document.getElementById("dday24");
            var checkexistence;

            if(((dmth21)!=null) && ((dmth22)==null) &&((dmth23)==null) &&((dmth24)==null)) 
            {
            checkexistence = 0;
            }
            else if(((dmth21)!=null) && ((dmth22)==null) &&((dmth23)!=null) &&((dmth24)==null)) 
            {
            checkexistence = 1;
            }
            else if(((dmth21)!=null) && ((dmth22)!=null) &&((dmth23)!=null) &&((dmth24)==null)) 
            {
            checkexistence = 2;
            }
            else if(((dmth21)!=null) && ((dmth22)==null) &&((dmth23)!=null) &&((dmth24)!=null)) 
            {
            checkexistence = 3;
            }
            else if(((dmth21)!=null) && ((dmth22)!=null) &&((dmth23)!=null) &&((dmth24)!=null)) 
            {
            checkexistence = 4;
            }
            else
            {
            checkexistence = 5;
            }
                switch(checkexistence)
                {
                case 0:     
                    break;            
                case 1:
                    if(dmth21.selectedIndex > dmth23.selectedIndex)
                        {
                            dmth23.selectedIndex = dmth21.selectedIndex;
                            dday23.selectedIndex = dday21.selectedIndex;
                        }
                        if(dmth21.selectedIndex == dmth23.selectedIndex)
                        {
                            if(dday21.selectedIndex >= dday23.selectedIndex)
                            {
                                if(dday21.selectedIndex == dday23.length - 1)
                                {
                                    dmth23.selectedIndex = dmth21.selectedIndex + 1;
                                    dday23.selectedIndex = 0;
                                }
                                else
                                {
                                    dday23.selectedIndex=dday21.selectedIndex+1;
                                }
                            }
                        }  
                case 2:
                    break;            
                        if(dmth21.selectedIndex > dmth22.selectedIndex)
                            {
                                dmth22.selectedIndex = dmth21.selectedIndex;
                                dday22.selectedIndex = dday21.selectedIndex;
                            }
                            if(dmth21.selectedIndex == dmth22.selectedIndex)
                            {
                                if(dday21.selectedIndex >= dday22.selectedIndex)
                                {
                                    if(dday21.selectedIndex == dday22.length - 1)
                                    {
                                        dmth22.selectedIndex = dmth21.selectedIndex + 1;
                                        dday22.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday22.selectedIndex=dday21.selectedIndex+1;
                                    }
                                }
                            }                 
                            if(dmth22.selectedIndex > dmth23.selectedIndex)
                            {
                                dmth23.selectedIndex = dmth22.selectedIndex;
                                dday23.selectedIndex = dday22.selectedIndex;
                            }
                            if(dmth22.selectedIndex == dmth23.selectedIndex)
                            {
                                if(dday22.selectedIndex >= dday23.selectedIndex)
                                {
                                    if(dday22.selectedIndex == dday23.length - 1)
                                    {
                                        dmth23.selectedIndex = dmth22.selectedIndex + 1;
                                        dday23.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday23.selectedIndex=dday22.selectedIndex+1;
                                    }
                                }
                            }      
                    break;                                   
                case 3:
                            if(dmth21.selectedIndex > dmth23.selectedIndex)
                                {
                                    dmth23.selectedIndex = dmth21.selectedIndex;
                                    dday23.selectedIndex = dday21.selectedIndex;
                                }
                                if(dmth21.selectedIndex == dmth23.selectedIndex)
                                {
                                    if(dday21.selectedIndex >= dday23.selectedIndex)
                                    {
                                        if(dday21.selectedIndex == dday23.length - 1)
                                        {
                                            dmth23.selectedIndex = dmth21.selectedIndex + 1;
                                            dday23.selectedIndex = 0;
                                        }
                                        else
                                        {
                                            dday23.selectedIndex=dday21.selectedIndex+1;
                                        }
                                    }
                                }                 
                                if(dmth23.selectedIndex > dmth24.selectedIndex)
                                {
                                    dmth24.selectedIndex = dmth23.selectedIndex;
                                    dday24.selectedIndex = dday23.selectedIndex;
                                }
                                if(dmth23.selectedIndex == dmth24.selectedIndex)
                                {
                                    if(dday23.selectedIndex >= dday24.selectedIndex)
                                    {
                                        if(dday23.selectedIndex == dday24.length - 1)
                                        {
                                            dmth24.selectedIndex = dmth23.selectedIndex + 1;
                                            dday24.selectedIndex = 0;
                                        }
                                        else
                                        {
                                            dday24.selectedIndex=dday23.selectedIndex+1;
                                        }
                                    }
                                }  
                    break;                                                  
                case 4:
                            if(dmth21.selectedIndex > dmth22.selectedIndex)
                            {
                                dmth22.selectedIndex = dmth21.selectedIndex;
                                dday22.selectedIndex = dday21.selectedIndex;
                            }
                            if(dmth21.selectedIndex == dmth22.selectedIndex)
                            {
                                if(dday21.selectedIndex >= dday22.selectedIndex)
                                {
                                    if(dday21.selectedIndex == dday22.length - 1)
                                    {
                                        dmth22.selectedIndex = dmth21.selectedIndex + 1;
                                        dday22.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday22.selectedIndex=dday21.selectedIndex+1;
                                    }
                                }
                            } 
                            
                            if(dmth22.selectedIndex > dmth23.selectedIndex)
                            {
                                dmth23.selectedIndex = dmth22.selectedIndex;
                                dday23.selectedIndex = dday22.selectedIndex;
                            }
                            if(dmth22.selectedIndex == dmth23.selectedIndex)
                            {
                                if(dday22.selectedIndex >= dday23.selectedIndex)
                                {
                                    if(dday22.selectedIndex == dday23.length - 1)
                                    {
                                        dmth23.selectedIndex = dmth22.selectedIndex + 1;
                                        dday23.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday23.selectedIndex=dday22.selectedIndex+1;
                                    }
                                }
                            }  
                            
                            if(dmth23.selectedIndex > dmth24.selectedIndex)
                            {
                                dmth24.selectedIndex = dmth23.selectedIndex;
                                dday24.selectedIndex = dday23.selectedIndex;
                            }
                            if(dmth23.selectedIndex == dmth24.selectedIndex)
                            {
                                if(dday23.selectedIndex >= dday24.selectedIndex)
                                {
                                    if(dday23.selectedIndex == dday24.length - 1)
                                    {
                                        dmth24.selectedIndex = dmth23.selectedIndex + 1;
                                        dday24.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday24.selectedIndex=dday23.selectedIndex+1;
                                    }
                                }
                            }
                    break;
                case 5:
                        alert("error");
                        break;
                }
       break;
    case 3:
            var dmth31 = document.getElementById("dmth31");
            var dmth32 = document.getElementById("dmth32");
            var dmth33 = document.getElementById("dmth33");
            var dmth34 = document.getElementById("dmth34");
            var dday31 = document.getElementById("dday31");
            var dday32 = document.getElementById("dday32");
            var dday33 = document.getElementById("dday33");
            var dday34 = document.getElementById("dday34");
            var checkexistence;

            if(((dmth31)!=null) && ((dmth32)==null) &&((dmth33)==null) &&((dmth34)==null)) 
            {
            checkexistence = 0;
            }
            else if(((dmth31)!=null) && ((dmth12)==null) &&((dmth33)!=null) &&((dmth34)==null)) 
            {
            checkexistence = 1;
            }
            else if(((dmth31)!=null) && ((dmth32)!=null) &&((dmth33)!=null) &&((dmth34)==null)) 
            {
            checkexistence = 2;
            }
            else if(((dmth31)!=null) && ((dmth32)==null) &&((dmth33)!=null) &&((dmth34)!=null)) 
            {
            checkexistence = 3;
            }
            else if(((dmth31)!=null) && ((dmth32)!=null) &&((dmth33)!=null) &&((dmth34)!=null)) 
            {
            checkexistence = 4;
            }
            else
            {
            checkexistence = 5;
            }
                switch(checkexistence)
                {
                case 0:     
                    break;            
                case 1:
                    if(dmth31.selectedIndex > dmth33.selectedIndex)
                        {
                            dmth33.selectedIndex = dmth31.selectedIndex;
                            dday33.selectedIndex = dday31.selectedIndex;
                        }
                        if(dmth31.selectedIndex == dmth33.selectedIndex)
                        {
                            if(dday31.selectedIndex >= dday33.selectedIndex)
                            {
                                if(dday31.selectedIndex == dday33.length - 1)
                                {
                                    dmth33.selectedIndex = dmth31.selectedIndex + 1;
                                    dday33.selectedIndex = 0;
                                }
                                else
                                {
                                    dday33.selectedIndex=dday31.selectedIndex+1;
                                }
                            }
                        }  
                case 2:
                    break;            
                        if(dmth31.selectedIndex > dmth32.selectedIndex)
                            {
                                dmth32.selectedIndex = dmth31.selectedIndex;
                                dday32.selectedIndex = dday31.selectedIndex;
                            }
                            if(dmth31.selectedIndex == dmth32.selectedIndex)
                            {
                                if(dday31.selectedIndex >= dday32.selectedIndex)
                                {
                                    if(dday31.selectedIndex == dday32.length - 1)
                                    {
                                        dmth32.selectedIndex = dmth31.selectedIndex + 1;
                                        dday32.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday32.selectedIndex=dday31.selectedIndex+1;
                                    }
                                }
                            }                 
                            if(dmth32.selectedIndex > dmth33.selectedIndex)
                            {
                                dmth33.selectedIndex = dmth32.selectedIndex;
                                dday33.selectedIndex = dday32.selectedIndex;
                            }
                            if(dmth32.selectedIndex == dmth33.selectedIndex)
                            {
                                if(dday32.selectedIndex >= dday33.selectedIndex)
                                {
                                    if(dday32.selectedIndex == dday33.length - 1)
                                    {
                                        dmth33.selectedIndex = dmth32.selectedIndex + 1;
                                        dday33.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday33.selectedIndex=dday32.selectedIndex+1;
                                    }
                                }
                            }      
                    break;                                   
                case 3:
                            if(dmth31.selectedIndex > dmth33.selectedIndex)
                                {
                                    dmth33.selectedIndex = dmth31.selectedIndex;
                                    dday33.selectedIndex = dday31.selectedIndex;
                                }
                                if(dmth31.selectedIndex == dmth33.selectedIndex)
                                {
                                    if(dday31.selectedIndex >= dday33.selectedIndex)
                                    {
                                        if(dday31.selectedIndex == dday33.length - 1)
                                        {
                                            dmth33.selectedIndex = dmth31.selectedIndex + 1;
                                            dday33.selectedIndex = 0;
                                        }
                                        else
                                        {
                                            dday33.selectedIndex=dday31.selectedIndex+1;
                                        }
                                    }
                                }                 
                                if(dmth33.selectedIndex > dmth34.selectedIndex)
                                {
                                    dmth34.selectedIndex = dmth33.selectedIndex;
                                    dday34.selectedIndex = dday33.selectedIndex;
                                }
                                if(dmth33.selectedIndex == dmth34.selectedIndex)
                                {
                                    if(dday33.selectedIndex >= dday34.selectedIndex)
                                    {
                                        if(dday33.selectedIndex == dday34.length - 1)
                                        {
                                            dmth34.selectedIndex = dmth33.selectedIndex + 1;
                                            dday34.selectedIndex = 0;
                                        }
                                        else
                                        {
                                            dday34.selectedIndex=dday33.selectedIndex+1;
                                        }
                                    }
                                }  
                    break;                                                  
                case 4:
                            if(dmth31.selectedIndex > dmth32.selectedIndex)
                            {
                                dmth32.selectedIndex = dmth31.selectedIndex;
                                dday32.selectedIndex = dday31.selectedIndex;
                            }
                            if(dmth31.selectedIndex == dmth32.selectedIndex)
                            {
                                if(dday31.selectedIndex >= dday32.selectedIndex)
                                {
                                    if(dday31.selectedIndex == dday32.length - 1)
                                    {
                                        dmth32.selectedIndex = dmth31.selectedIndex + 1;
                                        dday32.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday32.selectedIndex=dday31.selectedIndex+1;
                                    }
                                }
                            } 
                            
                            if(dmth32.selectedIndex > dmth33.selectedIndex)
                            {
                                dmth33.selectedIndex = dmth32.selectedIndex;
                                dday33.selectedIndex = dday32.selectedIndex;
                            }
                            if(dmth32.selectedIndex == dmth33.selectedIndex)
                            {
                                if(dday32.selectedIndex >= dday33.selectedIndex)
                                {
                                    if(dday32.selectedIndex == dday33.length - 1)
                                    {
                                        dmth33.selectedIndex = dmth32.selectedIndex + 1;
                                        dday33.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday33.selectedIndex=dday32.selectedIndex+1;
                                    }
                                }
                            }  
                            
                            if(dmth33.selectedIndex > dmth34.selectedIndex)
                            {
                                dmth34.selectedIndex = dmth33.selectedIndex;
                                dday34.selectedIndex = dday33.selectedIndex;
                            }
                            if(dmth33.selectedIndex == dmth34.selectedIndex)
                            {
                                if(dday33.selectedIndex >= dday34.selectedIndex)
                                {
                                    if(dday33.selectedIndex == dday34.length - 1)
                                    {
                                        dmth34.selectedIndex = dmth33.selectedIndex + 1;
                                        dday34.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday34.selectedIndex=dday33.selectedIndex+1;
                                    }
                                }
                            }
                    break;
                case 5:
                        alert("error");
                        break;
                }
    
        break;
    }
}
}

function updatedate()
{
        var dmth1 = document.getElementById("dmth1");
        var dmth2 = document.getElementById("dmth2");
        var dmth3 = document.getElementById("dmth3");
        var dmth4 = document.getElementById("dmth4");
        var dday1 = document.getElementById("dday1");
        var dday2 = document.getElementById("dday2");
        var dday3 = document.getElementById("dday3");
        var dday4 = document.getElementById("dday4");
        var outstop1 = document.getElementById("outstopover1");
        var outstop2 = document.getElementById("outstopover2");
        var instop1 = document.getElementById("instopover1");
        var instop2 = document.getElementById("instopover2");

        
            var checkexistence;

            if(((outstop1)!=null) && ((outstop2)==null) &&((instop1)==null) &&((instop2)==null)) 
            {
            checkexistence = 0;
            }
            else if(((outstop1)!=null) && ((outstop2)==null) &&((instop1)!=null) &&((instop2)==null)) 
            {
            checkexistence = 1;
            }
            else if(((outstop1)!=null) && ((outstop2)!=null) &&((instop1)!=null) &&((instop2)==null)) 
            {
            checkexistence = 2;
            }
            else if(((outstop1)!=null) && ((outstop2)==null) &&((instop1)!=null) &&((instop2)!=null)) 
            {
            checkexistence = 3;
            }
            else if(((outstop1)!=null) && ((outstop2)!=null) &&((instop1)!=null) &&((instop2)!=null)) 
            {
            checkexistence = 4;
            }
            else
            {
            checkexistence = 5;
            }
                switch(checkexistence)
                {
                case 0:     
                    break;            
                case 1:
                    if(dmth1.selectedIndex > dmth3.selectedIndex)
                        {
                            dmth3.selectedIndex = dmth1.selectedIndex;
                            dday3.selectedIndex = dday1.selectedIndex;
                        }
                        if(dmth1.selectedIndex == dmth3.selectedIndex)
                        {
                            if(dday1.selectedIndex >= dday3.selectedIndex)
                            {
                                if(dday1.selectedIndex == dday3.length - 1)
                                {
                                    dmth3.selectedIndex = dmth1.selectedIndex + 1;
                                    dday3.selectedIndex = 0;
                                }
                                else
                                {
                                    dday3.selectedIndex=dday1.selectedIndex+1;
                                }
                            }
                        }  
                        break;            
                case 2:                    
                        if(dmth1.selectedIndex > dmth2.selectedIndex)
                            {
                                dmth2.selectedIndex = dmth1.selectedIndex;
                                dday2.selectedIndex = dday1.selectedIndex;
                            }
                            if(dmth1.selectedIndex == dmth2.selectedIndex)
                            {
                                if(dday1.selectedIndex >= dday2.selectedIndex)
                                {
                                    if(dday1.selectedIndex == dday2.length - 1)
                                    {
                                        dmth2.selectedIndex = dmth1.selectedIndex + 1;
                                        dday2.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday2.selectedIndex=dday1.selectedIndex+1;
                                    }
                                }
                            }                 
                            if(dmth2.selectedIndex > dmth3.selectedIndex)
                            {
                                dmth3.selectedIndex = dmth2.selectedIndex;
                                dday3.selectedIndex = dday2.selectedIndex;
                            }
                            if(dmth2.selectedIndex == dmth3.selectedIndex)
                            {
                                if(dday2.selectedIndex >= dday3.selectedIndex)
                                {
                                    if(dday2.selectedIndex == dday3.length - 1)
                                    {
                                        dmth3.selectedIndex = dmth2.selectedIndex + 1;
                                        dday3.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday3.selectedIndex=dday2.selectedIndex+1;
                                    }
                                }
                            }      
                    break;                                   
                case 3:
                            if(dmth1.selectedIndex > dmth3.selectedIndex)
                                {
                                    dmth3.selectedIndex = dmth1.selectedIndex;
                                    dday3.selectedIndex = dday1.selectedIndex;
                                }
                                if(dmth1.selectedIndex == dmth3.selectedIndex)
                                {
                                    if(dday1.selectedIndex >= dday3.selectedIndex)
                                    {
                                        if(dday1.selectedIndex == dday3.length - 1)
                                        {
                                            dmth3.selectedIndex = dmth1.selectedIndex + 1;
                                            dday3.selectedIndex = 0;
                                        }
                                        else
                                        {
                                            dday3.selectedIndex=dday1.selectedIndex+1;
                                        }
                                    }
                                }                 
                                if(dmth3.selectedIndex > dmth4.selectedIndex)
                                {
                                    dmth4.selectedIndex = dmth3.selectedIndex;
                                    dday4.selectedIndex = dday3.selectedIndex;
                                }
                                if(dmth3.selectedIndex == dmth4.selectedIndex)
                                {
                                    if(dday3.selectedIndex >= dday4.selectedIndex)
                                    {
                                        if(dday3.selectedIndex == dday4.length - 1)
                                        {
                                            dmth4.selectedIndex = dmth3.selectedIndex + 1;
                                            dday4.selectedIndex = 0;
                                        }
                                        else
                                        {
                                            dday4.selectedIndex=dday3.selectedIndex+1;
                                        }
                                    }
                                }  
                    break;                                                  
                case 4:
                            if(dmth1.selectedIndex > dmth2.selectedIndex)
                            {
                                dmth2.selectedIndex = dmth1.selectedIndex;
                                dday2.selectedIndex = dday1.selectedIndex;
                            }
                            if(dmth1.selectedIndex == dmth2.selectedIndex)
                            {
                                if(dday1.selectedIndex >= dday2.selectedIndex)
                                {
                                    if(dday1.selectedIndex == dday2.length - 1)
                                    {
                                        dmth2.selectedIndex = dmth1.selectedIndex + 1;
                                        dday2.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday2.selectedIndex=dday1.selectedIndex+1;
                                    }
                                }
                            } 
                            
                            if(dmth2.selectedIndex > dmth3.selectedIndex)
                            {
                                dmth3.selectedIndex = dmth2.selectedIndex;
                                dday3.selectedIndex = dday2.selectedIndex;
                            }
                            if(dmth2.selectedIndex == dmth3.selectedIndex)
                            {
                                if(dday2.selectedIndex >= dday3.selectedIndex)
                                {
                                    if(dday2.selectedIndex == dday3.length - 1)
                                    {
                                        dmth3.selectedIndex = dmth2.selectedIndex + 1;
                                        dday3.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday3.selectedIndex=dday2.selectedIndex+1;
                                    }
                                }
                            }  
                            
                            if(dmth3.selectedIndex > dmth4.selectedIndex)
                            {
                                dmth4.selectedIndex = dmth3.selectedIndex;
                                dday4.selectedIndex = dday3.selectedIndex;
                            }
                            if(dmth3.selectedIndex == dmth4.selectedIndex)
                            {
                                if(dday3.selectedIndex >= dday4.selectedIndex)
                                {
                                    if(dday3.selectedIndex == dday4.length - 1)
                                    {
                                        dmth4.selectedIndex = dmth3.selectedIndex + 1;
                                        dday4.selectedIndex = 0;
                                    }
                                    else
                                    {
                                        dday4.selectedIndex=dday3.selectedIndex+1;
                                    }
                                }
                            }
                    break;
                case 5:
                        alert("error");
                        break;
                }
}

//-------------------------------------------------- schedule.aspx

    function checkdates(type,d1,d2,d3,r1,r2,r3,o1,o2,i1,i2)
    {
               
        var mth1;    
        var depdate1;
        var depdatedis1;
        var mth2;    
        var depdate2;
        var depdatedis2;
        var mth3;
        var depdate3 = "";
        var depdatedis3;
        var mth4;
        var depdate4 = "";
        var depdatedis4;
        var curdate = new Date();
        var d1_;
        var d2_;
        var d3_;

        var errormsg = "This is the following errors that are against the fare condtions -: \n";

        if(type==1){
                var depday1 = document.getElementById("lsto1day");
                var depmth1 = document.getElementById("lsto1mth");
                var depday2= document.getElementById("lsto2day");
                var depmth2 = document.getElementById("lsto2mth");
                var depday3= document.getElementById("lsti1day");
                var depmth3 = document.getElementById("lsti1mth");
                var depday4= document.getElementById("lsti2day");
                var depmth4 = document.getElementById("lsti2mth");

                if(depmth1!=null)
                {
                    mth1 = depmth1.options[depmth1.selectedIndex].value;    
                    depdate1 = new Date("20" + mth1.substr((String(mth1).length)-2,2),returnmth(mth1.substr(0,3))-1,depday1.selectedIndex+1);
                    depdatedis1 = depday1.selectedIndex+1 + "/" + returnmth(mth1.substr(0,3)) + "/" + "20" + mth1.substr((String(mth1).length)-2,2); 
                    if(depdate1 < curdate)
                    {
                        errormsg += "- Invalid Departure date " + depdatedis1 + "\n";
                    }
                }
                else
                {
                    if(o1!="")
                    {
                        var splitdate = o1.split("/");
                        mth1 = splitdate[1];
                        depdate1 = new Date(splitdate[0],splitdate[1]-1,splitdate[2]);
                        depdatedis1 = splitdate[2] + "/" + splitdate[1] + "/" + splitdate[0]; 
                    }
                }
                if(depmth2!=null)
                {
                    mth2 = depmth2.options[depmth2.selectedIndex].value;
                    depdate2 = new Date("20" + mth2.substr((String(mth2).length)-2,2),returnmth(mth2.substr(0,3))-1,depday2.selectedIndex+1);
                    depdatedis2 = depday2.selectedIndex+1 + "/" + returnmth(mth2.substr(0,3)) + "/" + "20" + mth2.substr((String(mth2).length)-2,2); 
                    if(depdate2 < curdate)
                    {
                        errormsg += "- Invalid Departure date " + depdatedis2 + "\n";
                    }
                }
                else
                {
                    if(o2!="")
                    {
                        var splitdate = o2.split("/");
                        mth2 = splitdate[1];
                        depdate2 = new Date(splitdate[0],splitdate[1]-1,splitdate[2]);
                        depdatedis2 = splitdate[2] + "/" + splitdate[1] + "/" + splitdate[0]; 
                    }
                }
                if(depmth3!=null)
                {    
                    mth3 = depmth3.options[depmth3.selectedIndex].value;
                    depdate3 = new Date("20" + mth3.substr((String(mth3).length)-2,2),returnmth(mth3.substr(0,3))-1,depday3.selectedIndex+1);
                    depdatedis3 = depday3.selectedIndex+1 + "/" + returnmth(mth3.substr(0,3)) + "/" + "20" + mth3.substr((String(mth3).length)-2,2); 
                    if(depdate3 < curdate)
                    {
                        errormsg += "- Invalid Departure date " + depdatedis3 + "\n";
                    }
                }
                else
                {
                    if(i1!="")
                    {        
                    var splitdate = i1.split("/");
                        mth3 = splitdate[1];            
                        depdate3 = new Date(splitdate[0],splitdate[1]-1,splitdate[2]);
                        depdatedis3 = splitdate[2] + "/" + splitdate[1] + "/" + splitdate[0]; 
                    }
                }
                if(depmth4!=null)
                {
                    mth4 = depmth4.options[depmth4.selectedIndex].value;
                    depdate4 = new Date("20" + mth4.substr((String(mth4).length)-2,2),returnmth(mth4.substr(0,3))-1,depday4.selectedIndex+1);
                    depdatedis4 = depday4.selectedIndex+1 + "/" + returnmth(mth4.substr(0,3)) + "/" + "20" + mth4.substr((String(mth4).length)-2,2); 
                    if(depdate4 < curdate)
                    {
                        errormsg += "- Invalid Departure date " + depdatedis4 + "\n";
                    }
                }
                else
                {
                    if(i2!="")
                    {
                        var splitdate = i2.split("/");
                        mth4 = splitdate[1];
                        depdate4 = new Date(splitdate[0],splitdate[1]-1,splitdate[2]);
                        depdatedis4 = splitdate[2] + "/" + splitdate[1] + "/" + splitdate[0]; 
                    }
                }
        }
        else{
                
                var depday1 = document.getElementById("l2sto1day");
                var depmth1 = document.getElementById("l2sto1mth");
                var depday2= document.getElementById("l2sto2day");
                var depmth2 = document.getElementById("l2sto2mth");
                var depday3= document.getElementById("l2sti1day");
                var depmth3 = document.getElementById("l2sti1mth");
                var depday4= document.getElementById("l2sti2day");
                var depmth4 = document.getElementById("l2sti2mth");                

                if(depmth1!=null)
                {
                    mth1 = depmth1.options[depmth1.selectedIndex].value;    
                    depdate1 = new Date("20" + mth1.substr((String(mth1).length)-2,2),returnmth(mth1.substr(0,3))-1,depday1.selectedIndex+1);
                    depdatedis1 = depday1.selectedIndex+1 + "/" + returnmth(mth1.substr(0,3)) + "/" + "20" + mth1.substr((String(mth1).length)-2,2); 
                    if(depdate1 < curdate)
                    {
                        errormsg += "- Invalid Departure date " + depdatedis1 + "\n";
                    }
                }
                else
                {
                    if(o1!="")
                    {
                        var splitdate = o1.split("/");
                        mth1 = splitdate[1];
                        depdate1 = new Date(splitdate[0],splitdate[1]-1,splitdate[2]);
                        depdatedis1 = splitdate[2] + "/" + splitdate[1] + "/" + splitdate[0]; 
                    }
                }
                if(depmth2!=null)
                {
                    mth2 = depmth2.options[depmth2.selectedIndex].value;
                    depdate2 = new Date("20" + mth2.substr((String(mth2).length)-2,2),returnmth(mth2.substr(0,3))-1,depday2.selectedIndex+1);
                    depdatedis2 = depday2.selectedIndex+1 + "/" + returnmth(mth2.substr(0,3)) + "/" + "20" + mth2.substr((String(mth2).length)-2,2); 
                    if(depdate2 < curdate)
                    {
                        errormsg += "- Invalid Departure date " + depdatedis2 + "\n";
                    }
                }
                else
                {
                    if(o2!="")
                    {
                        var splitdate = o2.split("/");
                        mth2 = splitdate[1];
                        depdate2 = new Date(splitdate[0],splitdate[1]-1,splitdate[2]);
                        depdatedis2 = splitdate[2] + "/" + splitdate[1] + "/" + splitdate[0]; 
                    }
                }
                if(depmth3!=null)
                {    
                    mth3 = depmth3.options[depmth3.selectedIndex].value;
                    depdate3 = new Date("20" + mth3.substr((String(mth3).length)-2,2),returnmth(mth3.substr(0,3))-1,depday3.selectedIndex+1);
                    depdatedis3 = depday3.selectedIndex+1 + "/" + returnmth(mth3.substr(0,3)) + "/" + "20" + mth3.substr((String(mth3).length)-2,2); 
                    if(depdate3 < curdate)
                    {
                        errormsg += "- Invalid Departure date " + depdatedis3 + "\n";
                    }
                }
                else
                {
                    if(i1!="")
                    {        
                    var splitdate = i1.split("/");
                        mth3 = splitdate[1];            
                        depdate3 = new Date(splitdate[0],splitdate[1]-1,splitdate[2]);
                        depdatedis3 = splitdate[2] + "/" + splitdate[1] + "/" + splitdate[0]; 
                    }
                }
                if(depmth4!=null)
                {
                    mth4 = depmth4.options[depmth4.selectedIndex].value;
                    depdate4 = new Date("20" + mth4.substr((String(mth4).length)-2,2),returnmth(mth4.substr(0,3))-1,depday4.selectedIndex+1);
                    depdatedis4 = depday4.selectedIndex+1 + "/" + returnmth(mth4.substr(0,3)) + "/" + "20" + mth4.substr((String(mth4).length)-2,2); 
                    if(depdate4 < curdate)
                    {
                        errormsg += "- Invalid Departure date " + depdatedis4 + "\n";
                    }
                }
                else
                {
                    if(i2!="")
                    {
                        var splitdate = i2.split("/");
                        mth4 = splitdate[1];
                        depdate4 = new Date(splitdate[0],splitdate[1]-1,splitdate[2]);
                        depdatedis4 = splitdate[2] + "/" + splitdate[1] + "/" + splitdate[0]; 
                    }
                }
                
        }                     
        
        if(d1!="")
        {    
            var spiltdate = d1.split("/");   
            d1_ = new Date(spiltdate[2],spiltdate[0]-1,spiltdate[1]);
            if(depdate1>d1_)
            {
                errormsg += "- Departure date " + depdatedis1 + " cannot be later than "  + spiltdate[1] + "/" + spiltdate[0] + "/" + spiltdate[2] + "\n";
            }
        }
        
        if(d2!="" && d3!="")
        {
            var spiltdate1 = d2.split("/");
            d2_ = new Date(spiltdate1[2],spiltdate1[0]-1,spiltdate1[1]);
            var spiltdate2 = d3.split("/");
            d3_ = new Date(spiltdate2[2],spiltdate2[0]-1,spiltdate2[1]);
            if(depdate1 < d2_ || depdate1 > d3_)
            {
                errormsg += "- Departure date " + depdatedis1 + " must be between "  + spiltdate1[1] + "/" + spiltdate1[0] + "/" + spiltdate1[2] + " and " + spiltdate2[1] + "/" + spiltdate2[0] + "/" + spiltdate2[2] + "\n";
            }
        }
        
        
        if(r2!="" && r2!="0")
        {
            var earliestretdate = new Date(depdate1);
            earliestretdate.setDate(earliestretdate.getDate()+Number(r2));        
            if(depdate4!="" || depdate3!=""){
                if(depdate4!="")
                {
                    if(depdate4 < earliestretdate)
                    {
                        errormsg += "- Return date " + depdatedis4 + " cannot be earlier than "  + earliestretdate.getDate() + "/" + (earliestretdate.getMonth()+1) + "/" + earliestretdate.getFullYear() + " due to Minimum stay of " + r2 + " days \n";
                    }
                }
                else
                {
                    if(depdate3 < earliestretdate)
                    {
                        errormsg += "- Return date " + depdatedis3 + " cannot be earlier than "  + earliestretdate.getDate() + "/" + (earliestretdate.getMonth()+1) + "/" + earliestretdate.getFullYear() + " due to Minimum stay of " + r2 + " days \n";
                    }
                }        
            }
        }
        
        if(r1!="" && r1!="0")
        {
        var latestretdate = new Date(depdate1);
            switch(r1.substr(0,1))
            {
                case "d":
                var iLen = String(r1).length;
                var nodays = r1.substr(1,iLen-1);     
                if(nodays!="")
                {
                    latestretdate.setDate(latestretdate.getDate()+ Number(nodays));                
                    if(depdate4!="" || depdate3!="")
                    {                       
                        if(depdate4!="")
                        {
                            if(depdate4 > latestretdate)
                            { 
                                errormsg += "- Return date " + depdatedis4 + " cannot be later than "  + latestretdate.getDate() + "/" + (latestretdate.getMonth()+1) + "/" + latestretdate.getFullYear() + " due to Maximum stay of " + nodays + " days\n";
                            }
                        }
                        else
                        {   
                            if(depdate3 > latestretdate)
                            { 
                                errormsg += "- Return date " + depdatedis3 + " cannot be later than "  + latestretdate.getDate() + "/" + (latestretdate.getMonth()+1) + "/" + latestretdate.getFullYear() + " due to Maximum stay of " + nodays + " days\n";
                            }
                        }                  
                    }
                }   
                break;
                case "m":
                    var iLen = String(r1).length;
                    var nomths = r1.substr(1,iLen-1);                
                    if(nomths!=""){
                        latestretdate.setMonth(latestretdate.getMonth() + Number(nomths));
                        if(depdate4!="" || depdate3!="")
                        {                       
                            if(depdate4!="")
                            {
                                if(depdate4 > latestretdate)
                                { 
                                    errormsg += "- Return date " + depdatedis4 + " cannot be later than "  + latestretdate.getDate() + "/" + (latestretdate.getMonth()+1) + "/" + latestretdate.getFullYear() + " due to Maximum stay of " + nomths + " months\n";
                                }
                            }
                            else
                            {   
                                if(depdate3 > latestretdate)
                                { 
                                    errormsg += "- Return date " + depdatedis3 + " cannot be later than "  + latestretdate.getDate() + "/" + (latestretdate.getMonth()+1) + "/" + latestretdate.getFullYear() + " due to Maximum stay of " + nomths + " months\n";
                                }
                            }                  
                        }                
                    }
                break;            
                case "y":
                    var iLen = String(r1).length;
                    var noyrs = r1.substr(1,iLen-1);
                    if(noyrs!=""){
                    latestretdate.setFullYear(latestretdate.getFullYear() + Number(noyrs));
                        if(depdate4!="" || depdate3!="")
                        {                       
                            if(depdate4!="")
                            {
                                if(depdate4 > latestretdate)
                                { 
                                    errormsg += "- Return date " + depdatedis4 + " cannot be later than "  + latestretdate.getDate() + "/" + (latestretdate.getMonth()+1) + "/" + latestretdate.getFullYear() + " due to Maximum stay of " + noyrs + " years\n";
                                }
                            }
                            else
                            {   
                                if(depdate3 > latestretdate)
                                { 
                                    errormsg += "- Return date " + depdatedis3 + " cannot be later than "  + latestretdate.getDate() + "/" + (latestretdate.getMonth()+1) + "/" + latestretdate.getFullYear() + " due to Maximum stay of " + noyrs + " years\n";
                                }
                            }                  
                        }                
                    }
                break;
            }
        }                
        if(errormsg!="This is the following errors that are against the fare condtions -: \n")
        {        
            alert(errormsg);
        }
        
    }
//--------------------------------------------------
                
    function returnmth(mth){
        switch(mth)
        {
        case "Jan":
            return 1;
            break;
        case "Feb":
            return 2;
            break;
        case "Mar":
            return 3;
            break;
        case "Apr":
            return 4;
            break;
        case "May":
            return 5;
            break;
        case "Jun":
            return 6;
            break;
        case "Jul":
            return 7;
            break;
        case "Aug":
            return 8;
            break;
        case "Sep":
            return 9;
            break;
        case "Oct":
            return 10;
            break;
        case "Nov":
            return 11;
            break;
        case "Dec":       
            return 12;
            break;
        }
                    
    }


