$.fn.clearfocus = function() {
	return this.focus(function() {
		if( this.value == this.defaultValue ) {
			this.value = "";
		}
	}).blur(function() {
		if( !this.value.length ) {
			this.value = this.defaultValue;
		}
	});
};


$(document).ready(function(){

	$("a").focus(function() {
		$(this).blur();
	});

	if(jQuery.support.opacity) {
	    $("a.opacityhover").hover(
	        function(){
	            $(this).addClass("hover");
	            $(this).fadeTo(500,.6);
	    },
	        function(){
	            $(this).removeClass("hover");
	            $(this).fadeTo(500,.99);
	    }
	    );
	}

	var productsnode = $("div#mainnavigation > ul > li.produkte > a");

	if( ! productsnode.parent("li").hasClass("active") ){

		var clicked = false;

		productsnode.click(
					function(){
						if(!clicked){
							//$(this).find("a.produkte").css({ "background-position" : "100% -42px" });
							$(this).parent("li").children("ul").slideDown(150);
							clicked = true;
						}else{
							//$(this).find("a.produkte").css({ "background-position" : "0% -42px" });
							$(this).parent("li").children("ul").slideUp(150);
							clicked = false;
						}
					}
		);
	}

	$('.jswarning').remove();
	$.get("/token/",function(txt){
	  $("form.secured").append('<input type="hidden" name="ts" value="'+txt+'" />');
	});
});
