// where are your calendar details hosted
var url = "calendar.php";
// where do you want the calendar to show
var dest = "kalender";

function switchdat(id,amcolor,pmcolor){
  id = id.substring(1);
  elt1 = "g"+id;elt2 = "n"+id;
  if(document.getElementById(elt1).value!=id && document.getElementById(elt2).value!=id ) SelectAll(id);
  else SelectNone(id, amcolor, pmcolor);
}

function cycledat(id,amcolor,pmcolor){
  id = id.substring(1);
  elt1 = "g"+id;elt2 = "n"+id;
  if(document.getElementById(elt1).value!=id && document.getElementById(elt2).value!=id ) SelectAll(id);
  else if(document.getElementById(elt1).value==id && document.getElementById(elt2).value==id ) SelectAM(id, pmcolor);
  else if(document.getElementById(elt1).value==id && document.getElementById(elt2).value!=id ) SelectPM(id, amcolor);
  else if(document.getElementById(elt1).value!=id && document.getElementById(elt2).value==id ) SelectNone(id, amcolor, pmcolor);
}
function SelectAll(id){
  elt1 = "g"+id;elt2 = "n"+id;
  document.getElementById(elt1).value=id;
  document.getElementById(elt2).value=id;
  document.getElementById("s"+id).style.backgroundImage="url('images/admin/bg_44.jpg')";
}

function SelectAM(id, color){
  elt1 = "g"+id;elt2 = "n"+id;
  document.getElementById(elt1).value=id;
  document.getElementById(elt2).value="";
  document.getElementById("s"+id).style.backgroundImage="url('images/admin/bg_4"+color+".jpg')";
}
function SelectPM(id, color){
  elt1 = "g"+id;elt2 = "n"+id;
  document.getElementById(elt1).value="";
  document.getElementById(elt2).value=id;
  document.getElementById("s"+id).style.backgroundImage="url('images/admin/bg_"+color+"4.jpg')";
}
function SelectNone(id, amcolor, pmcolor){
  elt1 = "g"+id;elt2 = "n"+id;
  document.getElementById(elt1).value="";
  document.getElementById(elt2).value="";
  document.getElementById("s"+id).style.backgroundImage="url('images/admin/bg_"+amcolor+pmcolor+".jpg')";
}

var cX=0; var cY=0; var rX=0; var rY=0;function UpdateCursorPosition(e){cX=e.pageX;cY=e.pageY;}function UpdateCursorPositionDocAll(e){cX=event.clientX;cY=event.clientY;}if(document.all){document.onmousemove=UpdateCursorPositionDocAll;}else{document.onmousemove=UpdateCursorPosition;}function AssignPosition(d){if(self.pageYOffset){rX=self.pageXOffset;	rY=self.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){rX=document.documentElement.scrollLeft;	rY=document.documentElement.scrollTop;}else if(document.body){rX=document.body.scrollLeft;rY=document.body.scrollTop;}if(document.all){cX += rX;cY += rY;}d.style.left=(cX+10)+"px";d.style.top=(cY+10)+"px";}function HideContent(d){if(d.length<1){return;}document.getElementById(d).style.display="none";}function ShowContent(d){if(d.length<1){return;}var dd=document.getElementById(d);AssignPosition(dd);dd.style.display="block";}function ReverseContentDisplay(d){if(d.length<1){return;}var dd=document.getElementById(d);AssignPosition(dd);if(dd.style.display=="none"){dd.style.display="block";}else{dd.style.display="none";}}
function xss_ajax(url){var script_id = null;var script = document.createElement('script');script.setAttribute('type', 'text/javascript');script.setAttribute('src', url);script.setAttribute('id', 'script_id');script_id = document.getElementById('script_id');if(script_id){document.getElementsByTagName('head')[0].removeChild(script_id);}document.getElementsByTagName('head')[0].appendChild(script);}
function callback(data) {var txt = '';for(var key in data){txt += data[key];txt += "\n";}document.getElementById(dest).innerHTML=txt;}
function showCalendar(){xss_ajax(url);}
