function Print(id){
	var param='';
	with (document.Data){
		for(i=0;i<length;i++){
			if (elements[i].name=='mess_array[]'){
				if (elements[i].checked) {
					if (param == '') {
						param='mess_array[]='+elements[i].value;
					} else {
						param=param+'&mess_array[]='+elements[i].value;
    	                                }
				}

			}
		}
	}
	if (id>0) param='mess_array[]='+id;
	if (param != '') {
		window.open(GLOBAL_DIR+'/print-mes/?'+param,'PrintMessage','menubar=yes, scrollbars=yes, location=no, toolbar=no, status=no, resizable=yes, width=600, height=300, left=0, top=0');
	}
}

function Mail(id){
	var param='';
	with (document.Data){
		for(i=0;i<length;i++){
			if (elements[i].name=='mess_array[]'){
				if (elements[i].checked) {
					if (param == '') {
						param='mess_array[]='+elements[i].value;
					} else {
						param=param+'&mess_array[]='+elements[i].value;
					}
				}
			}
		}
	}
	if (id>0) param='mess_array[]='+id;
	if (param != '') {
		window.open(GLOBAL_DIR+'/mail-mes/?'+param,'MailMessage','menubar=yes, scrollbars=yes, location=no, toolbar=no, status=no, resizable=yes, width=600, height=300, left=0, top=0');
	}
}


// Check all for note
var ELE_NAME_ARRAY = new Array('mess_array[]');
function check_all_note(checked){
  setCheckedFlag(document.Data,ELE_NAME_ARRAY,checked);
  document.Data.all_check.checked = checked;
}
function setCheckedFlag(formObj,eleNameArr,checkedFlag){
  for(var i=0;i<formObj.elements.length;i++){
     var ele = formObj.elements[i];
     for(var j=0;j<eleNameArr.length;j++){
       if(ele.name == eleNameArr[j]){
          ele.checked = checkedFlag;
          break;
       }        
     }
  }
}

function getEl(name) {
   return document.getElementById(name);
}
function $(name) {
   return document.getElementById(name);
}

function one_check(){  // проверяем отмечен хоть бы один чекбокс
	var param='';
	with (document.Data){
		for(i=0;i<length;i++){
			if (elements[i].name=='mess_array[]'){
				if (elements[i].checked) {
                         		return true;
				}
			}
		}
	}
}
function showOriginalPicture( width, height, link, title ) {
    if( width<=0 || height<=0 ) return false;

    var winWidth, winHeight;

    if( Math.ceil(width)>Math.ceil(screen.width*0.8) ) { winWidth = Math.ceil(screen.width*0.8); }
    else { winWidth = Math.ceil(width); }
    if( Math.ceil(height)>Math.ceil(screen.height*0.8) ) { winHeight = Math.ceil(screen.height*0.8); }
    else { winHeight = Math.ceil(height); }

    winParam = 'width='+winWidth+',height='+winHeight+',';
    winParam += 'resizable=yes,';
    if( winWidth<width || winHeight<height ) winParam += 'scrollbars=yes,';
    else winParam += 'scrollbars=no,';
    winParam += 'left='+(screen.width*0.2)+',top='+(screen.height*0.2)+',screenX='+(screen.width*0.2)+',screenY='+(screen.height*0.2)+'';
    myWin = window.open("","_blank", winParam);

    myWin.document.open();
    myWin.document.clear();
    try {
    myWin.document.title = title;
    } catch(e) {/*ie does not support document.title*/}
    myWin.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
    myWin.document.write('<html xmlns="http://www.w3.org/1999/xhtml" lang="ru" xml:lang="ru"><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />');
    myWin.document.write('<title>'+title+'</title>');
    myWin.document.write('</head><body style="margin:0px;background-color:#ebebeb;text-align:center;" leftMargin=0 topMargin=0 marginheight=0 marginwidth=0>');
    myWin.document.write('<a href="javascript:window.close();" onClick="window.close();return false;" title="Закрыть!"><img src="'+link+'" border="0"/>');
    myWin.document.write('</body></html>');
    myWin.document.close();
    return false;
}