/* Windows Popup
*/
function Popup(Popupname,options,url)
{
    Popupname = window.open(url, Popupname , options);
    Popupname.focus(); //wenn fenster bereits geöffnet in vordergrund holen
}

function senddata(button,id,js_id){
	if(button == "delete") {
		Check = confirm("Willst Du diesen Eintrag endgültig löschen?\nBitte beachte, dass die Daten nicht wieder hergestellt werden können.");
		if(Check == false) button = "cancel";
	}
	if(button == "delete_favorite" || button == "delete_member") {
		Check = confirm("Foto wird aus den Favoriten entfernt.");
		if(Check == false) button = "cancel";
	}
	if(button == "delete_all_msg" || button == "delete_all_msg_member") {
		Check = confirm("Willst Du diese Einträge endgültig löschen?\nBitte beachte, dass die Daten nicht wieder hergestellt werden können.");
		if(Check == false) button = "cancel";
	}
  document.form.button.value = button;
	if(id)
	  document.form.id.value = id;
    if(js_id)
      document.form.js_id.value = js_id;
//	  hidden_textde = document.form.textde.value;
//		window.alert(hidden_textde);
}

function showCategory1(id,changed) {

	if (changed == 1) {
		document.form.category1_selInd.value = document.form.category1.selectedIndex;
	}
	else {
		document.form.category1.selectedIndex = document.form.category1_selInd.value;
		document.form.category1.disabled = false;
	}

	for(i = 0; i < category.length; i++)
	{
		if (category[i][2] == 0) {
  	  var addme = new Option(category[i][1], category[i][0]);
  	  document.form.category1[i] = addme;
			if (changed == 2 && (category[i][0] == id && id > 0))
				document.form.category1.selectedIndex = i;
		}
	}

	if (document.form.category1_selInd.value > 0)
		document.form.category1.selectedIndex = document.form.category1_selInd.value;
	if (document.form.category1.selectedIndex > 0) {
		document.form.category1_selInd.value = document.form.category1.selectedIndex;
	}

	if (changed == 1) {
		showCategory2(id,0,0);
		showCategory3(0,0,0);
	}
}

function showCategory2(parent_id,id,changed) {
	var i2 = 0;
	if (changed == 0) {
		document.form.category2_selInd.value = 0;
		document.form.category2.selectedIndex = 0;
	}
	if (changed == 1) {
		document.form.category2_selInd.value = document.form.category2.selectedIndex;
	}

	if (changed == 0 || changed == 2) {
		document.form.category2.length = 0;
		document.form.category2.disabled = false;

		for(i = 0; i < category.length; i++)
		{
			if (i == 0 || (category[i][2] == parent_id && parent_id > 0)) {
	  	  var addme = new Option(category[i][1], category[i][0]);
	  	  document.form.category2[i2] = addme;
				if (changed == 2 && category[i][0] == id)
					document.form.category2.selectedIndex = i2;
				i2++;
			}
		}
		if (document.form.category2.length < 2)
			document.form.category2.disabled = true;
	}

	if (document.form.category2_selInd.value > 0)
		document.form.category2.selectedIndex = document.form.category2_selInd.value;
	if (document.form.category2.selectedIndex > 0) {
		document.form.category2_selInd.value = document.form.category2.selectedIndex;
	}

	if (changed == 1)
		showCategory3(parent_id,0,0);
}

function showCategory3(parent_id,id,changed) {
	var i2 = 0;	
	if (changed == 0) {
		document.form.category3_selInd.value = 0;
		document.form.category3.selectedIndex = 0;
	}
	if (changed == 1) {
		document.form.category3_selInd.value = document.form.category3.selectedIndex;
	}
	if (changed == 0 || changed == 2) {
		document.form.category3.length = 0;
		document.form.category3.disabled = false;
	
		for(i = 0; i < category.length; i++)
		{
			if (i == 0 || (category[i][2] == parent_id && parent_id > 0)) {
	  	  var addme = new Option(category[i][1], category[i][0]);
	  	  document.form.category3[i2] = addme;
				if (changed == 2 && category[i][0] == id)
					document.form.category3.selectedIndex = i2;
				i2++;
			}
		}
		document.form.category3_length.value = document.form.category3.length;
		if (document.form.category3.length < 2)
			document.form.category3.disabled = true;
	}

	if (document.form.category3_selInd.value > 0)
		document.form.category3.selectedIndex = document.form.category3_selInd.value;
	if (document.form.category3.selectedIndex > 0) {
		document.form.category3_selInd.value = document.form.category3.selectedIndex;
	}
}
