
(function () {
	var doc = $(document);
	var win = $(window);
	
	// secure show
	doc.ready(function () {
		if(window.secure) { 
			var code = getCookie("sec");
			if(code && code != "") {
				$("#all").show()
			} else {
				window.location.href="/"
			}
		}
	})
	
	var position = function position () {
		// position fingerprint;
		var print = $('#fingerprint');
		var base  = $('#content').offset();
		print.css('left', base.left - 208 );
		print.fadeIn()
	};
	
	doc.ready(position);
	win.resize(position);
	
	doc.ready(function () {
		var subNav = $('#subNavigation');
		var active = $('#navigation .active')
		
		var width  = subNav.width();
		var pos    = active.position()
		if(pos) {
			var offset = 78
			var left   = pos.left + offset;
			//if(left + width > 748) {
			//	left    = left - width + active.innerWidth() + offset;
			//}
				
			subNav.css("left", left)
			subNav.fadeIn();
		}
	})
	
	
	
})()


function searchDoc(plz) {
	$(".ortGroup").hide();
	$(".ortGroup li").hide();
	$(".noHits").hide();
	var counter = 0;
	$(".ortGroup").each(function () {
		var me = $(this);
		
		me.find(".plzData").each(function () {
			if(this.innerHTML.indexOf(plz) == 0) {
				me.show()
				$(this).parent().show()
				counter = counter + 1;
			}
		})
	})
	if (counter == 0) {
		$(".noHits").show();
	}
}

function getCookie(name) {
  a = document.cookie;
	res = '';
    while(a != '' && res == '') {
        cookiename = a.substring(0,a.search('='));
        if (a.search(';') >= 0) {
            cookiewert = a.substring(a.search('=')+1,a.search(';'));
        } else {
            cookiewert = a.substring(a.search('=')+1,a.length);
        }

		while(cookiename.substring(0, 1) == ' ') {
			cookiename = cookiename.substring(1, cookiename.length);
		}
		
		if(name == cookiename) {res = unescape(cookiewert);}

		i = a.search(';')+1;
        if(i == 0) {i = a.length;}
        a = a.substring(i,a.length);
    }
    return res;
}