// ActiveCArd
/****************************/
var aCheckRegion = Array();
var aNameRegion = Array();
aNameRegion[1] = "Fischland Darß Zingst";
aNameRegion[2] = "Insel Rügen";
aNameRegion[3] = "Insel Usedom";
aNameRegion[4] = "Mecklenburgische Ostseeküste";
aNameRegion[5] = "Mecklenburgische Schweiz";
aNameRegion[6] = "Mecklenburgische Seenplatte";
aNameRegion[7] = "Vorpommern";
aNameRegion[8] = "Mecklenburg-Schwerin";
aNameRegion[9]  ="Neubrandenburg";
aNameRegion[10] ="Rostock";
aNameRegion[11] ="Schwerin";
aNameRegion[12] ="Stralsund";
aNameRegion[14] ="Wismar";
aNameRegion[15] ="Greifswald";
var aInRegion = new Array();
aInRegion[10] = 4;
aInRegion[14] = 4;
aInRegion[12] = 7;
aInRegion[15] = 7;
aInRegion[9]  = 6;
aInRegion[11] = 8;
var tid = new Array();
var time = 100;

// Check it
function checkRegion(fp_nRegionID){
	if (!aNameRegion[fp_nRegionID]) return;
	aCheckRegion[fp_nRegionID] = (aCheckRegion[fp_nRegionID] != true) ? true : false;
	displayRegion();
}
// Check it
function displayRegion(){
	var inner = "";
	var oElem = document.getElementById("regiondisplay");
	for(var id=0; id<=aNameRegion.length; id++)
		if (aCheckRegion[id] == true || aCheckRegion[aInRegion[id]] == true) inner += "<div class=\"selected\">"+aNameRegion[id]+"</div>";
	if (inner == ""){
		inner = "<div class=\"selected\">[alle]</div>";
		qbDisplay("regiondescription");
		}
	else qbDisplayOut("regiondescription");
	oElem.innerHTML = inner;
}
//Show it
function qbActiveCard(fp_nRegionID){
	clearTimeout(tid[fp_nRegionID]);
	if (document.getElementById("card_"+fp_nRegionID+"_on"))
		document.getElementById("card_"+fp_nRegionID+"_on").style.visibility  = 'visible';
}
//Hides it
function qbUnActiveCard(fp_nRegionID){
	clearTimeout(tid[fp_nRegionID]);
	if (!aCheckRegion[fp_nRegionID] != false)
		tid[fp_nRegionID] = setTimeout("qbUnshowCard('card_" + fp_nRegionID + "_on')",time);
}
function qbUnshowCard(fp_sElemId){
	document.getElementById(fp_sElemId).style.visibility  = 'hidden';
}


// Display
/*****************************/
//ID for setTimeout
var tid = new Array;
var aBlockElements = new Array("address", "blockquote", "center", "dl", "dir", "div", "fieldset", "form", "h1-6", "hr", "isindex", "menu", "noframes", "noscript", "ol", "p", "pre", "table", "ul");

var aDisplayOption = new Array();
aDisplayOption["queryperiod"] = "option"; 
aDisplayOption["querytype"] = "option"; 

function displayOption(fp_oField){
	if(aDisplayOption[fp_oField.id])
		(fp_oField.value == aDisplayOption[fp_oField.id])
			? qbDisplay("option_"+fp_oField.id)
			: qbDisplayOut("option_"+fp_oField.id);
}

function qbDisplay(fp_sElemId){
	clearTimeout(tid[fp_sElemId]);
	oElem = document.getElementById(fp_sElemId);
	bBlock = false;
	for (var name in aBlockElements)
		if (aBlockElements[name] == oElem.nodeName.toLowerCase()){
			bBlock = true;
			break;
			}
	oElem.style.display  = (bBlock)
		? 'block'
		: 'inline';
}
//Hides it
function qbDisplayOut(fp_sElemId){
	clearTimeout(tid[fp_sElemId]);
	document.getElementById(fp_sElemId).style.display  = 'none';
}
function qbSetTimeout(fp_sElemId, time){
	if (!time) time = 100;
	clearTimeout(tid[fp_sElemId]);
	tid[fp_sElemId] = setTimeout("qbPopout('" + fp_sElemId + "')",time);
}
function qbClearTimeout(fp_sElemId){
	clearTimeout(tid[fp_sElemId]);
}

/****************************/
aInputDate = new Array("queryfrom", "queryuntil");

function prepareDefault(fp_oForm){
	aOption = document.getElementById("defregion").options;
	for(var i=0; i<=aOption.length; i++){
		if(aOption[i].selected == true){
			checkRegion(aOption[i].value);
			qbActiveCard(aOption[i].value);
			}
		}
}

function prepareSubmit(fp_oForm){
	for(var id in aInputDate){
		sDate = fp_oForm.elements[aInputDate[id]].value;
		aDate = sDate.split(".");
		if (aDate[0]) fp_oForm.elements[aInputDate[id]+"_DD"].value = aDate[0];
		if (aDate[1]) fp_oForm.elements[aInputDate[id]+"_MM"].value = aDate[1];
		if (aDate[2]) fp_oForm.elements[aInputDate[id]+"_JJJJ"].value = aDate[2];
		}
	for(var id=0; id<=aNameRegion.length; id++){
		if (aCheckRegion[id] == true)
			document.getElementById("region"+id).value = id;
		}
}
