/* IE6nomore
------------------------------------------------------------------------------------------------ */

$.IE6nomore = function() {

    if(!$('#ie6nomore').length)
        return;

    $('#ie6nomore').css({
        'left'      : 0,
        'top'       : 0,
        'bottom'    : 0,
        'right'     : 0,
        'position'  : 'absolute',
        'z-index'   : 9999
    });

};

/* Swap image
------------------------------------------------------------------------------------------------ */

function swapImage(element, newimage) {

    var oldsrc      = element.src;
    element.src     = newimage;

    if (!element.onmouseout) {
        element.onmouseout = function() {
            swapImage(this, oldsrc);
        }
    }

}

/* Get url vars
------------------------------------------------------------------------------------------------ */

$.getUrlVars = function() {

    var vars    = [],
        hash    = '',
        hashes  = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    $(hashes).each(function() {
        hash = this.split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    });

    return vars;
};

/* Spam protection
------------------------------------------------------------------------------------------------ */

function getAdr(prefix, postfix, text) {
    document.write('<a href="mailto:' + prefix + '@' + postfix + '">' + (text ? text.replace(/&quot;/g, '"').replace(/%EMAIL%/, prefix + '@' + postfix) : prefix + '@' + postfix) + '</a>');
}

function animateSubnav() {
    var target=($.browser.msie)?window:document;
    
	    $(target).scroll(function() {
	        if($(target).scrollTop()>420)
	        {
	           $('#submenu').delay(200).stop().animate({top:$(target).scrollTop()-1},350);
	        }
	        else
	        {
	           $('#submenu').delay(200).stop().animate({top:460},460);
	        }
	    });
  	};

/* DOM
------------------------------------------------------------------------------------------------ */

$(document).ready(function() {
if(!($('#datev_menu').length))
{
$(".entry > h3").click(function()
	{
           if($(this).parent().hasClass('clicked'))
           {
               $(this).parent().removeClass('clicked');
               $(this).parent().children(".text").slideUp(500);
           }
		   else {
               $(this).parent().addClass('clicked');
               $(this).parent().children(".text").slideDown(500);
           }
	});
}

	$('.start_h2').hover(
	
	function () {
	$(this).siblings('.zms_textarea').addClass('hover');
	},
	
	function () {
	$(this).siblings('.zms_textarea').removeClass('hover');
	}
	
	)

    // IE6nomore

    $.IE6nomore();

    // Forms
if($('textarea').length)
    $('textarea').autogrow();

    // News object
if($('#news_selection').length)
{
    $('#news_selection').createOnchangeSelect({
        'label' : '#news_selection h3'
    });
}

    // DATEV Unternehmen online
if($('#datev_menu').length)
    $.datev_uo();

    // Popup plugin
if($('.popup').length)
    $('.popup').popup();

	animateSubnav();
	
	$(".product_overview .entry:first").css('margin-left','0');
	
});
