var lagreMame = new Array();
var lagreWd = new Array();
var lagreHt = new Array();
var w = 0;
var nv = navigator.userAgent.indexOf("Gecko");

function pageStart(all_comments_count, show_last, comm){
  //showDate();
  if(all_comments_count == 0){
	var e_id = document.getElementById("comm_autor");
	if(e_id)
	  e_id.scrollIntoView(true);
  }
  else if(show_last){
	var e_id = document.getElementById("comm_" + show_last);
	if(e_id)
	  e_id.scrollIntoView(true);
  }
  else if(comm){
	var e_id = document.getElementById("comm_div");
	if(e_id)
	  e_id.scrollIntoView(true);
  }
}

function isMSIE(){
  if(navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Opera") == -1)
    return true;
  else
    return false; 
}

function addFavorite(){
  if(!isMSIE()){
    alert("Извините пожалуйста,\nданныя возможность реализуется только\nдля браузеров Microsoft Internet Explorer.\n\nВы можете выполнить добавление вручную.\n");
	return;
  }
  window.external.AddFavorite(parent.location, document.title);
}

function showDate(){
  var atime = new Date();			
  // дата
  var date_id = document.getElementById("cur_date");
  if(date_id){
    var date = atime.getDate();
    var month = String(atime.getMonth() + 1);
	if(month.length == 1)
	  month = "0" + month;
    var year = atime.getFullYear();
    var sdate = date + "." + month + "." + year;
	if(nv != -1){
      var date_val = date_id.firstChild;
      if(date_val)
        date_val.replaceData(0, 10, sdate);
	}
	else
	  date_id.innerHTML = sdate;
  }
  // время  
  var time_id = document.getElementById("cur_time");
  if(time_id){
    var hours = atime.getHours();
    var minutes = String(atime.getMinutes());
	if(minutes.length == 1)
	  minutes = "0" + minutes;
    var stime = String(hours + ":" + minutes);
	if(nv != -1){
      var time_val = time_id.firstChild;
  	  if(time_val)
	    time_val.replaceData(0, 5, stime);  
	}
	else
	  time_id.innerHTML = stime;
  }
  setTimeout("showDate()", 1000);   
}
////////////////////////////////////////////////////////////////////////////////

function load_img(img_name){
  var op = navigator.userAgent.indexOf("Opera");
  if(op != -1){
    if(w && w.self && !w.closed)
      w.close();
  }
  else{
    if(w && !w.closed)
      w.close();
  }
  w = window.open();
  if(w.self){
    w.focus();
	w.document.write('<html><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1251"><title>');
	w.document.write('Увеличенное изображение');
	w.document.write('</title>');
	w.document.write('');
	w.document.write('</head>');
	w.document.write('<body>');
	w.document.write('');
    w.document.write('<img src="'+img_name+'" alt="" border="0">');
    w.document.write('<p>');
    w.document.write('<a href="javascript:window.close();" style="text-decoration : none; color : #9d0a0e;" title="Закрыть изображение">&nbsp;&nbsp;&nbsp;закрыть</a>');
    w.document.write('</p>');
	w.document.write('</body></html>');
	w.document.close();
  }
  else{
    alert("Для просмотра увеличенного изображения в Вашем браузере необходимо разрешить открытие \"всплывающих\" окон!");
    return;
  }
}

function closeWindow(){
  var op = navigator.userAgent.indexOf("Opera");
  if(op != -1){
    if(w && w.self && !w.closed)
      w.close();
  }
  else{
    if(w && !w.closed)
      w.close();
  }
}
///////////////////////////////////////////////////////////////////////////////////////////
    var isDOM      = (typeof(document.getElementsByTagName) != 'undefined'
                      && typeof(document.createElement) != 'undefined')
                   ? 1 : 0;
    var isIE4      = (typeof(document.all) != 'undefined'
                      && parseInt(navigator.appVersion) >= 4)
                   ? 1 : 0;
    var isNS4      = (typeof(document.layers) != 'undefined')
                   ? 1 : 0;
    var capable    = (isDOM || isIE4 || isNS4)
                   ? 1 : 0;

function insertValueQuery() {
// из php-MyAdmin
    var myQuery = document.sqlform.sql_query;
    var myListBox = document.sqlform.dummy;

    if(myListBox.options.length > 0) {
        var chaineAj = "";
        var NbSelect = 0;
        for(var i=0; i<myListBox.options.length; i++) {
            if (myListBox.options[i].selected){
                NbSelect++;
                if (NbSelect > 1)
                    chaineAj += ", ";
                chaineAj += myListBox.options[i].value;
            }
        }

        //IE support
        if (document.selection) {
            myQuery.focus();
            sel = document.selection.createRange();
            sel.text = chaineAj;
            document.sqlform.insert.focus();
        }
        //MOZILLA/NETSCAPE support
        else if (document.sqlform.sql_query.selectionStart || document.sqlform.sql_query.selectionStart == "0") {
            var startPos = document.sqlform.sql_query.selectionStart;
            var endPos = document.sqlform.sql_query.selectionEnd;
            var chaineSql = document.sqlform.sql_query.value;

            myQuery.value = chaineSql.substring(0, startPos) + chaineAj + chaineSql.substring(endPos, chaineSql.length);
        } else {
            myQuery.value += chaineAj;
        }
    }
}
///////////////////////////////////////////////////////////////////////////////////////////
function lagreImg(n){
  load_img("pictures/large/" + n);
}

