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("Are you sure you want to delete this item?");
	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 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 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 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++;
		}
	}
}
