function open_AGB() {
	open_win('pop.AGB.php','AGB',620,450,'yes','no');
}

function open_win(target,fensternamen,w,h,scrollbars,resizable) {
	// namen darf kein whitespace beinhalten
	
	if(scrollbars==undefined) scrollbars='yes';
	if(resizable==undefined) resizable='0';
	
	margin_left = calc_margin_left(w);
	margin_top = calc_margin_top(h);
	window.open(target,fensternamen,'width='+w+',height='+h+',left='+margin_left+',top='+margin_top+',resizable='+resizable+',toolbar=0,status=0,location=0,scrollbars='+scrollbars);
	
	//alert('open_win(target ['+target+'],namen ['+fensternamen+'],w ['+w+'],h ['+h+'],scrollbars ['+scrollbars+'],resizable ['+resizable+'])');
}
function js_confirm(msg,url) {
	flag = confirm(msg);
	if(flag) {
		document.main.location.href = url;
	}
}

function open_fg_cerb(params) {
	// open_win('pop.fotogalerie.cerb.php?seite=disable_img&id=62','popFGcerb',400,400,'no','no')
	open_win('pop.fotogalerie.cerb.php'+params,'popFGcerb',600,600,'no','yes');
}

function open_img(id,fotogalerie,filmrolle) {
	
	if(id==undefined) {
		alert('Fehler: JavaScript open_img() bekam keine ID uebergeben!');
	} else {
// gg - more
//		w = 580;
//		h = 500;
		w = 680;
		h = 600;
		margin_left = calc_margin_left(w);
		margin_top = calc_margin_top(h);
		
		param = '?id='+id;
		if(fotogalerie!=undefined && fotogalerie!=0) {
			param = param + '&fotogalerie=1';
		}
		if(filmrolle!=undefined && filmrolle!=0) {
			param = param + '&filmrolle=1';
		}
		
		window.open('pop.bild.php'+param,'popbild','width='+w+',height='+h+',left='+margin_left+',top='+margin_top+',resizable=0,toolbar=0,status=0,location=0,scrollbars=no');
	}
	
}

function chk_input(in_out,wer,txt) {
	// alert('in_out: '+in_out+'; wer: '+wer+'; txt='+txt);
	if(in_out == 'in') {
		if(wer.value == txt) {
			wer.value = '';
		}
	} else {
		if(wer.value == '') {
			wer.value = txt;	
		}
	}
}

function my_add_sgrp_submit() {
	flag = false;
	kurztitel = document.my_add_sgrp_frm.stitel.value;
	if(kurztitel=='') {
		alert('Fehler: Keinen Kurztitel eingegeben!');
	} else {
		var objRegExp  =  /[^A-Za-z0-9_]/;
		if(objRegExp.test(kurztitel)) {
			alert('Fehler: Kurztitel ist ungueltig!');
		} else {
			flag = true
			
			if(document.my_add_sgrp_frm.id_grp.value==0) {
				flag = false;
				alert('Fehler: Ungueltige Gruppe!');
			} else if(document.my_add_sgrp_frm.titel.value=='') {
				flag = false;
				alert('Fehler: Keinen Titel eingegeben!');
			}
			
		}
	}
	if(flag) {
		document.my_add_sgrp_frm.submit();
	}
}

function my_submit_login(wohin) {
	user = document.my_login_frm.user.value;
	passwd = document.my_login_frm.passwd.value;
	if(user=='Benutzername') {
		alert('Benutzername vergessen?!');
	} else if(passwd=='xxxx') {
		alert('Passwort vergessen?!');
	} else {
		my_url = 'fotogalerie.login.php?user='+user+'&passwd='+passwd;
		if(wohin=='main') {
			//alert('login auf main');
			top.main.location.href = my_url;
		} else if(wohin=='parent') {
			parent.location.href = my_url;
		} else {
			//alert('login auf parent');
			top.location.href = my_url;
		}
	}
}


function my_scoll_click(dir,who) {
	distanz = 100;
	if(dir=='l') {
		distanz *= -1;
	}
	eval(who+'.scrollBy('+distanz+',0)');
}

function my_scroll(who,dir) {
	if(dir=='r') {
		geschw = +7;
	} else {
		geschw = -7;
	}
	eval(who+'.scrollBy('+geschw+',0)');
}


var scroll_handle;
function my_scroll_on(dir,who) {
	scroll_handle = window.setInterval("my_scroll('"+who+"','"+dir+"')",30);
	//alert('over; dir: '+dir+'; who: '+who);
	
	//window.setTimeout("my_scroll_on",500);
}
function my_scroll_off(dir,who) {
	window.clearInterval(scroll_handle);
	//alert('out; dir: '+dir+'; who: '+who);
}

function my_upload_all(i) {
	for(j=1;j<=i;j++) {
		my_eval = 'document.i_admin'+j+'.frm_fg_upload.submit_add.click()';
		//alert(my_eval);
		eval(my_eval);
	}
}

function open_lageplan(seite) {
	w = 810;
	h = 430;
	margin_left = calc_margin_left(w);
	margin_top = calc_margin_top(h);
	if(seite == undefined) {
		ad_url = '';
	} else {
		ad_url = '?seite='+seite;
	}
	window.open('pop.lageplan.php'+ad_url,'lageplan','width='+w+',height='+h+',left='+margin_left+',top='+margin_top+',resizable=0,toolbar=0,status=0,location=0,scrollbars=yes');
}
function open_legende() {
	open_win('pop.legende.php','legende',500,560,'yes')
}

function js_bold(frm,inp) {
	txt = prompt("Text eingeben:");
	if(txt!=null) {
		document[frm][inp].value += '<b>'+txt+'</b> ';
	}
}
function js_italic(frm,inp) {
	txt = prompt("Text eingeben:");
	if(txt!=null) {
		document[frm][inp].value += '<i>'+txt+'</i> ';
	}
}
function js_underline(frm,inp) {
	txt = prompt("Text eingeben:");
	if(txt!=null) {
		document[frm][inp].value += '<u>'+txt+'</u> ';
	}
}
function js_h5(frm,inp) {
	txt = prompt("Text eingeben:");
	if(txt!=null) {
		document[frm][inp].value += '<h5>'+txt+'</h5> ';
	}
}
function js_hr(frm,inp) {
	document[frm][inp].value += '<hr />';
}

function js_link(frm,inp) {
	uri = prompt("Internetadresse eingeben (ohne http://):");
	if(uri!=null) {
		txt = prompt("Sichtbaren Text eingeben::");
		if(txt!=null) {
			document[frm][inp].value += '<a href="http://'+uri+'" target="_blank">'+txt+'</a> ';
		}
	}
}
function open_impressum() {
	open_win('/pop.impressum.php','impressum',670,520,'yes');
}
function calc_margin_left(w) {
	screen_w = screen.availWidth;
	m = (screen_w-w)/2;
	return m;
}
function calc_margin_top(h) {
	screen_h = screen.availHeight;
	m = (screen_h-h)/2;
	return m;
}
function js_sgrp_link(frm,inp) {
	w = 400;
	h = 400;
	margin_left = calc_margin_left(w);
	margin_top = calc_margin_top(h);
	window.open('pop.sgrp_link.php?frm='+frm+'&inp='+inp,'sgrplink','width='+w+',height='+h+',left='+margin_left+',top='+margin_top+',resizable=0,toolbar=0,status=0,location=0,scrollbars=no');
}

function click_sitemap(who,href) {
	if(who == 'hund') {
		f = document.frm_hund;
		opt = f.opt_hund;
	} else if(who == 'wurf') {
		f = document.frm_wurf;
		opt = f.opt_wurf;
	} else if(who == 'zucht') {
		f = document.frm_zucht;
		opt = f.opt_zucht;
	}
	if(opt[0].checked == true) {
		i = 0;
	} else if(opt[1].checked == true) {
		i = 1;
	} else if(opt[2].checked == true) {
		i = 2;
	}
	// fotogalerie.view.php?grp=3&sgrp=18
	if(href == 'http://vomtullnerbach.at/fotogalerie') {
		href2 = 'http://vomtullnerbach.at/fotogalerie.view.php';
		if(who=='hund') {
			if(i==0) href2 += '?grp=3&sgrp=23';
			if(i==1) href2 += '?grp=3&sgrp=24';
		} else if(who=='wurf') {
			if(i==0) href2 += '?grp=3&sgrp=27';
			if(i==1) href2 += '?grp=3&sgrp=28';
			if(i==2) href2 += '?grp=3&sgrp=29';
		} else if(who=='zucht') {
			if(i==0) href2 += '?grp=3&sgrp=25';
			if(i==1) href2 += '?grp=3&sgrp=26';
		}
	} else {
		opt_value = f.elements[i].value;
		href2 = href.replace(/xxx/,opt_value);
	}
	document.location.href = href2;
}

function sitemap_change(who) {
	if(who == 'news') {
		f = document.frm_news;
		sel = f.select_news;
		url = 'news.php?seite=view&id=';
	} else if(who == 'user') {
		f = document.frm_user;
		sel = f.select_user;
		url = 'fotogalerie.user.php?id=';
	} else {
		alert('Unbekannte Option! [who='+who+']');
		return false;
	}
	id = sel.value;
	document.location.href=url+id;
}

function suche_submit(js_location) {
	such_term = document.frm_suchen.such.value;
	my_href = 'fotogalerie.suche.php?submit_suche=1&such='+encodeURI(such_term);
	my_cmd = js_location+" = '"+my_href+"';"; // "document."+
	//alert(my_cmd);
	
	eval(my_cmd);
	
	return false;
}

function switch_page(nr,max) {
	for(i = 1; i <= max; i++) {
		if(i == nr) {
			document.getElementById('a_page'+i).style.fontWeight = "bold";
		} else {
			document.getElementById('a_page'+i).style.fontWeight = "normal";
		}
	}
}

