jQuery.noConflict();
jQuery(document).ready(function($){
    
	
	//////////////////////////////////////////////////
	// Home Kopfbilder Ini und Animation
	
	(function(){
	
	    jQuery('body.home #header .page .header-img')
    	.addClass('toggle')
    	.before('<img class="header-img" src="/26jcd47rmt/wp-content/themes/landhaus-heidehof/images/head-img-sommer.jpg"/>');
	
    	var timer = setInterval( toogleImages, 5000);
    	function toogleImages() 
    	{
    	    var visibility = jQuery('body.home #header .page .header-img.toggle')
    	    .hasClass('hidden');
	    
    	    if(visibility === true)
    	    {
    	        jQuery('body.home #header .page .header-img.toggle')
    	        .fadeIn()
    	        .removeClass('hidden');
	        
    	    }
    	    else
    	    {
                jQuery('body.home #header .page .header-img.toggle')
                .fadeOut()
                .addClass('hidden');
    	    }
    	}
    	
	}());
    
	
	//////////////////////////////////////////////////
	// IE 6 and 7 detection 
	
	var is_ie67 = ie67_detection();
	
	
	//////////////////////////////////////////////////
	// fixes margin of hr and other elements in IE 6 and 7
	
	if(is_ie67 === true)
	{
		//////////////////////////////////////////////////
    	// reset margin of first and last element

        jQuery('.content > *:first-child').css('margin-top','0');
    	jQuery('.content > *:last-child').css('margin-bottom','0');
    	
    	//////////////////////////////////////////////////
    	// fix hr margins
    	
		jQuery('#content hr').each(function()
		{
			hr_top = jQuery(this).css('margin-top');
			hr_bottom = jQuery(this).css('margin-bottom');
			prev_bottom = jQuery(this).prev().css('margin-bottom');
			next_top = jQuery(this).next().css('margin-top');

			hr_top = parseInt(hr_top);
			hr_bottom = parseInt(hr_bottom);
			prev_bottom = parseInt(prev_bottom);
			if(next_top) next_top = parseInt(next_top);
			if(!next_top) next_top = 0;

			if(hr_top >= prev_bottom) 
			{
    			jQuery(this).css('margin-top', (hr_top - 7) + 'px');
    			if((hr_top - prev_bottom) < 7) jQuery(this).css('margin-top', (hr_top - prev_bottom - 7)  + 'px');
			}
			else
			{
    			jQuery(this).css('margin-top', '-7px');
			}
			
			if(hr_bottom <= next_top)
			{
    			jQuery(this).css('margin-bottom', (hr_bottom - hr_bottom - 7) + 'px');
			}
			else
			{
			    jQuery(this).css('margin-bottom', ((0 - 7) + (hr_bottom - next_top)) + 'px');
    			if((hr_bottom - next_top) > 7) 
			    jQuery(this).css('margin-bottom', (hr_bottom - 7) + 'px');
			}
			
		});
		    	
	}
	
	
	//////////////////////////////////////////////////
	// helper functions
	
	function SearchAndReplace(source, search, replace) 
	{
        source = source.replace(/ + search + /g,replace);
        
        return source;
    }

	function ie67_detection() 
	{
	  if (document.createElement && document.getElementsByTagName && document.getElementById) 
	  {
	    var el = document.createElement('script'),
	    head = document.getElementsByTagName('head')[0];
	    if (el && head && head.appendChild && head.removeChild) 
	    {
	      el.type = 'text/javascript';
	      el.id = 'A';
	      head.appendChild(el);
	      var buggy = !!document.getElementById('a');
	      head.removeChild(el);
	      el = null;
	      return buggy;
	    }
	  }
	  return null;
	}
	


	

});
