var debug_mode=0;

/***********************************************************************************/
/* URL Params                                                                      */
/***********************************************************************************/
var URLParams =location.search.substr(1,location.search.length).split('&'); 
function getURLParams(x) 
  { 
  t=''; 
  for(i=0;i<URLParams.length;i++) 
    { 
    r=URLParams[i].split('='); 
    if(r[0]==x) t = r[1];     
    } 
  return t; 
  } 

/***********************************************************************************/
/* Main menu                                                                       */
/***********************************************************************************/
var MainMenu;

function MainMenuPrepare()
{
  //Menu properties   
  MainMenu.pxBetween=0;
  MainMenu.rows=1;
  MainMenu.menuPlacement=0;
  MainMenu.onlineRoot="";
  MainMenu.fillImg="/images/cm_fill.gif";
  MainMenu.resizeCheck=1;
  MainMenu.wait=0;
  MainMenu.zIndex=1;
  MainMenu.useBar=0;
  
  //Level properties - ALL properties have to be spesified in level 0
  MainMenu.level[0]=new cm_makeLevel();
  MainMenu.level[0].width=90;
  MainMenu.level[0].height=20;
  MainMenu.level[0].regClass="clLevel0";
  MainMenu.level[0].overClass="clLevel0over";
  MainMenu.level[0].borderX=1;
  MainMenu.level[0].borderY=0;
  MainMenu.level[0].borderClass="clLevel0border";
  MainMenu.level[0].offsetX=0;
  MainMenu.level[0].offsetY=0;
  MainMenu.level[0].rows=0;
  MainMenu.level[0].arrow=0;
  MainMenu.level[0].arrowWidth=0;
  MainMenu.level[0].arrowHeight=0;
  MainMenu.level[0].align="bottom";
  
  //EXAMPLE SUB LEVEL[1] PROPERTIES - You have to specify the properties you want different from LEVEL[0] - If you want all items to look the same just remove this
  MainMenu.level[1]=new cm_makeLevel();
  MainMenu.level[1].width=200;
  MainMenu.level[1].height=20;
  MainMenu.level[1].regClass="clLevel1";
  MainMenu.level[1].overClass="clLevel1over";
  MainMenu.level[1].borderX=1;
  MainMenu.level[1].borderY=1;
  MainMenu.level[1].align="right";
  MainMenu.level[1].offsetX=-(MainMenu.level[0].width-2)/2+20;
  MainMenu.level[1].offsetY=0;
  MainMenu.level[1].borderClass="clLevel1border";
}

/***********************************************************************************/
/* TDocumentHeader object                                                          */
/***********************************************************************************/
function TDocumentHeader_AddHeader()
{
  var headtext = '<!--- Document name: '+this.docname+'--->';
  headtext += '<HTML>\n<HEAD>\n';
  headtext += '<META http-equiv="Content-Type" content="text/html; charset='+TDocumentHeader_charset+'">\n';
  headtext += '<TITLE>'+TDocumentHeader_htmlname+'</TITLE>\n';
  headtext += '<LINK href="../layout/layout.css" rel="stylesheet" type="text/css">\n';
  headtext += '<SCRIPT language=JavaScript1.2 src="../layout/menumain.js"></SCRIPT>\n';
  headtext += '<SCRIPT language=JavaScript1.2 src="../layout/layout.js"></SCRIPT>\n';
  headtext += '<SCRIPT language=JavaScript1.2 src="dictionary.js"></SCRIPT>\n';
  headtext += '</HEAD>\n\n';
  headtext += '<BODY topMargin=10 marginwidth="10" marginheight="10">\n';
  headtext += '<SCRIPT language=JavaScript1.2> document.bgColor = "'+this.col0+'"; document.linkColor = document.alinkColor = document.vlinkColor = "navy"; </SCRIPT>\n';
  var maintext = '';
  var nmenu = 'm_area';
  var cc = this.flagru+this.flagen+this.flagde+2;
  var cc1 = cc+2;
  var rus_path = (debug_mode == 0)? '../source_rus/':'../rus/';
  var eng_path = (debug_mode == 0)? '../source_eng/':'../eng/';
  var ger_path = (debug_mode == 0)? '../source_ger/':'../ger/';
  
  if(this.prnver == 0)
    {
    onMainMenuCreate();
    document.linkColor = document.alinkColor = document.vlinkColor = 'navy';	
    document.bgColor = this.col0;
    // main area
    maintext += '<DIV align=center>\n';
    maintext += '<TABLE bgColor='+this.col3+' width='+(this.width1+7)+' border=0 cellPadding=0 cellSpacing=0>\n';
    maintext += '<COLGROUP><COL width=2><COL width='+this.width1+'><COL width=5></COLGROUP><TBODY>\n';
    maintext += '<TR><TD colspan=3><IMG height=6 src="../layout/blattende_oben.gif" width=807></TD></TR>\n';
    maintext += '<TR><TD bgColor='+this.col1+'></TD><TD width='+this.width1+'>\n';
    // header and menu area
    maintext += ' <TABLE bgColor='+this.col3+' width='+this.width1+' border=0 cellPadding=0 cellSpacing=0><TBODY>\n';
    maintext += '  <TR><TD colspan='+cc1+' width="100%" align="center"><A name="BeginOfPage">\n    <IMG width="100%" height=100 alt="'+TDocumentHeader_imagealt+'" src="'+TDocumentHeader_topimage+'" border=0></A></TD></TR>\n';
    maintext += '  <TR><TD colspan='+cc1+' width="100%" height=1 bgColor='+this.col1+'></TD></TR>\n';
    maintext += '  <TR><TD colspan='+cc1+' width="100%" height=1></TD></TR>\n';
    maintext += '  <TR><TD width=8></TD>\n';
    maintext += '    <TD bgColor='+this.col2+' width='+(this.width1-cc*31)+' height=20 vAlign=top><IMG width=1 height=1 name=m_area src="../layout/dot.gif">'+onAltMenuCreate("TDocumentHeader_altmenu")+'</TD>\n';
    if(this.flagru)
      maintext += '    <TD bgColor='+this.col2+'><A href='+rus_path+this.docname+'><IMG width=30 height=15 src="../layout/flag_ru.gif" border=0 alt="Russian version"></A></TD>\n';
    if(this.flagen)
      maintext += '    <TD bgColor='+this.col2+'><A href='+eng_path+this.docname+'><IMG width=30 height=15 src="../layout/flag_en.gif" border=0 alt="English version"></A></TD>\n';
    if(this.flagde)  
      maintext += '    <TD bgColor='+this.col2+'><A href='+ger_path+this.docname+'><IMG width=30 height=15 src="../layout/flag_de.gif" border=0 alt="German version"></A></TD>\n';
    if(debug_mode == 0)  
      maintext += '    <TD bgColor='+this.col2+'><A href='+this.docname+'?PrintVer=1><IMG width=30 height=15 src="../layout/printer.gif" border=0 alt="'+TDocumentBody_printname+'"></A></TD><TD width=8></TD></TR>\n';
    else  
      {
      var prn_ver = this.docname.substring(0, this.docname.indexOf('.html'))+'.pdf';
      maintext += '    <TD bgColor='+this.col2+'><A href='+prn_ver+'><IMG width=30 height=15 src="../layout/printer.gif" border=0 alt="'+TDocumentBody_printname+'"></A></TD><TD width=8></TD></TR>\n';
      }
    maintext += '  <TR><TD colspan='+cc1+' width="100%" height=1></TD></TR>\n';
    maintext += '  <TR><TD colspan='+cc1+' width="100%" height=1 bgColor='+this.col1+'></TD></TR>\n';
    maintext += '  </TBODY></TABLE>\n';
    // body area
    maintext += ' <TABLE bgColor='+this.col3+' border=0 cellPadding=0 cellSpacing=0 width="100%"><TBODY><TR><TD>\n\n';
    }
  else
    {
    document.linkColor = document.alinkColor = document.vlinkColor = '#45474E';	
    maintext += '<TABLE bgColor='+this.col3+' border=0 cellPadding=0 cellSpacing=0 width='+this.width2+'><TBODY><TR><TD>\n';
    }  
  document.write(maintext);
  if(debug_mode == 1) 
    document.write('<TEXTAREA NAME="main_text" ROWS=30 COLS=150>'+ headtext + maintext);
}

function TDocumentHeader_AddButtom()
{
  var maintext = '';
  if(this.prnver == 0)
    {
    // end of body area
    maintext += ' </TD></TR></TBODY></TABLE>\n';
    // end of main area
    maintext += '</TD><TD background="../layout/blattende_right.gif"></TD></TR>\n';
    maintext += '<TR><TD colspan=3><IMG height=7 src="../layout/blattende_unten.gif" width=807></TD></TR></TBODY></TABLE>\n';
    // page info
    maintext += '<TABLE bgColor='+this.col0+' border=0 cellPadding=0 cellSpacing=0 width='+this.width+'><TBODY>\n';
    maintext += ' <TR><TD align="center">'+onAltMenuCreate("TDocumentHeader_pageinfo")+'</TD></TR>\n';
    maintext += ' <TR><TD align="center"><DIV id="TDocumentHeader_pageinfo">\n';
    maintext += ' '+TDocumentHeader_name+' (kma@icmm.ru), '+TDocumentHeader_lastupd+'<SCRIPT language=JavaScript1.2> document.write(document.lastModified) </SCRIPT>, '+TDocumentHeader_visits+'\n';
    maintext += ' <a href="http://counter.co.kz" target="_blank"><img src="http://counter.co.kz/counter.cgi?page=http://users.math.uni-potsdam.de/~mkulesh/'+TDocumentHeader_CounterCO+'&style=arialb_11&digits="5" alt="Counter CO.KZ" border=0></a><BR><BR>\n';
    maintext += ' <a href="http://top100.rambler.ru/top100/"><img src="http://counter.rambler.ru/top100.cnt?640374" alt="" width=1 height=1 border=0></a>\n';
    maintext += ' <a href="http://top100.rambler.ru/top100/"><img src="http://top100-images.rambler.ru/top100/banner-88x31-rambler-blue.gif" alt="Rambler\'s Top100" width=88 height=31 border=0></a>\n';
    maintext += ' <a href="http://www.liveinternet.ru/click" target=_blank><img src="http://counter.yadro.ru/hit?t44.10;r' + escape(document.referrer) + ((typeof(screen)=='undefined')?'':';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?screen.colorDepth:screen.pixelDepth)) + ';u' + escape(document.URL) + ';' + Math.random() + '" border=0 width=31 height=31 title="liveinternet.ru"></a>\n';
    maintext += ' <a href="http://top.germany.ru" alt="TOP.germany.ru" target="_top"><img src="http://top.germany.ru/cgi-bin/links/top.cgi?ID=3939&v=13" height=31 border=0></a>\n';
    maintext += ' </DIV></TD></TR>\n</TBODY></TABLE>\n\n</DIV>';
    }
  else
    {
    // end of body area
    maintext += '</TD></TR></TBODY></TABLE>';
    }  
  if(debug_mode == 1) document.write(maintext+'<SCRIPT language=JavaScript1.2> onMainMenuCreate(); MainMenu.construct(); </SCRIPT></BODY></HTML></TEXTAREA>');
  document.write(maintext);
  if(this.prnver == 0) MainMenu.construct();
}

function TDocumentHeader() 
{
  this.col0 = '#EAECF0'; // bg color
  this.col1 = '#E6E8EC'; // border color
  this.col2 = '#808297'; // menu color
  this.col3 = '#FFFFFF'; // bg color
  this.flagru = 0;
  this.flagen = 0;
  this.flagde = 0;
  this.docname='';
  this.width1 = 800; // width of screen version
  this.width2 = 640; // width of print version
  this.prnver = getURLParams('PrintVer');
  this.AddHeader = TDocumentHeader_AddHeader;
  this.AddButtom = TDocumentHeader_AddButtom;
}

/***********************************************************************************/
/* TDocumentBody object                                                            */
/***********************************************************************************/
function TDocumentBody_AddHeader(mask)
{
  var maintext = '';
  this.colsnum = TDocumentBody_AddHeader.arguments.length;
  maintext += ' <TABLE border=0 cellspacing=0 cellpadding=6 width="100%">\n';
  maintext += ' <COLGROUP>'
  for (var i=0; i<this.colsnum; i++) 
    maintext += '<COL width="' + TDocumentBody_AddHeader.arguments[i] + '">';
  maintext += '</COLGROUP><TBODY>\n';
  if(this.prnver==0 && this.title)
    {
    maintext += '  <TR><TD colspan="'+this.colsnum+'" align="center"><DIV id="TDocumentBody_Head"><BR>'+this.title.toUpperCase()+'</DIV></TD></TR>\n\n';
    }
  if(this.prnver==1 && this.title)
    {
    maintext += '<TR><TD colspan="'+this.colsnum+'" align="center"><DIV id="TDocumentBody_Head">'+TDocumentHeader_name.toUpperCase()+'</DIV></TD></TR>\n';
    maintext += '  <TR><TD colspan="'+this.colsnum+'" align="center"><DIV id="TDocumentBody_Head">'+this.title.toUpperCase()+'</DIV></TD></TR>\n\n';
    }
  document.write(maintext);
}

function TDocumentBody_AddButtom(num)
{
  var maintext = '';
  maintext += '  </TBODY></TABLE>\n  ';
  if(num) for (var i=0; i<num; i++) maintext += '<BR>';
  maintext += '\n';
  document.write(maintext);
}

function TDocumentBody_AddSectionName(txt, lhref)
{
  var maintext = '';
  maintext += '  <TR valign="top"><TD colspan='+this.colsnum+'>\n';
  maintext += '    <TABLE border=0 cellspacing=1 cellpadding=0><TR><TD width="100%"><DIV id="TDocumentBody_SectionName">\n';
  if(lhref)
    maintext += '    <A name="#' + lhref + '">' + this.secnum + '. </A>';
  else  
    maintext += '    '+this.secnum + '. ';
  this.secnum++;
  maintext += txt;
  maintext += '</DIV></TD>\n    <TD width=20>';
  if(this.prnver==0)
    maintext += '<A href="#BeginOfPage"><IMG src="../layout/arrow_top.gif" alt="'+TDocumentBody_topname+'" border=0></A>';
  maintext += '</TD></TR>\n    </TABLE></TD></TR>\n\n';
  document.write(maintext);
}

function TDocumentBody_AddInfoItem(num, txt)
{
  var maintext = '';
  maintext += '  <TR valign="top">\n';
  maintext += '    <TD><IMG src="../layout/triangle.gif" height="9" style="position: relative; top: 3"></TD>\n';  
  maintext += '    <TD><DIV id="TDocumentBody_InfoItem1">'+num+':</DIV></TD>\n';
  maintext += '    <TD><DIV id="TDocumentBody_InfoItem2">'+txt+'</DIV></TD></TR>\n\n';
  document.write(maintext);
}

function TDocumentBody_AddInfoItemTwo(num, txt)
{
  var maintext = '';
  maintext += '  <TR valign="top">\n';
  maintext += '    <TD><DIV id="TDocumentBody_InfoItem1">'+num+':</DIV></TD>\n';
  maintext += '    <TD><DIV id="TDocumentBody_InfoItem2">'+txt+'</DIV></TD></TR>\n\n';
  document.write(maintext);
}

function TDocumentBody_AddListItem(txt)
{
  var maintext = '';
  maintext += '  <TR valign="top">\n';
  maintext += '    <TD><IMG src="../layout/triangle.gif" height="9" style="position: relative; top: 3"></TD>\n';  
  maintext += '    <TD colspan='+(this.colsnum-1)+'><DIV id="TDocumentBody_InfoItem2">'+txt+'</DIV></TD></TR>\n\n';
  document.write(maintext);
}

function TDocumentBody_AddPar(restext)
{
  var maintext = '';
  maintext += '  <TR><TD colspan='+this.colsnum+'><DIV id="TDocumentBody_Par"><P style="text-align:justify">\n';
  maintext += '    ' + restext + '\n';
  maintext += '    </P></DIV></TD></TR>\n\n';
  document.write(maintext);
}

function TDocumentBody_AddIndentPar(restext)
{
  var maintext = '';
  maintext += '  <TR valign="top"><TD></TD><TD colspan='+(this.colsnum-1)+'><DIV id="TDocumentBody_Par"><P style="text-align:justify">\n';
  maintext += '    ' + restext + '\n';
  maintext += '    </P></DIV></TD></TR>\n\n';
  document.write(maintext);
}

function TDocumentBody_AddPhotoLine(alb,num)
{
  var maintext = '';
  maintext += '<TR valign="top">\n';  
  for (var i=0; i<num.length; i++) 
    {
    maintext += '<TD align="center">';
    if(num[i])
      maintext += '<A href=../07-Photos/'+alb+'/'+alb+num[i]+'.jpg target="blank"><IMG src="../07-Photos/'+alb+'/Preview/'+alb+num[i]+'.jpg" border="1" alt="'+TDocumentBody_zoom+'"></A>';
    maintext += '</TD>';
    }
  document.write(maintext);
}

function TDocumentBody_AddPic(num, name, sour)
{
  var maintext = '';
  img = new Image();
  img.src = sour;
  var wd=(this.prnver==0)? this.head.width1-45:this.head.width2-45;
  maintext += '<TR><TD colspan='+this.colsnum+' align="center"><DIV id="TDocumentBody_Pic">\n';
  if(img.width>=wd)
    maintext += '<BR><IMG src="'+sour+'" width="'+wd+'" border=0> <BR>\n';
  else
    maintext += '<BR><IMG src="'+sour+'" border=0> <BR>\n';
  if(num)
    {
    maintext += TDocumentBody_figname + ' ' + this.fignum + '. ';
    this.fignum ++;
    }
  if(name)  
    maintext += name;
  maintext += '<BR><BR></DIV></TD></TR>\n';
  document.write(maintext);
}

function TDocumentBody(title,head) 
{
  this.title = title;
  this.head = head;
  this.colsnum = 0;
  this.secnum = 1;
  this.fignum = 1;
  this.prnver = getURLParams('PrintVer');
  this.AddHeader = TDocumentBody_AddHeader;
  this.AddInfoItem = TDocumentBody_AddInfoItem;
  this.AddInfoItemTwo = TDocumentBody_AddInfoItemTwo;
  this.AddListItem = TDocumentBody_AddListItem;
  this.AddSectionName = TDocumentBody_AddSectionName;
  this.AddPar = TDocumentBody_AddPar;
  this.AddIndentPar = TDocumentBody_AddIndentPar;
  this.AddPic = TDocumentBody_AddPic;
  this.AddPhotoLine = TDocumentBody_AddPhotoLine;
  this.AddButtom = TDocumentBody_AddButtom;
} 



/***********************************************************************************/
/* TBibItem object                                                                 */
/***********************************************************************************/
function TBibItem_Get() 
{
  var maintext = '';
  maintext += '<DIV id="TBibItem_Author">'+this.authors+'</DIV>'; 
  maintext += '<DIV id="TBibItem_Title"> '+this.title;
  if(this.journal) maintext += ' // '+this.journal;
  if(this.lang==0 && this.year) maintext += ', '+this.year;
  if(this.vol) maintext += '. '+this.volumename+this.vol;
  if(this.num) maintext += '. '+this.numname+this.num;
  if(this.page) maintext += '. '+this.pagename+this.page;
  if(this.lang==1 && this.year) maintext += ' ('+this.year+')';
  maintext += '.</DIV>';
  if(this.prnver == 0)
    for (var i=0; i<this.links.length; i++) 
      {
      maintext += this.links[i];
      if(i<(this.links.length-1)) maintext += '<A>;</A> ';
      }
  return maintext;
}

function TBibItem_AddLink(type, link, info) 
{
  var maintext = '';
  if(type == 1) { maintext=TBibItem_fulltext; }
  else if(type == 2) { maintext=TBibItem_referat; }
  else if(type == 3) { maintext=TBibItem_present; }
  else if(type == 4) { maintext=TBibItem_confer; }
  else if(type == 5) { maintext=TBibItem_journal; }
  else { maintext=type; }
  if(info) maintext+=' ('+info+')'
  this.links[this.ind] = '<A href='+link+' target="_blank">'+maintext+'</A>';	
  this.ind++;
}

function TBibItem(type, id, lang, authors, title, journal, year, vol, num, page) 
{
  this.type = type;
  this.id = id;
  this.lang = lang;
  this.authors = authors;
  this.title = title;
  this.journal = journal;
  this.year = year;
  this.vol = vol;
  this.num = num;
  this.page = page;
  this.volumename = '';
  this.numname = '';
  this.pagename = '';
  this.links = new Array();
  this.ind = 0;
  if(this.lang==0)
    {
    this.volumename = 'Ò. ';
    this.numname = '¹ ';
    this.pagename = 'Ñ. ';
    }
  else  
    {
    this.volumename = 'V. ';
    this.numname = 'No. ';
    this.pagename = 'P. ';
    }
  this.prnver = getURLParams('PrintVer');
  this.Get = TBibItem_Get;
  this.AddLink = TBibItem_AddLink;  
} 

/***********************************************************************************/
/* TBibContainer object                                                            */
/***********************************************************************************/
function TBibContainer_AddItem(type, id, lang, authors, title, journal, year, vol, num, page) 
{
  var nb = new TBibItem(type, id, lang, authors, title, journal, year, vol, num, page);
  this.cont[this.ind] = nb;
  this.ind++;
  return nb;
}

function TBibContainer_GetForType(type) 
{
  var maintext = '<TABLE border="0" cellspacing="0" cellpadding="4"><TBODY>\n';
  var k=1;
  for (var i=0; i<this.cont.length; i++) 
    {
    if(this.cont[i].type == type)
      {
      maintext += '    <TR valign="top"><TD><DIV id="TBibItem_Num">['+k+']</DIV></TD><TD>'+this.cont[i].Get()+'</TD></TR>\n\n';
      k++;
      }
    }
  maintext += '    </TBODY></TABLE>';
  return maintext;
}

function TBibContainer_CountForType(type) 
{
  var k=0;
  for (var i=0; i<this.cont.length; i++) 
    if(this.cont[i].type == type) k++;
  return k;
}

function TBibContainer_GetForIds(ids) 
{
  var maintext = '<TABLE border="0" cellspacing="0" cellpadding="4"><TBODY>\n';
  for (var k=1; k<=TBibContainer_GetForIds.arguments.length; k++) 
    {
    for (var i=0; i<this.cont.length; i++)
      if(this.cont[i].id == TBibContainer_GetForIds.arguments[k-1]) 	
        maintext += '    <TR valign="top"><TD><DIV id="TBibItem_Num">['+k+']</DIV></TD><TD>'+this.cont[i].Get()+'</TD></TR>\n\n';
    }
  maintext += '    </TBODY></TABLE>';
  return maintext;
}

function TBibContainer() 
{
  this.ind = 0;
  this.cont = new Array();	
  this.AddItem = TBibContainer_AddItem;
  this.GetForType = TBibContainer_GetForType;
  this.GetForIds = TBibContainer_GetForIds;
  this.CountForType = TBibContainer_CountForType;
}

/***********************************************************************************/
/* TSpecArray object                                                              */
/***********************************************************************************/
function TSpecArray() 
{
  this.name = new Array();	
  this.link = new Array();
  this.info = new Array();
  this.prnver = getURLParams('PrintVer');
  this.ind = 0;	
}

TSpecArray.prototype.Add = function(name,link,info)
{
  this.name[this.ind] = name;	
  this.link[this.ind] = link;
  this.info[this.ind] = info;
  this.ind++;
}

TSpecArray.prototype.GetLink = function(num,descr)
{
  var maintext = '';
  if(this.link[num] && this.prnver==0)
    maintext = '<A href="'+this.link[num]+'">'+descr+'</A>';
  return maintext;  
}

