
var curDate;
var Days      = new Array("Вск", "Пон", "Втр", "Срд", "Чтв", "Пят", "Суб");
var DaysFull  = new Array("воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота");
var rusMonths = new Array("январь","февраль","март","апрель","май","июнь","июль","август","сентябрь","октябрь","ноябрь","декабрь");
Date.prototype.getRusMonth   = getRusMonth
Date.prototype.get2digitDay  = get2digitDay
Date.prototype.get2digitMonth= get2digitMonth
Date.prototype.getCurTime    = getCurTime
Date.prototype.get4digitYear = get4digitYear
function getDayRusFull()
{
  var D = new Date();
  return DaysFull[D.getDay()];
}
function get4digitYear()
{
  var n = this.getYear();
  return ((n < 1900) ? n+1900 :  n);
}
function getRusMonthName()
{
  var D = new Date();
  return D.getRusMonth();
}
function getRusMonth()
{
  return rusMonths[this.getMonth()];
}
function get2digitDay()
{
  return get2digit("0"+this.getDate());
}
function get2digitMonth()
{
  return get2digit("0"+this.getMonth());
}
function getCurDate()
{
  var D = new Date();
  return D.getRusMonth() + " " + D.get2digitDay() + ", " + D.get4digitYear();
}
function getCurDateN()
{
  var D = new Date();
  return D.get2digitDay() + "." + D.get2digitMonth() + "." + D.get4digitYear();

}
function getMilitaryDate()
{
  var D = new Date();
  return D.get4digitYear() + " " + D.getRusMonth() + " " + D.get2digitDay();
}
function getMilitary()
{
  var D = new Date();
  return D.get4digitYear() + D.get2digitMonth() + D.get2digitDay();
}
function getMyTime()
{
  var D = new Date();
  return D.getCurTime();
}
function getCurTime()
{
 return get2digit("0"+this.getHours()) + ":" + get2digit("0"+this.getMinutes()) + ":" + get2digit("0"+this.getSeconds());
}
function Str2status(nm)
{
  window.status = document.all[nm].value;
}
function check (myform)
{
  var j;
  if (myform.elements['selector'])
  {
    for (var i = 0; i < myform.elements['selector'].length; i++)
      if (myform.elements['selector'][i].checked) {return true;}
    alert('Вы не сделали свой выбор!');
    return false;
  }
  
  for(var i = myform.min_id.value; i<= myform.max_id.value; i++)
  {
    if ((myform.elements['cb_'+i]) && (myform.elements['cb_'+i].checked)){
      return true;
    }
  }
  alert('Вы не сделали свой выбор!');
  return false;
}

function loadMeFirst()
{
  showCurrentDate();
}
function getRusShortDateTime()
{
  var D = new Date();
  return Days[D.getDay()] + " " + D.getCurTime();
}
function showCurrentDate()
{
 if(document.all) {
   
   document.all.iiiiiii.innerHTML = "<span>" + getRusShortDateTime() + "</span>";
   setTimeout("showCurrentDate()",1000);
   return true;
 } else return false;
}
function showCurrentTime()
{
 if(document.all) {
   document.all.iiiiiii.innerHTML = "<span>" + getMyTime() + "</span>";
   setTimeout("showCurrentTime()",1000);
   return true;
 } else return false;
}
function get2digit(aStr)
{
  return ((aStr.length == 2) ? aStr.substr(0,2) :  aStr.substr(1,2));
}

function noChecked(me)
{
  if (me.checked) {me.checked = false;}
}

function newImage(arg) {
 if (document.images) {
  rslt = new Image();
  rslt.src = arg;
  return rslt;
 }
}

function changeImages(nm,im)
{
  document.vpage[nm].src = im;
}

var preloadFlag = false;
function preloadImages() {
 if (document.images) {
  newImage("/Images/button-green.gif");
  newImage("/Images/button-white.gif");
  preloadFlag = true;
 }
}

function isNumeric(str)
{
  for (var i=0; i < str.length; i++){
    var ch = str.substring(i, i+1);
    if( ch < "0" || ch>"9" || str.length == null)
    {
      return false;
    }
  }
  return true;
}

function Min(v1, v2)
{
  return (v1 <= v2) ? v1 : v2;
}

function Max(v1, v2)
{
  return (v1 >= v2) ? v1 : v2;
}
//  -----------------------------------------
//  Cookie Cookie Cookie Cookie Cookie Cookie
//  -----------------------------------------
var never = new Date()
never.setTime(never.getTime() + 2000*24*60*60*1000);

// name is a string of the name of your cookie
// value is the value corresponding to name
function SetCookie(name, value, expires, path, domain, secure) {
 var newCookie = name + "=" + escape(value) +
   ((expires) ? ";expires=" + expires.toGMTString() : ";expires=" + never.toGMTString()) +
   ((path)    ? ";path="    + path   : "") +
   ((domain)  ? ";domain="  + domain : "") +
   ((secure)  ? ";secure="  + secure : "");
 document.cookie = newCookie;
}

// returns value of cookie or null if cookie does not exist
function GetCookie(name) {
  var prefix = name + "=";
  var start  = document.cookie.indexOf(prefix);
  if (start < 0) return null;
  var aend = document.cookie.indexOf(';', start + 1);
  if (aend < 0) aend = document.cookie.length;
  var value = document.cookie.substring(start+prefix.length, aend);
  return unescape(value);
}

function DelCookie(name, path, domain)
{
  var value = GetCookie(name);
  if (value){
    document.cookie = name + "=" + value +
      ";expires=Thu, 01-Jan-70 00:00:01 GTM" +
      ((path) ? ";path=" + path : "") +
      ((domain) ? ";domain=" + domain : "");
  }
}

function ShowCookie(name)
{
  var value = GetCookie(name);
  if (!value) value = "[пусто]";
  alert(value);
}
