//== Karte ==================================================================//
function karte_img(dateiname)
{
	document.getElementById("imglaender").src=dateiname;
}
//===========================================================================//

//== formular ===============================================================//
function wahl_feld_sel(feld) {document.getElementById("feld"+feld).className="normal_sel";}
function wahl_feld(feld) {document.getElementById("feld"+feld).className="normal";}

function wahl_textarea_sel(feld) {document.getElementById("feld"+feld).className="textarea_sel";}
function wahl_textarea(feld) {document.getElementById("feld"+feld).className="textarea";}

function wahl_file_sel(feld) {document.getElementById("feld"+feld).className="datei_sel";}
function wahl_file(feld) {document.getElementById("feld"+feld).className="datei";}

function wahl_profilbild_sel(feld) {document.getElementById("feld"+feld).className="profilbild_sel";}
function wahl_profilbild(feld) {document.getElementById("feld"+feld).className="profilbild";}

function europa_wahlcheck_js()
{
	if (!document.wahlplattform.europawahlcheck) return;
	if (!document.wahlplattform.ueberschrift) return;

	if (document.wahlplattform.europawahlcheck.checked)
	{
		document.getElementById("europawahlcheckdiv").style.visibility="visible";
		document.getElementById("europawahlcheckdiv").style.height="40px";
		if (document.wahlplattform.ueberschrift.value=="") 
			document.wahlplattform.ueberschrift.value=document.wahlplattform.europawahlcheck_ueberschrift.value;
	}
	else
	{
		document.getElementById("europawahlcheckdiv").style.visibility="hidden";
		document.getElementById("europawahlcheckdiv").style.height="1px";
	}
}
//===========================================================================//


//== Admin ==================================================================//
function frage_sperren(frage_id)
{ 
	width=530;
	height=100;
	width_pos=(screen.width/2)-(width/2);
	height_pos=(screen.height/2)-(height/1.5);
	eval('frage_sperren_window=window.open("","frage_sperren_window","directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,width='+width+',height='+height+', left='+width_pos+',top='+height_pos+',screenX='+width_pos+',screenY='+height_pos+'");')
	frage_sperren_window.focus();
  frage_sperren_window.document.location.href="/modules/wahlplattform/frage_sperren.php?f_id="+frage_id;
}

function kommentar_sperren(kommentar_id)
{ 
	width=530;
	height=100;
	width_pos=(screen.width/2)-(width/2);
	height_pos=(screen.height/2)-(height/1.5);
	eval('kommentar_sperren_window=window.open("","kommentar_sperren_window","directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,width='+width+',height='+height+', left='+width_pos+',top='+height_pos+',screenX='+width_pos+',screenY='+height_pos+'");')
	kommentar_sperren_window.focus();
  kommentar_sperren_window.document.location.href="/modules/wahlplattform/kommentar_sperren.php?kom_id="+kommentar_id;
}
//===========================================================================//


//== Bewertung ==================================================================//
function sternbewertung(stern,imgid)
{
	document.getElementById("imgsternbild"+imgid).src="/layout/imgs/"+stern+"stern.gif";
}

function sternbewertung_klick(wahltype,stern,imgid)
{
	str='Bewertung abgegeben!';
	bewertungoeffnen(wahltype,stern,imgid);
	document.getElementById("divsternbild"+imgid).innerHTML=str;
	return false;
}

function bewertungoeffnen(wahltype,sterne,imgid)
{
	rnd=Math.random();
	url="https://www.hotellerie.de/modules/wahlplattform"+wahltype+"/bewerten.php";
	url+="?frage_id="+imgid;
	url+="&sterne="+sterne;
	//url+="&rnd="+rnd;

	//== Request-Object =============================================================//
	var req = null;
	
	try{req = new XMLHttpRequest();}
	catch (ms){try{req = new ActiveXObject("Msxml2.XMLHTTP");} 
	catch (nonms){try{req = new ActiveXObject("Microsoft.XMLHTTP");} catch (failed){req = null;}}}
	
	if (req == null) {return}
	req.open("POST", url, true);
	
	
	//Wenn alle funktioniert
	req.onreadystatechange = function()
	{ 
		switch(req.readyState) 
		{
			case 4:
				if(req.status!=200)
				{//Wenn etwas mit dem Öffnen nicht klappt, Fehlernumme anzeigen
					alert("Fehler:"+req.status); 
				}
				else
				{//sonst mach nix
				}
			break;

			default: return false;break; 
		}
	};

	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	req.send(null);
}
//===========================================================================//

//== Extra Datei ==================================================================//
function extradateifeld()
{
	i=document.wahlplattform.extradateien_anzahl.value;
	i++;
	str=document.getElementById("extradateien").innerHTML;
	tab=15*1+i*1;

	str+='<input type="file" name="file[]" class="datei" ';
	str+='title="Zusatzdatei" ';
	str+='id="felddatei'+i+'" ';
	str+='tabindex="'+tab+'" ';
	str+='onmouseover="wahl_file_sel(\'datei'+i+'\')" ';
	str+='onfocus="wahl_file_sel(\'datei'+i+'\')" ';
	str+='onmouseout="wahl_file(\'datei'+i+'\')" ';
	str+='onblur="wahl_file(\'datei'+i+'\');"> ';
	
	document.getElementById("extradateien").innerHTML=str
	document.wahlplattform.extradateien_anzahl.value=i;
/**/
}

function datei_loeschen(kandidat_dateien_id)
{
	width=530;
	height=100;
	width_pos=(screen.width/2)-(width/2);
	height_pos=(screen.height/2)-(height/1.5);
	eval('kandidat=window.open("","kandidat","directories=0,location=0,menubar=0,resizable=1,scrollbars=1,status=1,toolbar=0,width='+width+',height='+height+', left='+width_pos+',top='+height_pos+',screenX='+width_pos+',screenY='+height_pos+'");')
	kandidat.focus();
  kandidat.document.location.href="/modules/wahlplattform/datei_loeschen.php?kandidat_dateien_id="+kandidat_dateien_id;
}

function datei_loesch_liste(kandidat_dateien_id)
{
	str=document.getElementById("kandidat_dateien_id"+kandidat_dateien_id).innerHTML;
	strpos=str.indexOf("<A class=");
	str=str.substr(0,strpos);
	document.getElementById("kandidat_dateien_id"+kandidat_dateien_id).innerHTML=str+" <b>gelöscht</b>";
}
//===========================================================================//


//== Wahlcheckliste =========================================================//
function wahlchecklistenantwort_speichern(wahltype,partei_id)
{

/*
	//== Pflichtfelder ========================================================//
	alles_ok=true;
	if(!document.antworten_wahlcheckliste.frage1a['0'].checked && !document.antworten_wahlcheckliste.frage1a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage2a['0'].checked && !document.antworten_wahlcheckliste.frage2a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage2b['0'].checked && !document.antworten_wahlcheckliste.frage2b['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage2c['0'].checked && !document.antworten_wahlcheckliste.frage2c['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage3a['0'].checked && !document.antworten_wahlcheckliste.frage3a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage3b['0'].checked && !document.antworten_wahlcheckliste.frage3b['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage4a['0'].checked && !document.antworten_wahlcheckliste.frage4a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage4b['0'].checked && !document.antworten_wahlcheckliste.frage4b['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage4c['0'].checked && !document.antworten_wahlcheckliste.frage4c['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage5a['0'].checked && !document.antworten_wahlcheckliste.frage5a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage5b['0'].checked && !document.antworten_wahlcheckliste.frage5b['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage6a['0'].checked && !document.antworten_wahlcheckliste.frage6a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage6b['0'].checked && !document.antworten_wahlcheckliste.frage6b['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage7a['0'].checked && !document.antworten_wahlcheckliste.frage7a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage7b['0'].checked && !document.antworten_wahlcheckliste.frage7b['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage8a['0'].checked && !document.antworten_wahlcheckliste.frage8a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage8b['0'].checked && !document.antworten_wahlcheckliste.frage8b['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage9a['0'].checked && !document.antworten_wahlcheckliste.frage9a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage9b['0'].checked && !document.antworten_wahlcheckliste.frage9b['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage10a['0'].checked && !document.antworten_wahlcheckliste.frage10a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage11a['0'].checked && !document.antworten_wahlcheckliste.frage11a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage12a['0'].checked && !document.antworten_wahlcheckliste.frage12a['1'].checked) alles_ok=false;
	if(!document.antworten_wahlcheckliste.frage12b['0'].checked && !document.antworten_wahlcheckliste.frage12b['1'].checked) alles_ok=false;
	if (!alles_ok)
	{
		alert("Bitte beantworten Sie jede Frage!");
		return;
	}
	//=========================================================================//
*/

	//== die URL erzeugen =====================================================//
	rnd=Math.random();
	url="https://www.hotellerie.de/modules/wahlplattform_bundestag/wahlcheckliste_speichern.php?rnd="+rnd;
	//=========================================================================//

	if (partei_id==undefined) partei_id="";
	if (partei_id!="") partei_id="_"+partei_id;


	//== Parameter füllen, für die Eingabefelder ==============================//
	parameter="";
	eval('parameter+="#--#statement1a="+document.antworten_wahlcheckliste'+partei_id+'.statement1a.value;');
// alert("1");
	eval('parameter+="#--#statement2a="+document.antworten_wahlcheckliste'+partei_id+'.statement2a.value;');
// alert("2");	
eval('parameter+="#--#statement2b="+document.antworten_wahlcheckliste'+partei_id+'.statement2b.value;');
// alert("3");
	eval('parameter+="#--#statement2c="+document.antworten_wahlcheckliste'+partei_id+'.statement2c.value;');
// alert("4");
	eval('parameter+="#--#statement2d="+document.antworten_wahlcheckliste'+partei_id+'.statement2d.value;');
// alert("5");
	eval('parameter+="#--#statement3a="+document.antworten_wahlcheckliste'+partei_id+'.statement3a.value;');
// alert("6");
	eval('parameter+="#--#statement3b="+document.antworten_wahlcheckliste'+partei_id+'.statement3b.value;');
// alert("7");
	eval('parameter+="#--#statement4a="+document.antworten_wahlcheckliste'+partei_id+'.statement4a.value;');
// alert("8");
	eval('parameter+="#--#statement4b="+document.antworten_wahlcheckliste'+partei_id+'.statement4b.value;');
// alert("9");
	eval('parameter+="#--#statement4c="+document.antworten_wahlcheckliste'+partei_id+'.statement4c.value;');
// alert("10");
	eval('parameter+="#--#statement5a="+document.antworten_wahlcheckliste'+partei_id+'.statement5a.value;');
// alert("11");
	eval('parameter+="#--#statement5b="+document.antworten_wahlcheckliste'+partei_id+'.statement5b.value;');
// alert("12");
	eval('parameter+="#--#statement5c="+document.antworten_wahlcheckliste'+partei_id+'.statement5c.value;');
// alert("13");
	eval('parameter+="#--#statement6a="+document.antworten_wahlcheckliste'+partei_id+'.statement6a.value;');
// alert("14");
	eval('parameter+="#--#statement6b="+document.antworten_wahlcheckliste'+partei_id+'.statement6b.value;');
// alert("15");
	eval('parameter+="#--#statement6c="+document.antworten_wahlcheckliste'+partei_id+'.statement6c.value;');
// alert("16");
	//=========================================================================//

  
	//== Parameter füllen, für die JA-Felder ==================================//
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage1a[\'0\'].checked) parameter+="#--#frage1a=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage2a[\'0\'].checked) parameter+="#--#frage2a=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage2b[\'0\'].checked) parameter+="#--#frage2b=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage2c[\'0\'].checked) parameter+="#--#frage2c=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage2d[\'0\'].checked) parameter+="#--#frage2d=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage3a[\'0\'].checked) parameter+="#--#frage3a=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage3b[\'0\'].checked) parameter+="#--#frage3b=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage4a[\'0\'].checked) parameter+="#--#frage4a=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage4b[\'0\'].checked) parameter+="#--#frage4b=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage4c[\'0\'].checked) parameter+="#--#frage4c=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage5a[\'0\'].checked) parameter+="#--#frage5a=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage5b[\'0\'].checked) parameter+="#--#frage5b=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage5c[\'0\'].checked) parameter+="#--#frage5c=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage6a[\'0\'].checked) parameter+="#--#frage6a=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage6b[\'0\'].checked) parameter+="#--#frage6b=1";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage6c[\'0\'].checked) parameter+="#--#frage6c=1";');
	//=========================================================================//
                                                       
                                                          
	//== Parameter füllen, für die NEIN-Felder ================================//
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage1a[\'1\'].checked) parameter+="#--#frage1a=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage2a[\'1\'].checked) parameter+="#--#frage2a=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage2b[\'1\'].checked) parameter+="#--#frage2b=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage2c[\'1\'].checked) parameter+="#--#frage2c=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage2d[\'1\'].checked) parameter+="#--#frage2d=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage3a[\'1\'].checked) parameter+="#--#frage3a=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage3b[\'1\'].checked) parameter+="#--#frage3b=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage4a[\'1\'].checked) parameter+="#--#frage4a=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage4b[\'1\'].checked) parameter+="#--#frage4b=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage4c[\'1\'].checked) parameter+="#--#frage4c=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage5a[\'1\'].checked) parameter+="#--#frage5a=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage5b[\'1\'].checked) parameter+="#--#frage5b=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage5c[\'1\'].checked) parameter+="#--#frage5c=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage6a[\'1\'].checked) parameter+="#--#frage6a=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage6b[\'1\'].checked) parameter+="#--#frage6b=2";');
	eval('if(document.antworten_wahlcheckliste'+partei_id+'.frage6c[\'1\'].checked) parameter+="#--#frage6c=2";');
	//=========================================================================//


                                      
	//== Parameter füllen, für Partei_id ================================//
	eval('parameter+="#--#partei_id="+document.antworten_wahlcheckliste'+partei_id+'.partei_id.value;');
	//=========================================================================//
                                                          
	parameter=parameter.replace(/&/gi,"&amp;");             
	parameter=parameter.replace(/#--#/gi,"&");      

	//alert(parameter);
        
                                                          
	//== Request-Object =======================================================//
	var req = null;                                         
	                                                        
	try{req = new XMLHttpRequest();}                        
	catch (ms){try{req = new ActiveXObject("Msxml2.XMLHTTP");} 
	catch (nonms){try{req = new ActiveXObject("Microsoft.XMLHTTP");} catch (failed){req = null;}}}
                                                          
	if (req == null) {return}                               
	req.open("POST", url, true);                            
                                                          
	//Wenn alle funktioniert                                
	req.onreadystatechange = function()                     
	{                                                       
		switch(req.readyState)                                
		{                                                     
			case 4:                                             
				if(req.status!=200)                               
				{//Wenn etwas mit dem Öffnen nicht klappt, Fehlernumme anzeigen
					alert("Fehler:"+req.status);                    
				}                                                 
				else                                              
				{//sonst fenster schließen                        
					wahlchecklite_formular_verstecken(partei_id);
				}                                                 
			break;                                              
                                                          
			default: return false;break;                        
		}                                                     
	};                                                      
                                                          
                                                          
                                                          
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  req.send(parameter);                                    
	//req.send(null);                                       
}                                                         
//===========================================================================//
                                                          
//== Wahlcheckliste =========================================================//
function wahlcheckliste_formular_zeigen()                 
{                                                         
	if (window.innerWidth) in_width=window.innerWidth;      
	if (document.body.offsetWidth) in_width=document.body.offsetWidth;
	in_width=in_width/2;                                    
	in_width=parseInt(in_width);                            
	in_width-=325;                                          
	if (in_width<10) in_width=10;                           
                                                          
	if (window.innerHeight) in_height=window.innerHeight;   
	if (document.body.offsetHeight) in_height=document.body.offsetHeight;
	in_height=in_height/2;                                  
	in_height=parseInt(in_height);                          
                                                          
	in_height-=220;                                         
	if (in_height<110) in_height=20;                        
                                                          
	document.getElementById('antworten_wahlcheckliste').style.visibility="visible";
	document.getElementById('antworten_wahlcheckliste').style.left=in_width+"px";
	document.getElementById('antworten_wahlcheckliste').style.top=in_height+"px";
}                                                         
                                                          
function wahlchecklite_formular_verstecken(op)            
{                                                         
	if (op=="")document.getElementById('antworten_wahlcheckliste').style.visibility="hidden";
	if (op!="")document.getElementById('antworten_wahlcheckliste'+op).style.visibility="hidden";
}

function partei_id(p_id,kuerzel)
{
	document.antworten_wahlcheckliste.partei_id.value=p_id;
	document.getElementById('wahlchecklistenname').innerHTML="Parteiantworten zur Wahlcheckliste für "+kuerzel;
}

function partei_wahlcheckliste_formular_zeigen(parteiid)
{
	if (window.innerWidth) in_width=window.innerWidth;
	if (document.body.offsetWidth) in_width=document.body.offsetWidth;
	in_width=in_width/2;
	in_width=parseInt(in_width);
	in_width-=325;
	if (in_width<10) in_width=10;

	if (window.innerHeight) in_height=window.innerHeight;
	if (document.body.offsetHeight) in_height=document.body.offsetHeight;
	in_height=in_height/2;
	in_height=parseInt(in_height);

	in_height-=220;
	if (in_height<110) in_height=20;

	document.getElementById('antworten_wahlcheckliste_'+parteiid).style.visibility="visible";
	document.getElementById('antworten_wahlcheckliste_'+parteiid).style.left=in_width+"px";
	document.getElementById('antworten_wahlcheckliste_'+parteiid).style.top=in_height+"px";
}
//===========================================================================//


//== Aufklapprahmen =========================================================//
function aufklapprahmen_auf(op,pixel)
{
	text='<a href="javascript:dono();" onclick="aufklapprahmen_zu(\''+op+'\',\''+pixel+'\');" class="open">schließen</a>';
	document.getElementById('rahmen_'+op).style.height=pixel;
	document.getElementById('open_'+op).innerHTML=text;
}

function aufklapprahmen_zu(op,pixel)
{
	text='<a href="javascript:dono();" onclick="aufklapprahmen_auf(\''+op+'\',\''+pixel+'\');" class="open">öffnen</a>';
	document.getElementById('rahmen_'+op).style.height="21px";
	document.getElementById('open_'+op).innerHTML=text;
}
//===========================================================================//


//== Wahlkreiskarte =========================================================//
function wahlkreis_karte_anzeigen(auftext,zutext)
{
	onclickstr="wahlkreis_karte_verstecken('"+auftext+"','"+zutext+"');";
	document.getElementById('kartendiv').style.visibility="visible";
	document.getElementById('kartendiv').style.height="480px";

	document.getElementById('kartenlink').outerHTML='<a href="javascript:dono();" onclick="'+onclickstr+'" id="kartenlink" class="kartenlink">'+zutext+'</a>';

}

function wahlkreis_karte_verstecken(auftext,zutext)
{
	onclickstr="wahlkreis_karte_anzeigen('"+auftext+"','"+zutext+"');";
	document.getElementById('kartendiv').style.visibility="hidden";
	document.getElementById('kartendiv').style.height="1px";

	document.getElementById('kartenlink').outerHTML='<a href="javascript:dono();" onclick="'+onclickstr+'" id="kartenlink" class="kartenlink">'+auftext+'</a>';
}

//===========================================================================//


