function SetCorpRate() {
    // Set contains function of array
    Array.prototype.contains = function (element) 
    {
       for (var i = 0; i < this.length; i++) 
       {
          if (this[i] == element) 
          {
             return true;
          }
       }
       return false;
    }

    // Weekend rules
    arrTimeForFriday = ["12:00","12:30","13:00","13:30","14:00","14:30","15:00","15:30","16:00","16:30","17:00","17:30","18:00","18:30","19:00","19:30","20:00","20:30","21:00","21:30","22:00","22:30","23:00","23:30"]
    arrTimeForMonday = ["00:00","00:30","01:00","01:30","02:00","02:30","03:00","03:30","04:00","04:30","05:00","05:30","06:00","06:30","07:00","07:30","08:00","08:30","09:00","09:30","10:00","10:30","11:00","11:30","12:00"]

    var pDay = GetE('pickup_day').value;
    var pMonth = GetE('pickup_month').value;
    var pYear = GetE('pickup_year').value;
    var pTime =  GetE('pickup_time').value;

    var rDay = GetE('return_day').value;
    var rMonth = GetE('return_month').value;
    var rYear = GetE('return_year').value;
    var rTime =  GetE('return_time').value;

    var dPickUp = new Date();
    dPickUp.setFullYear(pYear, pMonth - 1, pDay);

    var dReturn = new Date();
    dReturn.setFullYear(rYear, rMonth - 1, rDay);

    // If pickup day is Friday
    if (dPickUp.getDay() == 5 && arrTimeForFriday.contains(pTime))
    {
       //alert("Pick up is in Friday week day.");
       if (dReturn.getDay() == 5 || dReturn.getDay() == 6 || dReturn.getDay() == 0)
       {
          //alert("Return is in either Friday or Saturday or Sunday.");
          GetE('corp_rate_id').value = 'CDWKEND600';
          //alert(GetE('corp_rate_id').value);
       }
       else if (dReturn.getDay() == 1 && arrTimeForMonday.contains(rTime))
       {
          //alert("Return is in Monday.");
          GetE('corp_rate_id').value = 'CDWKEND600';
          //alert(GetE('corp_rate_id').value);
       }
       else
       {
          GetE('corp_rate_id').value = 'CD100KMS';
          //alert(GetE('corp_rate_id').value);
       }
    }
    // If pickup day is Saturday
    else if (dPickUp.getDay() == 6)
    {
       //alert("Pick up is in Saturday.");
       if (dReturn.getDay() == 6 || dReturn.getDay() == 0)
       {
          //alert("Return is Sunday.");
          GetE('corp_rate_id').value = 'CDWKEND600';
          //alert(GetE('corp_rate_id').value);
       }
       else if (dReturn.getDay() == 1 && arrTimeForMonday.contains(rTime))
       {
          //alert("Return is in Monday.");
          GetE('corp_rate_id').value = 'CDWKEND600';
          //alert(GetE('corp_rate_id').value);
       }
       else
       {
          GetE('corp_rate_id').value = 'CD100KMS';
          //alert(GetE('corp_rate_id').value);
       }
    }
    // If pickup day is Sunday
    else if (dPickUp.getDay() == 0)
    {
       alert("Pick up is in Sunday.");
       if (dReturn.getDay() == 0)
       {
          //alert("Return is Sunday.");
          GetE('corp_rate_id').value = 'CDWKEND600';
          //alert(GetE('corp_rate_id').value);
       }
       else if (dReturn.getDay() == 1 && arrTimeForMonday.contains(rTime))
       {
          //alert("Return is in Monday.");
          GetE('corp_rate_id').value = 'CDWKEND600';
          //alert(GetE('corp_rate_id').value);
       }
       else
       {
          GetE('corp_rate_id').value = 'CD100KMS';
          //alert(GetE('corp_rate_id').value);
       }
    }
    else
    {
       GetE('corp_rate_id').value = 'CD100KMS';
       //alert(GetE('corp_rate_id').value);
    }
}