/* Mail decryption */
function decryptThis(s) {
	var n=0;
	var r="mailto:";
	for(var i=0;i<s.length;i++) { 
		n=s.charCodeAt(i); 
		if (n>=8364) {n = 128;}
		r += String.fromCharCode(n-(2)); 
	}
	return r;
}

function doMailto(s) {
	location.href=decryptThis(s);
}

/* Neues Fenster für Großbildanzeige */
var imagewindow = null;
function foto(img,titel,w,h){
	if (w && h) {
		dummy = "../_katalog/coverzoom.cfm?image=" + img + "&w=" + w + "&h=" + h + "&titel=" + titel;
		imagewindow=window.open(dummy,"Bigimage","width="+w+",height="+h+",top=0,left=0");
	} else {
		dummy = "../_katalog/coverzoom.cfm?image=" + img + "&titel=" + titel;
		imagewindow=window.open(dummy,"Bigimage","width=20,height=20,top=0,left=0");
	}
}

/* Popup Fenster für Flashclips oder sonstige Teaser und Links */
var w_popup = null;
function opendtvWin(url,w,h) {
	if (w_popup == null || w_popup.closed == true) {
		w_popup = window.open(url,"dtvpopupwin","width="+w+",height="+h);
		w_popup.focus();
	} else {
		w_popup.focus();
	}
}

var is_set_alter = false;
var is_set_thema = false;

/* "Unmögliche" Auswahl einer Themen-Alters-Kombination unterbinden */
function ajax_suchformular( element, ziel_url ) {	
    var ajax = false;
    ajax = get_ajax();
    
    if(ajax) {    
		switch( element.name )
		{
			case "Thema":
				if( element.value == 0 ) {
					//alert( '1is_set_thema=' + is_set_thema + '&is_set_alter=' + is_set_alter );
					if( is_set_thema == true ) {
						var ajax_thema = new ajaxObject( ziel_url );
						document.getElementById('ladeschlange_thema').innerHTML = '<img src="../../_images/reload.gif" border="0" align="absmiddle" />';
						ajax_thema.callback = function() {
							document.getElementById('auswahl_thema').innerHTML = ajax_thema.responseText;
					    	is_set_thema = false;
						};					
						ajax_thema.update('getthema=true&alter=', 'get');
					}
				
					if( is_set_alter == true ) {
						var ajax_alter = new ajaxObject( ziel_url );
						document.getElementById('ladeschlange_alter').innerHTML = '<img src="../../_images/reload.gif" border="0" align="absmiddle" />';
						ajax_alter.callback = function() {
							document.getElementById('auswahl_alter').innerHTML = ajax_alter.responseText;
					    	is_set_alter = false;
						};					
						ajax_alter.update('getalter=true&thema=0', 'get');
					}
				} else if( is_set_thema == false ) {
					var ajax_alter = new ajaxObject( ziel_url );
					document.getElementById('ladeschlange_alter').innerHTML = '<img src="../../_images/reload.gif" border="0" align="absmiddle" />';
					ajax_alter.callback = function() {
						document.getElementById('auswahl_alter').innerHTML = ajax_alter.responseText;
				    	is_set_alter = true;
					};					
					ajax_alter.update('getalter=true&thema=' + element.value, 'get');
				} else {
					is_set_thema = true;
				}
				break;
			
			case "alter":
				if( element.value == '' ) {
					//alert( '2is_set_thema=' + is_set_thema + '&is_set_alter=' + is_set_alter );
					if( is_set_thema == true ) {
						var ajax_thema = new ajaxObject( ziel_url );
						document.getElementById('ladeschlange_thema').innerHTML = '<img src="../../_images/reload.gif" border="0" align="absmiddle" />';
						ajax_thema.callback = function() {
							document.getElementById('auswahl_thema').innerHTML = ajax_thema.responseText;
					    	is_set_thema = false;
						};					
						ajax_thema.update('getthema=true&alter=', 'get');
					}
				
					if( is_set_alter == true ) {
						var ajax_alter = new ajaxObject( ziel_url );
						document.getElementById('ladeschlange_alter').innerHTML = '<img src="../../_images/reload.gif" border="0" align="absmiddle" />';
						ajax_alter.callback = function() {
							document.getElementById('auswahl_alter').innerHTML = ajax_alter.responseText;
					    	is_set_alter = false;
						};					
						ajax_alter.update('getalter=true&thema=0', 'get');
					}
				} else if( is_set_alter == false ) {
					var ajax_thema = new ajaxObject( ziel_url );
					document.getElementById('ladeschlange_thema').innerHTML = '<img src="../../_images/reload.gif" border="0" align="absmiddle" />';
					ajax_thema.callback = function() {
						document.getElementById('auswahl_thema').innerHTML = ajax_thema.responseText;
				    	is_set_thema = true;
					};					
					ajax_thema.update('getthema=true&alter=' + element.value, 'get');
				} else {
					is_set_alter = true;
				}
				break;
			
			default:
				alert("Falsches Formularfeld übergeben!");
				break;
		}
    }
}

