function check($value)
 {
    switch ($value)
     {
        case "check_rc":
                  $result_check = "true";
                  return $result_check;
         break;
        case "check_note":
                  $result_check = "true";
                  return $result_check;
         break;
        default:
          return "false";
     }
 }

function viki_click(rec_id)
 {
   var separator = ",";
   var list_rec = document.myForm.list_rec.value;
   var check_rec = "false";

   if(list_rec != "")
    {
      array_list_rec = list_rec.split(separator);
      list_rec = "";
      for (var i=0; i < array_list_rec.length; i++)
       {
          if(array_list_rec[i] != rec_id)
           {
              if(list_rec == "")
               {
                  list_rec = array_list_rec[i];
               }
              else
               {
                  list_rec = list_rec + "," + array_list_rec[i];
               }
           }
          else
           {
              check_rec = "true";
           }
       }

      if(check_rec == "true")
        document.myForm.list_rec.value = list_rec;
      else
        document.myForm.list_rec.value = list_rec + "," + rec_id;
    }
   else
     document.myForm.list_rec.value = rec_id;
 }

//********************************************************************************************************************
// Otevre nove okno s parametrama
// pName       string     jmeno okna prohlizece
// pUrlPage    string     pUrl na script, ktery se ma v okne zobrazit
// pWidth      integer    sirka okna
// pHeight     integer    vyska okna
//********************************************************************************************************************
function fcNewWindow(pName, pUrlPage, pWidth, pHeight)
 {
	WLeft = (screen.width) ? (screen.width - pWidth) / 2 : 0;
	WTop = (screen.height) ? (screen.height - pHeight) / 2 : 0;
	openwindow = "window.open('"+ pUrlPage +"','"+ pName +"','modal=yes,toolbar=no,location=no,scrollbars=no,resizable=no,directories=no,width="+ pWidth +",height="+ pHeight +",top="+ WTop +",left="+ WLeft +"');";
    eval(openwindow);
 }

//*****************************************************************************
// Prevede znak na jiny znak
//
// pString   string   string, ktrery upravujeme
// pChar1    string   jaky znak nahradime
// pChar2    string   nahradime timto znakem
//*****************************************************************************
function fcReplaceChar(pString, pChar1, pChar2)
 {
    temp = "" + pString;

    while(temp.indexOf(pChar1)>-1)
     {
        pos = temp.indexOf(pChar1);
        temp = "" + (temp.substring(0, pos) + pChar2 + temp.substring((pos + pChar1.length), temp.length));
     }
    return temp;
 }


//********************************************************************************************************************
// Overeni spravnosti napsaneho datumu
//                    - kontrola prestupneho roku
//                    - nahrada znaku za jednotny symbol mezi cislicema
//
// vDateName     object   oznaceni textoveho pole pro datum ve formulari
// vDateValue    string   udaj o zadanem datumu v textovem poli formulare
//
//********************************************************************************************************************
   function fcFormCheckDate(vDateName, vDateValue)
    {
       if(vDateValue != "")
        {
           // Prevedeni znaku - / , na .
           vDateValue = fcReplaceChar(vDateValue, '/', '.');
           vDateValue = fcReplaceChar(vDateValue, '-', '.');
           vDateValue = fcReplaceChar(vDateValue, ',', '.');

           // Kontrola povolenych znaku
           var lAllowChars = "1234567890.";
           var lNumber = 0;
           var lSign = "";
           var lCase = 1;
           var lDay = "";
           var lMonth = "";
           var lYear = "";
           var lWarning = false;

           for(var i = 0; i < vDateValue.length; i++)
            {
               lSign = vDateValue.charAt(i);

               if(lSign == ".")
                {
                   lNumber = lNumber + 1;
                   lCase = lCase + 1;
                }
               else
                {
                   // Rozdelit datum na dd mm YYYY
                   switch(lCase)
                    {
                       case 1: lDay = lDay + lSign; break;
                       case 2: lMonth = lMonth + lSign; break;
                       case 3: lYear = lYear + lSign; break;
                    }
                }

               if(lAllowChars.indexOf(lSign) == -1)
                {
                   alert("©patně zadaný datum !");
                   if(vDateName.type != "hidden") vDateName.focus();
                   return false;
                }
            }

           // Kontrola poctu '.' ... musi byt 2x
           if(lNumber != 2)
            {
               alert("©patně zadaný datum !");
               if(vDateName.type != "hidden") vDateName.focus();
               return false;
            }

           // Pokud je vetsi nebo zadny (u roku musi byt 4 cislice) -> spatny datum
           if((lDay.length > 2) || (lDay.length == 0)) lWarning = true;
           if((lMonth.length > 2) || (lMonth.length = 0)) lWarning = true;
           if((lYear.length > 4) || (lYear.length < 4)) lWarning = true;
           if(lWarning)
            {
               alert("©patně zadaný datum !");
               if(vDateName.type != "hidden") vDateName.focus();
               return false;
            }

           // Prevod datumu na format 'dd.mm.YYYY'
           if(lDay.length  == 1) lDay = "0"+ lDay;
           if(lMonth.length  == 1) lMonth = "0"+ lMonth;

           // Vytvoreni kompletniho datumu
           lDateFull = lDay +"."+ lMonth +"."+ lYear;
           vDateName.value = lDateFull;

           // Kontrola existujiciho datumu
           if(!fcFormCheckDateYear(vDateName, lDateFull))
            {
               alert("©patně zadaný datum !");
               if(vDateName.type != "hidden") vDateName.focus();
               return false;
            }
        }
       return true;
    }

   function fcFormCheckDateYear(vDateName, vDateValue)
    {
       var mDay   = vDateValue.substr(0,2);
       var mMonth = vDateValue.substr(3,2);
       var mYear  = vDateValue.substr(6,4);

       var intDay   = parseInt(mDay, 10);
       var intMonth = parseInt(mMonth, 10);
       var intYear  = parseInt(mYear, 10);

       if (intYear == 0)
        {
           return false;
        }
       else
        {
           if (intYear % 100 == 0)
            {
               if (intYear % 400 == 0)
                {
                   var LeapYear = "true";
                }
               else
                {
                   if ((intYear % 4) == 0)
                    {
                       var LeapYear = "true";
                    }
                }
            }
           else
            {
               var LeapYear = "false";
            }
        }

       if (intMonth > 12 || intMonth < 1)
        { return false; }

       if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intDay > 31 || intDay < 1))
         { return false; }

       if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intDay > 30 || intDay < 1))
        { return false; }

       if (intMonth == 2)
        {
           if (intDay < 1)
            { return false; }
           if (LeapYear == true)
            {
              if (intDay > 29)
               { return false; }
            }
           else
            {
               if (intDay > 28)
                { return false; }
            }
        }
       switch(arguments[2])
        {
           case "1":    // neprovede se nic - pouze kontrola datumu
                        break;
           default:     if(vDateName.value != "") vDateName.value = mDay + "." + mMonth + "." + mYear;
        }
       return true;
    }