var version
function news_date(x,y,z){
y=(y<9)?"0"+(y+1):y+1
z=(z<10)?"0"+z:z
window.location.href="http://news.rusmarket."+version+"/"+x+y+z+"/"
//light_month=y
}
function cal(){
//блок определений
var x=new Date()
var my_day=x.getDay()
var my_date=x.getDate()
var my_month=x.getMonth()
var my_year=x.getYear()
month_name_ru=new Array("января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря")
month_name_en=new Array('January','February','March','April','May','June','July','August','September','October','November','December')
month_number=new Array(31,28,31,30,31,30,31,31,30,31,30,31)
month_name=new Array()
var news_text
//предварительные вычисления
if(my_year%4==0){month_number[1]=29}
my_year+=(my_year<1900)?1900:0
my_day=(my_day==0)?6:my_day-1
if(my_date<29){
if(my_month==0){prev_month=11;prev_year=my_year-1}
else{prev_month=my_month-1;prev_year=my_year}
prev_date=month_number[prev_month]+my_date-28
}
else{prev_month=my_month;prev_date=my_date-28}
n=window.location.href
light_date=my_date
light_month=my_month
if(/rusmarket.ru/.test(n)){version="ru";month_name=month_name_ru}
else{version="com";month_name=month_name_en}
if(/\d{8}/.test(n)){
i=(version=="ru")?n.indexOf(".ru/"):n.indexOf(".com/")+1
light_date=n.substring(i+10,i+12)-0
light_month=n.substring(i+8,i+10)-1
}
//запись
news_top=(version=="ru")?"Архив новостей":"News archive"
cal_begin="<div class=\"white\" align=\"right\"><h1 id=\"outside\">"+news_top+"</div><div class=\"block-container\" id=\"lime\"><div class=\"ptl\"><img src=\"/i/p.gif\" width=\"5\" height=\"5\"/></div><div class=\"rt\"><img src=\"/i/p.gif\" width=\"5\" height=\"5\"/></div><div class=\"r-block-content\"><div class=\"r-block-text\" style=\"border:0;\">"
cal_end="</div></div><div class=\"pbl\" id=\"lime\"><img src=\"/i/p.gif\" width=\"5\" height=\"5\"/></div><div class=\"rb\" id=\"lime\"><img src=\"/i/p.gif\" width=\"5\" height=\"5\"/></div></div>"
bb="border-bottom-color:#666;"
bbr="border-right-color:#666;"
y="<table cellspacing=\"0\" cellpadding=\"2\" width=\"100%\">"
for(i=k=0,l=1;i<5;i++){
   y+="<tr align=\"center\">"
   for(j=0;j<7;j++){
      y+="<td class=\""
      my_class=(j<5)?"mon":"sun"
      if((i==0&&j<my_day)||(i==4&&j>my_day)){y+="default\">&nbsp;"}//пустые ячейки
      else{
         if(k<=month_number[prev_month]-prev_date&&prev_month!=my_month){//за предыдущий месяц
            news_text=(version=="ru")?"Новости за "+(prev_date+k)+" "+month_name[prev_month]+" "+prev_year+" г.":prev_year+" "+month_name[prev_month]+" "+(prev_date+k)+" "+"news"
            y+=(prev_date+k==light_date&&prev_month==light_month)?"light\"":my_class+"\" onmouseover=\"this.className='"+my_class+"-on'\" onmouseout=\"this.className='"+my_class+"'\" onclick=\"news_date("+prev_year+","+prev_month+","+(prev_date+k)+")\" title=\""+news_text+"\""
            if((prev_date+k)>month_number[prev_month]-7){
               y+=" style=\""+bb
               if((prev_date+k)==month_number[prev_month]&&j!=6){y+=bbr}
               y+="\""
            }
            y+=">"+(prev_date+k)
            k++
         }
         else{//за этот месяц
            news_text=(version=="ru")?"Новости за "+l+" "+month_name[my_month]+" "+my_year+" г.":my_year+" "+month_name[my_month]+" "+l+" "+"news"
            y+=(l==light_date&&my_month==light_month)?"light\"":my_class+"\" onmouseover=\"this.className='"+my_class+"-on'\" onmouseout=\"this.className='"+my_class+"'\" onclick=\"news_date("+my_year+","+my_month+","+l+")\" title=\""+news_text+"\""
            y+=">"+l
            l++
         }
      }
      y+="</td>"
   }
   y+="</tr>"
}
y+="</table>"
cal_result=cal_begin+y+cal_end
document.write(cal_result)
}