
/**
 * Hier werden Funktionen fuer Office und Advisor aufgerufen
 * JQuery + UI
 * Setting autoHeight: false allows to accordion panels to keep their native height.
 */
$(function() {
	$("#accordion").accordion({ 
		autoHeight: false,
		navigation: true,
		header: 'h3'
		//collapsible: false,
		//header: '.testMenuItem'
	});
	
	$(".testMenuItem").click(function(event){
		//alert("hash: " + this.hash);
		window.location.hash=this.hash;
	});
});

/**
 * Hier wird der Hintergrund bei den Startseiten an die Hoehe der Spalten angepasst
 */
$(function() {
	var height = 1500;
	var col1 = $("#column1").height();
	var col2 = $("#column2").height();
	var col3 = $("#column3").height();
	
	if(col1 > col2)	
		height = col1;
	else
		height = col2;
	
	if(height < col3)
		height = col3;
	
	$("#contentStartseite").css("height", height + 6);
});


/**
 * Hier werden Funktionen fuer Office und Advisor aufgerufen
 * JQuery + UI
 * Setting autoHeight: false allows to accordion panels to keep their native height.
 */
$(function() {
	$("#accordion_advisor").accordion({ 
	    header: 'h3', 
	    active: false, 
	    alwaysOpen: false, 
	    animated: true, 
	    autoheight: true,
	    navigation: true
	});
});

/**
 * Diese Funktion wird fuer den Austausch vom Captcha-Bild benutzt<br />
 * Verwendung: Kontaktformular-Microsites u. Kontaktform-Errorpage
 * @return
 */
function setNewSrcForImage() 
{
  for (var i=0; i<document.images.length; i++) 
  {
    if (document.images[i].id == "modJCaptcha")
      document.images[i].src='jcaptcha.jpg?tmp=' + Math.round(1000*Math.random());
  }
}

/**
 * Funktion setz das Focus in das Eingabefeld "nutzername"
 * @param was
 * @return
 */
function login(was)
{
	if(was == "nutzername")
	{	
		document.forms["loginform"].elements[was].focus();
	}
	else
	{
		if(document.getElementById("username").value.indexOf("#") != -1)
		{
			document.getElementById("username").value = document.getElementById("username").value.substring(0,document.getElementById("username").value.indexOf("#"));
			document.forms["loginform"].elements[was].focus();
		}
	}
}

/**
 * Simple Benutzer/Passwort - Abfrage
 * @param form
 * @return
 */
function loginValidate(form){
	 var userName = form.nutzername.value;
	 var password = form.wort.value;
	 
	 //alert(userName);

	 if (userName.length === 0) {
		 alert("Bitte geben Sie Ihren Benutzernamen ein:");
		 return false;
	 }

	 if (password.length === 0) {
		 alert("Bitte geben Sie das Passwort ein:");
		 return false;
	 }

	 return true;
}

/**
 * Tooltip-Plugin wird bei der Beratersuche eingesetzt
 */
$.fn.tooltip = function(opt, contenttooltip){
 	opt = $.extend({
 		hintergrund: "#000000",
 		schriftfarbe: "#FFFFFF",
 		rand: "1px #ABABAB solid",
 		eckenradius: 10,
 		zeit: 300
 	}, opt);
  
 	function showTooltip(evt, zeit, id){
 		$("<div>", {
 			id: "tooltip",
 			css: {
 				position: "absolute",
 				left: evt.pageX + 20,
 				top: evt.pageY + 20,
 				padding: "10px",
 				background: opt.hintergrund,
 				color: opt.schriftfarbe,
 				fontFamily: "arial,helvetica,sans-serif",
 				fontSize: "12px",
 				border: opt.rand,
 				display: "none",
 				"-moz-border-radius": opt.eckenradius,
 				"-webkit-border-radius": opt.eckenradius
 			},
 			html: contenttooltip["contenttooltip"][0][id]
 		})
 		.appendTo("body")
 		.fadeIn(zeit);
 	}
  
 	$(this).each(function(){
 		var id = $(this).attr("id");
 		$(this).attr("title", "");
 		$(this).bind({
 			mouseenter: function(evt){
 				if ($("#tooltip").css("opacity") != 0) {
 					$("#tooltip").stop().remove();
 				}
  
 				showTooltip(evt, opt.zeit, id);
 			},
 			mouseleave: function(){
 				$("#tooltip").fadeOut(
 					opt.zeit,
 					function(){
 						$(this).remove();
 					}
 				);
 			},
 			mousemove: function(evt){
 				$("#tooltip").css({
 					left: $('#sAdresse').offset().left + 320,
	 				top: $('#sAdresse').offset().top - 10 
 				});
 			}
 		});
 	});
 }

