function post_values(formname){
	eval("document."+formname+".submit()");
}

function reset_values(formname){
	eval("document."+formname+".reset()");
}

function change_image(id,image){
	document.getElementById(id).setAttribute("src",image);
}

function delete_check(){
	var x = window.confirm("Sind Sie sicher, dass Sie diesen Eintrag löschen wollen?");
	return x;
}

function open_image(imagename,title,width,height){
	var newwin = window.open("popup.php?imagename="+imagename+"&title="+title+"&width="+width+"&height="+height,"gallerie_popup","width="+(width+10)+",height="+(height+10)+",left=0,top=0,scrollbars=no,status=no,toolbar=no,menubar=no,resizable=no");
  newwin.focus();
}

function change_class(id,classname){
	document.getElementById(id).className = classname;
}

function open_popup(filename,width,height){
	var newwin = window.open(filename,"popup","width="+width+",height="+height+",left=0,top=0,scrollbars=no,status=no,toolbar=no,menubar=no,resizable=no");
  newwin.focus();
}

function popup(url,name,eigenschaften){
	var newwin = window.open(url,name,eigenschaften);
	if(version > 1.0){
		setTimeout('newwin.focus();',200);
	}
}
		   
function open_printpopup(filename,width,height){
	var newwin = window.open(filename,"printpopup","width="+width+",height="+height+",left=0,top=0,scrollbars=no,status=no,toolbar=no,menubar=no,resizable=no");
  newwin.focus();
}

function open_imageDB(formname,url){
	var newwin = window.open(url,"imageDB");
	setTimeout("post_values('"+formname+"');",1000);
  	newwin.focus();
}

function select_link_target(formname,internal_id,news_id,external_id,mail_id,popup_id,product_id,external_links,internal_links,news_links,product_links,external_field,internal_field,news_field,product_field){
	document.getElementById(external_links).style.display="none";
	document.getElementById(internal_links).style.display="none";
	document.getElementById(news_links).style.display="none";
	document.getElementById(product_links).style.display="none";
	document.getElementById(external_field).name="";
	document.getElementById(internal_field).name="";
	document.getElementById(news_field).name="";
	document.getElementById(product_field).name="";
	if(eval("document."+formname).post_text_update_links_id.value==internal_id){
		document.getElementById(internal_links).style.display="block";
		document.getElementById(internal_field).name="post_text_update_link";
	}
	if(eval("document."+formname).post_text_update_links_id.value==external_id || eval("document."+formname).post_text_update_links_id.value==mail_id || eval("document."+formname).post_text_update_links_id.value==popup_id){
		document.getElementById(external_links).style.display="block";
		document.getElementById(external_field).name="post_text_update_link";
	}
	if(eval("document."+formname).post_text_update_links_id.value==news_id){
		document.getElementById(news_links).style.display="block";
		document.getElementById(news_field).name="post_text_update_link";
	}
	if(eval("document."+formname).post_text_update_links_id.value==product_id){
		document.getElementById(product_links).style.display="block";
		document.getElementById(product_field).name="post_text_update_link";
	}
}

function select_news_target(formname,internal_id,news_id,external_id,mail_id,popup_id,product_id,external_links,internal_links,news_links,product_links,external_field,internal_field,news_field,product_field){
	document.getElementById(external_links).style.display="none";
	document.getElementById(internal_links).style.display="none";
	document.getElementById(news_links).style.display="none";
	document.getElementById(product_links).style.display="none";
	document.getElementById(external_field).name="";
	document.getElementById(internal_field).name="";
	document.getElementById(news_field).name="";
	document.getElementById(product_field).name="";
	if(eval("document."+formname).post_news_update_links_id.value==internal_id){
		document.getElementById(internal_links).style.display="block";
		document.getElementById(internal_field).name="post_news_update_link";
	}
	if(eval("document."+formname).post_news_update_links_id.value==external_id || eval("document."+formname).post_news_update_links_id.value==mail_id || eval("document."+formname).post_news_update_links_id.value==popup_id){
		document.getElementById(external_links).style.display="block";
		document.getElementById(external_field).name="post_news_update_link";
	}
	if(eval("document."+formname).post_news_update_links_id.value==news_id){
		document.getElementById(news_links).style.display="block";
		document.getElementById(news_field).name="post_news_update_link";
	}
	if(eval("document."+formname).post_news_update_links_id.value==product_id){
		document.getElementById(product_links).style.display="block";
		document.getElementById(product_field).name="post_text_update_link";
	}
}

function changeProductSelect(productcheck,productdiv,productselect){
	if(document.getElementById(productcheck).checked){
		document.getElementById(productdiv).style.display="inline";
	}else{	
		document.getElementById(productdiv).style.display="none";
		var i = 0;
		if(document.getElementById(productselect)){
			while(document.getElementById(productselect).options[i]){
				document.getElementById(productselect).options[i].selected = false;
				i++;
			}
		}
	}
}

function changeVerbraucherServiceFields(){
	if(document.getElementById("post_contact_themes_1").checked){
		document.getElementById("VerbraucherServiceFields").style.display="inline";
	}else{
		var i = 0;
		for(i=0;i<10;i++){
			if(document.getElementById("verbrauchercheck_"+i)){
				document.getElementById("verbrauchercheck_"+i).checked = false;
				changeProductSelect("verbrauchercheck_"+i,"verbraucherselect_"+i,"post_contact_themes_1_"+i+"[]");
			}
		}
		document.getElementById("VerbraucherServiceFields").style.display="none";
	}
}

function changeProductFields(){
	if(document.getElementById("productcheck").checked){
		document.getElementById("productfields").style.display="inline";
	}else{	
		var i = 0;
		for(i=0;i<10;i++){
			if(document.getElementById("productcheck_"+i)){
				document.getElementById("productcheck_"+i).checked = false;
				changeProductSelect("productcheck_"+i,"productselect_"+i,"post_contact_products_"+i+"[]");
			}
		}
		document.getElementById("productfields").style.display="none";
	}
}

function changeReklamationFields(){
	if(document.getElementById("reklamationcheck").checked){
		document.getElementById("reklamationfields").style.display="inline";
	}else{
		var i = 0;
		for(i=0;i<10;i++){
			if(document.getElementById("reklamationcheck_"+i)){
				document.getElementById("reklamationcheck_"+i).checked = false;
				changeProductSelect("reklamationcheck_"+i,"reklamationselect_"+i,"post_contact_reklamation_"+i+"[]");
			}
		}
		document.getElementById("reklamationfields").style.display="none";
	}
}

function changeSubscribeSelect(){
	var i = 1;
	var j = 1;
	if(document.getElementById('checksubscribe').options[0].selected){
		while(document.getElementById('gastro'+i)){
			document.getElementById('gastro'+i).style.display="inline";
			i++;
		}
		while(document.getElementById('gfgh'+j)){
			document.getElementById('gfgh'+j).style.display="none";
			j++;
		}
	}else{	
		while(document.getElementById('gastro'+i)){
			document.getElementById('gastro'+i).style.display="none";
			i++;
		}
		while(document.getElementById('gfgh'+j)){
			document.getElementById('gfgh'+j).style.display="inline";
			j++;
		}
	}
}

var win= null;
function PopUp(url,name,w,h,scroll,menu,rezi,tool,stat,direct){
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  var settings  ='height='+h+',';
			settings +='width='+w+',';
			settings +='top='+wint+',';
			settings +='left='+winl+',';
			settings +='scrollbars='+scroll+',';
			settings +='menubar='+menu+',';
			settings +='resizable='+rezi+',';
			settings +='toolbar='+tool+',';
			settings +='status='+stat+',';
			settings +='directories='+direct+',';
			win=window.open(url,name,settings);
	if(parseInt(navigator.appVersion) >= 4){win.window.focus();}
}
