var mouse_x,mouse_y;
$().mousemove(function(e){
	mouse_x = e.pageX;
	mouse_y = e.pageY;
});

	
function showStatDetail(id) {
	$('#stat_detail_daten').html('');
	$("#stat_details").css("top",(mouse_y+10));
	$("#stat_details").css("left",(mouse_x+10));
	$("#stat_details").show();
	$("#stat_details").dropShadow();
	$("#stat_details").redrawShadow();
	$("#stat_detail_daten").load("ajax_getBuchungsDetail.php",{'buchID':id});
}

function showStatDetailFromRight(id) {
	$('#stat_detail_daten').html('');
	$("#stat_details").css("top",(mouse_y+10));
	$("#stat_details").css("left",(mouse_x-1000));
	$("#stat_details").show();
	$("#stat_details").dropShadow();
	$("#stat_details").redrawShadow();
	$("#stat_detail_daten").load("ajax_getBuchungsDetail.php",{'buchID':id});
}

function showStatDetailTxid(txid) {
	$("#stat_details").css("top",(mouse_y+10));
	$("#stat_details").css("left",(mouse_x-1000));
	$("#stat_details").show();
	$("#stat_details").dropShadow();
	$("#stat_details").redrawShadow();
	$("#stat_detail_daten").load("ajax_getBuchungsDetail.php",{'txid':txid});
}

function closeStat() {
	$("#stat_details").removeShadow();
	$("#stat_details").hide();
}

function toggleFilter() {
	if($('#statistik_filterkrams').is(":hidden")) {
		document.getElementById("ein_ausblenden").innerHTML = "ausblenden";
		document.getElementById("pfeil_pic").src = host+"design/statistik/pfeil_up.gif";
		$('#statistik_filterkrams').slideDown("slow");
	} else {
		document.getElementById("ein_ausblenden").innerHTML = "einblenden";
		document.getElementById("pfeil_pic").src = host+"design/statistik/pfeil_down.gif";
		$('#statistik_filterkrams').slideUp("slow");
	}
}

function sortTable(field) {
	$.ajax({
		type:"POST",
		url:"ajax_setSortTable.php",
		dataType:"script",
		data:"val="+field+"&sessid="+sessid,
		success: function(data,textstatus) {
			document.location.reload();
		}
	});
}

function setVarAndRedirect(href,mode,plain) {
	$.ajax ({
		type:"POST",
		url:"ajax_setVarAndRedirect.php",
		dataType:"script",
		data:"mode="+mode+"&vars="+plain+"&sessid="+sessid,
		success: function(data,textstatus) {
			document.location.href = href;
		}
	});
}

function unsetAllFilters(href) {
	$.ajax ({
		type:"POST",
		url:"ajax_unsetAllFilters.php",
		dataType:"script",
		data:"sessid="+sessid,
		success: function(data,textstatus) {
			document.location.href = href;
		}
	});
}

function openChart(strType) {
	var strUrl, iWidth, iHeight,strId;
	switch(strType) {
		case 'gesamt':
			strUrl = host+"functions/getChartGesamtstatistik.php";
			iWidth = 750;
			iHeight = 300;
			strId = 'chart';
			break;
		case 'zahlart_umsatz':
			strUrl = host+"functions/getChartZahlart.php?type=umsatz";
			iWidth = 375;
			iHeight = 300;
			strId = 'chart_left';
			break;
		case 'zahlart_anzahl':
			strUrl = host+"functions/getChartZahlart.php?type=anzahl";
			iWidth = 375;
			iHeight = 300;
			strId = 'chart_right';
			break;
		case 'start':
			strUrl = host+"functions/getChartStart.php";
			iWidth = 750;
			iHeight = 300;
			strId = 'chart';
			break;
		default:
			return false;
	}
	var params = {wmode: "transparent"};
	swfobject.embedSWF(
		host+"design/swf/open-flash-chart.swf", strId, iWidth, iHeight,
		"9.0.0", "expressInstall.swf",
		{"data-file":strUrl,"loading":"Daten werden geladen."}, params
	);
}
