function ajaxListeByPraemie(praemie_id, character)
{
	var url = window.location.href.substr(0, 5);
	var pre = '';
	if (url == 'https')
		pre = 'https://';
	else
		pre = 'http://';
		
	$.ajax({
   		type: "POST",
   		url: pre + js_root + "getAjaxListByPraemie",
		data: "praemieid=" + praemie_id + "&az=" + character,
   		success: function(html) {
			$("#listenContent").html(html);
			$(".azActive").removeClass('azActive');
			$("#az"+character).addClass('azActive');
		}
 	});
}

function ajaxListeByKategorie(kategorie_id, character)
{
	var url = window.location.href.substr(0, 5);
	var pre = '';
	if (url == 'https')
		pre = 'https://';
	else
		pre = 'http://';
		
	$.ajax({
   		type: "POST",
   		url: pre + js_root + "ajaxListeByKategorie",
		data: "themaid=" + kategorie_id + "&az=" + character,
   		success: function(html) {
			$("#listenContent").html(html);
			$(".azActive").removeClass('azActive');
			$("#az"+character).addClass('azActive');
		}
 	});
}

function ajaxListeByAboform(aboform_id, character)
{
	var url = window.location.href.substr(0, 5);
	var pre = '';
	if (url == 'https')
		pre = 'https://';
	else
		pre = 'http://';
		
	$.ajax({
   		type: "POST",
   		url: pre + js_root + "ajaxListeByAboform",
		data: "aboformid=" + aboform_id + "&az=" + character,
   		success: function(html) {
			$("#listenContent").html(html);
			$(".azActive").removeClass('azActive');
			$("#az"+character).addClass('azActive');
		}
 	});
}

function ajaxListeStartseite(character)
{
	var url = window.location.href.substr(0, 5);
	var pre = '';
	if (url == 'https')
		pre = 'https://';
	else
		pre = 'http://';
	

	$.ajax({
   		type: "POST",
   		url: pre + js_root + "ajaxListeStartseite",
		data: "&az=" + character,
   		success: function(html) {
			$("#listenContent").html(html);
			$(".azActive").removeClass('azActive');
			$("#az"+character).addClass('azActive');
		}
 	});
}

function geschenkMaxiInfo(id, pos)
{
	var url = window.location.href.substr(0, 5);
	var pre = '';
	if (url == 'https')
		pre = 'https://';
	else
		pre = 'http://';
		
	$.ajax({
   		type: "POST",
   		url: pre + js_root + "getGeschenkInfo",
   		data: "id=" + id,
   		success: function(html) {
			$("#MaxiInfo").html(html);
			$("#greyLayer").css('width', $("#geschenke_items").width());
			$("#greyLayer").css('height', $("#geschenke_items").height()-20);
			$("#greyLayer").css('display', 'block');
			$("#MaxiInfo").css('top', (pos * 238)+'px');
			$("#MaxiInfo").css('display', 'block');
		}
 	});
	$('#greyLayer').click(function() {
  		closeMaxiAnsicht();
	});
	//location.href = 'http://' + $(location).attr('host') + $(location).attr('pathname') + "#maxiAnsicht"; 
}

function praemieMaxiInfo(id, pos)
{
	var url = window.location.href.substr(0, 5);
	var pre = '';
	if (url == 'https')
		pre = 'https://';
	else
		pre = 'http://';
		
	$.ajax({
   		type: "POST",
   		url: pre + js_root + "getPraemieInfo",
   		data: "id=" + id,
   		success: function(html) {
			$("#MaxiInfo").html(html);
			$("#greyLayer").css('width', $("#geschenke_items").width());
			$("#greyLayer").css('height', $("#geschenke_items").height()-20);
			$("#greyLayer").css('display', 'block');
			$("#MaxiInfo").css('top', (238 * pos)+'px');
			$("#MaxiInfo").css('display', 'block');
		}
 	});
	$('#greyLayer').click(function() {
  		closeMaxiAnsicht();
	});
	//location.href = 'http://' + $(location).attr('host') + $(location).attr('pathname') + "#maxiAnsicht"; 
}

function chooseGeschenk(id)
{
	$("#bestellung_Praemienartikel_" + id).attr("checked", "checked");
	$("#MaxiInfo").html(''); 
	$("#greyLayer").css('display', 'none');
	$("#MaxiInfo").css('display', 'none');
}


function choosePraemie(id)
{
	$("#bestellung_Praemienartikel2_" + id).attr("checked", "checked");
	$("#MaxiInfo").html(''); 
	$("#greyLayer").css('display', 'none');
	$("#MaxiInfo").css('display', 'none');
}


function closeMaxiAnsicht()
{
	$("#MaxiInfo").html('');
	$("#greyLayer").css('display', 'none');
	$("#MaxiInfo").css('display', 'none');
}

function decryptmail(mailadr) {	
	var n=0;
	var r="";
	for(var i=0; i < mailadr.length; i++) {
		n=mailadr.charCodeAt(i);
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(5));
	}
	return r;
}

function post(mail)	{
	location.href=decryptmail(mail);
}
