checkEmail = function(value) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value)) {
        return true;
    }
    return false;
}

$(window).bind('load', function() {
	$('#navigation li a').bind({
		mouseenter: function() {
			$(this).parent().addClass('hover');
		},
		mouseleave: function() {
			$(this).blur().parent().removeClass('hover');
		}
	});

    // IE6 warning
    if ($.browser.msie && parseFloat($.browser.version) <= 6) {
        //alert('IE6');
        $("#site-container").prepend('<div id="ie6_warning"><strong>HINWEIS!</strong> Sie benutzen einen veralteten Browser. Dies führt zu Problemen mit der Darstellung und Funktionalität dieser Seite. <a href="/ie6">Mehr Informationen</a></div>');
    }

    // recomend popup
    $('#recommend_link').click(function(e) {
        e.preventDefault();
        sxPopup("/versenden?href="+escape(window.location.pathname));
    });
});


afterPound = function(){
	var x = window.location.hash;
	x = x.replace('#','');
	return x;
}

setAfterPound = function(v){
        v = v.replace('//','/');
	window.location.hash = '#'+v;
	return window.location.href;
}

aAfterPound = function(){
	var x = window.location.hash;
	x = x.replace('#','');
	x = x.split('/');
	return x;
}

aSetAfterPound = function(aV,setAll){
	var v = '';

	if( !setAll ){
		aExisting = aAfterPound();
	}

	if( !setAll ){
		var aCount;
		if( aExisting.length > aV.length ){
			aCount = aExisting.length;
		}else{
			aCount = aV.length;
		}

		for ( i=0; i<aCount; i++ )
		{
			//alert(aV[i]+'---');
			if( aV[i]==undefined || aV[i]=='' ){

				v += aExisting[i]+'/';
			}else{
				v += aV[i]+'/';
			}
		}
	} else {
		for ( var i in aV )
		{
			if( !setAll && aV[i] ){
				v += aExisting[i]+'/';
			}else{
				v += aV[i]+'/';
			}
		}
	}
        v = v.replace('//','/');
	window.location.hash = '#'+v;

	return window.location.href;
}

jQuery.preloadImages = function() {
    for(var i = 0; i<arguments.length; i++) {
        jQuery("<img>").attr("src", arguments[i]);
    }
}


/* cufon */
if ($.browser.msie && parseFloat($.browser.version) <= 6) {
	// no cufon for IE6 (almost nothing for IE6)
} else {
	Cufon
		.replace('h1, h2, h3, #panels .sidepanel .btn-blue, #reference-all-list .char', {fontFamily: 'HouseGothicHG23TextBold'})
	;
}


var sxPopup = function(url, cssClass, callback) {
    $('#sx-overlay, #sx-popup').remove();

    $('<div>').attr('id', 'sx-overlay').css('opacity', 0).appendTo('body').animate({opacity: 0.7}, 250);
    $('<div>')
        .addClass(cssClass)
        .attr('id', 'sx-popup')
        .css({opacity: 0, top: -750})
        .append($('<span>').text('schliessen').addClass('close'))
        .append($('<div>').addClass('content'))
            .find('.content')
            .load(url, function() {
                Cufon.refresh();
            })
            .end()
        .appendTo('body')
        .animate({opacity: 1, top: 150}, 300)
    ;

    $('#sx-overlay, #sx-popup .close').bind('click', function() {
        $('#sx-popup').animate({top: -500}, 300);
        $('#sx-overlay, #sx-popup').animate({opacity: 0}, 250, function() {
            $(this).remove();
        });

        if (typeof callback == "function") {
            callback();
        }
    });
}

