if ("onhashchange" in window) {
   ohc = false;
}
else {
	ohc = false;
}

if (ohc) {
	window.onhashchange = function() {
		tools.hashes.processNewHash();
	}
}
else {
	tools.hashes.oldHash = window.location.hash;
	var pageInt = setInterval(function() {tools.hashes.checkHash();}, 100);
}

// Array.indexOf not supported in IE
if (!Array.indexOf) {
  Array.prototype.indexOf = function (obj, start) {
    for (var i = (start || 0); i < this.length; i++) {
      if (this[i] == obj) {
        return i;
      }
    }
    return -1;
  }
}

function _initTooltip() {
	$('.loch').live('mouseenter',function() {
		$(this).children('.tooltip').fadeIn();
	});
	
	$('.loch').live('mouseleave',function() {
		$(this).children('.tooltip').fadeOut();
	})
	
	$('.loch').live('click',function() {
		$(this).children('.tooltip').fadeOut();
	});
}

jQuery(document).ready(function() {
	if (window.location.hash == '') {
		jQuery('#overlay').remove();
	}
	
	if(animations.config.images.slideshow.images.length > 1) {
		animations.createImageNavigation();
	}

	jQuery('#overlay').show();
	
	tools.log($('.e2').width());
	
	jQuery('.bg_img').fadeIn(animations.config.animation.speed);
	
	jQuery('.viewToggle').live('click', function() {
		animations.toggleView();
	});
	
	// Starte Slideshow wenn diese aktiviert ist
	if(animations.config.images.slideshow.enabled) {
		animations.config.images.slideshow.cur = 0;
		animations.config.images.slideshow.timeout = setTimeout(function() {
			animations.changeImage();
		}, animations.config.images.slideshow.timer);
	};
	
	$('#metanavi a').mouseover(function() {
		if(!$(this).hasClass(animations.config.navigation.active)) {
			//animations.colorFade($(this), '#fff');
		}		
	});
	
	$('#metanavi a').mouseout(function() {
		if(!$(this).hasClass(animations.config.navigation.active)) {
			//animations.colorFade($(this), '#999', false);
		}
	});
	
	$('#navigation a').each(function() {
		$(this).children('.bg').animate({
			opacity: 0
		})
	});
	
	$('#navigation a').mouseover(function() {		
			$(this).children('.bg').stop().animate({
				opacity: 1
			});	
	});
	
	$('#navigation a').mouseout(function() {
		if(!$(this).parent().hasClass('nav_active')) {
			$(this).children('.bg').stop().animate({
				opacity: 0
			});
		}
	});
	
	$('.ansprechpartner_name').live('click', function() {
		animations.toggleAnsprechpartner($(this).attr('id'));
	});
		
	
	$('.platzinfo img').live('click' ,function() {
		animations.toggleTooltip($(this).parent().children('.tooltip'));
	});
	
	$('.button').live('mouseenter' ,function() {
		animations.showButtonTooltip($(this));
	});
	
	$('.button').live('mouseleave' ,function() {
		animations.hideButtonTooltip($(this));
	});
	
	$('.mail').live('click', function() {
	//	addthis_sendto('email', {url: 'http://winstongolf.de'});
	});
	
	tabs.bind();
	
	_initTooltip();
		
	// Setze die Bilder- und Containergrößen anhand der Browsergröße
	background.setSize();
	animations.resizeContainer();
	
	
	// Clickfunktionen für Claims
	$('.claim_readmore').live('click', function() {
		var claimID = $(this).attr('id').replace('claim_toggle_', '');
		animations.toggleClaimText(claimID);
		
		//automatische Slideshow unterbrechen 
		if(animations.config.images.slideshow.timeout != false && animations.config.images.slideshow.enabled == true) {
			clearTimeout(animations.config.images.slideshow.timeout);
			animations.config.images.slideshow.timeout = false;
		}
		
	});
	
	$('.claim_text_close').live('click', function() {
		var claimID = $(this).attr('id').replace('claim_close_', '');
		animations.toggleClaimText(claimID);
		
		//automatische Slideshow fortsetzen 
		if(animations.config.images.slideshow.timeout == false && animations.config.images.slideshow.enabled == true) {
			animations.imageObjectTimeout();
		}
		
	});
	
	// pulsierender Claim Pfeil
	animations.fadeOutClaimReadMore();
	
});

jQuery(document).mousemove(function(e){

	animations.config.mouseX = e.pageX;
	animations.config.mouseY = e.pageY;
	
	/*screenPos = Math.round(100/background.win.size.width * e.pageX);
	
	background.img.pos.left = background.img.pos.max*(screenPos/50);	
	
	background.addStyle('.e2', 'left', background.img.pos.left+'px');
	background.addStyle('.claim', 'marginLeft', Math.round(screenPos*(-0.2))+'px');*/

});
	  	
jQuery(window).resize(function(e) {
	animations.resizeContainer();
	background.setSize();
	plus.setPosition('.platzinfo');
});

if (window.location.hash != '') {
	tools.hashes.processNewHash();
}
