$(document).ready(function() {
	init();

}); // Ende $(document).ready();
/*******************************************************************************
 * log() : sort of var_dump() for JS
 ******************************************************************************/
var log = function() {
	if (window && window.console && window.console.log) {
		for ( var i = 0, len = arguments.length; i < len; i++) {
			console.log(arguments[i]);
		}
	} else {
		for ( var i = 0, len = arguments.length; i < len; i++) {
			$("body").prepend(arguments[i]);
		}
	}
}// Ende log
/*******************************************************************************
 * all the things that have to be done on document load requires JQuery
 * 
 * @return void
 ******************************************************************************/
var init = function() {

	// init_FontSize(11, 'px', 1);

	$(".hidden").hide();
	$("a[href^=#]").each(function() {
		$(this).click(function() {
			var $href = $(this).attr("href");
			$href = $href.split("#");
			$href = "#" + $href[1];
			window.location.hash = $href;
			return false;
		});
	});
	// Empty Search-Field on focus, refill on blur
	var $val;
	/*
	 * $("#such_input, .empty-on-focus").focus(function() { $val =
	 * $(this).val(); $(this).val(""); }).blur(function() { if
	 * ($(this).val().length <= 0) { $(this).val($val); } });
	 */
	/*
	 * seminar_ort = $(".seminar_ort").html(); seminar_strasse =
	 * $(".seminar_strasse").html();
	 * 
	 * if (seminar_ort && seminar_strasse) {
	 * 
	 * if (seminar_ort.length > 0 && seminar_strasse.length > 0)
	 * loadGoogleMap(seminar_ort + ", " + seminar_strasse); }
	 */

	$("#print").click(function() {
		$("#content, #content2, #content3, #content4").print();
	});
	// IE6 PNG-Fix
	if ($.browser.msie && parseInt($.browser.version) == 6) {
		// $("body").prepend($.browser.version);
		DD_belatedPNG.fix('body, img');
	}

	$('#content-tabs').tabs();

	$("#kontakt_form").validate()
	/*
	 * $("#center").dropShadow( { "opacity" : 0.1 });
	 */
	setBWFarbig();
	manipulateLI();
}

/*******************************************************************************
 * GOOGLE MAP laden
 ******************************************************************************/
function loadGoogleMap(address) {
	geocoder = new GClientGeocoder();
	if (GBrowserIsCompatible()) {

		map = new GMap2(document.getElementById("google_map_anfahrt"));
		if (geocoder) {
			geocoder.getLatLng(address, function(point) {
				if (!point) {
					alert(address + " not found");
				} else {
					map.setCenter(point, 13);
					map.addControl(new GSmallMapControl());
					map.addControl(new GMapTypeControl());
					var marker = new GMarker(point);
					map.addOverlay(marker);

					marker.openInfoWindowHtml($('.seminar_name').html()
							+ "<br/><br/>" + $(".seminar_ort").html() + '<br/>'
							+ $(".seminar_strasse").html());
				}
			});
		}
	}
}

/*******************************************************************************
 * JQuery Print by OT
 ******************************************************************************/
jQuery.fn.print = function() {
	var styles = '';
	$("head link").each(
			function() {
				styles += '<link rel="stylesheet" type="text/css" href="'
						+ $(this).attr("href") + '" />' + "\n";
			})
	var frameName = ("printer-" + (new Date()).getTime());
	var frameTitle = document.title;
	$("<iframe name='" + frameName + "'>").css( {
		"width" : "1px",
		"height" : "1px",
		"position" : "absolute",
		"left" : "-10px"
	}).appendTo($("body"));
	var frameDoc = window.frames[frameName].document;
	frameDoc.open();
	frameDoc
			.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
	frameDoc.write("<html>");
	frameDoc.write("<head>");
	frameDoc
			.write("<style type=\"text/css\">#content_bottom{display:none;}</style>");
	frameDoc.write("<title>");
	frameDoc.write(frameTitle);
	frameDoc.write("</title>");
	frameDoc.write("</head>");
	frameDoc.write("<body>");
	frameDoc.write(styles);
	frameDoc.write(this.html());
	frameDoc.write("</body>");
	frameDoc.write("</html>");
	frameDoc.close();
	window.frames[frameName].focus();
	window.frames[frameName].print();

}

/**
 * 
 */
function cm_expander(id) {
	var expander = document.getElementById('cm_expander_' + id);
	var teaser = document.getElementById('cm_expander_teaser_' + id);

	// cmCloseDenRest(id);

	if (expander.style.display != 'block') {
		// document.all.expander.style.setAttribute('display', 'block',
		// 'false');
		// document.all.teaser.style.setAttribute('display', 'none', 'false');
		expander.style.display = 'block';
		teaser.style.display = 'none';
	} else {
		expander.style.display = 'none';
		teaser.style.display = 'block';
	}
}
function setBWFarbig() {

	$(document).ready(function() {
		$(".swc_sw").hover(function() {
			$(this).animate( {
				"opacity" : "0"
			}, "fast");
		}, function() {
			$(this).animate( {
				"opacity" : "1"
			}, "fast");
		});

	});

}
function loadToFrom(divid, ahref) {
	try {
		$("#" + divid).load(ahref);
		$("#" + divid).css("display", "block");
	} catch (Ex) {
		debug.consoloe(ex);
	}
}
function manipulateLI() {
	var element = "div.text ul li";
	$(element).wrapInner("<p></p>");

}

