function kontakt_vali() {
	if(document.getElementById("kont_name").value == "" || document.getElementById("kont_email").value == "" || document.getElementById("kont_betreff").value == "" || document.getElementById("kont_nachricht").value == "") {
		alert("Bitte füllen Sie alle Felder vollständig aus!");
		return false;
	}
}
function seminaranmeldung_vali() {
	if(document.getElementById("sem_anm_name").value == "" || document.getElementById("sem_anm_email").value == "" || document.getElementById("sem_anm_telefon").value == "" || document.getElementById("sem_anm_seminar").value == "") {
		alert("Bitte füllen Sie alle Felder vollständig aus!");		
		return false;
	}
}

function popUp(url) {
	fenster = window.open(url, "", "width=660,scrollbars=yes");
	fenster.focus();
}

function confirmDelete(obj) {
	var pruef = confirm("Eintrag wirklich löschen?");
	if(pruef) {
		obj.href = obj.href+"&del=ok";
		return true;	
	} else {
		return false;	
	}
}


/* ####################################################################### */
/* ################################# SEMINARE ############################ */
/* ####################################################################### */

function seminarAnmeldung(id, datum, titel) {
	var backgr = document.getElementById("anmeldungFenster");
	backgr.style.visibility = "visible";
	
	backgr.style.width = (window.innerWidth - 17) + "px";
	backgr.style.height = (document.height + 30) + "px";
	
	var formulare = document.getElementById("anmeldungFensterInhalt");
	formulare.style.visibility = "visible";
	
	document.getElementById("seminar_titel").value = titel;
	document.getElementById("seminar_datum").value = datum;
	document.getElementById("seminarId").value = id;
	
}
function hideSeminarAnmeldung() {
	document.getElementById("anmeldungFenster").style.visibility = "hidden";
	document.getElementById("anmeldungFensterInhalt").style.visibility = "hidden";
}


function showEmailInput() {
	$("#emailInputCourses").slideToggle(300);
}

/* ####################################################################### */
/* ############################## INTEGRASHOP ############################ */
/* ####################################################################### */

function cartChangeAnz(objId) {
 	document.getElementById("cartAnzFrm_"+objId).submit();
}


function documentHeight() {
	if(parseInt(document.body.clientHeight) >= parseInt(document.documentElement.clientHeight)) {
		return document.body.clientHeight;	
	}
	else {
		return document.documentElement.clientHeight;	
	}
}
function documentWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
  }
  return myWidth;
}

function getScrollY() {
	var scrOfY = 0;

	if( typeof( window.pageYOffset ) == 'number' ) {
		//Netscape compliant
		scrOfY = window.pageYOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	return [ scrOfY ];
}

function showLightbox() {
	$('#blackBackground').show();
	$("#requestDetails").show();
	
	$("#requestDetails").fadeTo(0, 0);
	$('#blackBackground').fadeTo(0, 0);
	
	pos = parseInt(getScrollY());
	pos = pos + 20;
	document.getElementById("requestDetails").style.top = pos + "px";
	
	$("#requestDetails").html('<center><img src="../../images/loader_white.gif" alt="Loading..." /></center>');
	if(document.getElementById("blackBackground") != documentWidth()-17) {
		$('#blackBackground').height(documentHeight()+30);
		$('#blackBackground').width(documentWidth()-17);
	}
	$('#blackBackground').fadeTo(400, 0.8, function() {
		//details einblenden
		$("#requestDetails").fadeTo(300, 1);
	});
	
	topPosition = pos;
}
function ajaxRequest(reqUrl, daten, reqMethod) {
	jQuery.ajax({
		type: reqMethod,
		data: daten,
		url: reqUrl,
		success: function(content) {
			$('#requestDetails').html(content);
			
			$("#blackBackground").click(function() {
					$("#blackBackground").fadeTo(500, 0, function() {
					$("#blackBackground").hide();								
				});
				$("#requestDetails").fadeTo(500, 0, function() {
					$("#requestDetails").hide();											
				});
			});
		}
	});
}
function closeRequestDetails() {
	$("#blackBackground").fadeTo(500, 0, function() {
		$("#blackBackground").hide();								
	});
	$("#requestDetails").fadeTo(500, 0, function() {
		$("#requestDetails").hide();											
	});
}
function showEditDetails(url, daten) {
	showLightbox();
	ajaxRequest(url, daten, "POST");	
}


function reloadCkEditor(id) {
	if (CKEDITOR.instances[id]) {
		CKEDITOR.remove(CKEDITOR.instances[id]);
	}
	
	CKEDITOR.replace(id);	
}

/* EMAIL */

function writeAdr(pre, domain, newMail) {
	var email = "";
	if(domain == "this") domain = "naturheilcentrum.com";
	email = pre+"@"+domain;
	
	if(newMail == "ok") {
		email = '<a href="mailto:'+email+'">'+email+'</a>';	
	}
	document.write(email);	
}
