var msg = null;
var Obj = null;
var rsp = null;
var m=null; var j=null; 
var wtag=null; var min=0; 
var aktmth = null;
var feld = null; 

var r_end = 80;
var g_end = 80;
var b_end = 80;
var x_dummy = 80;

var ind = 0;
var ok = 0;
var alt=0;

var fenst = null;

function save(dat) { wtag = dat; }

function crx() {
try {
Obj = new ActiveXObject("MicrosoftXMLHTTP");
} catch (Error){ try {
Obj = new ActiveXObject("MSXML2.XMLHTTP");  
} catch (Error){ try {
Obj = new XMLHttpRequest; 
} catch (Error) {
alert ("Es ist ein Browserfehler aufgetreten"); 
//m=0; aktmth=0; window.name="";
}}}}

function ask(m, feld, ct) { 
  if(feld == 'd') { min=0;
  if(m != 0) { 
  aktmth = (Number(aktmth) + Number(m)); 
  msg = "m="+aktmth; } else { msg="m=start"; }
  if (j != null) { msg += "&j="+j; }
  } else { if(document.getElementById('date').value != "") { 
           if (ct == "1") { min++; } else { min--; if(min < 0) { min=0; } }  
           msg="t="+wtag+"&min="+min;           
           } else {  //alert("Bitte zuerst das Datum eingeben"); 
                     msg="m=start";  
               }
           }
  Obj.open('POST', '../assets/askal.php?'+msg, true); 
  Obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
  Obj.onreadystatechange = handleResponse;  
  Obj.send(msg);   
}

function vcount(pfad) { 
if(pfad == "start") { pf='assets/askal.php?'; } else {pf='../assets/askal.php?';}
msg="vc=on";
Obj.open('POST', pf+msg, true); 
Obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
Obj.onreadystatechange = handleResponse;  
Obj.send(msg); 
}

function handleResponse() {
if (Obj.readyState == 4) { 
rsp = Obj.responseText; 
rsp = unescape(rsp);
rsp = rsp.split('~');
if(document.getElementById('kal')) { document.getElementById('kal').innerHTML = rsp[0]; }
if (rsp != "") { window.name = rsp[1]; }
aktmth = window.name;
if(rsp[2] == "y") {  m=0; aktmth=1;  }
if(rsp[2] == "neg") {  m=0; aktmth=12;  }
if(rsp[3] != "") { j=rsp[3]; }
if(rsp[1] == "0") { min=0; }
}
}

function time() { setTimeout('kalres()', 500); }
function kalres() {
if(document.getElementById('kal')) { document.getElementById('kal').innerHTML  = ""; }
if(document.getElementById('uhrzeit')) { document.getElementById('uhrzeit').innerHTML  = ""; } 
}

function fixt(data) {
if(document.getElementById('time')) { document.getElementById('time').value = data; pruef();  }
}

function pruef() {
  tag=document.getElementById('date').value; 
  inf = "info="+tag; 
  Obj.open('POST', '../assets/pruef.php?'+inf, true); 
  Obj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
  Obj.onreadystatechange = fb; //feedback 
  Obj.send(inf);  
}

function fb() {
if (Obj.readyState == 4) { 
anm = Obj.responseText; 
anm = unescape(anm);
var txt = "";
if(anm == "insert") { document.getElementById(anm).style.display = "block";  }
if(anm == "insclose") { insclose(); }
}
}

function insclose() {
document.getElementById("insert").style.display = "none";
}
/* andere Funktionen, nicht für Kalender */

function coltm() {
if(x_dummy == 254) {x_dummy = 255;}
if (x_dummy < Number(255)) {
r_end = r_end + 1;
g_end = g_end + 1;
b_end = b_end + 1; if (x_dummy != 254) { x_dummy++; }
}
if(x_dummy == Number(255)) { 
if(r_end > 224) { r_end = r_end-1; } if(g_end > 200) { g_end = g_end-1; } if(b_end > 60) { b_end = b_end - 2; }
}
if(document.getElementById('tel')) { document.getElementById('tel').style.color="rgb(" + r_end +", " + g_end +", " + b_end +")"; }
}

function ftcol() { 
setInterval("coltm()", 15);
}

function chngIt() {
if (ok == 0 && ind == 0) { alt=1; setTimeout("srcch(), philover(1)", 8500); } 
}

function srcch() { 
if (document.getElementById('hotline')) { var hot = document.getElementById('hotline'); }
if ( ok == 0 || alt == 1) { if ( alt == 1 ) { hot.src = "../images/Philo.jpg"; alt=0; ok=2;  } } 
if ( ok >= 1 ) {  if(ok > 1) { ind=1; ok=0; } else { ind=0; ok=1; } 
           if ( ind == 1 || alt == 1 ) { hot.src = "../images/Philo.jpg"; alt=0; } 
           if ( ind == 0 && alt != 1) { hot.src = "../images/serviceline_480.jpg"; } 
           
 }
 philover();
}

function philover(arr) { 
if((ok == 1 && ind==0) || (ok ==0 && ind==1) || (ok == 0 && ind == 0)) { 
   if (ok ==0 && ind==1 || (arr==1 && ok != 1) ) { document.getElementById('arrow').style.background = "url('../images/philo_arr.gif')"; }
   if ((ok ==1 && ind==0 && arr!=1 || (ok == 0 && ind == 0 && arr!=1)) ) { document.getElementById('arrow').style.background = "url('../images/philo_arr2.gif')";
     } 
   } else { document.getElementById('arrow').style.background = "url('../images/philo_empty.gif')";  }   
}

function startimgch() {
  fenst = window.open("topicpop.html", "Zweitfenster", "width=567,height=425, scrollbars=no, toolbar=0, resizable=0");
  fenst.focus(); 
 }

function topiccl() { this.window.opener = null; this.window.close(); }
function hand() { document.getElementById("topic").style.cursor = "pointer"; }
/*
function philout() { 
  document.getElementById('arrow').style.background = "url('../images/philo_empty.gif')"; 
}
*/
//js
//function brws() { alert(document.body.clientWidth); }
//document.onmousedown = brws; 
