
var RootDir = 'http://195.188.244.12/coop-travel/'
var HomePage = 'default.htm';
var searchPage = RootDir + 'search.asp';
var shoppingBasket = RootDir + 'basket.asp';
var AccountsPage = 'operators.asp';
var ImagesDir = RootDir + 'images/'

function InsertPageHeader() {
  document.write ('<img src="' + ImagesDir + 'banner.jpg"><br>');
  document.write ('<center><br>');
  document.write ('<img src="' + ImagesDir + 'tqlogo.jpg"><br><br>');
};

function GetParam(name) {
  var url = window.location.toString();
//  alert(url);
  var name_loc = url.indexOf(name);
  var val_start = url.indexOf('=',name_loc)+1;
  var val_end = url.indexOf('&',val_start);
  if (val_end == -1) { val_end = url.length };
  if (val_start > 0) { return url.substring(val_start,val_end) } else { return null; };
};

function RenameDests() {
  for (x=1;x<=count;x++) {
    id = 'shortdest' + x;
    code_obj = document.all( id );
    id = 'RC' + x + '_2';
    desc_obj = document.all( id );
    id = 'longdest' + x;
    dest_obj = document.all( id );    
    if (code_obj.value == 'PMI') { desc_obj.innerHTML = 'MAJORCA'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'KGS') { desc_obj.innerHTML = 'KOS'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'LPA') { desc_obj.innerHTML = 'GRAN CANARIA'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'MAH') { desc_obj.innerHTML = 'MENORCA'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'ZTH') { desc_obj.innerHTML = 'ZAKYNTHOS'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'HER') { desc_obj.innerHTML = 'CRETE'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'GRO') { desc_obj.innerHTML = 'COSTA BRAVA'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'LCA') { desc_obj.innerHTML = 'CYPRUS'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'FAO') { desc_obj.innerHTML = 'PORTUGAL'; dest_obj.value = desc_obj.innerHTML; };
    if (code_obj.value == 'REU') { desc_obj.innerHTML = 'COSTA DORADA'; dest_obj.value = desc_obj.innerHTML; };
  };  
};

function MouseOver(img) {
  pos = img.src.indexOf('.gif');
  img.src = img.src.substring(0,pos) + '2.gif';
};

function MouseOut(img) {
  pos = img.src.indexOf('2.gif');
  img.src = img.src.substring(0,pos) + '.gif';
};

function CookieCheck() {
  var result = true
  var id = ReadCookie('userid');
  if (id == null) { 
    result = false
  };
  return result;
};

function WriteCookie(name,value,hours) {
  var expiry = new Date;
  var nowPlusNumHours = expiry.getTime() + (60 * 60 * 1000 * hours);
  expiry.setTime(nowPlusNumHours);
  document.cookie = name + "=" + value + "; expires=" + expiry.toGMTString();
};

function ReadCookie(name) {
  var CookieText = document.cookie;                             // Read the cookie
  var start = CookieText.indexOf(name,0);                       // Get the position of the name/value pair
  if (start > -1) {                                             // Check the name/value pair exists
    var end = CookieText.indexOf(";",start);                    // Get position of end of name/value pair
    if (end == -1) { end = CookieText.length };                 // If this is the last pair, then set end to length of Cookie
    var value = CookieText.substring(start+name.length+1,end);  // Read value of name/value pair
  } else { var value = null };                                  // If doesn't exist, set to null
  return value;                                                 // Return the value of the name/value pair
};

function DeleteCookie(name) {
  var expiry = new Date();
  expiry.setTime(expiry.getTime() - 1);
  var value = ReadCookie(name);
  document.cookie = name + "=" + value + "; expires=" + expiry.toGMTString();
};


function LogOff() {
  DeleteCookie('userid');
  DeleteCookie('username');
  window.location = HomePage;
};

function LogOn(id,name) {
  DeleteCookie('userid');
  DeleteCookie('username');
  WriteCookie('userid',id,8);
  WriteCookie('username',name,8);
  window.location = SearchPage;
};


function highlight(iRow,iCol,sColor)
{
  var r, c;
  var obj;

  //alert(iRow + ':' + iCol + ':' + sColor);

  //if (type==1) { sColor='yellow' };
  //if (type==2) { sColor='#dde1f5' };
  //if (type==3) { sColor='#b9c2ef' };
  
  if ( iRow && iCol ) // Crosshair
  {
    for ( r = 0; r <= iRow; r++ )
    {
      id = 'RC' + r + '_' + iCol;
      obj = document.all( id );
      if (obj)
        obj.bgColor = sColor;
    }

    for ( c = 0; c <= iCol; c++ )
    {
      id = 'RC' + iRow + '_' + c;
      obj = document.all( id );
      if (obj)
        obj.bgColor = sColor;
    }
  }
  else if ( iRow == 0 ) // Doing the whole column
  {
  //alert('Col:'+iRow);
    r = 0;
    id = 'RC' + r + '_' + iCol;
    obj = document.all( id );
    while (obj)
    {
//      if (sColor != 'yellow') { if (isOdd(r)) { sColor='#dde1f5' } else { sColor='#b9c2ef' }; };
      obj.style.backgroundColor = sColor;
//      obj.bgColor = sColor;
      r++;
      id = 'RC' + r + '_' + iCol;
      obj = document.all( id );
    }
  }
  else if ( iCol == 0 ) // Doing the whole row
  {
  //alert('Row:'+iCol);
    c = 0;
    id = 'RC' + iRow + '_' + c;
    obj = document.all( id );
    while (obj)
    {
      obj.style.backgroundColor = sColor;
      c++;
      id = 'RC' + iRow + '_' + c;
      obj = document.all( id );
    }
  }
};