var sw=0;
var sh=0;
var aktsite="home";
var objVIEW=document.getElementById("VIEW");
var objIssuu=document.getElementById("IssuuViewer");
var arrSite = new Array();
var IE=false;
var loaded=false;
var aktsite="";
var aktsub="";
var AdminDate="<div style=\"border-top: 1px dotted #000000\">Datum <i>(tt.mm.jjjj)</i>: <input type=\"text\" id=\"dt%CNT%\" name=\"dt%CNT%\" size=\"12\" class=\"small\"> T&uuml;r&ouml;ffnung (<i>hh:mm, opt.</i>): <input type=\"text\" id=\"tm%CNT%_1\" name=\"tm%CNT%_1\" size=\"6\" class=\"small\"> Beginn (<i>hh:mm, opt.</i>): <input type=\"text\" id=\"tm%CNT%_2\" name=\"tm%CNT%_2\" size=\"6\" class=\"small\"> Ende (<i>hh:mm, opt.</i>): <input type=\"text\" id=\"tm%CNT%_3\" name=\"tm%CNT%_3\" size=\"6\" class=\"small\"></div>";
var AdminEvery="<div style=\"border-top: 1px dotted #000000\"><select id=\"every%CNT%\" name=\"every%CNT%\" class=\"small\" style=\"width:70px\"><option value=\"0\">Jeden</option><option value=\"1\">Jeden 1.</option><option value=\"2\">Jeden 2.</option><option value=\"3\">Jeden 3.</option><option value=\"4\">Jeden 4.</option><option value=\"5\">Jeden letzten</option></select><select id=\"day%CNT%\" name=\"day%CNT%\" class=\"small\"><option value=\"1\">Mo</option><option value=\"2\">Di</option><option value=\"3\">Mi</option><option value=\"4\">Do</option><option value=\"5\">Fr</option><option value=\"6\">Sa</option><option value=\"7\">So</option></select> <strong>im Monat:</strong> T&uuml;r&ouml;ffnung (<i>hh:mm, opt.</i>): <input type=\"text\" id=\"tm%CNT%_1\" name=\"tm%CNT%_1\" size=\"6\" class=\"small\"> Beginn (<i>hh:mm, opt.</i>): <input type=\"text\" id=\"tm%CNT%_2\" name=\"tm%CNT%_2\" size=\"6\" class=\"small\"> Ende (<i>hh:mm, opt.</i>): <input type=\"text\" id=\"tm%CNT%_3\" name=\"tm%CNT%_3\" size=\"6\" class=\"small\"></div>";
var AdminDtCnt=0;
var AboContent="";
var aktZip="";
var aktLoc="";

arrBanner=new Array();
arrBanner["TOP"]=new Array();
arrBanner["RIGHT1"]=new Array();
arrBanner["RIGHT2"]=new Array();
arrBanner["RIGHT3"]=new Array();
//arrBanner["TOP"][0]="<a href=\"http://www.nachschlag-magazin.ch/\" target=\"_blank\"><img src=\"/banner/nachschlag.jpg\" border=\"0\"></a>";
arrBanner["TOP"][0]="<a href=\"http://www.dietschi.ch/\" target=\"_blank\"><img src=\"/banner/leader_dietschi.jpg\" border=\"0\"></a>";
//arrBanner["TOP"][0]="<a href=\"http://www.kolt.ch/fredagoodlet/\"><img src=\"/banner/fgoodlet.jpg\" border=\"0\"></a>";
//arrBanner["RIGHT1"][0]="<a href=\"http://www.boesner.ch/\" target=\"_blank\"><img src=\"/banner/boesner.gif\" border=\"0\"></a>";
arrBanner["RIGHT1"][0]="<a href=\"http://www.oltentourismus.ch/\" target=\"_blank\"><img src=\"/banner/vertical_olteninfo.jpg\" border=\"0\"></a>";
arrBanner["RIGHT1"][1]="<a href=\"http://www.cover.ch/\" target=\"_blank\"><img src=\"/banner/vertical_sio.jpg\" border=\"0\"></a>";
arrBanner["RIGHT1"][2]="<a href=\"http://trans.zhdk.ch/\" target=\"_blank\"><img src=\"/banner/zhdk.gif\" border=\"0\"></a>";
//arrBanner["RIGHT1"][3]="<a href=\"http://www.buchplanet.ch/\" target=\"_blank\"><img src=\"/banner/buchplanet.gif\" border=\"0\"></a>";
//arrBanner["RIGHT2"][0]="<a href=\"http://www.beachevent-olten.ch/\"><img src=\"/banner/beachevent.jpg\" border=\"0\"></a>";
//arrBanner["RIGHT2"][0]="<a href=\"http://www.kabarett.ch\"><img src=\"/banner/kabarett.gif\" border=\"0\"></a>";
//arrBanner["RIGHT2"][1]="<a href=\"http://www.polioplus.ch\"><img src=\"/banner/polioplus.jpg\" border=\"0\"></a>";
arrBanner["RIGHT2"][0]="<a href=\"javascript:doLoad('newsletter');\"><img src=\"/banner/n.jpg\" border=\"0\"></a>";
//arrBanner["RIGHT2"][1]="<a href=\"http://www.kolt.ch/agenda/182000/\"><img src=\"/banner/koltfest.png\" border=\"0\"></a>";
//arrBanner["RIGHT2"][1]="<a href=\"http://www.jugendart.ch/\" target=\"_blank\"><img src=\"/banner/ja.gif\" border=\"0\"></a>";
arrBanner["RIGHT3"][0]="<a href=\"javascript:doLoad('inserieren');\"><img src=\"/banner/w.jpg\" border=\"0\"></a>";
//arrBanner["RIGHT3"][0]="<a target=\"_blank\" href=\"http://www.guggilari.ch/\"><img src=\"/banner/guggilari.jpg\" border=\"0\"></a>";
//arrBanner["RIGHT3"][1]="<a target=\"_blank\" href=\"http://www.guggilari.ch/\"><img src=\"/banner/hilari.jpg\" border=\"0\"></a>";
//arrBanner["RIGHT3"][0]="<a target=\"_blank\" href=\"http://www.starticket.ch/0ShowInfo.asp?ShowID=43255&ShowDetails=1\"><img src=\"/banner/veri.png\" border=\"0\"></a>";
var aktBT=undefined;
var aktBR1=undefined;
var aktBR2=undefined;
var aktBR3=undefined;
var iBanner=undefined;

function rand(n)
{
	return (Math.floor(Math.random() * n + 1));
}


function doBanner()
{
	if(aktBT==undefined){
		aktBT=rand(arrBanner["TOP"].length)-1;
		aktBR1=rand(arrBanner["RIGHT1"].length)-1;
		aktBR2=rand(arrBanner["RIGHT2"].length)-1;
		aktBR3=rand(arrBanner["RIGHT3"].length)-1;
	}else{
		aktBT++;
		aktBR1++;
		aktBR2++;
		aktBR3++;
		if(aktBT==arrBanner["TOP"].length){
			aktBT=0;
		}
		if(aktBR1==arrBanner["RIGHT1"].length){
			aktBR1=0;
		}
		if(aktBR2==arrBanner["RIGHT2"].length){
			aktBR2=0;
		}
		if(aktBR3==arrBanner["RIGHT3"].length){
			aktBR3=0;
		}
	}
	obj=document.getElementById("LEADERBOARD");
	obj.innerHTML=arrBanner["TOP"][aktBT];
	obj=document.getElementById("VERTICALBANNER");
	obj.innerHTML=arrBanner["RIGHT1"][aktBR1];
	obj=document.getElementById("BUTTON1");
	obj.innerHTML=arrBanner["RIGHT2"][aktBR2];
	obj=document.getElementById("BUTTON2");
	obj.innerHTML=arrBanner["RIGHT3"][aktBR3];
}
function doLoad2(resp)
{
	eid=0;
	loc="";
	if(resp.responseText.indexOf("|oc|")==-1){
		oC="CONTENT";
		txt=resp.responseText;
	}else{
		arrR=resp.responseText.split("|oc|");
		oC=arrR[1];
		txt=arrR[0];
	}
	if(resp.responseText.indexOf("|eid|")>-1){
		arrR=resp.responseText.split("|eid|");
		eid=arrR[1]*1;
		txt=arrR[0];	
	}
	if(txt.indexOf("|loc|")>-1){
		arrR=txt.split("|loc|");
		loc=arrR[1];
		txt=arrR[0];
	}
	objW=document.getElementById("WAIT");
	objW.style.visibility="hidden";
	objC=document.getElementById(oC);
	objC.innerHTML=txt
	if(eid>0){
		doLoad("agenda","event","&eid="+eid,"EVENT");
	}
	if(loc!=""){
		arrL=loc.split("|");
		initialize(arrL[0],arrL[1],arrL[2]);
	}
	objSM=document.getElementById("SHOUTMAIN");
	objS=document.getElementById("SHOUTS");
	if(aktsite=="leserbriefe" && aktsub==""){
		refreshShout();
	}
}

function goBig()
{
	objM=document.getElementById("MAIN");
	objC=document.getElementById("CONTENT");
	objF=document.getElementById("FOOTER");
	var t=objM.style.top;
	t=t.replace("px","");
	t=t.replace("pt","");
	t=t*1;
	t=t-10;
	if(t<2){
		t=2;
	}
	objM.style.top=t;
	var h=objM.style.height;
	h=h.replace("px","");
	h=h.replace("pt","");
	h=h*1;
	h=h+20;
	if(h>(sh-4)){
		h=sh-4;
	}
	objM.style.top=t;
	objM.style.height=h;
	objC.style.height=h-125;
	objF.style.top=h-20;
	if(t>2 || h<(sh-4)){
		setTimeout("goBig()",25);
	}
}

function goSmall()
{
	objM=document.getElementById("MAIN");
	objC=document.getElementById("CONTENT");
	objF=document.getElementById("FOOTER");
	var t=objM.style.top;
	t=t.replace("px","");
	t=t.replace("pt","");
	t=t*1;
	t=t+10;
	if(t>(sh-555)/2){
		t=(sh-555)/2;
	}
	objM.style.top=t;
	var h=objM.style.height;
	h=h.replace("px","");
	h=h.replace("pt","");
	h=h*1;
	h=h-20;
	if(h<555){
		h=555;
	}
	objM.style.top=t;
	objM.style.height=h;
	objC.style.height=h-125;
	objF.style.top=h-20;
	if(t<(sh-555)/2 || h>555){
		setTimeout("goSmall()",25);
	}
}

function initialize(l,address,id)
{
	var ll="";
	var map = new GMap2(document.getElementById("map_canvas"));
	map.setUIToDefault();
	var geocoder = new GClientGeocoder();
	if(l==undefined || l==""){
		geocoder.getLatLng(address, function(point){
		if (!point)
		{
			ll=0;
			omap=document.getElementById("map_canvas");
			omap.style.visibility="hidden";
			omap.style.position="absolute";
		}else{
			ll=point.y+","+point.x;
			map.setCenter(point, 15);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			//marker.openInfoWindowHtml(address);
		}
		if(id!=undefined && id!=""){
			var objD = new Date();
			var t=objD.valueOf();
			var newAjax = new Ajax.Request("/savell.php?id="+id+"&ll="+ll+"&t="+t,{method: 'get'});
		}
	});
	}else{
			arrL=l.split(",");
			point=new GLatLng(arrL[0],arrL[1]);
			map.setCenter(point, 15);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			//marker.openInfoWindowHtml(address);
	}
}
function mapHierlesen(l,address,id)
{
	var ll="";
	obj=document.getElementById("MAP_"+id);
	obj.innerHTML="<span class=\"small\"><a href=\"javascript:mapHierlesenAusblenden('"+l+"','"+address+"',"+id+");\">&raquo; Karte ausblenden</a></span><br><br><div id=\"map_canvas_"+id+"\" style=\"width: 480px; height: 250px\"><center><img src=\"/img/wait.gif\"></center></div><br><br></span>";
	var map = new GMap2(document.getElementById("map_canvas_"+id));
	map.setUIToDefault();
	var geocoder = new GClientGeocoder();
	if(l==undefined || l==""){
		geocoder.getLatLng(address, function(point){
		if (!point)
		{
			ll=0;
			omap=document.getElementById("map_canvas");
			omap.style.visibility="hidden";
			omap.style.position="absolute";
		}else{
			ll=point.y+","+point.x;
			map.setCenter(point, 15);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			//marker.openInfoWindowHtml(address);
		}
		if(id!=undefined && id!=""){
			var objD = new Date();
			var t=objD.valueOf();
			var newAjax = new Ajax.Request("/savellhierlesen.php?id="+id+"&ll="+ll+"&t="+t,{method: 'get'});
		}
	});
	}else{
			arrL=l.split(",");
			point=new GLatLng(arrL[0],arrL[1]);
			map.setCenter(point, 15);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			//marker.openInfoWindowHtml(address);
	}
}
function mapHierlesenAusblenden(l,address,id)
{
	obj=document.getElementById("MAP_"+id);
	obj.innerHTML="<span class=\"small\"><a href=\"javascript:mapHierlesen('"+l+"','"+address+"',"+id+");\">&raquo; Karte anzeigen</a></span>";
}
function showAGB()
{
	obj=document.getElementById("SPANAGB");
	if(obj.style.visibility=="hidden"){
		obj.style.position="static";
		obj.style.visibility="visible";
	}else{
		obj.style.visibility="hidden";	
		obj.style.position="absolute";
	}
}
function doAbo()
{
	objC=document.getElementById("CONTENT");
	objC.style.visibility="hidden";
	objW=document.getElementById("WAIT");
	objW.style.visibility="visible";
	var txtfields="company,firstname,lastname,street,street2,zip,location,birthday,email,rcompany,rfirstname,rlastname,rstreet,rstreet2,rzip,rlocation";
	var selectfields="sex,rsex";
	var checkboxfields="AGB,otherbill";
	var query="";
	var abo=1;
	obj=document.getElementById("abo2");
	if(obj.checked){
		abo=2;
	}
	query=query+"&abo="+escape(abo);
	arrTMP=txtfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=obj.value;
		query=query+"&"+arrTMP[i]+"="+escape(val);
	}
	arrTMP=selectfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=obj.options[obj.selectedIndex].value;
		query=query+"&"+arrTMP[i]+"="+escape(val);
	}
	arrTMP=checkboxfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=0;
		if(obj.checked){
			val=1;
		}
		query=query+"&"+arrTMP[i]+"="+escape(val);
	}
	
	obj=document.getElementById("ERRAGB");
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#000000";
	
	var pay=2;
	obj=document.getElementById("pay3");
	if(obj.checked){
		pay=3;
	}
	//obj=document.getElementById("pay1");
	//if(obj.checked){
	//	pay=1;
	//}
	query=query+"&pay="+escape(pay);
	var objD = new Date();
	var t=objD.valueOf();
	query=doQuery(query);
	var newAjax = new Ajax.Request("/abo.php?action=save&t="+t+query,{method: 'get', onComplete: doAbo2});
}
function doAbo2(resp)
{
	objC=document.getElementById("CONTENT");
	objC.style.visibility="visible";
	objW=document.getElementById("WAIT");
	objW.style.visibility="hidden";
	r=resp.responseText;
	if(r.indexOf("||")>-1){
		arrTMP=r.split("||");
		action=arrTMP[0];
		value=arrTMP[1];
		if(action=="ERR"){
			arrE=value.split(";");
			for(i=0;i<arrE.length;i++){
				if(arrE[i]=="age"){
					alert("Du musst mindestens 18 Jahre alt sein!\r\nWenn du noch nicht 18 bist, muessen Deine Eltern das Abo fuer dich bestellen.");
				}else{
					if(arrE[i]=="AGB"){
						obj=document.getElementById("ERRAGB");
						obj.style.backgroundColor="#ffdcdc";
						obj.style.color="#000000";
					}
					obj=document.getElementById(arrE[i]);
					obj.style.backgroundColor="#ffdcdc";
					obj.style.color="#000000";
				}
			}
		}else if(action=="SAVED"){
			AboContent=objC.innerHTML;
			objC.innerHTML=arrTMP[1];
		}
	}
}

function doOrder(oid)
{
	objC=document.getElementById("CONTENT");
	objC.style.visibility="hidden";
	objW=document.getElementById("WAIT");
	objW.style.visibility="visible";
	objE=document.getElementById("ex");
	var ex=objE.value;
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/abo.php?action=order&id="+oid+"&ex="+escape(ex)+"&t="+t,{method: 'get', onComplete: doOrder2});
}
function doOrder2(resp)
{
	objC=document.getElementById("CONTENT");
	objC.style.visibility="visible";
	objW=document.getElementById("WAIT");
	objW.style.visibility="hidden";
	r=resp.responseText;
	objC.innerHTML=r;
}

function restoreAbo()
{
	objC=document.getElementById("CONTENT");
	objC.innerHTML=AboContent;
}

function doShout()
{
	objS=document.getElementById("SHOUT");
	objS.style.visibility="hidden";
	objW=document.getElementById("SHOUTWAIT");
	objW.style.position="static";
	objW.style.visibility="visible";
	
	var txtfields="name,code";
	var query="";
	arrTMP=txtfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=obj.value;
		query=query+"&"+arrTMP[i]+"="+escape(val);
	}
	obj=document.getElementById("msg");
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#000000";
	val=obj.value;
	query=query+"&msg="+escape(val);
	
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/shout.php?action=save&t="+t+query,{method: 'get', onComplete: doShout2});
}
function doShout2(resp)
{
	r=resp.responseText;
	if(r.indexOf("||")>-1){
		arrTMP=r.split("||");
		action=arrTMP[0];
		value=arrTMP[1];
		if(action=="ERR"){
			objS=document.getElementById("SHOUT");
			objS.style.visibility="visible";
			objW=document.getElementById("SHOUTWAIT");
			objW.style.position="absolute";
			objW.style.visibility="hidden";
			r=resp.responseText;
			obj=document.getElementById("code");
			obj.style.backgroundColor="#FFFFFF";
			obj.style.color="#000000";
			obj.value="";
			arrE=value.split(";");
			for(i=0;i<arrE.length;i++){
					obj=document.getElementById(arrE[i]);
					obj.style.backgroundColor="#ffdcdc";
					obj.style.color="#000000";
			}
			var objD = new Date();
			var t=objD.valueOf();
			img=document.getElementById("codeimg");
			img.src="/img/code/code.php?"+t;
		}else if(action=="SAVED"){
			var txtfields="name,code";
			var query="";
			arrTMP=txtfields.split(",");
			for(i=0;i<arrTMP.length;i++){
				obj=document.getElementById(arrTMP[i]);
				obj.value="";
			}
			obj=document.getElementById("msg");
			obj.value="";
			refreshShout();
		}
	}
}

function refreshShout()
{
	if(aktsite=="leserbriefe" && aktsub==""){
		obj=document.getElementById("SHOUTS");
		if(obj!=null)
		{
			var objD = new Date();
			var t=objD.valueOf();
			var newAjax = new Ajax.Request("/shout.php?action=get&t="+t,{method: 'get', onComplete: refreshShout2});
		}else{
			setTimeout("refreshShout()",1000);
		}
	}
}
function refreshShout2(resp)
{
	if(aktsite=="leserbriefe" && aktsub==""){
		obj=document.getElementById("SHOUTS");
		if(obj!=null)
		{
			objS=document.getElementById("SHOUT");
			objS.style.visibility="visible";
			objW=document.getElementById("SHOUTWAIT");
			objW.style.position="absolute";
			objW.style.visibility="hidden";
			obj.innerHTML=resp.responseText;
			setTimeout("refreshShout()",3000);
		}else{
			setTimeout("refreshShout()",1000);
		}
	}
}

function doZip(oZip,oLoc,oLocation)
{
		if(oZip==undefined){
			aktZip="zip";
		}else{
			aktZip=oZip;
		}
		if(oLoc==undefined){
			aktLoc="loc";
		}else{
			aktLoc=oLoc;
		}
		if(oLocation==undefined){
			oLocation="location";
		}
		obj=document.getElementById(aktZip);
		val=obj.value;
		var objD = new Date();
		var t=objD.valueOf();
		var newAjax = new Ajax.Request("/zip.php?action=get&zip="+escape(val)+"&locfield="+escape(oLocation)+"&t="+t,{method: 'get', onComplete: doZip2});
}
function doZip2(resp)
{
	r=resp.responseText;
	obj=document.getElementById(aktLoc);
	obj.innerHTML=r;
}

function doRegister()
{
	objC=document.getElementById("CONTENT");
	objC.style.visibility="hidden";
	objW=document.getElementById("WAIT");
	objW.style.visibility="visible";
	var txtfields="firstname,lastname,mobile,company,street,zip,tel,email,url,login,pw,pwchk";
	var selectfields="sex";
	var query="";
	arrTMP=txtfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=obj.value;
		query=query+"&"+arrTMP[i]+"="+escape(val);
	}
	arrTMP=selectfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=obj.options[obj.selectedIndex].value;
		query=query+"&"+arrTMP[i]+"="+escape(val);
	}
	obj=document.getElementById("location");
	var loc="";
	if(obj.type=="select-one"){
		loc=obj.options[obj.selectedIndex].value;
	}else{
		loc=obj.value;
	}
	query=query+"&location="+loc;
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/register.php?action=save&t="+t+query,{method: 'get', onComplete: doRegister2});
}
function doRegister2(resp)
{
	objC=document.getElementById("CONTENT");
	r=resp.responseText;
	if(r.indexOf("||")>-1){
		arrTMP=r.split("||");
		action=arrTMP[0];
		value=arrTMP[1];
		if(action=="ERR"){
			arrE=value.split(";");
			for(i=0;i<arrE.length;i++){
				if(arrE[i]=="login2"){
					alert("Es existiert bereits ein Account\r\nmit der angegebene Emailadresse (Login)!");
				}else{
					obj=document.getElementById(arrE[i]);
					obj.style.backgroundColor="#ffdcdc";
					obj.style.color="#000000";
				}
			}
		}else if(action=="SAVED"){
			objC.innerHTML=value;
		}
	}
	objC.style.visibility="visible";
	objW=document.getElementById("WAIT");
	objW.style.visibility="hidden";
}

function doLogin()
{
	objS=document.getElementById("CONTENT");
	objS.style.visibility="hidden";
	objW=document.getElementById("WAIT");
	objW.style.visibility="visible";
	
	var txtfields="login,pw";
	var query="";
	arrTMP=txtfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=obj.value;
		query=query+"&"+arrTMP[i]+"="+escape(val);
	}
	
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/login.php?action=save&t="+t+query,{method: 'get', onComplete: doLogin2});
}
function doLogin2(resp)
{
	objS=document.getElementById("CONTENT");
	objS.style.visibility="visible";
	objW=document.getElementById("WAIT");
	objW.style.visibility="hidden";
	r=resp.responseText;
	if(r.indexOf("||")>-1){
		arrTMP=r.split("||");
		action=arrTMP[0];
		value=arrTMP[1];
		if(action=="ERR"){
			arrE=value.split(";");
			for(i=0;i<arrE.length;i++){
					obj=document.getElementById(arrE[i]);
					obj.style.backgroundColor="#ffdcdc";
					obj.style.color="#000000";
			}
		}else if(action=="SAVED"){
			document.location.href="/admin/";
		}
	}
}
function doAdminNewEvery(every)
{
	AdminDtCnt=0;
	obj=document.getElementById("DATES");
	obj2=document.getElementById("SLASTDT");
	if(every==true){
		obj.innerHTML=AdminEvery.replace(/%CNT%/g,AdminDtCnt);
		obj2.style.position="static";
		obj2.style.visibility="visible";
	}else{
		obj.innerHTML=AdminDate.replace(/%CNT%/g,AdminDtCnt);
		obj2.style.visibility="hidden";
		obj2.style.position="absolute";
	}
}

function doAdminNewAddDt()
{
	AdminDtCnt=AdminDtCnt+1;
	obj=document.getElementById("DATES");
	var every=document.getElementById("evy").checked;
	if(every==true){
		obj.innerHTML=obj.innerHTML+AdminEvery.replace(/%CNT%/g,AdminDtCnt);
	}else{
		obj.innerHTML=obj.innerHTML+AdminDate.replace(/%CNT%/g,AdminDtCnt);
	}
}
function doEvent()
{
	objC=document.getElementById("CONTENT");
	objC.style.visibility="hidden";
	objW=document.getElementById("WAIT");
	objW.style.visibility="visible";
	var txtfields="titel,vtxt,loc,price,bes_print,bes,contact,tel,email,url";
	var query="";
	arrTMP=txtfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=obj.value;
		query=query+arrTMP[i]+"="+escape(val)+"&";
	}
	obj=document.getElementById("cid");
	obj.style.backgroundColor="#FFFFFF";
	obj.style.color="#000000";
	val=obj.options[obj.selectedIndex].value;
	query=query+"cid="+escape(val)+"&";
	var every=document.getElementById("evy").checked;
	for(i=0;i<=AdminDtCnt;i++){
		if(every==true){
			query=query+"every=1&";
			obj=document.getElementById("every"+i);
			obj.style.backgroundColor="#FFFFFF";
			obj.style.color="#000000";
			val=obj.options[obj.selectedIndex].value;
			query=query+"EVERY_"+i+"="+escape(val)+"&";
			obj=document.getElementById("day"+i);
			obj.style.backgroundColor="#FFFFFF";
			obj.style.color="#000000";
			val=obj.options[obj.selectedIndex].value;
			query=query+"DAY_"+i+"="+escape(val)+"&";
			obj=document.getElementById("lastdt");
			val=obj.value;
			obj.style.backgroundColor="#FFFFFF";
			obj.style.color="#000000";
			query=query+"lastdt="+escape(val)+"&";
		}else{
			obj=document.getElementById("dt"+i);
			val=obj.value;
			obj.style.backgroundColor="#FFFFFF";
			obj.style.color="#000000";
			query=query+"DT_"+i+"="+escape(val)+"&";
		}
		obj=document.getElementById("tm"+i+"_1");
		val=obj.value;
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		query=query+"TM_"+i+"_1="+escape(val)+"&";
		obj=document.getElementById("tm"+i+"_2");
		val=obj.value;
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		query=query+"TM_"+i+"_2="+escape(val)+"&";
		obj=document.getElementById("tm"+i+"_3");
		val=obj.value;
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		query=query+"TM_"+i+"_3="+escape(val)+"&";
	}
	var objD = new Date();
	var t=objD.valueOf();
	query=doQuery(query);
	var newAjax = new Ajax.Request("/event.php?action=save&t="+t+"&"+query,{method: 'get', onComplete: doEvent2});
}

function doQuery(str)
{
	str=str.replace(/\%u\d\d\d\d/g, "");
	return str;
}

function doEvent2(resp)
{
	objC=document.getElementById("CONTENT");
	r=resp.responseText;
	if(r.indexOf("||")>-1){
		arrTMP=r.split("||");
		action=arrTMP[0];
		value=arrTMP[1];
		if(action=="ERR"){
			arrE=value.split(";");
			for(i=0;i<arrE.length;i++){
				obj=document.getElementById(arrE[i]);
				obj.style.backgroundColor="#ffdcdc";
				obj.style.color="#000000";
			}
		}else if(action=="SAVED"){
			document.getElementById("ADMIN_CONTENT").innerHTML=value;
		}
	}
	objC.style.visibility="visible";
	objW=document.getElementById("WAIT");
	objW.style.visibility="hidden";
}
function doDelEvent(id)
{
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/delevent.php?id="+id+"&t="+t,{method: 'get', onComplete: doDelEvent2});
}
function doDelEvent2(resp)
{
	doLoad('admin','','&show=veranstaltungen');
}
function doActivate()
{
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/sendactivate.php?t="+t,{method: 'get', onComplete: doActivate2});
}
function doActivate2(resp)
{
	document.getElementById("CONTENT").innerHTML=resp.responseText;
}
function setAdminUser(obj)
{
	var val=obj.options[obj.selectedIndex].value;
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/adminuser.php?uid="+val+"&t="+t,{method: 'get', onComplete: setAdminUser2});
}
function setAdminUser2()
{
	document.location.href="http://www.kolt.ch/admin/";
}
function doNewsletter()
{
	objE=document.getElementById("email");
	var email=objE.value;
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/newsletter.php?email="+email+"&t="+t,{method: 'get', onComplete: doNewsletter2});
}
function doNewsletter2(resp)
{
	r=resp.responseText;
	objERROR=document.getElementById("ERROR");
	objERROR.innerHTML=r+"<br><br>";
	if(r.indexOf("eingetragen")>-1){
		objE=document.getElementById("email");
		objE.value="";
	}
}
function doThema()
{
	objI=document.getElementById("iid");
	var id=objI.options[objI.selectedIndex].value*1;
	objC=document.getElementById("SUBCONTENT");
	objC.innerHTML="";
	if(id>0)
	{
		var objD = new Date();
		var t=objD.valueOf();
		var newAjax = new Ajax.Request("/thema.php?id="+id+"&t="+t,{method: 'get', onComplete: doThema2});
	}
}
function doThema2(resp)
{
	r=resp.responseText;
	objC=document.getElementById("SUBCONTENT");
	objC.innerHTML=r;	
}
function doBill(show)
{
	obj=document.getElementById("BILL");
	if(show==false){
		obj.style.position="static";
		obj.style.visibility="visible";
	}else{
		obj.style.visibility="hidden";
		obj.style.position="absolute";	
	}
}
function doLeserbrief()
{
	objC=document.getElementById("CONTENT");
	objC.style.visibility="hidden";
	objW=document.getElementById("WAIT");
	objW.style.visibility="visible";
	var txtfields="firstname,lastname,zip,location,lbcode";
	var selectfields="sex,iid,iid2";
	var query="";
	arrTMP=txtfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		if(obj!=null)
		{
			obj.style.backgroundColor="#FFFFFF";
			obj.style.color="#000000";
			val=obj.value;
			query=query+"&"+arrTMP[i]+"="+escape(val);
		}
	}
	arrTMP=selectfields.split(",");
	for(i=0;i<arrTMP.length;i++){
		obj=document.getElementById(arrTMP[i]);
		if(obj!=null)
		{
			obj.style.backgroundColor="#FFFFFF";
			obj.style.color="#000000";
			val=obj.options[obj.selectedIndex].value;
			query=query+"&"+arrTMP[i]+"="+escape(val);
		}
	}
	
	obj=document.getElementById("txt");
	if(obj!=null)
	{
		obj.style.backgroundColor="#FFFFFF";
		obj.style.color="#000000";
		val=obj.innerText;
		query=query+"&txt="+escape(val);
	}
	
	var objD = new Date();
	var t=objD.valueOf();
	query=doQuery(query);
	var newAjax = new Ajax.Request("/leserbriefe.php?action=save&t="+t+query,{method: 'get', onComplete: doLeserbrief2});
}
function doLeserbrief2(resp)
{
	objC=document.getElementById("CONTENT");
	objC.style.visibility="visible";
	objW=document.getElementById("WAIT");
	objW.style.visibility="hidden";
	r=resp.responseText;
	if(r.indexOf("||")>-1){
		arrTMP=r.split("||");
		action=arrTMP[0];
		value=arrTMP[1];
		if(action=="ERR"){
			arrE=value.split(";");
			for(i=0;i<arrE.length;i++){
				obj=document.getElementById(arrE[i]);
				obj.style.backgroundColor="#ffdcdc";
				obj.style.color="#000000";
				if(arrE[i]=="lbcode"){
					obj.value="";
					objI=document.getElementById("lbcodeimg");
					objI.src=objI.src+"1";
				}
			}
		}else if(action=="SAVED"){
			doLoad('leserbriefe');
		}
	}
}
function doDelHierLesen(id)
{
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/delhierlesen.php?id="+id+"&t="+t,{method: 'get', onComplete: doDelHierLesen2});
}
function doDelHierLesen2(resp)
{
	doLoad('admin','','&show=hierlesen');
}
function doAddHierLesen(id)
{
	var loc=document.getElementById("loc").value;
	var adr=document.getElementById("adr").value;
	var query="&loc="+escape(loc)+"&adr="+escape(adr);
	query=doQuery(query);
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/addhierlesen.php?t="+t+query,{method: 'get', onComplete: doAddHierLesen2});
}
function doAddHierLesen2(resp)
{
	doLoad('admin','','&show=hierlesen');
}
function doCalcAbo(pay)
{
	objC1=document.getElementById("c1");
	objC2=document.getElementById("c2");
	objCGANZ=document.getElementById("cganz");
	objCGTOT=document.getElementById("cgtot");
	objCRANZ=document.getElementById("cranz");
	objCRTOT=document.getElementById("crtot");
	
	objEX=document.getElementById("ex");
	var ex=objEX.value;
	if(ex!="" && isNumeric(ex))
	{
		if(ex==0)
		{
			ex=1;
		}
	}else{
		ex=1;
	}	
	var abo=ex*12*5;
	var total=abo;
	if(pay==2)
	{
		total=total+5;
	}
	objC1.innerHTML=abo.toFixed(2);
	var goenner=0;
	if(objCGANZ!=null)
	{
		objCGANZ.innerHTML=ex;
		goenner=ex*50;
		objCGTOT.innerHTML=goenner.toFixed(2);
	}
	total=total+goenner;
	var red=ex*-11;
	objCRANZ.innerHTML=ex;
	objCRTOT.innerHTML=red.toFixed(2);
	total=total+red;
	objC2.innerHTML="<strong>"+total.toFixed(2)+"</strong>";
}

function isNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}
function doCreateBill(anz)
{
	id="";
	for(i=1;i<=anz;i++)
	{
		obj=document.getElementById("CHKNEW"+i);
		if(obj!=null)
		{
			if(obj.checked==true)
			{
				id=id+obj.value+",";
			}
		}
	}
	objW = window.open("http://www.kolt.ch/dobill/"+id, "DOBILL");
	objW.focus();
}
function doHandleFree(anz)
{
	id="";
	for(i=1;i<=anz;i++)
	{
		obj=document.getElementById("CHKGRATIS"+i);
		if(obj!=null)
		{
			if(obj.checked==true)
			{
				id=id+obj.value+",";
			}
		}
	}
	objA=document.getElementById("gratisaction");
	var action=objA.options[objA.selectedIndex].value;
	var objD = new Date();
	var t=objD.valueOf();
	var newAjax = new Ajax.Request("/dohandlefree.php?action="+action+"&id="+id+"&t="+t,{method: 'get', onComplete: doHandleFree2});
}
function doHandleFree2(resp)
{
	doLoad("admin","","&show=abos");
}
function doHandleNonFree(anz)
{
	id="";
	for(i=1;i<=anz;i++)
	{
		obj=document.getElementById("CHKNONFREE"+i);
		if(obj!=null)
		{
			if(obj.checked==true)
			{
				id=id+obj.value+",";
			}
		}
	}
	if(id==""){
		alert("Keine Abos ausgewählt");
	}else{
		var objD = new Date();
		var t=objD.valueOf();
		var newAjax = new Ajax.Request("/dohandlenonfree.php?action=extend&id="+id+"&t="+t,{method: 'get', onComplete: doHandleNonFree2});
	}
}
function doHandleNonFree2(resp)
{
	doLoad("admin","","&show=abos");
}
function doSchnupperAbo()
{
	objW = window.open("http://www.kolt.ch/schnupperorder/", "ABO", "width=800,height=600,left="+((sw-800)/2)+",top="+((sh-600)/2)+",scrollbars=yes,status=no,toolbar=no,resizable=no,menubar=no");
	objW.focus();
}
function doAboWindow()
{
	var chk1=document.getElementById("abo1").checked;
	var chk2=document.getElementById("abo2").checked;
	var anz1=0;
	var anz2=0;
	if(chk1==true)
	{
		typ=1;
	}
	if(chk2==true)
	{
		typ=2;
	}
	objW = window.open("http://www.kolt.ch/order/?typ="+typ, "ABO", "width=800,height=600,left="+((sw-800)/2)+",top="+((sh-600)/2)+",scrollbars=yes,status=no,toolbar=no,resizable=no,menubar=no");
	objW.focus();
}
function doAboKAWindow()
{
	var anz1=0;
	var anz2=0;
	var	typ=1;
	objW = window.open("http://www.kolt.ch/orderkabarett/?typ="+typ, "ABO", "width=800,height=600,left="+((sw-800)/2)+",top="+((sh-600)/2)+",scrollbars=yes,status=no,toolbar=no,resizable=no,menubar=no");
	objW.focus();
}
function doAboOTWindow()
{
	var anz1=0;
	var anz2=0;
	var	typ=1;
	objW = window.open("http://www.kolt.ch/orderot/?typ="+typ, "ABO", "width=800,height=600,left="+((sw-800)/2)+",top="+((sh-600)/2)+",scrollbars=yes,status=no,toolbar=no,resizable=no,menubar=no");
	objW.focus();
}
function doAboOAWindow()
{
	var anz1=0;
	var anz2=0;
	var	typ=1;
	objW = window.open("http://www.kolt.ch/orderoa/?typ="+typ, "ABO", "width=800,height=600,left="+((sw-800)/2)+",top="+((sh-600)/2)+",scrollbars=yes,status=no,toolbar=no,resizable=no,menubar=no");
	objW.focus();
}
function doAboTOWindow()
{
	var anz1=0;
	var anz2=0;
	var	typ=1;
	objW = window.open("http://www.kolt.ch/ordertourismus/?typ="+typ, "ABO", "width=800,height=600,left="+((sw-800)/2)+",top="+((sh-600)/2)+",scrollbars=yes,status=no,toolbar=no,resizable=no,menubar=no");
	objW.focus();
}
function doAbo2Window()
{
	objW = window.open("http://www.kolt.ch/order2/", "ABO2", "width=800,height=600,left="+((sw-800)/2)+",top="+((sh-600)/2)+",scrollbars=yes,status=no,toolbar=no,resizable=no,menubar=no");
	objW.focus();
}
function doNewBill(id)
{
	var url="http://www.kolt.ch/dobillother/"
	if(id!="")
	{
		url=url+id+"/";
	}
	objW = window.open(url, "DOBILLOTHER");
	objW.focus();
}
function doOtherBillsAction(type,cnt)
{
	objA=document.getElementById("ACTION"+type);
	var action=objA.options[objA.selectedIndex].value;
	var msg="";
	if(action!="")
	{
		var ids="";
		for(i=1;i<=cnt;i++)
		{
			objCHK=document.getElementById("CHK"+type+""+i);
			if(objCHK.checked==true)
			{
				if(action=="edit")
				{
					if(ids!="")
					{
						msg="Es kann nur eine Rechnung gleichzeitig bearbeitet werden,\r\nR"+((ids*1)+1000)+" wird geöffnet!";
					}else{
						ids=objCHK.value;
					}
				}else{
					ids=ids+objCHK.value+",";
				}
				objCHK.checked=false;
			}
		}
		if(ids=="")
		{
			alert("Nichts ausgewählt!");
		}else{
			if(action=="show")
			{
				objW = window.open("http://www.kolt.ch/pdf/otherbills.php?id="+ids, "BILLS_OTHER");
				objW.focus();
			}else if(action=="del"){
				if(confirm("Wollen Sie die markierten Rechnungen wirklich löschen?")==true){
					doLoad('admin','','&show=billsother&del='+ids);
				}
			}else if(action=="edit"){
				if(msg!="")
				{
					alert(msg);
				}
				objW = window.open("http://www.kolt.ch/dobillother/"+ids+"/", "DO_BILL_OTHER");
				objW.focus();
			}
		}
		objA.selectedIndex=0;
	}
}
function doAbosBillsAction(type,cnt)
{
	objA=document.getElementById("ACTION"+type);
	var action=objA.options[objA.selectedIndex].value;
	var msg="";
	if(action!="")
	{
		var ids="";
		for(i=1;i<=cnt;i++)
		{
			objCHK=document.getElementById("CHK"+type+""+i);
			if(objCHK.checked==true)
			{
				if(action=="edit")
				{
					if(ids!="")
					{
						msg="Es kann nur eine Rechnung gleichzeitig bearbeitet werden,\r\nR"+((ids*1)+1000)+" wird geöffnet!";
					}else{
						ids=objCHK.value;
					}
				}else{
					ids=ids+objCHK.value+",";
				}
				objCHK.checked=false;
			}
		}
		if(ids=="")
		{
			alert("Nichts ausgewählt!");
		}else{
			if(action=="show")
			{
				objW = window.open("http://www.kolt.ch/pdf/abobills.php?id="+ids, "BILLS_ABOS");
				objW.focus();
			}else if(action=="del"){
				if(confirm("Wollen Sie die markierten Rechnungen wirklich löschen?")==true){
					doLoad('admin','','&show=billsabos&del='+ids);
				}
			}else if(action=="edit"){
				if(msg!="")
				{
					alert(msg);
				}
				objW = window.open("http://www.kolt.ch/doeditbill/"+ids+"/", "DO_BILL_ABOS");
				objW.focus();
			}else if(action=="dunning"){
				objW = window.open("http://www.kolt.ch/dodunning.php?id="+ids, "DUNNING_ABOS");
				objW.focus();
			}
		}
		objA.selectedIndex=0;
	}
}
function doReceived(typ,id)
{
	objW = window.open("http://www.kolt.ch/doreceived.php?typ="+typ+"&id="+id, "RECEIVED", "width=500,height=600,left="+((sw-500)/2)+",top="+((sh-600)/2)+",scrollbars=yes,status=no,toolbar=no,resizable=no,menubar=no");
	objW.focus();
}

