/**
 * @author Thomas Apfelbacher | strom-im-zoo.de
 * @client GlobRob Kinderschutzsoftware 
 * evertything in noConflict-mode to prevent weird interference with other js-libs like prototype 
 */
jQuery(document).ready(function() {
var oldOpacity = "0";

jQuery('ul.addlinks').before("<h3 class='addlinkslist'>Inhalte auf dieser Seite<\/h3>");
jQuery('#mainContent .span-7').find('h3').each(function(n) {
jQuery(this).attr('id',"clink"+(n+1));
jQuery('ul.addlinks').append("<li class='crosslink" + (n+1) + "'><a href='"+ window.location.href.split('#')[0]+"#clink" + (n+1) + "' class='cross-link'>" + jQuery(this).text() + "<\/a><\/li>");
}); 

// show the zoom on mouseover a fancybox image
jQuery(".hoverLinkFancyLink").hover(
function () {
		oldOpacity = jQuery(this).css("opacity");		
		jQuery(this).animate({opacity: '1'},{"duration":200});
		},
		function () {
		jQuery(this).animate({opacity: oldOpacity},{"duration":200});
	});
	
var oldlinkOpacity = "0";
jQuery(".gal_link").hover(
function () {
		oldlinkOpacity = jQuery(this).css("opacity");		
		jQuery(this).animate({opacity: '1'},{"duration":200});
	},
	function () {
		jQuery(this).animate({opacity: oldlinkOpacity},{"duration":200});
	}
	);

// Creating custom :external selector
jQuery.expr[':'].external = function(obj){
    return !obj.href.match(/^mailto\:/)
            && (obj.hostname != location.hostname);
};

// Add 'external' CSS class to all external links
jQuery('a:external').addClass('external').attr('target','_blank');

//clear the search inputform on click
defaultValue = jQuery('#SearchForm_SearchForm_Search').val();  
jQuery('#SearchForm_SearchForm_Search').click(function() {
		if( this.value == defaultValue ) {
		jQuery(this).val("");
		}
	});
jQuery.trackPage('UA-5970789-3');
jQuery('#bigimage_chrome img').preload();

});

initHomepage = function() {	
	jQuery('a.fancybox').fancybox({
		'zoomOpacity'			: true,
		'overlayShow'			: true,
		'zoomSpeedIn'			: 500,
		'zoomSpeedOut'			: 500
	}); 
    jQuery("#explore-tabs a").click(function() {        
        // Figure out current list via CSS class
        var curList = jQuery("#explore-tabs a.current").attr("rel");

        // List moving to
        var $newList = jQuery(this);
        
        // Set outer wrapper height to height of current inner list
        var curListHeight = jQuery("#all-list-wrap").height();
        jQuery("#all-list-wrap").height(curListHeight);
        
        // Remove highlighting - Add to just-clicked tab
        jQuery("#explore-tabs a").removeClass("current");
        $newList.addClass("current");
        
        // Figure out ID of new list
        var listID = $newList.attr("rel");
             
        if (listID != curList) {
                 
            // Fade out current list
            jQuery("#"+curList).fadeOut(250, function() {
                
                // Fade in new list on callback
                jQuery("#"+listID).fadeIn();
                
                // Adjust outer wrapper to fit new list snuggly
                var newHeight = jQuery("#"+listID).height();
                jQuery("#all-list-wrap").animate({
                    height: newHeight
                });
            
            });

            
        }        
        
        // Don't behave like a regular link
        return false;
    });      
   };
