function smdivs(id,aid) {
 if (!((aid>=5) && (aid<=9))) document.getElementById('m2').style.display='none';
 if (!((aid>=10) && (aid<=13))) document.getElementById('m3').style.display='none';
 if (!((aid>=14) && (aid<=17))) document.getElementById('m4').style.display='none';
 document.getElementById('m'+id).style.display='block';
}

function hmdivs(aid) {
 if (!((aid>=5) && (aid<=9))) document.getElementById('m2').style.display='none';
 if (!((aid>=10) && (aid<=13))) document.getElementById('m3').style.display='none';
 if (!((aid>=14) && (aid<=17))) document.getElementById('m4').style.display='none';
}

function showtip(text,top,left,d) {
 document.getElementById('tt1').style.left='1px';
 document.getElementById('tt1').innerHTML=text;
 if (d) {
  document.getElementById('tt1').style.display='block';
  w=document.getElementById('tt1').offsetWidth;
  document.getElementById('tt1').style.display='none';
  document.getElementById('tt1').style.left=(left-w)+'px';
 } else document.getElementById('tt1').style.left=left+'px';
 document.getElementById('tt1').style.top=top+'px'; 
 document.getElementById('tt1').style.display='block';
}

function hidetip() {
 document.getElementById('tt1').style.display='none';
}

am=0;
function ttcal_months(pm,mm,mp) {
 var i,j,k,x,y,tr,top,left;
 var d=new Date();
 var month=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); 
 
 am=am+pm;
 if (am<mm) am=mm;
 if (am>mp) am=mp;
 
 d0=new Date(d.getFullYear(),d.getMonth()+am,1,0,0,0,0);
 document.getElementById('ttcal1').innerHTML=month[d0.getMonth()];
 d0=new Date(d.getFullYear(),d.getMonth()+am+1,1,0,0,0,0);
 document.getElementById('ttcal2').innerHTML=month[d0.getMonth()];
 d0=new Date(d.getFullYear(),d.getMonth()+am+2,1,0,0,0,0);
 document.getElementById('ttcal3').innerHTML=month[d0.getMonth()];
 d0=new Date(d.getFullYear(),d.getMonth()+am+3,1,0,0,0,0);
 document.getElementById('ttcal4').innerHTML=month[d0.getMonth()];
 
 d0=new Date(d.getFullYear(),d.getMonth()+am,1,0,0,0,0);
 day=d0.getDay(); if (day==0) day=6; else day--;
 mon=d0.getMonth(); mon++; yea=d0.getFullYear();
 d1m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d0=new Date(d.getFullYear(),d.getMonth()+am+1,1,0,0,0,0);
 d2m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d21m=Math.round((d2m-d1m)/86400);
 j=0; pt=0; for (i=1;i<=42;i++) {
  if ((i>=1+day) && (i<=d21m+day)) {
   j++; tr=0; 
   for (k in cids) {
    if ((cyea[k]==yea) && (cmon[k]==mon) && (cday[k]==j)) {
	 tr=1;
	 x=(i%7)-1; if (x<0) x=6; y=((i-1)-((i-1)%7))/7;
	 top=58-27-ctrow[k]*14+16*y; left=114+26*x;
	 if ((pt!=cids[k]) && (pt>0)) document.getElementById('ttcal1_p'+i).innerHTML='<div class="ttcalad"><a href="'+cids[k]+'" class="ttcalaad" onmouseover="showtip(\''+cnames[k]+'\','+top+','+left+',0)" onmouseout="hidetip()">'+j+'</a></div>';
	 else document.getElementById('ttcal1_p'+i).innerHTML='<div class="ttcala"><a href="'+cids[k]+'" class="ttcalaa" onmouseover="showtip(\''+cnames[k]+'\','+top+','+left+',0)" onmouseout="hidetip()">'+j+'</a></div>';
	 pt=cids[k];
	}
   }
   if (!tr) document.getElementById('ttcal1_p'+i).innerHTML=j;   
  } else document.getElementById('ttcal1_p'+i).innerHTML='';
 }
 
 d0=new Date(d.getFullYear(),d.getMonth()+am+1,1,0,0,0,0);
 day=d0.getDay(); if (day==0) day=6; else day--;
 mon=d0.getMonth(); mon++; yea=d0.getFullYear();
 d1m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d0=new Date(d.getFullYear(),d.getMonth()+am+2,1,0,0,0,0);
 d2m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d21m=Math.round((d2m-d1m)/86400);
 j=0; pt=0; for (i=1;i<=42;i++) {
  if ((i>=1+day) && (i<=d21m+day)) {
   j++; tr=0; 
   for (k in cids) {
    if ((cyea[k]==yea) && (cmon[k]==mon) && (cday[k]==j)) {
	 tr=1;
	 x=(i%7)-1; if (x<0) x=6; y=((i-1)-((i-1)%7))/7;
	 top=58-27-ctrow[k]*14+16*y; left=317+26*x;
	 if ((pt!=cids[k]) && (pt>0)) document.getElementById('ttcal2_p'+i).innerHTML='<div class="ttcalad"><a href="'+cids[k]+'" class="ttcalaad" onmouseover="showtip(\''+cnames[k]+'\','+top+','+left+',0)" onmouseout="hidetip()">'+j+'</a></div>';
	 else document.getElementById('ttcal2_p'+i).innerHTML='<div class="ttcala"><a href="'+cids[k]+'" class="ttcalaa" onmouseover="showtip(\''+cnames[k]+'\','+top+','+left+',0)" onmouseout="hidetip()">'+j+'</a></div>';
	 pt=cids[k];
	}
   }
   if (!tr) document.getElementById('ttcal2_p'+i).innerHTML=j;   
  } else document.getElementById('ttcal2_p'+i).innerHTML='';
 }
 
 d0=new Date(d.getFullYear(),d.getMonth()+am+2,1,0,0,0,0);
 day=d0.getDay(); if (day==0) day=6; else day--;
 mon=d0.getMonth(); mon++; yea=d0.getFullYear();
 d1m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d0=new Date(d.getFullYear(),d.getMonth()+am+3,1,0,0,0,0);
 d2m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d21m=Math.round((d2m-d1m)/86400);
 j=0; for (i=1;i<=42;i++) {
  if ((i>=1+day) && (i<=d21m+day)) {
   j++; tr=0; 
   for (k in cids) {
    if ((cyea[k]==yea) && (cmon[k]==mon) && (cday[k]==j)) {
	 tr=1;
	 x=(i%7)-1; if (x<0) x=6; y=((i-1)-((i-1)%7))/7;
	 top=58-27-ctrow[k]*14+16*y; left=523+26*x;
	 if ((pt!=cids[k]) && (pt>0)) document.getElementById('ttcal3_p'+i).innerHTML='<div class="ttcalad"><a href="'+cids[k]+'" class="ttcalaad" onmouseover="showtip(\''+cnames[k]+'\','+top+','+left+',1)" onmouseout="hidetip()">'+j+'</a></div>';
	 else document.getElementById('ttcal3_p'+i).innerHTML='<div class="ttcala"><a href="'+cids[k]+'" class="ttcalaa" onmouseover="showtip(\''+cnames[k]+'\','+top+','+left+',1)" onmouseout="hidetip()">'+j+'</a></div>';
	 pt=cids[k];
	}
   }
   if (!tr) document.getElementById('ttcal3_p'+i).innerHTML=j;   
  } else document.getElementById('ttcal3_p'+i).innerHTML='';
 }
 
 d0=new Date(d.getFullYear(),d.getMonth()+am+3,1,0,0,0,0);
 day=d0.getDay(); if (day==0) day=6; else day--;
 mon=d0.getMonth(); mon++; yea=d0.getFullYear();
 d1m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d0=new Date(d.getFullYear(),d.getMonth()+am+4,1,0,0,0,0);
 d2m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d21m=Math.round((d2m-d1m)/86400);
 j=0; for (i=1;i<=42;i++) {
  if ((i>=1+day) && (i<=d21m+day)) {
   j++; tr=0; 
   for (k in cids) {
    if ((cyea[k]==yea) && (cmon[k]==mon) && (cday[k]==j)) {
	 tr=1;
	 x=(i%7)-1; if (x<0) x=6; y=((i-1)-((i-1)%7))/7;
	 top=58-27-ctrow[k]*14+16*y; left=726+26*x;
	 if ((pt!=cids[k]) && (pt>0)) document.getElementById('ttcal4_p'+i).innerHTML='<div class="ttcalad"><a href="'+cids[k]+'" class="ttcalaad" onmouseover="showtip(\''+cnames[k]+'\','+top+','+left+',1)" onmouseout="hidetip()">'+j+'</a></div>';
	 else document.getElementById('ttcal4_p'+i).innerHTML='<div class="ttcala"><a href="'+cids[k]+'" class="ttcalaa" onmouseover="showtip(\''+cnames[k]+'\','+top+','+left+',1)" onmouseout="hidetip()">'+j+'</a></div>';
	 pt=cids[k];
	}
   }
   if (!tr) document.getElementById('ttcal4_p'+i).innerHTML=j;   
  } else document.getElementById('ttcal4_p'+i).innerHTML='';
 }
}

function hcal_months(pm) {
 var i,j,k,ct;
 var d=new Date();
 var month=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); 
 
 ham=ham+pm;
 if (ham<0) ham=0;
 
 d0a=new Date(d.getFullYear(),d.getMonth()+ham,1,0,0,0,0);
 document.getElementById('hcal').innerHTML=month[d0a.getMonth()];
 document.getElementById('hcaly').innerHTML=d0a.getFullYear();
 
 hymd0=d0a.getFullYear()+'-';
 if ((d0a.getMonth()+1)<10) hymd0=hymd0+'0'+(d0a.getMonth()+1)+'-';
 else hymd0=hymd0+(d0a.getMonth()+1)+'-';
 
 d0=new Date(d.getFullYear(),d.getMonth()+ham,1,0,0,0,0);
 day=d0.getDay(); if (day==0) day=6; else day--;
 mon=d0.getMonth(); mon++; yea=d0.getFullYear();
 d1m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d0=new Date(d.getFullYear(),d.getMonth()+ham+1,1,0,0,0,0);
 d2m=Date.parse(month[d0.getMonth()]+' 1, '+d0.getFullYear()+' 00:00:00')/1000;
 d21m=Math.round((d2m-d1m)/86400);
 j=0; for (i=1;i<=42;i++) {
  if ((i>=1+day) && (i<=d21m+day)) {
   j++; ct=0; 
   if (j<10) hymd=hymd0+'0'+j; else hymd=hymd0+j;
   for (k=1;k<=hnum;k++) {    
    if (hcdays[k]==hymd) {
	 ct=1;
	 if (hmday==hymd) document.getElementById('hcal_p'+i).innerHTML='<div class="hcala"><a href="javascript:void(0)" class="hcalaa">'+j+'</a></div>';
	 else document.getElementById('hcal_p'+i).innerHTML='<div class="hacala"><a href="javascript:void(0)" onclick="hcalsel('+i+','+j+','+ham+',\''+hymd+'\');" class="hacalaa">'+j+'</a></div>';
	}
   }   
   if (!ct) document.getElementById('hcal_p'+i).innerHTML=j;
  } else document.getElementById('hcal_p'+i).innerHTML='';
 }
}

function hcalsel(pos,txt,ham,day) {
 hmday=day;
 if ((hselpos>0) && (hselham==ham)) document.getElementById('hcal_p'+hselpos).innerHTML='<div class="hacala"><a href="javascript:void(0)" onclick="hcalsel('+hselpos+','+hseltxt+','+hselham+',\''+hselday+'\');" class="hacalaa">'+hseltxt+'</a></div>'; 
 document.helpdesk.mpos.value=pos; document.helpdesk.mtxt.value=txt;
 document.helpdesk.mham.value=ham; document.helpdesk.mday.value=day; 
 hselpos=pos; hseltxt=txt; hselham=ham; hselday=day; 
 document.getElementById('hcal_p'+pos).innerHTML='<div class="hcala"><a href="javascript:void(0)" class="hcalaa">'+txt+'</a></div>';
 document.getElementById('hour').disabled="";
 var selem=document.getElementById('hour');
 if (selem.length>0) for (i=selem.length-1;i>0;i--) selem.remove(i);
 
 k=0; for (i=1;i<=hcdays.length;i++) if (hcdays[i]==day) k=i; 
 var sonew=new Array();
 for (i=0;i<hhours[k].length;i++) {
  sonew[i]=document.createElement('option');
  sonew[i].text=hhours[k][i];
  sonew[i].value=hhours[k][i];
  try { selem.add(sonew[i],null); }
  catch(ex) { selem.add(sonew[i]); }
 }
 
 document.getElementById('dur1').disabled="disabled";
 document.getElementById('dur2').disabled="disabled";
 document.getElementById('dur3').disabled="disabled";
 document.getElementById('dur1').checked="";
 document.getElementById('dur2').checked="";
 document.getElementById('dur3').checked="";
 document.getElementById('prc').innerHTML='<b>Total price: 0 EUR</b>';
}

function hhoursel() {
 document.getElementById('dur1').checked="";
 document.getElementById('dur2').checked="";
 document.getElementById('dur3').checked="";
 var hh=document.getElementById('hour');
 document.getElementById('dur1').disabled="";
 if (hh.value<='15:30') document.getElementById('dur2').disabled="";
 else document.getElementById('dur2').disabled="disabled";
 if (hh.value<='15:00') document.getElementById('dur3').disabled="";
 else document.getElementById('dur3').disabled="disabled";
 document.getElementById('prc').innerHTML='<b>Total price: 0 EUR</b>';
}

function hdelcal() {
 document.getElementById('dur1').checked="";
 document.getElementById('dur2').checked="";
 document.getElementById('dur3').checked="";
 document.helpdesk.mpos.value=0; document.helpdesk.mtxt.value="";
 document.helpdesk.mham.value=0; document.helpdesk.mday.value="";
 document.helpdesk.hour.value="";
 document.getElementById('prc').innerHTML='<b>Total price: 0 EUR</b>';
}

function hcalcprice() {
 var dur=0;
 if (document.getElementById('dur1').checked) dur=1;
 if (document.getElementById('dur2').checked) dur=1.5;
 if (document.getElementById('dur3').checked) dur=2;
 document.getElementById('prc').innerHTML='<b>Total price: '+(Math.round((dur-1)*document.helpdesk.hprc.value*(1+(document.helpdesk.hvat.value/100))))+' EUR</b>';
}

function ow(file,wid,hei,bars,resiz,status) {
xpos=(750-wid)/2;
ypos=100; window1=window.open(''+file+'',"MG",'scrollbars='+bars+',resizable='+resiz+',width='+wid+',height='+hei+',left='+(screen.width-wid)/2+',top='+(screen.height-hei)/2+',screenx='+xpos+',screeny='+ypos+',status='+status+'');
 window1.focus();
}

function nospam(name,domain) { document.location="mailto:"+name+"@"+domain; }
function nospamt(name,domain) { document.write(name+"@"+domain); }
function nospama(name,domain) { document.write('<a href="mailto:'+name+'@'+domain+'">'+name+'@'+domain+'</a>'); }
