<!--
// imena mesecev in zacetnice dnevov
rcMonths=new Array("Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December")
rcDays=new Array("P","T","S","Č","P","S","N")

var obj = "document.getElementById";

// skreiramo koledar za en mesec
function getRCCalendar(year, month, calId, form) {
	now=new Date()
	nowDate=now.getDate()
	nowMonth=now.getMonth()
	nowYear=now.getYear()  
	if (nowYear < 1000) {nowYear += 1900}

	if(year==null || month==null){rcNow = new Date()}
	else{rcNow = new Date(year, month, 1)}
	var rcDate = rcNow.getDate()
	var rcMonth = rcNow.getMonth()
	var rcYear = rcNow.getYear()
	if (rcYear < 1000) {rcYear += 1900}
 
  whatMonth=rcMonth;
  whatMonths=rcMonths[whatMonth]  
  thisMonth = new Date(rcYear, whatMonth, 1)
  nextMonth = new Date(rcYear, whatMonth+1, 1)
  
  totalDays=Math.round((nextMonth.getTime() - thisMonth.getTime()) / (1000 * 60 * 60 * 24));
  
  firstDay = thisMonth.getDay();
  lastDay = new Date(rcYear, whatMonth, totalDays).getDay()
  
  cal='<table border="0" cellpadding="0" cellspacing="0" class="calendar"><tr><td colspan="2">';
  cal+='<table border="0" cellpadding="0" cellspacing="0" style="border:1px solid #7f9db9"><tr><td class="month">';
  cal+='<a href="javascript:void(0)" onClick="getRCCalendar('+rcYear+','+(rcMonth-1)+',\''+calId+'\',\''+form+'\')" class="monthLink" title="Back">&laquo;<\/a>';
  cal+='<\/td><td colspan="5" align="center" valign="top" nowrap="nowrap" class="month">'+whatMonths+' '+rcYear+'<\/td><td class="month">';  
  cal+='<a href="javascript:void(0)" onClick="getRCCalendar('+rcYear+','+(rcMonth+1)+',\''+calId+'\',\''+form+'\')" class="monthLink" title="Forward">&raquo;<\/a>';
  cal+='<\/td><\/tr><tr>';

  for(y=0;y<7;y++){
    cal+='<td class="dayhead"';
    if(y<6){cal+='style="border-right:1px solid #ededed"';}
    cal+='>'+rcDays[y]+'<\/td>';   
  }
  cal+='<\/tr>';
  cal+='<tr>';
  displayDate=1;
  cellID=1;
  
  while (displayDate <= totalDays)
  {
  
    if(cellID<firstDay) {
		cal+='<td class="absent">&nbsp;<\/td>';
	}
    else
    {
      if(!(cellID%7-6)||!(cellID%7)){
		  newClass="weekend";
	  }
      else{
        if (displayDate==nowDate&&rcMonth==nowMonth&&rcYear==nowYear) {
			newClass="today";
		}
        else {
			newClass="day";
		}
      }
      cal+='<td>';
	  eDay = displayDate;
	  if (eDay <= 9) eDay = '0'+eDay;
	  eMonth = rcMonth+1;
	  if (eMonth <= 9) eMonth = '0'+eMonth;
      cal+='<a href="javascript:void(0)" onclick="'+form+'.'+calId+'.value = \''+eDay+'.'+eMonth+'.'+rcYear+'\';closeCalendar();return true" class="'+newClass+'">'+displayDate+'<\/a>';
      cal+='<\/td>';
    }
    if (!(cellID%7)) {
		cal+='<\/tr>'
	}  
    if(cellID>=firstDay){
		displayDate++;
	}
    cellID++
    
  }
  while(((cellID-1)%7))
  {
    cal+='<td class="absent"';
    if(!(cellID%7-5)) {
		cal+='style="border-right:1px solid #ededed"';
	}
    cal+='>&nbsp;<\/td>';
    cellID++
  } 
  cal+='<\/table><\/td><\/tr>';
  cal+='<tr>';
  cal+='<td align="center" class="txtSmall" style="background-color:#fff;padding-top:3px"><a href="javascript:void(0)" onClick="closeCalendar()">Zapri koledar<\/a><\/td>';  
  cal+='<\/tr>';
  
  eval(obj+'("calendarBox").innerHTML = cal');
  
  showCalendar(calId);
}

// prikazemo koledar
function showCalendar(calId){
	var dateBoxObj = eval(obj+'("calendarBox")')
    var dateDivObj = eval(obj+'(calId)')
	
    //getOffset(dateDivObj,'top')
	// pohekamo zgornji luft
	oTop = dateDivObj.offsetTop;
	
    getOffset(dateDivObj,'left')
	// prevozimo levi luft
	oLeft = dateDivObj.offsetLeft;
	
    getOffset(dateDivObj,'width')
	
	dateBoxObj.style.left=oLeft+oWidth+30+"px";
    dateBoxObj.style.top=oTop+"px";
	dateBoxObj.name = calId;
    dateBoxObj.style.visibility = "visible";
}

// kam postaviti koledar
function getOffset(obj, dim) 
{
  if(dim=="left") 
  {     
    oLeft = obj.offsetLeft;
    while(obj.offsetParent!=null) 
    {    
      oParent = obj.offsetParent     
      oLeft += oParent.offsetLeft 
      obj = oParent
    }
    return oLeft
  }
  else if(dim=="top")
  {
    oTop = obj.offsetTop;
    while(obj.offsetParent!=null) 
    {
      oParent = obj.offsetParent
      oTop += oParent.offsetTop
      obj = oParent 	
    }
    return oTop
  }
  else if(dim=="width")
  {
    oWidth = obj.offsetWidth
    return oWidth
  }  
  else if(dim=="height")
  {
    oHeight = obj.offsetHeight
    return oHeight
  }    
  else
  {
    alert("Error: invalid offset dimension '" + dim + "' in getOffset()")
    return false;
  }
}

// zapremo koledar
function closeCalendar(){  
  var dateBoxObj = eval(obj+'("calendarBox")')
  dateBoxObj.style.visibility = "hidden";
}
// End Of Script=======================================================================================================
//-->
