
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 );
    }
  }
};

 
   function InitMenu()
   {
     var bar = menuBar.children     

     for(var i=0;i < bar.length;i++) 
        {
          var menu=eval(bar[i].menu)
          menu.style.visibility = "hidden"
          bar[i].onmouseover = new Function("ShowMenu("+bar[i].id+")")
          var Items = menu.children
          for(var j=0; j<Items.length; j++)
            {
              var menuItem = eval(Items[j].id)
                
                if(menuItem.menu != null)
                   { 
                    menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>10</Span>"
                    //var tmp = eval(menuItem.id+"_Arrow")
                    // tmp.style.pixelLeft = menu.getBoundingClientRect().Right //- tmp.offsetWidth - 15
                    FindSubMenu(menuItem.menu)}
               
                 if(menuItem.cmd != null) 
                   {
                   menuItem.onclick = new Function("Do("+menuItem.id+")") } 
                   
              menuItem.onmouseover = new Function("menuhighlight("+Items[j].id+")")
            
            }    
        
        }  
   }
   function FindSubMenu(subMenu)
   {
         var menu=eval(subMenu)
         var Items = menu.children
          for(var j=0; j<Items.length; j++)
            {
              menu.style.visibility = "hidden"
              var menuItem = eval(Items[j].id)
              
              
              if(menuItem.menu!= null)
                 {
                    menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>10</Span>"
                    // var tmp = eval(menuItem.id+"_Arrow")
                    //tmp.style.pixelLeft = 10 
                    //menuItem.getBoundingClientRect().right - tmp.offsetWidth - 10
                    FindSubMenu(menuItem.menu)
                 }

                 if(menuItem.cmd != null) 
                   {
                   menuItem.onclick = new Function("Do("+menuItem.id+")") } 
                  
              menuItem.onmouseover = new Function("menuhighlight("+Items[j].id+")")
                 
            }  
   } 
   function ShowMenu(obj)
   {
     HideMenu(menuBar)
     var menu = eval(obj.menu)
     var bar = eval(obj.id)
     bar.className="barOver"
     menu.style.visibility = "visible"
     //menu.style.pixelTop =  obj.getBoundingClientRect().top + obj.offsetHeight + Bdy.scrollTop
       menu.style.pixelBottom =  18
     
    menu.style.pixelLeft = obj.getBoundingClientRect().left + Bdy.scrollLeft
      

   }
   
   function menuhighlight(obj)
   {
     var PElement = eval(obj.parentElement.id)
     if(PElement.hasChildNodes() == true)
     {  var Elements = PElement.children
       for(var i=0;i<Elements.length;i++)
       {
          TE = eval(Elements[i].id)
          TE.className = "menuItem"
       }
      } 
     obj.className="ItemMouseOver"
     window.defaultStatus = obj.title
     ShowSubMenu(obj)
   }
   
   function Do(obj)
   {
    var cmd = eval(obj).cmd	
    top.mainFrame.navigate(cmd)
    //window.navigate(cmd) 
   }
   
   function HideMenu(obj)
   {
          if(obj.hasChildNodes()==true)
              {  
                 var child = obj.children     
                 
                 for(var j =0;j<child.length;j++)
                  {
                     if (child[j].className=="barOver")
                     {var bar = eval(child[j].id)
                      bar.className="Bar"}
                      
                     if(child[j].menu != null)
                       {
                          var childMenu = eval(child[j].menu)
                          if(childMenu.hasChildNodes()==true) 
                               HideMenu(childMenu)
                          
                           childMenu.style.visibility = "hidden" 
                         }
                  }
              
              }
   }
  function ShowSubMenu(obj)
  {
     PMenu = eval(obj.parentElement.id)
      HideMenu(PMenu)
     if(obj.menu != null)
     {
     var menu = eval(obj.menu)
     menu.style.visibility = "visible"
     //menu.style.pixelTop =  obj.getBoundingClientRect().top + Bdy.scrollTop
     //menu.style.pixelTop =  20
     //menu.style.pixelLeft = obj.getBoundingClientRect().right + Bdy.scrollLeft
     if(menu.getBoundingClientRect().right > window.screen.availWidth )
       menu.style.pixelLeft = obj.getBoundingClientRect().left - menu.offsetWidth
    }
  } 




