var SPEED = 800;
var EASING = 'easeInOutQuart';


var keepHeight = true;

function HoldHeight()
{
	if (keepHeight == false) return;
	$('#Navi').animate({ top: GetTop() }, SPEED / 4, HoldHeight);
}

function GetTop()
{
	var ST = 0;
	var MaxHeight = $(document).height() - $('#Navi').height() - $('#footer').height() + 22;
	
	if( ( window.pageYOffset )) { ST = window.pageYOffset;}
	if( ( document.documentElement.scrollTop ) ) { ST = document.documentElement.scrollTop ; }
	if( ( document.body.scrollTop )) { ST = document.body.scrollTop; }
	if (ST > MaxHeight) return MaxHeight;
	return ST;
}


function GetHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  OffsetHeight = myHeight - 150;
  
  //document.getElementById('BarryWhite').style.height= OffsetHeight +'px';
  return myHeight;
}

function initialize() {
    var myOptions = {
      zoom: 13,
      center: new google.maps.LatLng(47.263082,11.394088),
      navigationControl: true,
      scaleControl: true,
	  streetViewControl: false,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    var map = new google.maps.Map(document.getElementById("mapCanvas"),
                                  myOptions);
	
	 var image = 'http://www.pp-medien.at/images/map/Icon.png';
	 var myLatLng = new google.maps.LatLng(47.263082,11.394088);
	 var beachMarker = new google.maps.Marker({
     position: myLatLng,
     map:map,
     icon:image
  	});

  }

function Route() {
	url ='http://maps.google.de/maps?&t=m&source=s_d&daddr=Maria-Theresien-Straße+24,+Innsbruck,+Österreich&saddr='+document.getElementById('Abfahrtsort').value;
	
	document.getElementById('googleMaps').action = url;
	document.getElementById('googleMaps').submit();
	
}

function GoogleMaps(code){
	if (code==13) {
		Route();
	}
}



// SETTING SCROLLABLE HASHES
function setScrollableAnchors() {
	$("a[href^='#']").click(function (e) {
		if(this.hash == '') return;
		e.preventDefault();
		var element = this.hash;
		scrollBodyTo(element);
		//document.location.hash = this.hash;
		//$.scrollTo(null, GetTop());
	});
}

function scrollBodyTo(element) {
	if ($(element).size() == 0) return;
	$.scrollTo(element, SPEED, {easing: EASING});
	keepHeight = false;
	$('#Navi').animate({ top: $(element).offset().top + 'px' }, SPEED / 1.15, EASING, function(){ keepHeight = true; HoldHeight(); });
}

function ready() {
	setScrollableAnchors();
	HoldHeight();
	Cufon.replace('h1, h2, h3, h4, .cufon');
	try { Cufon.now(); } catch(e){}
	try { Cufon.refresh(); } catch(e){}
}


$(document).ready(ready);

