function Pchange(a){
    document.form1.submit();
}

function Default_position(a){
if (a.selectedIndex!=0) {a.selectedIndex=0};
}

function addBookMark(bookMarkURL,bookMarkTitle) {
  window.external.AddFavorite(bookMarkURL,bookMarkTitle)
  }

function fnSet(){
  oHomePage.setHomePage('http://www.horse21.net');
  event.returnValue = false;
}

//Added by Nick 07.10.02
var arCtV = Array();
var arCtT = Array();

function ChCn()
{  var i = 0;
  var j = 0;
  var k = 0;
  var arPr = new Array(2);
  var oStr = '';

  j = document.QuickSearch.sCt.options.length;
  for (i = j - 1; i > 0; i--)
    document.QuickSearch.sCt.options[i] = null;
  k = parseInt(document.QuickSearch.sCn.options[document.QuickSearch.sCn.selectedIndex].value);
  j = 1;
  var elOpt = new Option;
  elOpt.value = "0:0";
  elOpt.text = "Select city";
  document.QuickSearch.sCt.options[0] = elOpt;
  for (i = 0; i < arCtV.length; i++) {
    oStr = arCtV[i];
    arPr = oStr.split(':');
    if ((k == 0) || (parseInt(arPr[0]) == k)) {
      elOpt = new Option;
      elOpt.value = arCtV[i];
      elOpt.text = arCtT[i];
      document.QuickSearch.sCt.options[j] = elOpt;
      j += 1;
    }
  }
}
var DayInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function ChDt(name)
{
  var mYear = parseInt(document.forms('QuickSearch').item(name+'3').options[document.forms('QuickSearch').item(name+'3').selectedIndex].value, 10);
  var mMonth = parseInt(document.forms('QuickSearch').item(name+'2').options[document.forms('QuickSearch').item(name+'2').selectedIndex].value, 10);
  var mDay = parseInt(document.forms('QuickSearch').item(name+'1').options[document.forms('QuickSearch').item(name+'1').selectedIndex].value, 10);
  var k = parseInt(document.forms('QuickSearch').item(name+'1').selectedIndex, 10);
  //alert(mYear + ' ' + mMonth + ' ' + mDay + ' ' + k);
  if (mYear % 4 == 0)
    DayInMonth[1] = 29;
  else
    DayInMonth[1] = 28;

  for (i = document.forms('QuickSearch').item(name+'1').length - 1; i >= 0; i--)
    document.forms('QuickSearch').item(name+'1').options[i] = null;

  for (i = 0; i < DayInMonth[mMonth - 1]; i++) {
    var elOpt = new Option;
    elOpt.value = i+1;
    elOpt.text = String(i+1);
    document.forms('QuickSearch').item(name+'1').options[i] = elOpt;
  }
  if (k > DayInMonth[mMonth]-1)
    document.forms('QuickSearch').item(name+'1').options[DayInMonth[mMonth]-1].selected = true;
  else
    document.forms('QuickSearch').item(name+'1').options[k].selected = true;
}

function ClientSetDates()
{
var nDate = new Date();
var DayInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31,31); //12+next january

  var aDay, aMonth, aYear, dDay, dMonth, dYear;
  aDay = nDate.getDate() + 30;
  aMonth = nDate.getMonth() + 1;
  aYear = nDate.getYear();
  if (aYear % 4 == 0) DayInMonth[1] = 29;
  if (aDay > DayInMonth[aMonth-1]) {
    aDay -= DayInMonth[aMonth-1];
    aMonth += 1;
  }
  if (aDay > DayInMonth[aMonth-1]) {
    aDay -= DayInMonth[aMonth-1];
    aMonth += 1;
  }
  if (aMonth > 12) {
    aMonth -= 12;
    aYear += 1;
    document.forms('QuickSearch').AD3.selectedIndex=1;
  }
  dDay = nDate.getDate() + 35;
  dMonth = nDate.getMonth() + 1;
  dYear = nDate.getYear();
  if (dYear % 4 == 0) DayInMonth[1] = 29;
  if (dDay > DayInMonth[dMonth-1]) {
    dDay -= DayInMonth[dMonth-1];
    dMonth += 1;
  }
  if (dDay > DayInMonth[dMonth-1]) {
    dDay -= DayInMonth[dMonth-1];
    dMonth += 1;
  }
  if (dMonth > 12) {
    dMonth -= 12;
    dYear += 1;
    document.forms('QuickSearch').DD3.selectedIndex=1;
  }
  document.forms('QuickSearch').AD2.selectedIndex=aMonth-1;
  ChDt('AD');
  document.forms('QuickSearch').AD1.selectedIndex=aDay-1;
  document.forms('QuickSearch').DD2.selectedIndex=dMonth-1;
  ChDt('DD');
  document.forms('QuickSearch').DD1.selectedIndex=dDay-1;

}

function ChRm(name)
{
  var NumberRoom;
  if (name == 'sSR')
    NumberRoom = 3 - parseInt(document.forms('QuickSearch').item('sDR').options[document.forms('QuickSearch').item('sDR').selectedIndex].value, 10);
  else
    NumberRoom = 3 - parseInt(document.forms('QuickSearch').item('sSR').options[document.forms('QuickSearch').item('sSR').selectedIndex].value, 10);
  if (parseInt(document.forms('QuickSearch').item(name).options[document.forms('QuickSearch').item(name).selectedIndex].value, 10) > NumberRoom)
    document.forms('QuickSearch').item(name).options[NumberRoom].selected = true;
}

function ExcSbm()
{  var bPer = true;
  var ADate = new Date(document.forms('QuickSearch').AD3.options[document.forms('QuickSearch').AD3.selectedIndex].value,
    document.forms('QuickSearch').AD2.selectedIndex,
    document.forms('QuickSearch').AD1.options[document.forms('QuickSearch').AD1.selectedIndex].value);
  var DDate = new Date();
  var iSR = (document.forms('QuickSearch').NumberOfPersons.value==1?document.forms('QuickSearch').NumberOfRooms.value:0);
  var iDR = (document.forms('QuickSearch').NumberOfPersons.value>1?document.forms('QuickSearch').NumberOfRooms.value:0);
  var oStr = document.forms('QuickSearch').sCt.options[document.forms('QuickSearch').sCt.selectedIndex].value;
  var arPr = new Array();
  var iPer = 0;

  arPr = oStr.split(':');

  if ((document.forms('QuickSearch').sCn.selectedIndex == 0) && (arPr[0] == '0')) {
    alert('Country should be selected.');
    bPer = false;
  }
    if (bPer) {
      if (document.forms('QuickSearch').MoreCities.value.search(/[^a-zA-Z .''-]/)!=-1) {
        alert('Please fill the "destination city" field with English spelling of the city name only.');
        bPer = false;
      }
    }

  if (bPer) {
    iPer = Math.round((ADate.getTime() - DDate.getTime()) / 86400000);
    if (iPer < -1) {
      alert('Arrival date should be later than today.');
      bPer = false;
    }
  }
  if (bPer) {
    DDate = new Date(document.forms('QuickSearch').DD3.options[document.forms('QuickSearch').DD3.selectedIndex].value,
      document.forms('QuickSearch').DD2.selectedIndex,
      document.forms('QuickSearch').DD1.options[document.forms('QuickSearch').DD1.selectedIndex].value);
    iPer = Math.round((DDate.getTime() - ADate.getTime()) / 86400000);
    if (iPer < 1) {
      alert('Arrival date should be sooner than departure date.');
      bPer = false;
    }
    else if (iPer > 31) {
      alert('There are more than 30 days between arrival and departure.');
      bPer = false;
    }
  }

  if (bPer) {
    iPer = document.forms('QuickSearch').sCn.selectedIndex;
    if (iPer == 0) {
      for (iPer = 1; iPer < document.forms('QuickSearch').sCn.options.length; iPer++)
        if (arPr[0] == document.forms('QuickSearch').sCn.options[iPer].value)
          break;
    }
    oStr = document.forms('QuickSearch').sCn.options[iPer].value + ':' +
      document.forms('QuickSearch').sCn.options[iPer].text + ':';
    oStr += arPr[1] + ':';
    if (arPr[1] != '0')
      oStr += document.forms('QuickSearch').sCt.options[document.forms('QuickSearch').sCt.selectedIndex].text;
    oStr += ';' + ADate.getFullYear() + '-';
    iPer = ADate.getMonth() + 1;
    if (iPer < 10)
      oStr += '0';
    oStr += iPer + '-';
    iPer = ADate.getDate();
    if (iPer < 10)
      oStr += '0';
    oStr += iPer + ';' + DDate.getFullYear() + '-';
    iPer = DDate.getMonth() + 1;
    if (iPer < 10)
      oStr += '0';
    oStr += iPer + '-';
    iPer = DDate.getDate();
    if (iPer < 10)
      oStr += '0';
    oStr += iPer + ';' + iSR + ';' + iSR + ';' + iDR + ';' + String(2*parseInt(iDR,10)) + ';1;';

  }
  if (bPer)
  {
    document.forms('QuickSearch').BP1.value = oStr + ";;5,4,3,2,1,0;;;";
    document.forms('QuickSearch').BP.value  = oStr + ";;5,4,3,2,1,0;;;";
//document.write(document.forms('QuickSearch').BP1.value);
    document.forms('QuickSearch').submit();
  }

}

//End Nick

function CityHelp()
{
var retval=showModalDialog('list_cities.asp?CountryID='+document.forms('QuickSearch').sCn.value, 'displayWindow', 'dialogWidth:320px;dialogHeight:500px;status:no;center:yes;help=no;minimize=no;maximize=no;');
if (String(retval)!="undefined") document.forms('QuickSearch').MoreCities.value = retval;
return false;
}

function SetDate(target,year,month,day)
{
if (target=="AD")
  {
                        eval (document.forms('QuickSearch').AD2.options[month].selected=true);
                        eval (document.forms('QuickSearch').AD3.options[year-2005].selected=true);
            ChDt('AD');
                        eval (document.forms('QuickSearch').AD1.options[day-1].selected=true);
  }
else
  {
                        eval (document.forms('QuickSearch').DD2.options[month].selected=true);
                        eval (document.forms('QuickSearch').DD3.options[year-2005].selected=true);
            ChDt('DD');
                        eval (document.forms('QuickSearch').DD1.options[day-1].selected=true);
  }
}

