function longMonthArray(){
        this[0] = "января";     this[1] = "февраля";    this[2] = "марта";
        this[3] = "апреля";     this[4] = "мая";        this[5] = "июня";
        this[6] = "июля";       this[7] = "августа";    this[8] = "сентября";
        this[9] = "октября";    this[10] = "ноября";    this[11] = "декабря";
        return (this);
}

function longDayArray(){
        this[0] = "Воскресенье";        this[1] = "Понедельник";        this[2] = "Вторник";
        this[3] = "Среда";      this[4] = "Четверг";    this[5] = "Пятница";
        this[6] = "Суббота";
        return (this);
}

function getLongYear(year){
        if (year > 1900) return year
        return year+1900;
}

function writeDateLong(format){
        longDays = new longDayArray();
        longMonths = new longMonthArray();
        d = new Date();
        day = d.getDate();
        month = d.getMonth();
        year = d.getYear();
        if (format == 0)
          str = longDays[d.getDay()] + ", " + day + " " + longMonths[month] + " " + getLongYear(year) + " г.";
        document.writeln(str);
}

function writeDate(){
        writeDateLong(0);
}

        function AddToBasket( id, w, h  ) {

                h = h ? h : 240;
                w = w ? w : 320;
                
                size = "height=" + h + ",width=" + w + ", status=no, toolbar=no, menubar=no, scrollbars=1";
                size += ",left=" + parseInt((screen.width - w)/2) + ",top=" + parseInt((screen.height - h)/2);
                
                quant = "";
                for( i=150; i<=240; i+=5 ){
                    c = parseInt(document.getElementById("S"+i).value);
                    if( c > 0 ){
                        quant += ( quant.length > 0 ? "_" : "" ) + i + "-" + c;
                    }
                }
                
                URL = '/add.2.basket/' + id + '/' + quant + '/';
                window.open( URL, 'displayWindow', size );
        }


        function add2basket_(id, w, h, quant) {
                var URL;
                if ( !h )
                    h = 600;
                if ( ! w )
                    w = 800;
                size="height="+h+",width="+w+", status=no, toolbar=no, menubar=no, scrollbars=1'";
                size+=",left="+(screen.width -w)/2+",top="+parseInt((screen.height -h)/2);
                URL = '/add.2.basket/' + id + '/' + quant + '/?url=/basket/';
                newWindow = window.open(URL, 'displayWindow', size);
        }

        function add2basket(id,go_to) {
                var URL;
                var h = 200;
                var w = 260;
                var k =document.getElementById("basket_kol_"+id);
                size="height="+h+",width="+w+", status=no, toolbar=no, menubar=no, scrollbars=1'";
                size+=",left="+(screen.width -w)/2+",top="+parseInt((screen.height -h)/2);
                //alert(k.value);
                if(go_to){
                  URL = '/add.2.basket/'+id+'/'+k.value+'/?url='+go_to;
                }
                else{
                  URL = '/add.2.basket/'+id+'/'+k.value+'/';
                }
                newWindow = window.open(URL, 'displayWindow', size);
        }

        function add4basket(a,id,msg,go_to){
          var kobj = document.getElementById("basket_kol_"+id);
          var kol = kobj.value;
          img = new Image();
          img.src = '/add.3.basket/' + id + '/' + kol + '/';
          img.onload = add5basket(msg,go_to);
          if(msg) alert(msg);
          if(go_to) window.location.href = go_to;
        }

        function add5basket(msg,go_to){
          if(msg) alert(msg);
          if(go_to) window.location.href = go_to;
          return;
        }

        // проверка корзинки
        function check_basket2(d) {
                var e;
                var o;
                var obj;
                var i;
                if(d=="->"){
                  document.forms['orderfrm'].submit();
                  return;
                }
                //
                i=0;
                e = d.split(";"); 
                while ( e[i]!="" ){
                  o = e[i].split("->");
                  obj=document.getElementById("z" + o[0]);
                  if(obj){
                    if( IsText(obj,"Заполните, пожалуйста, поле: " + o[1]) != 1 ) return;
                  }
                  i++;
                }
                document.forms['orderfrm'].submit();
                return;
        }

