function initPage(){
	updatelist();
	updatefregion();
}

function updatelist() {
	var q = document.getElementById('bundesland').options[document.getElementById('bundesland').selectedIndex].value;
	new Ajax.Updater('ucat', 'includes/get_ucat.php', {
		method:'get',
		parameters: {sel_bland: q},
		onComplete: function(){ updatefregion(0) }
	});
}

function initList(id) {
    if(!id) {
	   var q = document.getElementById('bundesland').options[document.getElementById('bundesland').selectedIndex].value;
	   new Ajax.Updater('ucat', 'includes/get_ucat.php', {
		  method:'get',
		  parameters: {sel_bland: q},
		  onComplete: function(){ updatefregion(0)}
	   });
    }
}

function updatefregion(erster) {
	if(erster==0) {
		var q = document.getElementById('pregion').options[erster].value;
	} else {
		var q = document.getElementById('pregion').options[document.getElementById('pregion').selectedIndex].value;
	}


	new Ajax.Updater('ferien', 'includes/get_fregio.php', {
		method:'get',
		parameters: {sel_fregio: q}
	});
}

function updateimage(imgname) {
	new Ajax.Updater('imagebild', 'includes/get_image.php', {
		method:'get',
		parameters: {sel_image: imgname}
	});
}

function toggleZW_alt() {
	var zw = document.getElementById('zahlungsweise');
	
	if(zw.type != 'hidden'){
		var q = zw.options[zw.selectedIndex].value;

		new Ajax.Updater('tbl_zahlweise', 'includes/get_tblzw.php', {
			method:'get',
			parameters: {sel_zw: q}
		});
	}
}

function toggleZW() {
	var zw = document.getElementById('zahlungsweise');
	var tzw = document.getElementById('tbl_zahlweise');
	
	if(zw.type != 'hidden'){
		var q = zw.options[zw.selectedIndex].value;
		if(q == 1) {
			tzw.style.visibility = 'visible';
		} else {
			tzw.style.visibility = 'hidden';
		}

	}
}

function CheckTA(name){
	var max = 500, textinhalt, TA;
	TA = document.getElementById(name);
	textinhalt = TA.value;

	if (textinhalt.length >= max){
		TA.value=textinhalt.substring(0,max);
		TA.blur();
	}
}

function toggleHinweis(){
	if(document.getElementById('produkt').options[document.getElementById('produkt').selectedIndex].value > 1){
		document.getElementById('produkt_hinweis').style.visibility = 'visible';
	} else {
		document.getElementById('produkt_hinweis').style.visibility = 'hidden';
	}
}

function changeLand(){
	if($('land').options[$('land').selectedIndex].value != 'DE'){
		$('zahlungsweise').selectedIndex = 1;
		toggleZW();
	}
}


function openWindow(url,name,width,height) {
	window.open(url,name,'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height);
}

function openWindower(url,name,width,height) {
	window.open(url,name,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height);
}

function detail(url){
	var wWidth = screen.availWidth/4*3;
	var wHeight = screen.availHeight/4*3;
	var detailsWindow = window.open(url, "details", "menubar=no,status=no,location=no,resizable=yes,scrollbars=yes,toolbar=no,width="+ wWidth +",height="+ wHeight+",left="+ (wWidth/2) +",top="+ (wHeight/2));
	detailsWindow.focus();
}

function thumbPopup(mypage, myname, w, h, caption) {
        if (caption == 'true'){
            caption_name = myname;
        }else{
            caption_name = "";
        }
        var props = '';
        var orig_w = w;
        var scroll = '';
        var winl = (screen.availWidth - w) / 2;
        var wint = (screen.availHeight - h) / 2;
        if (winl < 0) { winl = 0; w = screen.availWidth -6; scroll = 1;}
        if (wint < 0) { wint = 0; h = screen.availHeight - 32; scroll = 1;}
        winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no'
        win = window.open('', 'myThumb', winprops)
        win.document.open();
        win.document.write('<html><head>');
        win.document.write('<scr' + 'ipt type="text/javascr' + 'ipt" language="JavaScr' + 'ipt">');
        win.document.write('</scr' + 'ipt>');
        win.document.write('<title>'+myname+'</title></head>');
        win.document.write('<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0">');
        win.document.write('<img src="'+mypage+'" border="0" alt="'+myname+'">');
        win.document.write('<br />');
        win.document.write('<div align="middle">'+caption_name+'</div>');
        win.document.write('</body></html>');

        win.document.close();
        if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
