//JavaScript file for www.sweeneys-hotel.com

function writeBackLink(){
  if( window.location ){
    var loc = window.location.href;
    var page = loc.substring( loc.lastIndexOf( "/" ) + 1, loc.indexOf( ".php" ) );
    if( page != "front" ){
      var linkDiv = document.getElementById( "backLink" );
      if( linkDiv )
        linkDiv.innerHTML = "<a href=\"javascript:window.history.go( -1 )\"><img src=\"images/Back.png\" title=\"Go Back\" class=\"backButton\"></a>";
    }
  }
}

function describeElement( el ){
  var assets = "";
  for( var i in el ){
    assets += i + "  *-*  ";
  }
  alert( assets );
}

function servOC( e ){
  var tab = xGetElementById( "tab" );
  var miniTab = xGetElementById( "miniTab" );
  if( tab != null ){
    if( tab.style.display == "none" ){
      tab.style.display = "block";
      xSlideTo( tab, xLeft( tab ), 0, 500 );
      miniTab.style.display = "none";
    }
    else if( e ){
      var x = ( e.x ) ? e.x + document.body.scrollLeft : e.pageX;
      var y = ( e.y ) ? e.y + document.body.scrollTop : e.pageY;
      if( !xHasPoint( tab, x, y ) ){
        xSlideTo( tab, xLeft( tab ), 95, 500 );
        miniTab.style.display = "block";
        setTimeout( "hide( 'tab' )", 500 );
      }
    }
  }
}

function hide( el ){
  if( ( el = xGetElementById( el ) ) ) el.style.display = "none";
}


//////////////////////////////////////////////////////////
//Floating Menu
window.onload = function(){
  if( window.winOnLoad ) window.winOnLoad();
}
window.onunload = function(){
  if( window.winOnUnload ) window.winOnUnload();
}

var slideTime = 400;
var floatAtBottom = true;

function winOnLoad(){
  winOnResize(); // set initial position
  xAddEventListener(window, 'resize', winOnResize, false);
  xAddEventListener(window, 'scroll', winOnScroll, false);
}
function winOnResize(){
  xWidth( 'pageFooter', xClientWidth() );
  winOnScroll(); // initial slide

  //xGetElementById( "miniTab" ).style.left = ( xClientWidth() - 700 ) / 2;
  xGetElementById( "tab" ).style.left = ( xClientWidth() - 700 ) / 2;
}
function winOnScroll() {
  var y = xScrollTop();
  if( floatAtBottom ){
    y += xClientHeight() - xHeight( 'pageFooter' );
  }
  xSlideTo( 'pageFooter', 0, y, slideTime );
}



//////////////////////////////////////////////////////////
var myrules = {
	'.tabButtonAbout' : function( el ){
		el.onmouseover = function(){ this.src = "images/icons/BookOrange.png"; }
		el.onmouseout = function(){ this.src = "images/icons/BookRed.png"; }
		el.onmousedown = function(){ this.src = "images/icons/BookBlack.png"; }
	},
	'.tabButtonTariffs' : function( el ){
		el.onmouseover = function(){ this.src = "images/icons/EuroOrange.png"; }
		el.onmouseout = function(){ this.src = "images/icons/EuroRed.png"; }
		el.onmousedown = function(){ this.src = "images/icons/EuroBlack.png"; }
	},
	'.tabButtonBooking' : function( el ){
		el.onmouseover = function(){ this.src = "images/icons/CalendarOrange.png"; }
		el.onmouseout = function(){ this.src = "images/icons/CalendarRed.png"; }
		el.onmousedown = function(){ this.src = "images/icons/CalendarBlack.png"; }
	},
	'.tabButtonGallery' : function( el ){
		el.onmouseover = function(){ this.src = "images/icons/PicturesOrange.png"; }
		el.onmouseout = function(){ this.src = "images/icons/PicturesRed.png"; }
		el.onmousedown = function(){ this.src = "images/icons/PicturesBlack.png"; }
	},
	'.tabButtonInfo' : function( el ){
		el.onmouseover = function(){ this.src = "images/icons/LetterOrange.png"; }
		el.onmouseout = function(){ this.src = "images/icons/LetterRed.png"; }
		el.onmousedown = function(){ this.src = "images/icons/LetterBlack.png"; }
	}
};

Behaviour.register( myrules );
//////////////////////////////////////////////////////////

/*
  <script type="text/javascript"></script>
  <noscript>
    <div style="width: 100%; position: absolute; bottom: 165px;><center>
      <div id="tab">
        <div style="position:absolute; width: 700px; height: 120px;"><img src="images/Tab.png" width="700px" height="120px"></div>
        <div style="position: absolute; z-index: 99; width: 716; height: 75px; left: 0px; top: 0px; text-align: center; padding-top: 10px;">
          <a href="about.php"><img src="images/icons/BookRed.png" class="tabButtonAbout"></a>
          <a href="tariffs.php"><img src="images/icons/EuroRed.png" class="tabButtonTariffs"></a>
          <a href="onlineBooking.php"><img src="images/icons/CalendarRed.png" class="tabButtonBooking"></a>
          <a href="gallery.php"><img src="images/icons/PicturesRed.png" class="tabButtonGallery"></a>
          <a href="contactInfo.php"><img src="images/icons/LetterRed.png" class="tabButtonInfo"></a>
        </div>
      </div></center>
    </div>
  </noscript>
*/
